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;

View File

@@ -753,6 +753,9 @@ void filemenu_cache_put(const std::string& dev_id,
//提取目录信息
bool filemenu_cache_take(const std::string& dev_id, std::vector<tag_dir_info>& out);
//清空装置台账
size_t erase_one_terminals_by_id(const std::string& terminal_id);
@@ -980,7 +983,6 @@ static bool parse_datetime_tm(const std::string& s, std::tm& out) {
std::memset(&out, 0, sizeof(out));
return strptime(s.c_str(), "%Y-%m-%d %H:%M:%S", &out) != nullptr;
}
#endif
/////////////////////////////////////////////////////////////////////////////补招文件记录
// 记录 (guid, monitorId) -> 文件完整路径
@@ -1015,4 +1017,56 @@ bool SendFileWebAuto(const std::string& id,
const std::string& remote_path,
std::string& out_filename);
void cleanup_old_unpaired_qvvr_events();
void cleanup_old_unpaired_qvvr_events();
// 运行信息
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
};
void runninginfo_cache_put(const std::string& dev_id, const RunningInformation& info);
bool runninginfo_cache_take(const std::string& dev_id, RunningInformation& out);
void versioninfo_cache_put(const std::string& dev_id, const DeviceVersionInfo& info);
bool versioninfo_cache_take(const std::string& dev_id, DeviceVersionInfo& out);
#endif

View File

@@ -2392,7 +2392,7 @@ bool parsemsg(const std::string& devid, const std::string& guid, const nlohmann:
}
// 方案AMsg 为空,直接使用当前系统时间下发
ClientManager::instance().set_righttime_action_to_devic(devid);
ClientManager::instance().set_righttime_action_to_device(devid);
return true;
}

View File

@@ -1493,7 +1493,7 @@ void process_received_message(string mac, string id,const char* data, size_t len
std::string payload(payloadBytes.begin(), payloadBytes.end());
// 定义类似New_MachMessage的结构体
struct RunningInformation {
/*struct RunningInformation {
std::string Time;
std::string CpuLoad;
std::string FreeMemory;
@@ -1504,7 +1504,8 @@ void process_received_message(string mac, string id,const char* data, size_t len
std::string SntpTimeSync;
std::string CloudTimeSync;
std::string SignalStrength;
} result;
} result;*/
RunningInformation result;
// 辅助函数:去除字符串两端的引号
auto trimQuotes = [](const std::string& str) -> std::string {
@@ -1896,7 +1897,7 @@ void process_received_message(string mac, string id,const char* data, size_t len
std::string payload(payloadBytes.begin(), payloadBytes.end());
// 定义存储装置版本信息的结构体
struct DeviceVersionInfo {
/*struct DeviceVersionInfo {
std::string BaseModel; // 1: 装置基础型号
std::string CloudProtocolVer; // 2: 云服务协议版本
std::string AppVersion; // 3: 应用程序版本号
@@ -1924,7 +1925,8 @@ void process_received_message(string mac, string id,const char* data, size_t len
unsigned int CommProtocols = 0; // 51: 投入的通讯协议
unsigned int TimeSyncMethods = 0;// 52: 投入的对时方式
unsigned int DeviceFunctions = 0;// 53: 装置功能配置
} versionInfo;
} versionInfo;*/
DeviceVersionInfo versionInfo;
// 分割字段
std::vector<std::string> fields;