modify for ledgerupdate
This commit is contained in:
@@ -597,10 +597,12 @@ bool ParseXMLConfig2(XmlConfig *cfg, list<CTopic*> *ctopiclist,QString path) //
|
||||
QFile file(xml_dir + JSON_CONFIG_FN);
|
||||
if (!file.open(QIODevice::ReadOnly | QFile::Text)) //<2F><>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>xml
|
||||
{
|
||||
std::cout << "can't open not define config file" << std::endl;//lnk20250208
|
||||
return 0;
|
||||
}
|
||||
if (!doc.setContent(&file)) //<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>doc<6F><63>
|
||||
{
|
||||
std::cout << "can't read not define config file" << std::endl;//lnk20250208
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
@@ -613,10 +615,12 @@ bool ParseXMLConfig2(XmlConfig *cfg, list<CTopic*> *ctopiclist,QString path) //
|
||||
QFile file(tmppath);
|
||||
if (!file.open(QIODevice::ReadOnly | QFile::Text)) //<2F><>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>xml
|
||||
{
|
||||
std::cout << "can't open config file" << tmppath.toStdString() <<std::endl;//lnk20250208
|
||||
return 0;
|
||||
}
|
||||
if (!doc.setContent(&file)) //<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>doc<6F><63>
|
||||
{
|
||||
std::cout << "can't read config file" << tmppath.toStdString() <<std::endl;//lnk20250208
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
@@ -2896,7 +2900,7 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20241125
|
||||
cout << "setxmldatabase:" << TMNL_TYPE << endl;
|
||||
|
||||
if (!xmlinfo_list.contains(type))//<2F><><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1>в<EFBFBD><EFBFBD><EFBFBD>
|
||||
if (!xmlinfo_list.contains(type))//<2F><><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>û<EFBFBD>鵽
|
||||
{
|
||||
Xmldata* config = new Xmldata(); //û<>ҵ<EFBFBD><D2B5>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ն<EFBFBD><D5B6><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>б<EFBFBD><D0B1><EFBFBD>
|
||||
xmlinfo_list.insert(type, config);
|
||||
@@ -2904,7 +2908,7 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20241125
|
||||
cout << "xmlinfo_list insert type:" << type.toStdString() << endl;
|
||||
}
|
||||
else
|
||||
else//<2F>鵽<EFBFBD><EFBFBD><CDB8>¸<EFBFBD><C2B8><EFBFBD>
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20241125
|
||||
cout << "xmlinfo_list type contain:" << type.toStdString() << endl;
|
||||
@@ -2916,13 +2920,19 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char
|
||||
else {
|
||||
xmlinfo_list[type]->updataflag = true;
|
||||
}
|
||||
|
||||
//lnk20250208<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
|
||||
}
|
||||
|
||||
xmlinfo_list[type]->xmlbase.MODEL_ID.append(id);
|
||||
xmlinfo_list[type]->xmlbase.TMNL_TYPE.append(type);
|
||||
xmlinfo_list[type]->xmlbase.FILE_PATH.append(filepath);
|
||||
xmlinfo_list[type]->xmlbase.FILE_NAME.append(name);
|
||||
//lnk20250208<30><38><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>Ǹ<EFBFBD><C7B8>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7B7>
|
||||
//xmlinfo_list[type]->xmlbase.MODEL_ID.append(id);
|
||||
//xmlinfo_list[type]->xmlbase.TMNL_TYPE.append(type);
|
||||
//xmlinfo_list[type]->xmlbase.FILE_PATH.append(filepath);
|
||||
//xmlinfo_list[type]->xmlbase.FILE_NAME.append(name);
|
||||
xmlinfo_list[type]->xmlbase.MODEL_ID = id;
|
||||
xmlinfo_list[type]->xmlbase.TMNL_TYPE = type;
|
||||
xmlinfo_list[type]->xmlbase.FILE_PATH = filepath;
|
||||
xmlinfo_list[type]->xmlbase.FILE_NAME = name;
|
||||
|
||||
|
||||
QDateTime time(QDate(year, month, day), QTime(hour, minute, second));
|
||||
xmlinfo_list[type]->xmlbase.datetime = time;
|
||||
@@ -3047,7 +3057,7 @@ char* Get_IED(char* devtype)
|
||||
QString type;
|
||||
type.append(devtype);
|
||||
if (xmlinfo_list.contains(type)) {
|
||||
cout << "!!!!!!!!!! xmlinfo_list.contains(devtype) == 1 !!!!!!!!!!!" << endl;
|
||||
cout << "!!!!!!!!!! Get_IED xmlinfo_list.contains(devtype) == 1 !!!!!!!!!!!" << endl;
|
||||
QString ied;
|
||||
ied.append(xmlinfo_list[devtype]->xmlcfg.IEDname);//PQMonitor
|
||||
ied.append(xmlinfo_list[devtype]->xmlcfg.LDevicePrefix);
|
||||
@@ -3059,7 +3069,7 @@ char* Get_IED(char* devtype)
|
||||
return charArray;
|
||||
}
|
||||
else {
|
||||
cout << "!!!!!!!!!! xmlinfo_list.contains(devtype) == 0 !!!!!!!!!!!" << endl;
|
||||
cout << "!!!!!!!!!! Get_IED xmlinfo_list.contains(devtype) == 0 !!!!!!!!!!!" << endl;
|
||||
//cout << "ttttttttttttttt" << topicList.size() << endl;
|
||||
//cout << "ttttttttttttttt" << xmlcfg.IEDname.toAscii().data() << endl;
|
||||
QString ied;
|
||||
|
||||
@@ -721,8 +721,16 @@ std::string extractDataJson(const char* inputJson) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// <20><>ȡ "messageBoy" <20><><EFBFBD><EFBFBD>
|
||||
cJSON* messageBoy = cJSON_GetObjectItem(root, "messageBoy");
|
||||
if (messageBoy == NULL || messageBoy->type != cJSON_Object) {
|
||||
std::cerr << "'messageBoy' is missing or is not an object" << std::endl;
|
||||
cJSON_Delete(root);
|
||||
return "";
|
||||
}
|
||||
|
||||
// <20><>ȡ "data" <20><><EFBFBD><EFBFBD>
|
||||
cJSON* data = cJSON_GetObjectItem(root, "data");
|
||||
cJSON* data = cJSON_GetObjectItem(messageBoy, "data");
|
||||
if (data == NULL || data->type != cJSON_Array) {
|
||||
std::cerr << "'data' is missing or is not an array" << std::endl;
|
||||
cJSON_Delete(root);
|
||||
@@ -768,12 +776,20 @@ bool parseJsonMessageRT(const std::string& body, std::string& devSeries, std::st
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><>ȡ "messageBoy" <20><><EFBFBD><EFBFBD>
|
||||
cJSON* messageBoy = cJSON_GetObjectItem(root, "messageBoy");
|
||||
if (messageBoy == NULL || messageBoy->type != cJSON_Object) {
|
||||
std::cerr << "'messageBoy' is missing or is not an object" << std::endl;
|
||||
cJSON_Delete(root);
|
||||
return "";
|
||||
}
|
||||
|
||||
// <20><>ȡ<EFBFBD>ֶ<EFBFBD>
|
||||
cJSON* devSeriesItem = cJSON_GetObjectItem(root, "devSeries");
|
||||
cJSON* lineItem = cJSON_GetObjectItem(root, "line");
|
||||
cJSON* realDataItem = cJSON_GetObjectItem(root, "realData");
|
||||
cJSON* soeDataItem = cJSON_GetObjectItem(root, "soeData");
|
||||
cJSON* limitItem = cJSON_GetObjectItem(root, "limit");
|
||||
cJSON* devSeriesItem = cJSON_GetObjectItem(messageBoy, "devSeries");
|
||||
cJSON* lineItem = cJSON_GetObjectItem(messageBoy, "line");
|
||||
cJSON* realDataItem = cJSON_GetObjectItem(messageBoy, "realData");
|
||||
cJSON* soeDataItem = cJSON_GetObjectItem(messageBoy, "soeData");
|
||||
cJSON* limitItem = cJSON_GetObjectItem(messageBoy, "limit");
|
||||
|
||||
if (devSeriesItem && lineItem && realDataItem && soeDataItem && limitItem) {
|
||||
devSeries = devSeriesItem->valuestring;
|
||||
@@ -896,6 +912,46 @@ void close_listening_socket() {
|
||||
}
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ip<69><70>ʽ
|
||||
bool isValidIP(const std::string &ip) {
|
||||
std::vector<std::string> parts;
|
||||
std::stringstream ss(ip);
|
||||
std::string part;
|
||||
|
||||
// ʹ<><CAB9> "." <20><>Ϊ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD> IP <20><>ַ<EFBFBD>ָ<EFBFBD><D6B8>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
while (getline(ss, part, '.')) {
|
||||
parts.push_back(part);
|
||||
}
|
||||
|
||||
// IP <20><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4 <20><><EFBFBD><EFBFBD>
|
||||
if (parts.size() != 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// У<><D0A3>ÿһ<C3BF><D2BB><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <20><> 255 ֮<><D6AE>
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
// У<><D0A3>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
for (size_t j = 0; j < parts[i].size(); ++j) {
|
||||
if (!isdigit(parts[i][j])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Χ<EFBFBD><CEA7>
|
||||
int num = atoi(parts[i].c_str());
|
||||
if (num < 0 || num > 255) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>㣨<EFBFBD><E3A3A8> 01<30><31>001 <20>ȣ<EFBFBD>
|
||||
if (parts[i].length() > 1 && parts[i][0] == '0') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//ִ<>нű<D0BD><C5B1><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>
|
||||
void execute_bash(string fun,int process_num,string type)
|
||||
{
|
||||
@@ -918,6 +974,25 @@ void execute_bash(string fun,int process_num,string type)
|
||||
system(command);
|
||||
}
|
||||
|
||||
//ִ<>нű<D0BD><C5B1><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>
|
||||
void execute_bash_debug(string fun,string ip,string type)
|
||||
{
|
||||
|
||||
const char* script = "/FeProject/bin/set_debug.sh";//ʹ<><CAB9>setsid<69><64>ֹ<EFBFBD>˿<EFBFBD>ռ<EFBFBD><D5BC>
|
||||
const char* param1 = fun.c_str();
|
||||
const char* param2 = ip.c_str();
|
||||
const char* param3 = type.c_str();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command), "%s %s %s %s &", script, param1, param2, param3);
|
||||
|
||||
std::cout << "command:" << command <<std::endl;
|
||||
|
||||
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
system(command);
|
||||
}
|
||||
|
||||
void parse_set(const std::string& json_str) {
|
||||
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
cJSON* root = cJSON_Parse(json_str.c_str());
|
||||
@@ -926,8 +1001,16 @@ void parse_set(const std::string& json_str) {
|
||||
return;
|
||||
}
|
||||
|
||||
// <20><>ȡ "messageBoy" <20><><EFBFBD><EFBFBD>
|
||||
cJSON* messageBoy = cJSON_GetObjectItem(root, "messageBoy");
|
||||
if (messageBoy == NULL || messageBoy->type != cJSON_Object) {
|
||||
std::cerr << "'messageBoy' is missing or is not an object" << std::endl;
|
||||
cJSON_Delete(root);
|
||||
return ;
|
||||
}
|
||||
|
||||
// <20><>ȡ code <20>ֶ<EFBFBD>
|
||||
cJSON* code = cJSON_GetObjectItem(root, "code");
|
||||
cJSON* code = cJSON_GetObjectItem(messageBoy, "code");
|
||||
if (code == nullptr) {
|
||||
std::cout << "Missing 'code' in JSON." << std::endl;
|
||||
cJSON_Delete(root);
|
||||
@@ -946,7 +1029,7 @@ void parse_set(const std::string& json_str) {
|
||||
string index_value_str = index->valuestring;
|
||||
int index_value = StringToInt(index_value_str);
|
||||
|
||||
//<2F><><EFBFBD>̺<EFBFBD>Ϊ0<CEAA>Ľ<EFBFBD><C4BD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
//<2F><><EFBFBD>̺<EFBFBD>Ϊ0<CEAA>Ľ<EFBFBD><C4BD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
if (index_value != g_front_seg_index && g_front_seg_index !=0) {
|
||||
std::cout << "msg index:"<< index_value <<"doesnt match self index:" << g_front_seg_index << std::endl;
|
||||
cJSON_Delete(root);
|
||||
@@ -997,6 +1080,38 @@ void parse_set(const std::string& json_str) {
|
||||
}
|
||||
|
||||
}
|
||||
else if (code_str == "set_debug"){
|
||||
if(g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1){
|
||||
std::cout << "cfg_stat_data process" << g_front_seg_index <<" handle this msg" << std::endl;
|
||||
// <20><><EFBFBD><EFBFBD> set_process
|
||||
cJSON* data = cJSON_GetObjectItem(root, "data");
|
||||
if (data != nullptr && data->type == cJSON_Array) {
|
||||
int data_size = cJSON_GetArraySize(data);
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
cJSON* item = cJSON_GetArrayItem(data, i);
|
||||
|
||||
std::string fun = cJSON_GetObjectItem(item, "fun")->valuestring;
|
||||
std::string ip = cJSON_GetObjectItem(item, "ip")->valuestring;
|
||||
std::string frontType = cJSON_GetObjectItem(item, "frontType")->valuestring;
|
||||
|
||||
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if((fun == "start" || fun == "delete") &&
|
||||
isValidIP(ip) &&
|
||||
(frontType == "stat" || frontType == "recall" || frontType == "3s" || frontType == "comtrade")){
|
||||
execute_bash_debug(fun, ip, frontType);
|
||||
std::cout << "!!!!!!!!!!!!!!!! execute mark:" << i << " !!!!!!!!!!!!!!!" <<std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << "param is not executable" <<std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "this msg should only execute once" <<std::endl;
|
||||
}
|
||||
}
|
||||
else{
|
||||
std::cout << "only cfg_stat_data index 1 can control process,this process not handle this msg" << std::endl;
|
||||
}
|
||||
}
|
||||
else{
|
||||
std::cout << "set process code str error" <<std::endl;
|
||||
}
|
||||
@@ -1197,15 +1312,23 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
// <20><>ȡ "messageBoy" <20><><EFBFBD><EFBFBD>
|
||||
cJSON* messageBoy = cJSON_GetObjectItem(root, "messageBoy");
|
||||
if (messageBoy == NULL || messageBoy->type != cJSON_Object) {
|
||||
std::cerr << "'messageBoy' is missing or is not an object" << std::endl;
|
||||
cJSON_Delete(root);
|
||||
return ;
|
||||
}
|
||||
|
||||
// <20><>ȡ code <20>ֶ<EFBFBD>
|
||||
cJSON* code = cJSON_GetObjectItem(root, "code");
|
||||
cJSON* code = cJSON_GetObjectItem(messageBoy, "code");
|
||||
if (code == nullptr) {
|
||||
std::cout << "Missing 'code' in JSON." << std::endl;
|
||||
cJSON_Delete(root);
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON* index = cJSON_GetObjectItem(root, "index");
|
||||
cJSON* index = cJSON_GetObjectItem(messageBoy, "index");
|
||||
if (index == nullptr) {
|
||||
std::cout << "Missing 'index' in JSON." << std::endl;
|
||||
cJSON_Delete(root);
|
||||
@@ -1235,7 +1358,7 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
|
||||
std::cout << "add or update ledger" <<std::endl;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> add_terminal <20><> ledger_modify
|
||||
cJSON* data = cJSON_GetObjectItem(root, "data");
|
||||
cJSON* data = cJSON_GetObjectItem(messageBoy, "data");
|
||||
if (data != nullptr && data->type == cJSON_Array) {
|
||||
int data_size = cJSON_GetArraySize(data);
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
Reference in New Issue
Block a user