mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现MQTT协议消息订阅和消息解析流程
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include "MQTTAsync.h"
|
||||
#include "common/JsonN.h"
|
||||
|
||||
class Station;
|
||||
|
||||
struct REGInfo
|
||||
{
|
||||
@@ -11,6 +14,7 @@ struct REGInfo
|
||||
std::string datatype;
|
||||
int bytes {0};
|
||||
std::string remark;
|
||||
int ratio {1};
|
||||
|
||||
REGInfo() {}
|
||||
REGInfo(std::string key, std::string datatype, std::string remark)
|
||||
@@ -41,32 +45,32 @@ public:
|
||||
void onConnectSuccess(MQTTAsync_successData* resp);
|
||||
void onConnectFaiure(MQTTAsync_failureData* resp);
|
||||
|
||||
void parseEMS_YX(std::string& text);
|
||||
void parseEMS_YC(std::string& text);
|
||||
void parsePCU_YX(std::string& text);
|
||||
void parsePCU_YC(std::string& text);
|
||||
void parsePCS_YX(std::string& text);
|
||||
void parsePCS_YC(std::string& text);
|
||||
void parseBMS_YC(std::string& text);
|
||||
void parseBCU_YX(std::string& text);
|
||||
void parseBCU_YC(std::string& text);
|
||||
void parseMEM_YC(std::string& text);
|
||||
void parseTH_YC(std::string& text);
|
||||
void parseFire40_YX(std::string& text);
|
||||
void parseCooling_YX(std::string& text);
|
||||
void parseCooling_YC(std::string& text);
|
||||
void parseCharger_YC(std::string& text);
|
||||
void parseGateway_YX(std::string& text);
|
||||
void parseGateway_YC(std::string& text);
|
||||
void parseGateway_YT(std::string& text);
|
||||
void parseTQ(std::string& text);
|
||||
void parseEMS_YX(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseEMS_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parsePCU_YX(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parsePCU_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parsePCS_YX(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parsePCS_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseBMS_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseBCU_YX(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseBCU_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseMEM_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseTH_YC(std::shared_ptr<Station> station, njson& json, std::map<std::string, REGInfo>& mapRegInfo);
|
||||
//void parseFire40_YX(std::string& text);
|
||||
//void parseCooling_YX(std::string& text);
|
||||
//void parseCooling_YC(std::string& text);
|
||||
//void parseCharger_YC(std::string& text);
|
||||
//void parseGateway_YX(std::string& text);
|
||||
//void parseGateway_YC(std::string& text);
|
||||
//void parseGateway_YT(std::string& text);
|
||||
//void parseTQ(std::string& text);
|
||||
|
||||
public:
|
||||
std::string clientId;
|
||||
MQTTAsync client = nullptr;
|
||||
std::vector<std::string> vecTopic;
|
||||
std::string addr; // "tcp://localhost:1883"
|
||||
int qos {1};
|
||||
int qos {0};
|
||||
bool isConnected {false};
|
||||
bool isSubscribed {false};
|
||||
};
|
||||
@@ -95,5 +99,5 @@ public:
|
||||
|
||||
|
||||
public:
|
||||
static string packEquipmentInfo();
|
||||
static string pack(std::string name);
|
||||
};
|
||||
Reference in New Issue
Block a user