增加了xc声纳的上电

This commit is contained in:
zjk
2025-09-12 11:35:17 +08:00
parent c2b9bccfc6
commit 481171d9ea
43 changed files with 1921 additions and 296 deletions
@@ -0,0 +1,63 @@
/* json 格式 XC阵控制软件→复合能源管控系统
{
"xcLowVoltageAdd_int32 " : XX //命令类型:“无命令”0,“申请仪表上电”1,“申请仪表断电”2;类型:int
"xcHighVoltageAdd_int32 " : XX, //命令类型:“无命令”0,“申请高压上电”1,“申请高压断电”2;类型:int
}
*/
#ifndef UDETECT_XCVOLTAGE_CMD_H
#define UDETECT_XCVOLTAGE_CMD_H
#include "../logc/loguru.hpp"
#include "json/json.h"
#include <string>
#include <memory>
class uDetect_xcVoltage_cmd
{
private:
/* data */
public:
uDetect_xcVoltage_cmd(){};
~uDetect_xcVoltage_cmd(){};
int xcLowVoltageAdd_int32;
int xcHighVoltageAdd_int32;
static std::string key;
std::string toJsonString()
{
Json::Value j;
j["xcLowVoltageAdd_int32"] = xcLowVoltageAdd_int32;
j["xcHighVoltageAdd_int32"] = xcHighVoltageAdd_int32;
Json::StreamWriterBuilder builder;
builder.settings_["indentation"] = "";
return Json::writeString(builder, j);
}
bool fromJsonString(std::string jsonString)
{
Json::CharReaderBuilder readerBuilder;
std::unique_ptr<Json::CharReader> reader(readerBuilder.newCharReader());
Json::Value j;
std::string errors;
bool parsingSuccessful = reader->parse(jsonString.c_str(), jsonString.c_str() + jsonString.length(), &j, &errors);
if (!parsingSuccessful) {
LOG_F(ERROR, "Failed to parse JSON: %s", errors.c_str());
return false;
}
if (j.isMember("xcLowVoltageAdd_int32") && j.isMember("xcHighVoltageAdd_int32")) {
xcLowVoltageAdd_int32 = j["xcLowVoltageAdd_int32"].asInt();
xcHighVoltageAdd_int32 = j["xcHighVoltageAdd_int32"].asInt();
LOG_F(INFO, "xcLowVoltageAdd_int32: %d", xcLowVoltageAdd_int32);
LOG_F(INFO, "xcHighVoltageAdd_int32: %d", xcHighVoltageAdd_int32);
LOG_F(INFO, "jsonString: %s", jsonString.c_str());
return true;
}
LOG_F(ERROR, "JSON does not contain required fields");
return false;
}
};
#endif
@@ -0,0 +1,58 @@
/* json 格式 XC阵控制软件→复合能源管控系统
{
"zdpVoltageAdd_int32 " : XX //命令类型:“无命令”0,“申请仪表上电”1,“申请仪表断电”2;类型:int
}
*/
#ifndef UDETECT_ZDPVOLTAGE_CMD_H
#define UDETECT_ZDPVOLTAGE_CMD_H
#include "../logc/loguru.hpp"
#include "json/json.h"
#include <string>
#include <memory>
class uDetect_zdpVoltage_cmd
{
private:
/* data */
public:
uDetect_zdpVoltage_cmd(){};
~uDetect_zdpVoltage_cmd(){};
int zdpVoltageAdd_int32;
static std::string key;
std::string toJsonString()
{
Json::Value j;
j["zdpVoltageAdd_int32"] = zdpVoltageAdd_int32;
Json::StreamWriterBuilder builder;
builder.settings_["indentation"] = "";
return Json::writeString(builder, j);
}
bool fromJsonString(std::string jsonString)
{
Json::CharReaderBuilder readerBuilder;
std::unique_ptr<Json::CharReader> reader(readerBuilder.newCharReader());
Json::Value j;
std::string errors;
bool parsingSuccessful = reader->parse(jsonString.c_str(), jsonString.c_str() + jsonString.length(), &j, &errors);
if (!parsingSuccessful) {
LOG_F(ERROR, "Failed to parse JSON: %s", errors.c_str());
return false;
}
if (j.isMember("zdpVoltageAdd_int32")) {
zdpVoltageAdd_int32 = j["zdpVoltageAdd_int32"].asInt();
LOG_F(INFO, "zdpVoltageAdd_int32: %d", zdpVoltageAdd_int32);
LOG_F(INFO, "jsonString: %s", jsonString.c_str());
return true;
}
LOG_F(ERROR, "JSON does not contain required fields");
return false;
}
};
#endif
@@ -0,0 +1,6 @@
#include "uDetect_zdpVoltage_cmd.h"
#include "uDetect_xcVoltage_cmd.h"
// 定义静态成员变量
std::string uDetect_zdpVoltage_cmd::key = "uDetect_zdpVoltage_cmd";
std::string uDetect_xcVoltage_cmd::key = "uDetect_xcVoltage_cmd";