Files
energy_storage/src/app/DataStruct.h

31 lines
671 B
C
Raw Normal View History

2025-09-16 19:38:46 +08:00
#pragma once
#include <map>
#include <string>
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;
int bytes {0};
std::string remark;
int ratio {1};
2025-09-04 19:31:04 +08:00
2025-09-16 19:38:46 +08:00
RegAddrUnit() {}
RegAddrUnit(std::string key, std::string datatype, std::string remark)
: key(key), datatype(datatype), remark(remark)
{
if (datatype == "uint16" || datatype == "int16") { bytes = 1; }
else if (datatype == "uint32" || datatype == "int32") { bytes = 2; }
}
2025-09-04 19:31:04 +08:00
};
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:
static std::map<std::string, std::map<std::string, RegAddrUnit>> s_mapReg;
2025-09-04 19:31:04 +08:00
2025-09-16 19:38:46 +08:00
static void load(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);
2025-09-04 19:31:04 +08:00
};