finish add interface

This commit is contained in:
lnk
2026-03-13 16:29:46 +08:00
parent 8e41e3f4d8
commit 69accad937
4 changed files with 89 additions and 60 deletions

View File

@@ -70,50 +70,7 @@ extern std::map<std::string, Xmldata*> xmlinfo_list2;//保存所有型号角形
extern time_t ConvertToTimestamp(const tagTime& time);
/////////////////////////////////////////////////////////////////////////////////////////////////
// 运行信息
struct RunningInformation {
std::string Time;
std::string CpuLoad;
std::string FreeMemory;
std::string TotalMemory;
std::string FreeStorage;
std::string TotalStorage;
std::string HardTimeSync;
std::string SntpTimeSync;
std::string CloudTimeSync;
std::string SignalStrength;
};
// 版本信息
struct DeviceVersionInfo {
std::string BaseModel; // 1
std::string CloudProtocolVer; // 2
std::string AppVersion; // 3
std::string AppDate; // 4
std::string AppChecksum; // 5
std::string VoltageWiring; // 6
std::string CurrentBSynthetic; // 7
int DataStatInterval = 0; // 8
float RatedVoltage = 0.0f; // 9
float PTRatio = 0.0f; // 10
float CTRatio = 0.0f; // 11
std::string SntpIP; // 12
int SntpPort = 0; // 13
int SntpInterval = 0; // 14
int WebPort = 0; // 15
int FtpPort = 0; // 16
int PqdifInterval = 0; // 17
int WaveFileTypeCount = 0; // 18
std::string SpecialVersion; // 19
std::string DeviceModel; // 20
int HarmonicEnergyFlag = 0; // 21
std::string PhysicalName; // 22
std::string WaveLDName; // 23
int HighFreqHarmonicFlag = 0; // 24
unsigned int CommProtocols = 0; // 51
unsigned int TimeSyncMethods = 0;// 52
unsigned int DeviceFunctions = 0;// 53
};
////////////////////////////////////////////////////////////////////////////////////////////////////
//补招记录文件
@@ -3485,9 +3442,13 @@ std::string normalize_mac(const std::string &mac) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////检查云前置终端的mq业务超时
std::string get_type_by_state(int state) {
switch (state) {
case static_cast<int>(DeviceState::IDLE):
return "空闲状态";
case static_cast<int>(DeviceState::HEART_BEAT):
return "装置心跳";
case static_cast<int>(DeviceState::READING_STATS):
return "读取统计数据";
@@ -3537,19 +3498,31 @@ std::string get_type_by_state(int state) {
return "读取装置版本配置信息";
case static_cast<int>(DeviceState::SET_RIGHTTIME):
return "设置装置对时";
return "设置装置对时(定时执行)";
case static_cast<int>(DeviceState::SET_RIGHTTIME_2):
return "设置装置对时(主动触发)";
case static_cast<int>(DeviceState::READING_EVENTLOG):
return "补招事件日志";
case static_cast<int>(DeviceState::READING_STATSFILE):
return "补招文件";
return "补招稳态数据文件";
case static_cast<int>(DeviceState::SET_CTRL):
return "装置控制命令";
case static_cast<int>(DeviceState::SET_PREUPGRADE):
return "装置预升级校验";
case static_cast<int>(DeviceState::SET_UPGRADE):
return "装置升级";
case static_cast<int>(DeviceState::CUSTOM_ACTION):
return "自定义动作";
default:
return "未知业务"; // 未匹配的类型
return "未知业务";
}
}
@@ -5790,9 +5763,9 @@ bool send_running_info(terminal_dev* dev, const RunningInformation& info) {
return false;
}
// 判断 isbusy==1 且 busytype==READING_RUNNINGINFO
if (dev->isbusy != 1 || dev->busytype != static_cast<int>(DeviceState::READING_RUNNINGINFO)) {
std::cerr << "[send_running_info] device not in READING_RUNNINGINFO state." << std::endl;
// 判断 isbusy==1 且 busytype==READING_RUNNINGINFORMATION_1
if (dev->isbusy != 1 || dev->busytype != static_cast<int>(DeviceState::READING_RUNNINGINFORMATION_1)) {
std::cerr << "[send_running_info] device not in READING_RUNNINGINFORMATION_1 state." << std::endl;
return false;
}
@@ -5881,9 +5854,9 @@ bool send_version_info(terminal_dev* dev, const DeviceVersionInfo& info) {
return false;
}
// 判断 isbusy==1 且 busytype==READING_VERSIONINFO
if (dev->isbusy != 1 || dev->busytype != static_cast<int>(DeviceState::READING_VERSIONINFO)) {
std::cerr << "[send_version_info] device not in READING_VERSIONINFO state." << std::endl;
// 判断 isbusy==1 且 busytype==READING_DEVVERSION
if (dev->isbusy != 1 || dev->busytype != static_cast<int>(DeviceState::READING_DEVVERSION)) {
std::cerr << "[send_version_info] device not in READING_DEVVERSION state." << std::endl;
return false;
}
@@ -6357,7 +6330,7 @@ void on_device_response_minimal(int response_code,
}
// ================= 特殊:读取运行信息 =================
case DeviceState::READING_RUNNINGINFO: {
case DeviceState::READING_RUNNINGINFORMATION_1: {
std::lock_guard<std::mutex> lk(ledgermtx);
terminal_dev* dev = nullptr;