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-08-20 19:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
class Device;
|
2025-09-04 19:31:04 +08:00
|
|
|
|
class MqttClient;
|
|
|
|
|
|
|
|
|
|
|
|
struct TempHumUnit
|
|
|
|
|
|
{
|
|
|
|
|
|
int temp {0};
|
|
|
|
|
|
int hum {0};
|
|
|
|
|
|
TempHumUnit(int temp, int hum) : temp(temp), hum(hum) {};
|
|
|
|
|
|
TempHumUnit() {}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Fire40Unit
|
|
|
|
|
|
{
|
|
|
|
|
|
//主控数量 R uint16 1 0x0002
|
|
|
|
|
|
//主控ID R uint16 1 0x0003
|
|
|
|
|
|
//主控状态 R uint16 0:正常 1:预警 2:火警 0x0004
|
|
|
|
|
|
//主控硬件版本 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
|
|
|
|
|
|
//警铃是否使用 R uint16 0x0012
|
|
|
|
|
|
//警铃状态 R uint16 0:无效 1:掉线 2:正常 3:启动 0x0013
|
|
|
|
|
|
//瓶头阀是否使用 R uint16 0x0014
|
|
|
|
|
|
//瓶头阀状态 R uint16 0:无效 1:掉线 2:正常 3:启动 0x0015
|
|
|
|
|
|
//手报是否使用 R uint16 0x0016
|
|
|
|
|
|
//手报状态 R uint16 0:无效 1:掉线 2:正常 3:启动 0x0017
|
|
|
|
|
|
//簇控制器数量 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-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-06 15:23:07 +08:00
|
|
|
|
void getDeviceByGroup(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-08-26 18:36:25 +08:00
|
|
|
|
|
2025-09-12 18:44:34 +08:00
|
|
|
|
void polling();
|
2025-08-28 18:42:37 +08:00
|
|
|
|
|
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-10 20:10:51 +08:00
|
|
|
|
int status {0};
|
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-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-06 15:23:07 +08:00
|
|
|
|
std::map<int, std::vector<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信息
|
|
|
|
|
|
std::map<int, int> mapFire40Unit;
|
|
|
|
|
|
// 冷机信息
|
|
|
|
|
|
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-08-20 19:00:22 +08:00
|
|
|
|
};
|