2025-08-20 19:00:22 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
#include <unordered_map>
|
2025-08-28 18:42:37 +08:00
|
|
|
|
#include "common/Fields.h"
|
2025-09-14 16:00:30 +08:00
|
|
|
|
#include "Policy.h"
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
class Device;
|
2025-09-04 19:31:04 +08:00
|
|
|
|
class MqttClient;
|
|
|
|
|
|
|
|
|
|
|
|
struct TempHumUnit
|
|
|
|
|
|
{
|
2025-09-16 19:38:46 +08:00
|
|
|
|
float temp {0};
|
|
|
|
|
|
float hum {0};
|
|
|
|
|
|
TempHumUnit(float temp, float hum) : temp(temp), hum(hum) {};
|
2025-09-04 19:31:04 +08:00
|
|
|
|
TempHumUnit() {}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Fire40Unit
|
|
|
|
|
|
{
|
|
|
|
|
|
//主控数量 R uint16 1 0x0002
|
|
|
|
|
|
//主控ID R uint16 1 0x0003
|
2025-09-16 19:38:46 +08:00
|
|
|
|
int statusMain {0}; //主控状态 R uint16 0:正常 1:预警 2:火警 0x0004
|
2025-09-04 19:31:04 +08:00
|
|
|
|
//主控硬件版本 R uint16[2] 主控硬件版本 0x0005~0x0006
|
|
|
|
|
|
//主控软件版本 R uint16[2] 主控软件版本 0x0007~0x0008
|
|
|
|
|
|
//主电状态 R uint16 0:使用市电 1:使用备电 0x0009
|
|
|
|
|
|
//备电电流 R uint32 0.1A 0x000A
|
|
|
|
|
|
//备电电压 R uint32 0.1V 0x000C
|
|
|
|
|
|
//可用容量 R uint32 0.01Ah 0x000E
|
|
|
|
|
|
//可充放容量 R uint32 0.01Ah 0x0010
|
2025-09-16 19:38:46 +08:00
|
|
|
|
int usedAlarm {0}; //警铃是否使用 R uint16 0x0012
|
|
|
|
|
|
int statusAlarm {0}; //警铃状态 R uint16 0:无效 1:掉线 2:正常 3:启动 0x0013
|
|
|
|
|
|
int usedValve {0}; //瓶头阀是否使用 R uint16 0x0014
|
|
|
|
|
|
int statusValve {0}; //瓶头阀状态 R uint16 0:无效 1:掉线 2:正常 3:启动 0x0015
|
|
|
|
|
|
int usedMCP {0}; //手报是否使用 R uint16 0x0016
|
|
|
|
|
|
int statusMCP {0}; //手报状态 R uint16 0:无效 1:掉线 2:正常 3:启动 0x0017 // Manual Call Point (MCP)
|
2025-09-04 19:31:04 +08:00
|
|
|
|
//簇控制器数量 R uint16 0x0018
|
|
|
|
|
|
//复合探测器总数量 R uint16 0x0019
|
|
|
|
|
|
//烟雾探测器总数量 R uint16 0x001A
|
|
|
|
|
|
//压力探测器总数量 R uint16 0x001B
|
|
|
|
|
|
//吸气式探测器总数量 R uint16 0x001C
|
|
|
|
|
|
//PACK探测器总数量 R uint16 0x001D
|
|
|
|
|
|
//电池总数量 R uint16 0x001E
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct CoolingUnit
|
|
|
|
|
|
{
|
|
|
|
|
|
int powerOn {0}; //开关 R uint16 0:关机,1:开机 0x1003
|
|
|
|
|
|
int mode {0}; //采样模式 R uint16 0-出水温度 1-电芯温度 0x1004
|
|
|
|
|
|
int cooling {0}; //制冷状态 R uint16 0:关闭, 1:启动 0x1005
|
|
|
|
|
|
int heating {0}; //制热状态 R uint16 0:关闭, 1:启动 0x1006
|
|
|
|
|
|
int highTemp {0}; //高温告警 R uint16 0:正常,1:告警 0x1007
|
|
|
|
|
|
int lowTemp {0}; //低温告警 R uint16 0:正常,1:告警 0x1008
|
|
|
|
|
|
int highPressure {0}; //高压告警 R uint16 0:正常,1:告警 0x1009
|
|
|
|
|
|
int lowPressure {0}; //低压告警 R uint16 0:正常,1:告警 0x100A
|
|
|
|
|
|
//进水温度传感器 R uint16 0:正常,1:告警 0x100B
|
|
|
|
|
|
//出水温度传感器 R uint16 0:正常,1:告警 0x100C
|
|
|
|
|
|
//进水压力传感器 R uint16 0:正常,1:告警 0x100D
|
|
|
|
|
|
//出水压力传感器 R uint16 0:正常,1:告警 0x100E
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct AircUnit
|
|
|
|
|
|
{
|
|
|
|
|
|
int powerOn {0}; //开关 R uint16 0:关机,1:开机
|
|
|
|
|
|
int cooling {0}; //启动制冷指令 R uint16 0:关闭, 1:启动
|
|
|
|
|
|
int airSupply {0}; //启动送风指令 R uint16 0:关闭, 1:启动
|
|
|
|
|
|
int standby {0}; //启动待机指令 R uint16 0:关闭, 1:启动
|
|
|
|
|
|
int heating {0}; //启动加热指令 R uint16 0:关闭, 1:启动
|
|
|
|
|
|
int sensorAlarm {0}; //传感器故障 R uint16 0:正常,1:告警
|
|
|
|
|
|
int voltageAlarm {0}; //高低电压告警 R uint16 0:正常,1:告警
|
|
|
|
|
|
int tempAlarm {0}; //高低温告警 R uint16 0:正常,1:告警
|
|
|
|
|
|
int pressureAlarm {0}; //高低压告警 R uint16 0:正常,1:告警
|
|
|
|
|
|
int compressorAlarm {0};//压缩机告警 R uint16 0:正常,1:告警
|
|
|
|
|
|
|
|
|
|
|
|
//制冷点 R int16 0.1℃ 0x0003
|
|
|
|
|
|
//制冷偏差 R int16 0.1℃ 0x0004
|
|
|
|
|
|
//高温告警值 R int16 0.1℃ 0x0005
|
|
|
|
|
|
//低温告警值 R int16 0.1℃ 0x0006
|
|
|
|
|
|
//制热点 R int16 0.1℃ 0x0007
|
|
|
|
|
|
//制热偏差 R int16 0.1℃ 0x0008
|
|
|
|
|
|
int temp {0}; //当前温度 R int16 0.1℃ 0x0009
|
|
|
|
|
|
int hum {0}; //当前湿度 R int16 0.1℃ 0x000A
|
|
|
|
|
|
//除湿开启温度 R int16 0.1℃ 0x000B
|
|
|
|
|
|
//除湿停止温度 R int16 0.1℃ 0x000C
|
|
|
|
|
|
//除湿开启湿度 R int16 0.1℃ 0x000D
|
|
|
|
|
|
//除湿停止湿度 R int16 0.1℃ 0x000E
|
|
|
|
|
|
};
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
class Station
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
2025-08-28 18:42:37 +08:00
|
|
|
|
Station();
|
|
|
|
|
|
|
|
|
|
|
|
void setFields(Fields& fields);
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
void addDevice(int deviceId, std::shared_ptr<Device> device);
|
2025-09-12 18:44:34 +08:00
|
|
|
|
void addDevice(Fields& fields);
|
2025-08-20 19:00:22 +08:00
|
|
|
|
std::shared_ptr<Device> getDevice(int deviceId);
|
2025-09-16 19:38:46 +08:00
|
|
|
|
|
|
|
|
|
|
void groupDevice();
|
2025-09-08 19:34:12 +08:00
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Device> getDeviceByType(int deviceType, std::string code);
|
2025-08-28 18:42:37 +08:00
|
|
|
|
void getDeviceByType(int typeId, std::vector<std::shared_ptr<Device>>& res);
|
2025-09-12 18:44:34 +08:00
|
|
|
|
int getDeviceCount(int category);
|
2025-09-16 19:38:46 +08:00
|
|
|
|
void getDeviceByCategory(int category, std::vector<std::shared_ptr<Device>>& res);
|
2025-08-28 18:42:37 +08:00
|
|
|
|
|
2025-08-26 18:36:25 +08:00
|
|
|
|
void setWorkMode(int modeId);
|
|
|
|
|
|
void setPolicy(int policyId);
|
|
|
|
|
|
|
2025-09-09 19:26:05 +08:00
|
|
|
|
void writeRuntimeData(std::string dt, int npos);
|
2025-09-16 19:38:46 +08:00
|
|
|
|
void writeStatistic(std::string dt);
|
2025-08-26 18:36:25 +08:00
|
|
|
|
|
2025-09-13 17:28:35 +08:00
|
|
|
|
void initMqtt();
|
2025-09-12 18:44:34 +08:00
|
|
|
|
void polling();
|
2025-09-13 17:28:35 +08:00
|
|
|
|
void setGarewayWorkMode();
|
2025-08-28 18:42:37 +08:00
|
|
|
|
|
2025-09-16 19:38:46 +08:00
|
|
|
|
void setRuntimeData(string addr, int val);
|
|
|
|
|
|
void setTHData(int deviceNo, string addr, int val);
|
|
|
|
|
|
void setFire40Data(int deviceNo, string addr, int val);
|
|
|
|
|
|
void setCoolingData(int deviceNo, string addr, int val);
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
public:
|
2025-09-09 19:26:05 +08:00
|
|
|
|
int stationId {};
|
2025-08-20 19:00:22 +08:00
|
|
|
|
std::string name;
|
2025-09-04 19:31:04 +08:00
|
|
|
|
std::string code;
|
2025-09-13 17:28:35 +08:00
|
|
|
|
bool isOpen {false};
|
2025-09-10 20:10:51 +08:00
|
|
|
|
int status {0};
|
2025-09-14 16:00:30 +08:00
|
|
|
|
std::string operationDate;
|
|
|
|
|
|
SysPolicy policy;
|
|
|
|
|
|
|
2025-09-01 20:08:40 +08:00
|
|
|
|
bool isConnected {false};
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
2025-08-28 18:42:37 +08:00
|
|
|
|
int workModeId {}; // 运行模式
|
|
|
|
|
|
int runPolicyId {}; // 运行策略
|
2025-08-26 18:36:25 +08:00
|
|
|
|
|
2025-09-16 19:38:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/// === 系统统计 ===
|
|
|
|
|
|
// 累计发电量,单位:kWh
|
2025-09-12 18:44:34 +08:00
|
|
|
|
double electGenTotal {};
|
2025-08-20 19:00:22 +08:00
|
|
|
|
// 累计入网电量,单位:kWh
|
|
|
|
|
|
double electGridTotal {};
|
|
|
|
|
|
// 累计收益,单位:元
|
|
|
|
|
|
double incomeTotal {};
|
|
|
|
|
|
// 累计储能充电电量
|
|
|
|
|
|
double electStorageIn {};
|
|
|
|
|
|
// 累计储能放电电量
|
|
|
|
|
|
double electStorageOut {};
|
|
|
|
|
|
|
2025-09-12 18:44:34 +08:00
|
|
|
|
// 储能容量
|
|
|
|
|
|
double capacity {};
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/// === 日统计 ===
|
|
|
|
|
|
double storageIn {}; // 储能充电电量
|
|
|
|
|
|
double storageOut {}; // 储能放电电量
|
|
|
|
|
|
|
|
|
|
|
|
int storageNumIn {}; // 储能充电次数
|
|
|
|
|
|
int storageNumOut {}; // 储能放电次数
|
|
|
|
|
|
int storageNumErr {}; // 储能故障次数
|
|
|
|
|
|
|
|
|
|
|
|
double solarGen {}; // 光伏发电电量
|
|
|
|
|
|
double solarGrid {}; // 光伏入网电量
|
|
|
|
|
|
int solarNumErr {}; // 光伏故障次数
|
|
|
|
|
|
|
|
|
|
|
|
double chargeElect {}; // 充电设备充电电量
|
|
|
|
|
|
int chargeNum {}; // 充电设备充电次数
|
|
|
|
|
|
int chargeNumErr {}; // 充电设备故障次数
|
|
|
|
|
|
|
|
|
|
|
|
double incomeElect {}; // 发电收益金额
|
|
|
|
|
|
double incomeCharge {}; // 充电收益金额
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/// === 环境 ===
|
|
|
|
|
|
// 光照度
|
|
|
|
|
|
double illuminance {};
|
|
|
|
|
|
// 辐照度
|
|
|
|
|
|
double irradiance {};
|
|
|
|
|
|
// 风速
|
|
|
|
|
|
double windspeed {};
|
|
|
|
|
|
// 温度
|
|
|
|
|
|
double temperature {};
|
|
|
|
|
|
// 湿度
|
|
|
|
|
|
double humidity {};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/// === 设备信息 ===
|
2025-08-28 18:42:37 +08:00
|
|
|
|
std::unordered_map<int, std::shared_ptr<Device>> mapDevice;
|
2025-09-16 19:38:46 +08:00
|
|
|
|
std::map<int, std::map<std::string, std::shared_ptr<Device>>> mapDeviceGroup;
|
2025-08-28 18:42:37 +08:00
|
|
|
|
|
2025-09-04 19:31:04 +08:00
|
|
|
|
|
|
|
|
|
|
// 温湿度信息
|
|
|
|
|
|
std::map<int, TempHumUnit> mapTempHumUnit;
|
|
|
|
|
|
// 消防4.0信息
|
2025-09-16 19:38:46 +08:00
|
|
|
|
std::map<int, Fire40Unit> mapFire40Unit;
|
2025-09-04 19:31:04 +08:00
|
|
|
|
// 冷机信息
|
|
|
|
|
|
std::map<int, CoolingUnit> mapCoolingUnit;
|
|
|
|
|
|
// 空调信息
|
|
|
|
|
|
std::map<int, AircUnit> mapAircUnit;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/// === MQTT client
|
|
|
|
|
|
std::shared_ptr<MqttClient> mqttCli {nullptr};
|
2025-09-06 15:23:07 +08:00
|
|
|
|
|
2025-09-16 19:38:46 +08:00
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
|
int64_t ts;
|
|
|
|
|
|
|
|
|
|
|
|
double totalElectIn; //总充电电量 R uint32 1kWh 6659(0x112D) 0x112C
|
|
|
|
|
|
double totalElectOut; //总放电电量 R uint32 1kWh 4925(0x112F) 0x112E
|
|
|
|
|
|
double totalIncomeIn; //总充电费用 R uint32 1RMB 6605(0x1131) 0x1130
|
|
|
|
|
|
double totalIncomeOut; //总放电费用 R uint32 1RMB 4949(0x1133) 0x1132
|
|
|
|
|
|
double totalIncome; //总收益 R int32 1RMB -1 0x1134
|
|
|
|
|
|
//储能充放电时段hh R uint16 时 336 0x01 0x121C
|
|
|
|
|
|
//储能充放电时段mm R uint16 分 0 0x01 0x121D
|
|
|
|
|
|
//储能充放电时段ss R uint16 秒 0 0x01 0x121E
|
|
|
|
|
|
|
|
|
|
|
|
double totalDurationIn;
|
|
|
|
|
|
double totalDurationOut;
|
|
|
|
|
|
|
|
|
|
|
|
double dayElectIn; // 日充电电量 R uint32 1kWh 0 0x110E
|
|
|
|
|
|
double dayElectOut; // 日放电电量 R uint32 1kWh 0 0x1110
|
|
|
|
|
|
double dayIncomeIn; // 日充电费用 R uint32 1RMB 0 0x1112
|
|
|
|
|
|
double dayIncomeOut; // 日放电费用 R uint32 1RMB 0 0x1114
|
|
|
|
|
|
double dayIncome; // 日收益 R int32 1RMB 0 0x1116
|
|
|
|
|
|
|
|
|
|
|
|
} statData;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
struct {
|
|
|
|
|
|
} runtimeData;
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
};
|