2025-05-19 09:54:33 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
#include "common/Fields.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
class CommEntity;
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
class Device
|
2025-07-18 09:08:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
|
|
int type = -1;
|
|
|
|
|
|
std::string name;
|
|
|
|
|
|
std::string code;
|
2025-08-28 18:42:37 +08:00
|
|
|
|
std::string group;
|
2025-07-18 09:08:09 +08:00
|
|
|
|
bool isOpen = false;
|
|
|
|
|
|
std::string attrsJson = "";
|
|
|
|
|
|
|
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
int online = 0;
|
|
|
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//std::map<std::string, std::string> mapAttrs;
|
2025-08-22 19:06:50 +08:00
|
|
|
|
Fields attrs;
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
// 通讯entity
|
|
|
|
|
|
std::shared_ptr<CommEntity> commEntity;
|
|
|
|
|
|
|
|
|
|
|
|
//int getAttrInt(std::string key);
|
|
|
|
|
|
//float getAttrFloat(std::string key);
|
|
|
|
|
|
//double getAttrDouble(std::string key);
|
|
|
|
|
|
//std::string getAttrStr(std::string key);
|
|
|
|
|
|
|
2025-09-04 19:31:04 +08:00
|
|
|
|
|
|
|
|
|
|
int64_t tsDataDate {};
|
|
|
|
|
|
std::map<int, double> mapCacheData;
|
|
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
// 启动通讯
|
|
|
|
|
|
int startComm();
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
static std::shared_ptr<Device> create(Fields& fields);
|
2025-08-20 19:00:22 +08:00
|
|
|
|
};
|