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-09-06 15:23:07 +08:00
|
|
|
|
int category;
|
2025-07-18 09:08:09 +08:00
|
|
|
|
bool isOpen = false;
|
|
|
|
|
|
std::string attrsJson = "";
|
|
|
|
|
|
|
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
int online = 0;
|
2025-09-06 15:23:07 +08:00
|
|
|
|
int running = 0;
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
//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 {};
|
2025-09-06 15:23:07 +08:00
|
|
|
|
std::map<int, double> mapCacheVoltage;
|
|
|
|
|
|
std::map<int, double> mapCacheCurrent;
|
|
|
|
|
|
std::map<int, double> mapCachePower;
|
2025-09-04 19:31:04 +08:00
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
// 启动通讯
|
|
|
|
|
|
int startComm();
|
2025-09-06 15:23:07 +08:00
|
|
|
|
void getRuntimeParams(std::vector<std::pair<std::string, std::string>>& params);
|
|
|
|
|
|
void getCacheVoltage(std::vector<std::string>& vec);
|
|
|
|
|
|
void getCacheCurrent(std::vector<std::string>& vec);
|
|
|
|
|
|
void getCachePower(std::vector<std::string>& vec);
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
static std::shared_ptr<Device> create(Fields& fields);
|
2025-08-20 19:00:22 +08:00
|
|
|
|
};
|