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>
|
|
|
|
|
|
|
|
|
|
|
|
#include <common/DataFields.h>
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
bool isOpen = false;
|
|
|
|
|
|
std::string attrsJson = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
int online = 0;
|
|
|
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//std::map<std::string, std::string> mapAttrs;
|
|
|
|
|
|
DataFields attrs;
|
|
|
|
|
|
|
|
|
|
|
|
// 通讯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);
|
|
|
|
|
|
|
|
|
|
|
|
// 启动通讯
|
|
|
|
|
|
int startComm();
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
static std::shared_ptr<Device> create(DataFields& fields);
|
|
|
|
|
|
};
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
//class Device
|
|
|
|
|
|
//{
|
|
|
|
|
|
//public:
|
|
|
|
|
|
// static void add(DataFields& fields);
|
|
|
|
|
|
//
|
|
|
|
|
|
// static std::vector<std::shared_ptr<DeviceEntity>> getDeviceByType(int type);
|
|
|
|
|
|
//
|
|
|
|
|
|
//public:
|
|
|
|
|
|
// static std::map<int, std::shared_ptr<DeviceEntity>> mapDevices;
|
|
|
|
|
|
//};
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|