mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#pragma once
|
||
|
||
#include <string>
|
||
#include <map>
|
||
#include <vector>
|
||
#include <memory>
|
||
#include <unordered_map>
|
||
|
||
#include "common/Fields.h"
|
||
|
||
class CommEntity;
|
||
|
||
|
||
class Device
|
||
{
|
||
public:
|
||
static std::shared_ptr<Device> create(Fields& fields);
|
||
|
||
void setFields(Fields& fields);
|
||
|
||
int startComm();
|
||
|
||
void getCacheVoltage(std::vector<std::string>& vec);
|
||
void getCacheCurrent(std::vector<std::string>& vec);
|
||
void getCachePower(std::vector<std::string>& vec);
|
||
|
||
// int datatype: 1: 电压,2:电流,3:功率
|
||
void setCache(int datatype, std::vector<double>& vec);
|
||
|
||
bool cache(int npos);
|
||
void storeDB(int npos);
|
||
|
||
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);
|
||
|
||
|
||
public:
|
||
int deviceId = -1;
|
||
int type = -1;
|
||
std::string name;
|
||
std::string code;
|
||
int category;
|
||
bool isOpen = false;
|
||
std::string attrsJson = "";
|
||
|
||
int err = 0;
|
||
int online = 0;
|
||
int running = 0;
|
||
|
||
//std::map<std::string, std::string> mapAttrs;
|
||
Fields attrs;
|
||
|
||
// 通讯entity
|
||
std::shared_ptr<CommEntity> commEntity;
|
||
|
||
int64_t tsDataDate {};
|
||
std::map<int, double> mapCacheVoltage;
|
||
std::map<int, double> mapCacheCurrent;
|
||
std::map<int, double> mapCachePower;
|
||
std::map<std::string, std::string> mapParams;
|
||
};
|