Files
energy_storage/src/app/DataStruct.h

99 lines
2.3 KiB
C
Raw Normal View History

2025-09-16 19:38:46 +08:00
#pragma once
#include <map>
#include <string>
#include <vector>
2025-09-04 19:31:04 +08:00
2025-09-19 18:54:36 +08:00
enum class EAlertType
{
SYS = 1, // 系统告警
USER = 2, // 用户告警
DEVICE = 3, // 设备告警
};
enum class EDeviceType
{
//1 变压器 0
//2 配电柜 0
//3 电表 1
//4 门禁 0
//5 空调 0
//6 照明 0
//7 消防 0
//8 光照监测设备 0
//9 风速监测设备 0
//10 温湿度监测设备 0
//11 烟感监测设备 0
//12 水浸传感器 0
//13 视频监控 4
//14 冷机 0
//15 网关 0
//100 储能预制舱 1
EMS = 101,//101 EMS 1
PCS = 102, //102 PCS 1
PCU = 103, //103 PCU 1
BMS = 104, //104 BMS 1
BCU = 105, //105 BCU 1
2025-09-22 20:01:41 +08:00
CHARGER = 106, //106 充电桩 2
2025-09-19 18:54:36 +08:00
//107 充电枪 2
//108 集中器 2
//109 光伏板 3
//110 风力发电机 3
};
2025-09-04 19:31:04 +08:00
2025-09-16 19:38:46 +08:00
struct RegAddrUnit
2025-09-04 19:31:04 +08:00
{
2025-09-16 19:38:46 +08:00
std::string key;
std::string datatype;
2025-09-19 18:54:36 +08:00
std::string name;
2025-09-16 19:38:46 +08:00
std::string remark;
int ratio {1};
2025-09-19 18:54:36 +08:00
int alert {0};
2025-09-04 19:31:04 +08:00
2025-09-16 19:38:46 +08:00
RegAddrUnit() {}
2025-09-19 18:54:36 +08:00
RegAddrUnit(std::string key, std::string datatype, int alert, std::string name, std::string remark)
: key(key), datatype(datatype), alert(alert), name(name), remark(remark)
2025-09-16 19:38:46 +08:00
{
}
2025-09-04 19:31:04 +08:00
};
// 需要在前端展示的设备参数
struct DeviceParamAddr
{
std::string name;
std::string addr;
std::string defaultVal;
std::string unit;
float ratio {1.0};
DeviceParamAddr() {};
DeviceParamAddr(std::string name, std::string addr, std::string defaultVal, std::string unit, float ratio = 1.0f)
: name(name), addr(addr), defaultVal(defaultVal), unit(unit), ratio(ratio)
{
if (this->ratio == 0.0)
{
this->ratio = 1.0f;
}
};
};
2025-09-16 19:38:46 +08:00
class REGAddr
2025-09-04 19:31:04 +08:00
{
2025-09-16 19:38:46 +08:00
public:
// key: 寄存器地址
2025-09-16 19:38:46 +08:00
static std::map<std::string, std::map<std::string, RegAddrUnit>> s_mapReg;
2025-09-04 19:31:04 +08:00
static std::map<int, std::vector<DeviceParamAddr>> s_mapDeviceAddrParam;
static std::map<int, std::vector<std::string>> s_mapDeviceAddrCurve;
static std::map<int, std::map<std::string, std::map<std::string, std::string>>> g_mapRegAddrValStr;
static std::map<int, std::map<std::string, RegAddrUnit>> g_mapRegDeviceType;
2025-09-16 19:38:46 +08:00
static void load(std::string filename);
static void loadParamAddr(std::string filename);
2025-09-04 19:31:04 +08:00
2025-09-16 19:38:46 +08:00
static std::map<std::string, RegAddrUnit>* getRegMap(std::string name);
static std::map<std::string, RegAddrUnit>* getRegMapByDeviceType(int deviceType);
static std::vector<DeviceParamAddr>& GetDeviceParamAddrs(int deviceType);
2025-09-04 19:31:04 +08:00
};