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-09-09 19:26:05 +08:00
|
|
|
|
#include <unordered_map>
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
#include "common/Fields.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
class CommEntity;
|
|
|
|
|
|
|
2025-09-08 19:34:12 +08:00
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
class Device
|
2025-07-18 09:08:09 +08:00
|
|
|
|
{
|
2025-09-08 19:34:12 +08:00
|
|
|
|
public:
|
|
|
|
|
|
static std::shared_ptr<Device> create(Fields& fields);
|
|
|
|
|
|
|
2025-09-12 18:44:34 +08:00
|
|
|
|
void setFields(Fields& fields);
|
|
|
|
|
|
|
2025-09-08 19:34:12 +08:00
|
|
|
|
int startComm();
|
|
|
|
|
|
|
|
|
|
|
|
void getCacheVoltage(std::vector<std::string>& vec);
|
|
|
|
|
|
void getCacheCurrent(std::vector<std::string>& vec);
|
|
|
|
|
|
void getCachePower(std::vector<std::string>& vec);
|
|
|
|
|
|
|
2025-09-09 19:26:05 +08:00
|
|
|
|
// int datatype: 1: 电压,2:电流,3:功率
|
|
|
|
|
|
void setCache(int datatype, std::vector<double>& vec);
|
|
|
|
|
|
|
|
|
|
|
|
bool cache(int npos);
|
|
|
|
|
|
void storeDB(int npos);
|
|
|
|
|
|
|
2025-09-08 19:34:12 +08:00
|
|
|
|
void setParam(std::string k, std::string v);
|
|
|
|
|
|
std::string getParam(std::string k, std::string defaultVal = "");
|
|
|
|
|
|
|
|
|
|
|
|
void getRuntimeParams(std::vector<std::pair<std::string, std::string>>& params);
|
|
|
|
|
|
|
2025-09-09 19:26:05 +08:00
|
|
|
|
|
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;
|
|
|
|
|
|
|
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-08 19:34:12 +08:00
|
|
|
|
std::map<std::string, std::string> mapParams;
|
2025-08-20 19:00:22 +08:00
|
|
|
|
};
|