mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Добавил три типа очередей: очередь сущностей, очередь структур, и очередь char
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "classes/NotAsync.h"
|
||||
#include "ESPConfiguration.h"
|
||||
#include "MqttClient.h"
|
||||
#include "classes/CommandBuf.h"
|
||||
#include "classes/QueueBuf.h"
|
||||
#include "classes/QueueFromChar.h"
|
||||
#include "classes/QueueFromInstance.h"
|
||||
#include "classes/QueueFromStruct.h"
|
||||
#include "classes/QueueInst.h"
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include "Global.h"
|
||||
|
||||
#define MAX_COMMAND_LENGTH 16
|
||||
#define BUFFER 128
|
||||
|
||||
class CommandBuf;
|
||||
|
||||
class CommandBuf {
|
||||
public:
|
||||
CommandBuf();
|
||||
~CommandBuf();
|
||||
|
||||
void addCommand(const char* command);
|
||||
|
||||
void printCommands();
|
||||
|
||||
String getLastCommand();
|
||||
|
||||
private:
|
||||
struct CharBufferStruct {
|
||||
char command[MAX_COMMAND_LENGTH + 1];
|
||||
};
|
||||
CharBufferStruct* commandList;
|
||||
int commandCount = 0;
|
||||
};
|
||||
|
||||
extern CommandBuf* myBuf;
|
||||
39
include/classes/QueueFromChar.h
Normal file
39
include/classes/QueueFromChar.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "Global.h"
|
||||
|
||||
#define MAX_COMMAND_LENGTH 16
|
||||
#define BUFFER 128
|
||||
|
||||
class QueueFromChar;
|
||||
|
||||
class QueueFromChar {
|
||||
public:
|
||||
QueueFromChar();
|
||||
~QueueFromChar();
|
||||
|
||||
void addCommand(const char* command);
|
||||
|
||||
void printCommands();
|
||||
|
||||
String getLastCommand();
|
||||
|
||||
private:
|
||||
struct CharBufferStruct {
|
||||
char command[MAX_COMMAND_LENGTH + 1];
|
||||
};
|
||||
CharBufferStruct* commandList;
|
||||
int commandCount = 0;
|
||||
};
|
||||
|
||||
extern QueueFromChar* myBuf;
|
||||
|
||||
//========проверка очереди=====================
|
||||
// myBuf = new QueueFromChar;
|
||||
// myBuf->addCommand("zero");
|
||||
// myBuf->addCommand("one");
|
||||
// myBuf->addCommand("two");
|
||||
// myBuf->printCommands();
|
||||
// myBuf->getLastCommand();
|
||||
// myBuf->getLastCommand();
|
||||
// myBuf->getLastCommand();
|
||||
// myBuf->printCommands();
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class QueueBuf;
|
||||
class QueueFromInstance;
|
||||
|
||||
class QueueBuf {
|
||||
class QueueFromInstance {
|
||||
public:
|
||||
QueueBuf();
|
||||
~QueueBuf();
|
||||
QueueFromInstance();
|
||||
~QueueFromInstance();
|
||||
|
||||
void push(QueueInstance instance);
|
||||
void pop();
|
||||
@@ -21,4 +21,4 @@ class QueueBuf {
|
||||
queue<QueueInstance> queue1;
|
||||
};
|
||||
|
||||
extern QueueBuf* myQueue;
|
||||
extern QueueFromInstance* myQueue;
|
||||
41
include/classes/QueueFromStruct.h
Normal file
41
include/classes/QueueFromStruct.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#include "Global.h"
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct QueueItems {
|
||||
String myword;
|
||||
};
|
||||
|
||||
class QueueFromStruct;
|
||||
|
||||
class QueueFromStruct {
|
||||
public:
|
||||
QueueFromStruct();
|
||||
~QueueFromStruct();
|
||||
|
||||
void push(QueueItems word);
|
||||
void pop();
|
||||
QueueItems front();
|
||||
|
||||
private:
|
||||
queue<QueueItems> queue1;
|
||||
QueueItems tmpItem;
|
||||
};
|
||||
|
||||
extern QueueFromStruct* myQueueStruct;
|
||||
|
||||
//=======проверка очереди из структур=================
|
||||
// myQueueStruct = new QueueFromStruct;
|
||||
// QueueItems myItem;
|
||||
// myItem.myword = "word1";
|
||||
// myQueueStruct->push(myItem);
|
||||
// myItem.myword = "word2";
|
||||
// myQueueStruct->push(myItem);
|
||||
// myItem.myword = "word3";
|
||||
// myQueueStruct->push(myItem);
|
||||
// Serial.println(myQueueStruct->front().myword);
|
||||
// Serial.println(myQueueStruct->front().myword);
|
||||
// Serial.println(myQueueStruct->front().myword);
|
||||
Reference in New Issue
Block a user