diff --git a/cfg_parse/cfg_parser.cpp b/cfg_parse/cfg_parser.cpp index 1cab107..c5cd493 100644 --- a/cfg_parse/cfg_parser.cpp +++ b/cfg_parse/cfg_parser.cpp @@ -212,6 +212,11 @@ std::string g_strOTLType = "PostgreSQL"; //OTL //std::string g_strOTLConnect = "postgres/postgres@pgsql"; //OTL数据库连接参数 std::string g_strOTLConnect = "postgres/bmdev@123@pgsql"; //OTL数据库连接参数 + +//lnk2024-8-14添加角型接线标志,0不存在角形接线,1存在角形接线 +int isdelta_flag = 0; + + //////CZY 2023-09-06 config //多前置flag:1为开启,0为关闭 int MULTIPLE_NODE_FLAG = 1; @@ -11731,6 +11736,7 @@ void printLedgerinshell(const ied_usr_t& ied_usr, QIODevice* outputDevice) { // 打印所有设备信息或特定终端信息 void ledger(const char* terminal_id, QIODevice* outputDevice) { + outputDevice->write("print ledger in shell"); pthread_mutex_lock(&mtx); bool found = false; ied_t* ied; @@ -12040,13 +12046,13 @@ int terminal_ledger_web(QMap* terminal_dev_map, terminal_dev_map->remove(key); // 插入新的 terminal_dev 对象 - if(atoi(dev->processNo) == g_front_seg_index){//lnk20250210匹配进程号 + if(atoi(dev->processNo) == g_front_seg_index || g_front_seg_index == 0){//lnk20250210匹配进程号 //调试用 std::cout<< "process num match" << std::endl; terminal_dev_map->insert(key, dev);}//后续修改为只有进程号匹配上index才录入当前进程 } else { // 插入新的 terminal_dev 对象 - if(atoi(dev->processNo) == g_front_seg_index){//lnk20250210匹配进程号 + if(atoi(dev->processNo) == g_front_seg_index || g_front_seg_index == 0){//lnk20250210匹配进程号 //调试用 std::cout<< "process num match" << std::endl; terminal_dev_map->insert(key, dev);}//后续修改为只有进程号匹配上index才录入当前进程 @@ -12489,6 +12495,13 @@ int parse_device_cfg_web() strcpy(line_info.v_wiring_type, terminal_connect); cout << "v_wiring_type:" << line_info.v_wiring_type << endl; + //lnk2024-8-14记录接线标志 + if (strcmp(line_info.v_wiring_type, "02") == 0) + { + isdelta_flag = 1; //存在一个监测点为角型接线则这个前置就要启动第二个配置列表 + cout << "monitor_id" << monitor_id << "v_wiring_type:" << line_info.v_wiring_type << "is delta wiring:" << isdelta_flag << endl; + } + strcpy(line_info.monitor_status, monitor_status); cout << "monitor_status:" << line_info.monitor_status << endl; @@ -12516,7 +12529,7 @@ int parse_device_cfg_web() char str[256]; //256大小 byte_t cpuno = line_info.cpuno; - cout << "cpuno:" << line_info.cpuno << endl; + cout << "cpuno:" << (int)line_info.cpuno << endl; cout << "index cpuno:" << cpuno-1 << endl; ied_usr = (ied_usr_t*)ied->usr_ext; @@ -14227,10 +14240,10 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i strncpy(logical_device_seq, monitor_data.logical_device_seq, sizeof(logical_device_seq) - 1); if (isCharPtrEmpty(logical_device_seq)) { line_info.cpuno = 1; // 默认监测点实例号1 - printf("logical_device_seq: is null, set cpuno: %d\n", line_info.cpuno); + printf("logical_device_seq: is null, set cpuno: %d\n", (int)line_info.cpuno); } else { line_info.cpuno = atoi(logical_device_seq); - printf("logical_device_seq: %d\n", line_info.cpuno); + printf("logical_device_seq: %d\n", (int)line_info.cpuno); } line_info.line_id = count_real_monitor; // 记录终端排号 @@ -14242,6 +14255,13 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i printf("monitor_status: %s\n", line_info.monitor_status); printf("name: %s\n", line_info.name); + //lnk20250214角形 + if (strcmp(line_info.v_wiring_type, "02") == 0) + { + isdelta_flag = 1; //存在一个监测点为角型接线则这个前置就要启动第二个配置列表 + cout << "monitor_id" << line_info.mp_id << "v_wiring_type:" << line_info.v_wiring_type << "is delta wiring:" << isdelta_flag << endl; + } + // 填充时间戳 if (update[i].timestamp[0] != '\0') { struct tm timeinfo; @@ -14273,7 +14293,7 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i if (ied && ied->usr_ext && line_info.cpuno && ((int)line_info.cpuno < 10)) { char str[256]; byte_t cpuno = line_info.cpuno; //使用新台账的逻辑序列号,在使用原有ied的情况下,如果序列号数量小于原有数量,那么新的部分会被覆盖,如果删除时没有清理,原有的其他部分会仍存在内存中,但不会被使用 - printf("cpuno: %d\n", line_info.cpuno); + printf("cpuno: %d\n", (int)line_info.cpuno); printf("index cpuno: %d\n", cpuno - 1); ied_usr = (ied_usr_t*)ied->usr_ext; @@ -14331,7 +14351,7 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i apr_snprintf(str, sizeof(str), "PQMonitorPQM%d", cpuno); // 仅在没有值时更新 LD_name,避免重复分配内存 - if (!ied_take) { + if (ied_usr->LD_info[cpuno - 1].LD_name == NULL) { //lnk20250208调试用 std::cout << "new space for LD_name" << std::endl; @@ -14350,12 +14370,16 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i } else {//已有则替换,在原有空间上覆盖 //lnk20250208调试用 - std::cout << "old space for LD_name:" << ied_usr->LD_info[cpuno].LD_name <LD_info[cpuno - 1].LD_name <LD_info[cpuno - 1].LD_name, 0, 256); + printf("check error333 !!!!!!!!!!!!!!\n"); + apr_cpystrn(ied_usr->LD_info[cpuno - 1].LD_name, str, 256); //原有空间覆盖 + + printf("check error222 !!!!!!!!!!!!!!\n"); } ldname = ied_usr->LD_info[cpuno - 1].LD_name; @@ -14876,10 +14900,13 @@ void clearIedUsr(ied_usr_t *ied_usr) { // 清空指针部分,但不清理非空指针 if (ied_usr->LD_info != nullptr) { + // 如果 LD_info 不为空,清理它内部的内容 for (int i = 0; i < MAX_CPUNO; ++i) { - if (&ied_usr->LD_info[i] != NULL) { - clearLDInfo(&ied_usr->LD_info[i]); + LD_info_t * ld =NULL; + ld = (LD_info_t *)&ied_usr->LD_info[i]; + if (ld != NULL) { + clearLDInfo(ld); } } } diff --git a/json/create_json.cpp b/json/create_json.cpp index a52a857..94545d2 100644 --- a/json/create_json.cpp +++ b/json/create_json.cpp @@ -45,6 +45,9 @@ QString JSON_CONFIG_FN = QString("JiangSu_Config.xml"); #define APR_EBADF 0 const string PhsSTR = "ABCT"; extern int FILE_FLAG; + +//lnk20250214 +extern int isdelta_flag; //江苏Kafka发送数据类定义-------------------------------------------------------------/* class CEventData //SOE事件类 { @@ -215,6 +218,11 @@ XmlConfig xmlcfg;//zw list topicList; //Kafka发送主题链表 int inited = false; //JiangSu_Config.xml是否初始化标识 +XmlConfig xmlcfg2;//lnk2024 - 8 - 13 新増角型xml节点解析的数据 +list topicList2; //lnk2024-8-14角型Kafka发送主题链表 +QMap xmlinfo_list2;//lnk2024-8-14 保存角型所有型号对应的xml数据-数据库数据 新增的节点解析数据 kafka发送链表 +extern int isdelta_flag;//lnk2024-8-16 角型接线标志 + ///////////////////////////////////////////////lnk20241021替换web接口////////////////////////////////// void connectlog_pgsql(char* id,char* datetime,int status); void errorlog_pgsql(char* id, QString time, QString filename); @@ -578,6 +586,7 @@ QString errorlog_datamatch_json(QMap data_match_map_1, QMap< return log_json; } +#if 0 bool ParseXMLConfig2(XmlConfig *cfg, list *ctopiclist,QString path) //解析JiangSu_Config.xml配置文件 { //cfg = new XmlConfig(); @@ -1056,6 +1065,652 @@ bool ParseXMLConfig2(XmlConfig *cfg, list *ctopiclist,QString path) // return true; } +#endif +//lnk2024-8-16 适配角型接线 +bool ParseXMLConfig2(int xml_flag, XmlConfig *cfg, list *ctopiclist,QString path) //解析JiangSu_Config.xml配置文件 +{ + //cfg = new XmlConfig(); + //注:①#7#代表通配符,用于通配数据类型 采用8421码,8-CP95 4-最小值 2-最大值 1-平均值 + // ②%2,50%代表通配符,用于通配谐波数据,采用范围编码,第一个数字表示谐波起始号,第二个数字谐波结束号 + // ③SEQ=后面的值采用8421码 8-T 4-C 2-B 1-A + //注:type类型:0-DataType 1-监测点 2-剔除标记 3-发生时刻,毫秒 4-数据链表 5-相位 6-值索引 9-实时SOE事件 11-实时SOE事件 + QString strPhasic[4] = { "A", "B", "C", "T" }; //数组枚举 相别(A-T) + QString strLine[4] = { "AB", "BC", "CA", "T" }; //lnk2024-8-14数组枚举 角型相别(AB-T) + int nStart = 1, nEnd = 1; //谐波起、止次数 + QString strValueTemp; //临时存放谐波次数字符串 例:%0,49% 或 %2,50% + + //加载JiangSu_Config.xml配置文件 + //QString xml_dir = QString("D:/")+QString("PQD-9k/config/"); //相对路径读取xml失败,此处改用绝对路径! zl 2018-11-14 15:43:34 + QDomDocument doc; //新建QDomDocument类对象,它代表一个XML文档 + if ("not define" == path) { + QString xml_dir = QString("../") + QString("etc/"); //Linux下调试路径 + QFile file(xml_dir + JSON_CONFIG_FN); + if (!file.open(QIODevice::ReadOnly | QFile::Text)) //以只读方式打开xml + { + return 0; + } + if (!doc.setContent(&file)) //将文件内容读到doc中 + { + file.close(); + return 0; + } + file.close(); + cout << "not define xml" << endl; + } + else { + QString tmppath; + tmppath.append("/FeProject/dat/").append(path).append(".xml"); + QFile file(tmppath); + if (!file.open(QIODevice::ReadOnly | QFile::Text)) //以只读方式打开xml + { + return 0; + } + if (!doc.setContent(&file)) //将文件内容读到doc中 + { + file.close(); + return 0; + } + file.close(); + cout << "define xml" << endl; + } + //将xml文件内容读到doc中 + QDomNode firstNode = doc.firstChild(); //根节点"JSConfigTemplate" + QDomElement docElem = doc.documentElement(); //返回根节点元素 + QDomNode n = docElem.firstChild(); //获得doc的第一个节点,即"Topic" + while (!n.isNull()) //如果Topic节点不为空 + { + if (n.isElement()) + { + QDomElement e = n.toElement(); //将其转换为元素 + QString strTag = e.tagName(); //Topic节点 + + if ("Topic" == strTag)//zw修改 2023 - 8 - 14 增加判断 将topic节点和其他节点的解析分离 + { + CTopic* topic = new CTopic(); //发送主题类指针 + topic->strTopic = e.attribute("name"); //发送主题名 + ctopiclist->push_back(topic); //添加 Kafka发送主题链表 + + //zw修改 2023 - 8 - 14 为历史数据部分 Value节点新增指标-BaseFlag LimitUp LimitDown + if ("Topic" == strTag && ("HISDATA" == topic->strTopic || "RTDATA" == topic->strTopic)) //①读取Topic,HISDATA、RTDATA主题--------------------------------------------------- + { + QDomNodeList list = e.childNodes(); //获得元素Topic的所有子节点的列表 + for (int i = 0; i < list.count(); i++) //遍历 DataType列表 + { + QDomNode node = list.at(i); //node1 + if (node.isElement()) + { + CDataType* dt = new CDataType(); //数据类型指针 + dt->iDataType = node.toElement().attribute("value").toInt(); //数据类型值(1-实时/历史稳态、2-实时/历史闪变、3-实时/历史暂态、4-补招稳态、5-补招闪变、6-补招暂态) + dt->type = node.toElement().attribute("type"); //参数等级 + dt->BaseFlag0 = 0; + dt->BaseFlag1 = 0; + topic->DataTypeList.push_back(dt); //添加 数据类型链表 + + QString strTag2 = node.toElement().tagName(); //DataType节点 + if ("DataType" == strTag2) //②读取数据类型DataType + { + QDomNodeList list2 = node.childNodes(); //获得元素DataType的所有子节点的列表 + for (int i2 = 0; i2 < list2.count(); i2++) //遍历 Monitor列表 + { + QDomNode node2 = list2.at(i2); //node2 + if (node2.isElement()) + { + CMonitor* mt = new CMonitor(); //监测点类型指针 + mt->strMonitor = node2.toElement().attribute("name"); //监测点名称 注:该值需要从Rpt解析中获取监测点号 + mt->type = node2.toElement().attribute("type"); //参数等级 + dt->MonitorList.push_back(mt); //添加 监测点链表 + + QString strTag3 = node2.toElement().tagName(); //Monitor节点 + if ("Monitor" == strTag3) //③读取监测点Monitor + { + QDomNodeList list3 = node2.childNodes(); //获得元素Monitor的所有子节点的列表 + for (int i3 = 0; i3 < list3.count(); i3++) //遍历 Item列表 + { + QDomNode node3 = list3.at(i3); //node3 + if (node3.isElement()) + { + CItem* it = new CItem(); //数据项类指针 + it->strItemName = node3.toElement().attribute("name"); //FLAG、TIME、V、I、PQ + it->type = node3.toElement().attribute("type"); //参数等级 + if ("FLAG" == it->strItemName) //剔除标记(1:不剔除,0:剔除,默认剔除) + it->strItemValue = node3.toElement().attribute("value"); //数据项值 + mt->ItemList.push_back(it); //添加 数据项链表 + + QString strTag4 = node3.toElement().tagName(); //Item节点 + if ("Item" == strTag4) //④读取数据项Item + { + QDomNodeList list4 = node3.childNodes(); //获得元素Item的所有子节点的列表 + for (int i4 = 0; i4 < list4.count(); i4++) //遍历 Sequence列表 + { + QDomNode node4 = list4.at(i4); //node4 + if (node4.isElement()) + { + QString strPhase = node4.toElement().attribute("value"); //相别 + if ((!xml_flag || "V" != it->strItemName) && "7" == strPhase) //⑤-①读取ABC三相数据 //lnk2024-8-14 角型判断 + { + for (int n = 0; n < 3; n++) //遍历 相别(ABC三相) + { + CSequence* sq = new CSequence(); //ABC三相相别类指针 + sq->strSValue = node4.toElement().attribute("value"); //相别值(7:ABC三相、8:T相) + sq->type = node4.toElement().attribute("type"); //参数等级 + sq->strSeq = strPhasic[n]; //相别赋值 例:A、B、C + it->SequenceList.push_back(sq); //添加 相别链表 + + QString strTag5 = node4.toElement().tagName(); //Sequence节点 + if ("Sequence" == strTag5) //⑤读取相别Sequence + { + QDomNodeList list5 = node4.childNodes(); //获得元素Sequence的所有子节点的列表 + for (int i5 = 0; i5 < list5.count(); i5++) //遍历 ABC三相Value列表 + { + QDomNode node5 = list5.at(i5); //node5 + if (node5.isElement()) + { + QDomElement e_Value = node5.toElement(); //将其转换为元素 + QString strTag6 = e_Value.tagName(); //相别Sequence下 所有DataValue子节点 + if ("Value" == strTag6) //⑥读取ABC三相Value + { + QString strDVName = e_Value.attribute("name"); //数据名 + QString strDAName = e_Value.attribute("DA"); //数据属性名 + if (strDAName.indexOf("phs*") >= 0) //DA包含"phs*" + strDAName = strDAName.replace("*", sq->strSeq); //将DA相别*替换为具体相别(A、B、C) 例:phsA$cVal$mag$f + //⑥-①谐波数据读取(ABC三相)------------------------------------- + if (strDVName.indexOf("%") >= 0 && strDAName.indexOf("%-") >= 0) //数据名包含% 且 DA包含%- 例:V_%0,49%_MAX + { + QStringList strHarm1 = strDVName.split('%'); + if (strHarm1.count() >= 2) //例:V_ | 0,49 | _MAX + { + strValueTemp = "%" + strHarm1.at(1) + "%"; //例:%0,49% + QStringList strHarm2 = strHarm1.at(1).split(','); //例:0,49 + if (strHarm2.count() >= 2) + { + nStart = (strHarm2.at(0)).toInt(); //谐波起始次数 例:0 + nEnd = (strHarm2.at(1)).toInt(); //谐波结束次数 例:49 + } + } + + QString substring = strDAName.mid(strDAName.indexOf("[") + 1, strDAName.indexOf("]") - strDAName.indexOf("[") - 1); + QStringList strDAList1 = substring.split('-'); + int strDAoffset = (strDAList1.at(1)).toInt(); + + for (int i = nStart; i <= nEnd; i++) //遍历 ABC三相谐波次数 + { + QString strDVNameTemp = strDVName; //临时 数据名 + QString strDANameTemp = strDAName; //临时 数据属性名 + CDataValue* dv1 = new CDataValue(); //ABC三相谐波数据值类指针 + dv1->type = e_Value.attribute("type"); //参数等级 + if (e_Value.attributes().contains("Coefficient")) { + dv1->strCoefficient = e_Value.attribute("Coefficient"); //数据系数(字符型) + dv1->fCoefficient = e_Value.attribute("Coefficient").toFloat(); //数据系数(浮点型) + } + dv1->strOffset = e_Value.attribute("Offset"); //起始序号偏移量(字符型) + dv1->iOffset = e_Value.attribute("Offset").toInt(); //起始序号偏移量(整型) = 江苏电科院臻迪数据项起始序号 - 装置数据项实际起始序号 + dv1->DO = e_Value.attribute("DO"); //数据对象名 + dv1->strName = strDVNameTemp.replace(strValueTemp, QString::number(i + e_Value.attribute("Offset").toInt())); //将数据名中%0,49%替换为具体数字 例:SI_%0,49%变为SI_1 + dv1->DA = strDANameTemp.replace(substring, QString::number(i - strDAoffset)); //将DA中%-2替换为具体数字 例:phs*Har[1]$mag$f + //cout << dv1->strName.toAscii().data() << "--" << dv1->DA.toAscii().data() << " (" << dv1->iOffset << endl; + //zw修改 2023 - 8 - 14 为历史数据部分 Value节点新增指标-BaseFlag LimitUp LimitDown + if (e_Value.attributes().contains("BaseFlag")) + { + dv1->BaseFlag = e_Value.attribute("BaseFlag"); + if (dv1->BaseFlag == "1") { + dt->BaseFlag1++; + } + else { + dt->BaseFlag0++; + } + } + else + { + dt->BaseFlag0++; + dv1->BaseFlag = "0"; + } + if (e_Value.attributes().contains("LimitUp")) + { + dv1->LimitUp = e_Value.attribute("LimitUp"); + } + else + { + dv1->LimitUp = "not define"; + } + if (e_Value.attributes().contains("LimitDown")) + { + dv1->LimitDown = e_Value.attribute("LimitDown"); + } + else + { + dv1->LimitDown = "not define"; + } + if (!dv1->DO.isEmpty() && !dv1->DA.isEmpty()) //数据对象名和数据属性名均不为空 + dv1->strFullName = dv1->DO + "$" + dv1->DA; + else + dv1->strFullName = "not define"; + sq->DataValueList.push_back(dv1); //添加 数据链表(ABC三相) + } //遍历ABC三相谐波次数 结束 + //continue; //ABC三相谐波次数遍历完成后,继续读取下一节点 + } + else //⑥-②非谐波数据读取(ABC三相)------------------------------- + { + CDataValue* dv2 = new CDataValue(); //ABC三相非谐波数据值类指针 + dv2->strName = e_Value.attribute("name"); //数据名 + dv2->type = e_Value.attribute("type"); //参数等级 + if (e_Value.attributes().contains("Coefficient")) { + dv2->strCoefficient = e_Value.attribute("Coefficient"); //数据系数(字符型) + dv2->fCoefficient = e_Value.attribute("Coefficient").toFloat(); //数据系数(浮点型) + } + dv2->DO = e_Value.attribute("DO"); //数据对象名 + dv2->DA = strDAName; //数据属性名 + + //zw修改 2023 - 8 - 14 为历史数据部分 Value节点新增指标-BaseFlag LimitUp LimitDown + if (e_Value.attributes().contains("BaseFlag")) + { + dv2->BaseFlag = e_Value.attribute("BaseFlag"); + if (dv2->BaseFlag == "1") { + dt->BaseFlag1++; + } + else { + dt->BaseFlag0++; + } + } + else + { + dt->BaseFlag0++; + dv2->BaseFlag = "0"; + } + if (e_Value.attributes().contains("LimitUp")) + { + dv2->LimitUp = e_Value.attribute("LimitUp"); + } + else + { + dv2->LimitUp = "not define"; + } + if (e_Value.attributes().contains("LimitDown")) + { + dv2->LimitDown = e_Value.attribute("LimitDown"); + } + else + { + dv2->LimitDown = "not define"; + } + if (!e_Value.attribute("PltFlag").isEmpty() && e_Value.attribute("PltFlag") == "True") //长时闪变标识 + dv2->bPlt = true; //长时闪变标识 + else + dv2->bPlt = false; //短时闪变 或 其他数据 + + if (!dv2->DO.isEmpty() && !dv2->DA.isEmpty()) //数据对象名和数据属性名均不为空 + dv2->strFullName = dv2->DO + "$" + dv2->DA; + else + dv2->strFullName = "not define"; + sq->DataValueList.push_back(dv2); //添加 数据链表(ABC三相) + } + } //读取ABC三相Value 结束 + } //判断node5为元素 结束 + } //遍历ABC三相Value列表 结束 + } //遍历 ABC三相 结束 + } + } //⑤-①读取ABC三相数据 结束 + + if (xml_flag && "V" == it->strItemName && "112" == strPhase) //lnk2024-8-13角型 + { + for (int n = 0; n < 3; n++) //遍历 相别(AB、BC、CA三相) + { + CSequence* sq = new CSequence(); //AB、BC、CA三相别类指针 + sq->strSValue = node4.toElement().attribute("value"); //相别值(7:ABC三相、112:线AB,BC,CA 8:T相) + sq->type = node4.toElement().attribute("type"); //参数等级 + sq->strSeq = strLine[n]; //相别赋值 例:AB、BC、CA + it->SequenceList.push_back(sq); //添加 相别链表 + + QString strTag5 = node4.toElement().tagName(); //Sequence节点 + if ("Sequence" == strTag5) //⑤读取相别Sequence + { + QDomNodeList list5 = node4.childNodes(); //获得元素Sequence的所有子节点的列表 + for (int i5 = 0; i5 < list5.count(); i5++) //遍历 AB、BC、CA三相Value列表 + { + QDomNode node5 = list5.at(i5); //node5 + if (node5.isElement()) + { + QDomElement e_Value = node5.toElement(); //将其转换为元素 + QString strTag6 = e_Value.tagName(); //相别Sequence下 所有DataValue子节点 + if ("Value" == strTag6) //⑥读取AB、BC、CA三相Value + { + QString strDVName = e_Value.attribute("name"); //数据名 + QString strDAName = e_Value.attribute("DA"); //数据属性名 + if (strDAName.indexOf("phs*") >= 0) //DA包含"phs*" + strDAName = strDAName.replace("*", sq->strSeq); //将DA相别*替换为具体相别(AB、BC、CA) 例:phsAB$cVal$mag$f + //⑥-①谐波数据读取(AB、BC、CA三相)------------------------------------- + if (strDVName.indexOf("%") >= 0 && strDAName.indexOf("%-") >= 0) //数据名包含% 且 DA包含%- 例:V_%0,49%_MAX + { + QStringList strHarm1 = strDVName.split('%'); + if (strHarm1.count() >= 2) //例:%0,49% + { + strValueTemp = "%" + strHarm1.at(1) + "%"; //例:%0,49% + QStringList strHarm2 = strHarm1.at(1).split(','); //例:0,49 + if (strHarm2.count() >= 2) + { + nStart = (strHarm2.at(0)).toInt(); //谐波起始次数 例:0 + nEnd = (strHarm2.at(1)).toInt(); //谐波结束次数 例:49 + } + } + + QString substring = strDAName.mid(strDAName.indexOf("[") + 1, strDAName.indexOf("]") - strDAName.indexOf("[") - 1); + QStringList strDAList1 = substring.split('-'); + int strDAoffset = (strDAList1.at(1)).toInt(); + + for (int i = nStart; i <= nEnd; i++) //遍历 AB、BC、CA三相谐波次数 + { + QString strDVNameTemp = strDVName; //临时 数据名 + QString strDANameTemp = strDAName;//临时 数据属性名 + CDataValue* dv1 = new CDataValue(); //AB、BC、CA三相谐波数据值类指针 + dv1->type = e_Value.attribute("type"); //参数等级 + if (e_Value.attributes().contains("Coefficient")) { + dv1->strCoefficient = e_Value.attribute("Coefficient"); //数据系数(字符型) + dv1->fCoefficient = e_Value.attribute("Coefficient").toFloat(); //数据系数(浮点型) + } + dv1->strOffset = e_Value.attribute("Offset"); //起始序号偏移量(字符型) + dv1->iOffset = e_Value.attribute("Offset").toInt(); //起始序号偏移量(整型) = 江苏电科院臻迪数据项起始序号 - 装置数据项实际起始序号 + dv1->DO = e_Value.attribute("DO"); //数据对象名 + + std::cout << "!!!!!!!!!!!!!ppv!!!!!!!!!!!!!!!!!!!!!!!!!!ppv!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << dv1->DO.toUtf8().constData() << std::endl; //lnk 输出ppv + std::cout << "!!!!!!!!!!!!!ppv!!!!!!!!!!!!!!!!!!!!!!!!!!ppv!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + + dv1->strName = strDVNameTemp.replace(strValueTemp, QString::number(i + e_Value.attribute("Offset").toInt())); //将数据名中%0,49%替换为具体数字 例:SI_%0,49%变为SI_1 + dv1->DA = strDANameTemp.replace(substring, QString::number(i - strDAoffset)); //将DA中%-2替换为具体数字 例:phs*Har[1]$mag$f + //cout << dv1->strName.toAscii().data() << "--" << dv1->DA.toAscii().data() << " (" << dv1->iOffset << endl; + //zw修改 2023 - 8 - 14 为历史数据部分 Value节点新增指标-BaseFlag LimitUp LimitDown + if (e_Value.attributes().contains("BaseFlag")) + { + dv1->BaseFlag = e_Value.attribute("BaseFlag"); + if (dv1->BaseFlag == "1") { + dt->BaseFlag1++; + } + else { + dt->BaseFlag0++; + } + } + else + { + dt->BaseFlag0++; + dv1->BaseFlag = "0"; + } + if (e_Value.attributes().contains("LimitUp")) + { + dv1->LimitUp = e_Value.attribute("LimitUp"); + } + else + { + dv1->LimitUp = "not define"; + } + if (e_Value.attributes().contains("LimitDown")) + { + dv1->LimitDown = e_Value.attribute("LimitDown"); + } + else + { + dv1->LimitDown = "not define"; + } + if (!dv1->DO.isEmpty() && !dv1->DA.isEmpty()) //数据对象名和数据属性名均不为空 + dv1->strFullName = dv1->DO + "$" + dv1->DA; + else + dv1->strFullName = "not define"; + sq->DataValueList.push_back(dv1); //添加 数据链表(AB、BC、CA三相) + } //遍历ABC三相谐波次数 结束 + //continue; //AB、BC、CA三相谐波次数遍历完成后,继续读取下一节点 + } + else //⑥-②非谐波数据读取(AB、BC、CA三相)------------------------------- + { + CDataValue* dv2 = new CDataValue(); //ABC三相非谐波数据值类指针 + dv2->strName = e_Value.attribute("name"); //数据名 + dv2->type = e_Value.attribute("type"); //参数等级 + if (e_Value.attributes().contains("Coefficient")) { + dv2->strCoefficient = e_Value.attribute("Coefficient"); //数据系数(字符型) + dv2->fCoefficient = e_Value.attribute("Coefficient").toFloat(); //数据系数(浮点型) + } + dv2->DO = e_Value.attribute("DO"); //数据对象名 + dv2->DA = strDAName; //数据属性名 + + //zw修改 2023 - 8 - 14 为历史数据部分 Value节点新增指标-BaseFlag LimitUp LimitDown + if (e_Value.attributes().contains("BaseFlag")) + { + dv2->BaseFlag = e_Value.attribute("BaseFlag"); + if (dv2->BaseFlag == "1") { + dt->BaseFlag1++; + } + else { + dt->BaseFlag0++; + } + } + else + { + dt->BaseFlag0++; + dv2->BaseFlag = "0"; + } + if (e_Value.attributes().contains("LimitUp")) + { + dv2->LimitUp = e_Value.attribute("LimitUp"); + } + else + { + dv2->LimitUp = "not define"; + } + if (e_Value.attributes().contains("LimitDown")) + { + dv2->LimitDown = e_Value.attribute("LimitDown"); + } + else + { + dv2->LimitDown = "not define"; + } + if (!e_Value.attribute("PltFlag").isEmpty() && e_Value.attribute("PltFlag") == "True") //长时闪变标识 + dv2->bPlt = true; //长时闪变标识 + else + dv2->bPlt = false;//短时闪变 或 其他数据 + + if (!dv2->DO.isEmpty() && !dv2->DA.isEmpty()) //数据对象名和数据属性名均不为空 + dv2->strFullName = dv2->DO + "$" + dv2->DA; + else + dv2->strFullName = "not define"; + sq->DataValueList.push_back(dv2); //添加 数据链表(AB、BC、CA三相) + } + } //读取AB、BC、CA三相Value 结束 + }//判断node5为元素 结束 + } //遍历AB、BC、CA三相Value列表 结束 + } //遍历 AB、BC、CA三相 结束 + } + }//⑤-①读取AB、BC、CA三相数据 结束 + + if ("8" == strPhase) //⑤-②读取T相数据 + { + CSequence* sq = new CSequence(); //T相相别类指针 + sq->strSValue = node4.toElement().attribute("value"); //相别值 + sq->type = node4.toElement().attribute("type"); //参数等级 + sq->strSeq = strPhasic[3]; //相别赋值 + it->SequenceList.push_back(sq); //添加 相别链表(T相) + + QDomNodeList list5 = node4.childNodes(); //获得元素Sequence的所有子节点的列表 + for (int i5 = 0; i5 < list5.count(); i5++) //遍历 T相Value列表 + { + QDomNode node5 = list5.at(i5); //node5 + if (node5.isElement()) + { + QDomElement e_Value = node5.toElement(); //将其转换为元素 + QString strTag6 = e_Value.tagName(); //相别Sequence下 所有DataValue子节点 + if ("Value" == strTag6) //⑥读取T相Value + { + //⑥-①谐波数据读取(T相) 注:T相没有谐波数据 + //⑥-②非谐波数据读取(T相) + CDataValue* dv2 = new CDataValue(); //T相非谐波数据值类指针 + dv2->strName = e_Value.attribute("name"); //数据名 + dv2->type = e_Value.attribute("type"); //参数等级 + if (e_Value.attributes().contains("Coefficient")) { + dv2->strCoefficient = e_Value.attribute("Coefficient"); //数据系数(字符型) + dv2->fCoefficient = e_Value.attribute("Coefficient").toFloat(); //数据系数(浮点型) + } + dv2->DO = e_Value.attribute("DO"); //数据对象名 + dv2->DA = e_Value.attribute("DA"); //数据属性名 + + //zw修改 2023 - 8 - 14 为历史数据部分 Value节点新增指标-BaseFlag LimitUp LimitDown + if (e_Value.attributes().contains("BaseFlag")) + { + dv2->BaseFlag = e_Value.attribute("BaseFlag"); + if (dv2->BaseFlag == "1") { + dt->BaseFlag1++; + } + else { + dt->BaseFlag0++; + } + } + else + { + dt->BaseFlag0++; + dv2->BaseFlag = "0"; + } + if (e_Value.attributes().contains("LimitUp")) + { + dv2->LimitUp = e_Value.attribute("LimitUp"); + } + else + { + dv2->LimitUp = "not define"; + } + if (e_Value.attributes().contains("LimitDown")) + { + dv2->LimitDown = e_Value.attribute("LimitDown"); + } + else + { + dv2->LimitDown = "not define"; + } + + if (!dv2->DO.isEmpty() && !dv2->DA.isEmpty()) //数据对象名和数据属性名均不为空 + dv2->strFullName = dv2->DO + "$" + dv2->DA; + else + dv2->strFullName = "not define"; + sq->DataValueList.push_back(dv2); //添加 数据链表(ABC三相) + } //读取T相Value 结束 + } //判断node5为元素 结束 + } //遍历T相Value列表 结束 + } //⑤-②读取T相数据 结束 + } //判断node4为元素 结束 + } //遍历Sequence列表 结束 + } //读取数据项Item 结束 + } //判断node3为元素 结束 + } //遍历Item列表 结束 + } //读取Monitor节点 结束 + } //判断node2为元素 结束 + } //遍历Monitor列表 结束 + } //读取数据类型DataType 结束 + } //判断node为元素 结束 + } //遍历DataType列表 结束 + } //读取Topic节点HISDATA、RTDATA 结束 + else if ("Topic" == strTag && "RTDATASOE" == topic->strTopic) //SOE事件------------------------------------------------------- + { + QDomNodeList list = e.childNodes(); //获得元素Topic的所有子节点的列表 + for (int i = 0; i < list.count(); i++) //遍历 DataType列表 + { + QDomNode node = list.at(i); //node1 + if (node.isElement()) + { + CDataType* dt = new CDataType(); //数据类型类指针 + dt->iDataType = node.toElement().attribute("value").toInt(); //数据类型值(1-稳态SOE、2-闪变SOE、3-暂态SOE) + dt->type = node.toElement().attribute("type"); //参数等级 + topic->DataTypeList.push_back(dt); //添加 数据类型链表 + + QString strTag2 = node.toElement().tagName(); //DataType节点 + if ("DataType" == strTag2) //②读取数据类型DataType + { + QDomNodeList list2 = node.childNodes(); //获得元素DataType的所有子节点的列表 + for (int i2 = 0; i2 < list2.count(); i2++) //遍历 SOE列表 + { + QDomNode node2 = list2.at(i2); //node2 + if (node2.isElement()) + { + CEventData* ed = new CEventData(); //SOE事件类指针 + ed->triggerFlag = node2.toElement().attribute("TriggerFlag"); //SOE触发标识 + ed->DO = node2.toElement().attribute("DO"); //数据对象名 + ed->DA = node2.toElement().attribute("DA"); //数据属性名 + ed->type = node2.toElement().attribute("type"); //参数等级type类型:0-DataType 1-监测点 2-剔除标记 3-发生时刻,毫秒 4-数据链表 5-相位 6-值索引 9-实时SOE事件 + if (!ed->DO.isEmpty() && !ed->DA.isEmpty()) //数据对象名和数据属性名均不为空 + ed->strFullName = ed->DO + "$" + ed->DA; + else + ed->strFullName = "not define"; + dt->SOEList.push_back(ed); //添加 SOE事件链表 + } //判断node2为元素 结束 + } //遍历SOE列表 结束 + } //读取数据类型DataType节点 结束 + } //判断node为元素 结束 + } //遍历DataType列表 结束 + } //Topic节点RTDATASOE 结束 + else if ("Topic" == strTag && "SOEDATA" == topic->strTopic) + { + QDomNodeList list = e.childNodes(); //获得元素Topic的所有子节点的列表 + for (int i = 0; i < list.count(); i++) //遍历 DataType列表 + { + QDomNode node = list.at(i); //node1 + if (node.isElement()) + { + CEventData* ed = new CEventData(); //SOE事件类指针 + ed->triggerFlag = node.toElement().attribute("name"); //SOE名称 + ed->DO = node.toElement().attribute("DO"); //数据对象名 + ed->DA = node.toElement().attribute("DA"); //数据属性名 + ed->type = node.toElement().attribute("type"); //参数等级type类型:0-DataType 1-监测点 2-剔除标记 3-发生时刻,毫秒 4-数据链表 5-相位 6-值索引 9-实时SOE事件 + if (!ed->DO.isEmpty() && !ed->DA.isEmpty()) //数据对象名和数据属性名均不为空 + ed->strFullName = ed->DO + "$" + ed->DA; + else + ed->strFullName = "not define"; + //cout << ed->triggerFlag.toAscii().data() << "=====" << ed->strFullName.toAscii().data() << endl; + cfg->SOEList.push_back(ed); + } + } + } + } + if ("ReportMap" == strTag)//zw修改 2023 - 8 - 15 增加判断 将触发报告的解析移至XML 原配置RptLogCfg.ini取消 + { + //cout << "ReportMap" << endl; + } + if ("Topic" != strTag && "ReportMap" != strTag)//zw修改 2023 - 8 - 14 增加判断 新增部分节点解析 + { + if ("WavePhasic" == strTag) + { + cfg->WavePhasicFlag.append(e.attribute("Flag")); + if (cfg->WavePhasicFlag == "1") { + cfg->WavePhasicA.append(e.attribute("A")); + cfg->WavePhasicB.append(e.attribute("B")); + cfg->WavePhasicC.append(e.attribute("C")); + } + + } + if ("UnitOfTime" == strTag) + { + cfg->UnitOfTimeUnit.append(e.attribute("Unit")); + } + if ("ValueOfTime" == strTag) + { + cfg->ValueOfTimeUnit.append(e.attribute("Unit")); + } + if ("ComtradeFile" == strTag) + { + cfg->WaveTimeFlag.append(e.attribute("WaveTimeFlag")); + //cout << xmlcfg->WaveTimeFlag.toAscii().data() << endl; + } + if ("IED" == strTag) + { + cfg->IEDname.append(e.attribute("name")); + //cout << xmlcfg->IEDname.toAscii().data() << endl; + } + if ("LDevice" == strTag) + { + cfg->LDevicePrefix.append(e.attribute("Prefix")); + //cout<LDevicePrefix.toAscii().data() < RTDATA —> RTDATASOE) + } //while (!n.isNull) 结束 + + return true; +} /// @@ -1078,9 +1733,32 @@ void print_interval(int flag,int interval) { } } -int transfer_json_block_data(json_block_data *data) //json生成函数 zw修改 2023-8-11 调整传送json结构 目前仅限历史稳态数据 +/// +/// czy kafka的json中将线电压转成相电压 +/// +/// +/// +QString line_to_phasic(QString qstrSeq) { + if (qstrSeq == "A" || qstrSeq == "AB") { + return "A"; + } + else if (qstrSeq == "B" || qstrSeq == "BC") { + return "B"; + } + else if (qstrSeq == "C" || qstrSeq == "CA") { + return "C"; + } + else { + return qstrSeq; + } +} + +//20250214添加角型接线处理 +int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json生成函数 zw修改 2023-8-11 调整传送json结构 目前仅限历史稳态数据 { list ctopic_list; + +#if 0 if (xmlinfo_list.contains(data->dev_type)) { cout << "transfer_json_block_data contain data->dev_type" << endl; ctopic_list = xmlinfo_list[data->dev_type]->topicList; @@ -1089,6 +1767,34 @@ int transfer_json_block_data(json_block_data *data) //json cout << "transfer_json_block_data not contain data->dev_type" << endl; ctopic_list = topicList; } +#endif + + ////lnk2024-8-15 区分星型,角型接线 + if (strcmp(v_wiring_type, "01") == 0) //lnk2024-8-15 星型接线 + { + cout << "report v_wiring_type is" << v_wiring_type << endl; + if (xmlinfo_list.contains(data->dev_type)) { + cout << "transfer_json_block_data contain data->dev_type" << endl; + ctopic_list = xmlinfo_list[data->dev_type]->topicList; + } + else { + cout << "transfer_json_block_data not contain data->dev_type" << endl; + ctopic_list = topicList; + } + } + else //lnk2024-8-15 角型接线 + { + cout << "report v_wiring_type is" << v_wiring_type << endl; + if (xmlinfo_list2.contains(data->dev_type)) { + cout << "transfer_json_block_data contain data->dev_type" << endl; + ctopic_list = xmlinfo_list2[data->dev_type]->topicList; + } + else { + cout << "transfer_json_block_data not contain data->dev_type" << endl; + ctopic_list = topicList; + } + } + //list* tmp; bool shortjumpflag = false; bool longjumpflag = false; @@ -1160,7 +1866,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -1277,7 +1983,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -1414,7 +2120,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -1694,7 +2400,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -1808,7 +2514,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -2104,7 +2810,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -2221,7 +2927,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -2356,7 +3062,7 @@ int transfer_json_block_data(json_block_data *data) //json { CSequence* pSequence = *sq++; //KafkaData.strText.append(QString("{\"SEQ\":\"%1\", ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 - KafkaData.strText.append(QString("\"%1\":{ ").arg(pSequence->strSeq)); //拼接 json相别 A、B、C、T相 + KafkaData.strText.append(QString("\"%1\":{ ").arg(line_to_phasic(pSequence->strSeq))); //拼接 json相别 A、B、C、T相 list::iterator dv = pSequence->DataValueList.begin(); //⑥遍历 DataValueList CDataValue* pDataValueBegin = *dv; @@ -2750,6 +3456,9 @@ int transfer_json_block_data(json_block_data *data) //json return 1; } + + + /*//生成json暂态消息 zw修改 2023-8-25 调整json结构 int transfer_json_qvvr_data(unsigned int func_type, int monitor_id, float mag, float dur, long long start_tm, long long end_tm, int dis_kind, char* uuid_cfg,char* uuid_dat,char* mp_id,char* Qvvr_rptname,char* devtype) //生成json暂态消息 ——> MMS_Wave { @@ -2936,6 +3645,33 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char QDateTime time(QDate(year, month, day), QTime(hour, minute, second)); xmlinfo_list[type]->xmlbase.datetime = time; + cout << "##################################isdelta_flag is " << isdelta_flag << endl; + /*lnk2024-8-14 根据isdelta_flag 选择xmllist*/ + if (isdelta_flag) { + cout << "xmllist2 create" << endl; + if (!xmlinfo_list2.contains(type)) + { + Xmldata* config2 = new Xmldata(); + xmlinfo_list2.insert(type, config2); + } + else + { + QDateTime time(QDate(year, month, day), QTime(hour, minute, second)); + if (xmlinfo_list2[type]->xmlbase.datetime == time) { + xmlinfo_list2[type]->updataflag = false; + } + else { + xmlinfo_list2[type]->updataflag = true; + } + } + xmlinfo_list2[type]->xmlbase.MODEL_ID = id; + xmlinfo_list2[type]->xmlbase.TMNL_TYPE = type; + xmlinfo_list2[type]->xmlbase.FILE_PATH = filepath; + xmlinfo_list2[type]->xmlbase.FILE_NAME = name; + xmlinfo_list2[type]->xmlbase.datetime = time; + } + /*lnk2024-8-14*/ + char file_name[256]; memset(file_name, 0, 256); sprintf(file_name, "%s", FILE_NAME); @@ -3006,7 +3742,10 @@ void Set_xml_nodeinfo() { QString path; path.append("not define"); - ParseXMLConfig2(&xmlcfg, &topicList, path); //调用 ParseXMLConfig() 解析JiangSu_Config.xml配置文件 + ParseXMLConfig2(0, &xmlcfg, &topicList, path); //调用 ParseXMLConfig() 解析JiangSu_Config.xml配置文件 + if (isdelta_flag) { + ParseXMLConfig2(1, &xmlcfg2, &topicList2, path); //lnk2024-8-13角型接线 + } inited = true; } @@ -3019,7 +3758,19 @@ void Set_xml_nodeinfo() Xmldata* value2 = it2.value(); if (value2->updataflag == true) { - ParseXMLConfig2(&(value2->xmlcfg), &(value2->topicList), value2->xmlbase.MODEL_ID); + ParseXMLConfig2(0,&(value2->xmlcfg), &(value2->topicList), value2->xmlbase.MODEL_ID); + } + } + //lnk2024-8-14 选择角型接线 + if (isdelta_flag) { + for (QMap::iterator it3 = xmlinfo_list2.begin(); it3 != xmlinfo_list2.end(); ++it3) + { + QString key3 = it3.key(); + Xmldata* value3 = it3.value(); // + + if (value3->updataflag == true) { + ParseXMLConfig2(1, &(value3->xmlcfg), &(value3->topicList), value3->xmlbase.MODEL_ID); + } } } } @@ -3615,7 +4366,7 @@ void Set_xml_nodeinfo_one(char* dev_type) //将这个点的xmlcfg和topicList删除 clearXmlConfigAndTopicList(xmlinfo_list[QString::fromUtf8(dev_type)]); - ret = ParseXMLConfig2(&(xmlinfo_list[QString::fromUtf8(dev_type)]->xmlcfg), &(xmlinfo_list[QString::fromUtf8(dev_type)]->topicList), xmlinfo_list[QString::fromUtf8(dev_type)]->xmlbase.MODEL_ID); + ret = ParseXMLConfig2(0,&(xmlinfo_list[QString::fromUtf8(dev_type)]->xmlcfg), &(xmlinfo_list[QString::fromUtf8(dev_type)]->topicList), xmlinfo_list[QString::fromUtf8(dev_type)]->xmlbase.MODEL_ID); if(!ret) { std::cout << "!!!! this ledger xml config fail!!!!" << std::endl; @@ -3626,6 +4377,26 @@ void Set_xml_nodeinfo_one(char* dev_type) else{ std::cout << "xmlinfo_list not contain this devtype" << std::endl; } + //添加角形 + if(isdelta_flag){ + if(xmlinfo_list2[QString::fromUtf8(dev_type)] != NULL){ //原来已存在这个类型的节点 + if(xmlinfo_list2[QString::fromUtf8(dev_type)]->updataflag == true){ //需要更新 + //将这个点的xmlcfg和topicList删除 + clearXmlConfigAndTopicList(xmlinfo_list2[QString::fromUtf8(dev_type)]); + + ret = ParseXMLConfig2(1,&(xmlinfo_list2[QString::fromUtf8(dev_type)]->xmlcfg), &(xmlinfo_list2[QString::fromUtf8(dev_type)]->topicList), xmlinfo_list2[QString::fromUtf8(dev_type)]->xmlbase.MODEL_ID); + if(!ret) + { + std::cout << "!!!! this ledger xml config fail!!!!" << std::endl; + } + } + + } + else{ + std::cout << "xmlinfo_list2 not contain this devtype" << std::endl; + } + } + } //4-配置映射文件/////////////////////////////////// diff --git a/json/mms_json_inter.h b/json/mms_json_inter.h index a2ff41f..c973f46 100644 --- a/json/mms_json_inter.h +++ b/json/mms_json_inter.h @@ -110,8 +110,8 @@ public: kafka_data_list.append(data); kafka_data_list_mutex.unlock(); */ - -int transfer_json_block_data(json_block_data *data); +int transfer_json_block_data(char v_wiring_type[], json_block_data* data);//lnk2024-8-16添加参数 +//int transfer_json_block_data(json_block_data *data); void errorlog_pgsql(char* id, QString time, QString filename); QString errorlog_num_pgsql(QString monitorId, QString datatime, QString filename, int count); QString errorlog_datamatch_pgsql(QString id, QString time, int BASE_MAT_NUM, int ADV_MAT_NUM, int BASE_ACT_NUM, int ADV_ACT_NUM, QString filename); diff --git a/json/save2json.cpp b/json/save2json.cpp index 5390f7e..dc3676e 100644 --- a/json/save2json.cpp +++ b/json/save2json.cpp @@ -721,16 +721,24 @@ std::string extractDataJson(const char* inputJson) { return ""; } - // 提取 "messageBoy" 部分 - 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; + // 提取 "messageBody" 部分 + cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody"); + if (messageJson == NULL || messageJson->type != cJSON_String) { + std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl; cJSON_Delete(root); - return ""; + return false; + } + + // 解析 messageBody 中的 JSON 字符串 + cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + if (messageBody == NULL) { + std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; + cJSON_Delete(root); + return false; } // 提取 "data" 部分 - cJSON* data = cJSON_GetObjectItem(messageBoy, "data"); + cJSON* data = cJSON_GetObjectItem(messageBody, "data"); if (data == NULL || data->type != cJSON_Array) { std::cerr << "'data' is missing or is not an array" << std::endl; cJSON_Delete(root); @@ -776,20 +784,28 @@ bool parseJsonMessageRT(const std::string& body, std::string& devSeries, std::st return false; } - // 提取 "messageBoy" 部分 - 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; + // 提取 "messageBody" 部分 + cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody"); + if (messageJson == NULL || messageJson->type != cJSON_String) { + std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl; cJSON_Delete(root); - return ""; + return false; + } + + // 解析 messageBody 中的 JSON 字符串 + cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + if (messageBody == NULL) { + std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; + cJSON_Delete(root); + return false; } // 提取字段 - 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"); + cJSON* devSeriesItem = cJSON_GetObjectItem(messageBody, "devSeries"); + cJSON* lineItem = cJSON_GetObjectItem(messageBody, "line"); + cJSON* realDataItem = cJSON_GetObjectItem(messageBody, "realData"); + cJSON* soeDataItem = cJSON_GetObjectItem(messageBody, "soeData"); + cJSON* limitItem = cJSON_GetObjectItem(messageBody, "limit"); if (devSeriesItem && lineItem && realDataItem && soeDataItem && limitItem) { devSeries = devSeriesItem->valuestring; @@ -975,17 +991,21 @@ void execute_bash(string fun,int process_num,string type) } //执行脚本控制进程 -void execute_bash_debug(string fun,string ip,string type) +void execute_bash_debug(string fun,string ip,string type,int proindex) { const char* script = "/FeProject/bin/set_debug.sh";//使用setsid防止端口占用 const char* param1 = fun.c_str(); const char* param2 = ip.c_str(); const char* param3 = type.c_str(); + + // 将 proindex 转换为字符串 + char param4[32]; + snprintf(param4, sizeof(param4), "%d", proindex); // 构造完整的命令 char command[256]; - snprintf(command, sizeof(command), "%s %s %s %s &", script, param1, param2, param3); + snprintf(command, sizeof(command), "%s %s %s %s &", script, param1, param2, param3,param4); std::cout << "command:" << command <type != cJSON_Object) { - std::cerr << "'messageBoy' is missing or is not an object" << std::endl; + // 提取 "messageBody" 部分 + cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody"); + if (messageJson == NULL || messageJson->type != cJSON_String) { + std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl; cJSON_Delete(root); return ; } + // 解析 messageBody 中的 JSON 字符串 + cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + if (messageBody == NULL) { + std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; + cJSON_Delete(root); + return ; + } + // 获取 code 字段 - cJSON* code = cJSON_GetObjectItem(messageBoy, "code"); + cJSON* code = cJSON_GetObjectItem(messageBody, "code"); if (code == nullptr) { std::cout << "Missing 'code' in JSON." << std::endl; cJSON_Delete(root); return; } - cJSON* index = cJSON_GetObjectItem(messageBoy, "index"); + cJSON* index = cJSON_GetObjectItem(messageBody, "index"); if (index == nullptr) { std::cout << "Missing 'index' in JSON." << std::endl; cJSON_Delete(root); @@ -1047,7 +1075,7 @@ void parse_set(const std::string& json_str) { 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; // 解析 set_process - cJSON* data = cJSON_GetObjectItem(messageBoy, "data"); + cJSON* data = cJSON_GetObjectItem(messageBody, "data"); if (data != nullptr && data->type == cJSON_Array) { int data_size = cJSON_GetArraySize(data); for (int i = 0; i < data_size; i++) { @@ -1084,7 +1112,7 @@ void parse_set(const std::string& json_str) { 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; // 解析 set_process - cJSON* data = cJSON_GetObjectItem(messageBoy, "data"); + cJSON* data = cJSON_GetObjectItem(messageBody, "data"); if (data != nullptr && data->type == cJSON_Array) { int data_size = cJSON_GetArraySize(data); for (int i = 0; i < data_size; i++) { @@ -1093,12 +1121,14 @@ void parse_set(const std::string& json_str) { std::string fun = cJSON_GetObjectItem(item, "fun")->valuestring; std::string ip = cJSON_GetObjectItem(item, "ip")->valuestring; std::string frontType = cJSON_GetObjectItem(item, "frontType")->valuestring; + int proindex = cJSON_GetObjectItem(item, "proindex")->valueint; //校验数据 if((fun == "start" || fun == "delete") && isValidIP(ip) && - (frontType == "stat" || frontType == "recall" || frontType == "3s" || frontType == "comtrade")){ - execute_bash_debug(fun, ip, frontType); + (frontType == "stat" || frontType == "recall" || frontType == "3s" || frontType == "comtrade") && + (proindex >= 10 && proindex < 100)){ //单连测试用的进程号应该大于10小于100 + execute_bash_debug(fun, ip, frontType,proindex); std::cout << "!!!!!!!!!!!!!!!! execute mark:" << i << " !!!!!!!!!!!!!!!" <type != cJSON_Object) { - std::cerr << "'messageBoy' is missing or is not an object" << std::endl; + // 提取 "messageBody" 部分 + cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody"); + if (messageJson == NULL || messageJson->type != cJSON_String) { + std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl; cJSON_Delete(root); return ; } + // 解析 messageBody 中的 JSON 字符串 + cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + if (messageBody == NULL) { + std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; + cJSON_Delete(root); + return ; + } + // 获取 code 字段 - cJSON* code = cJSON_GetObjectItem(messageBoy, "code"); + cJSON* code = cJSON_GetObjectItem(messageBody, "code"); if (code == nullptr) { std::cout << "Missing 'code' in JSON." << std::endl; cJSON_Delete(root); return; } - cJSON* index = cJSON_GetObjectItem(messageBoy, "index"); + cJSON* index = cJSON_GetObjectItem(messageBody, "index"); if (index == nullptr) { std::cout << "Missing 'index' in JSON." << std::endl; cJSON_Delete(root); @@ -1362,7 +1400,7 @@ void parse_control(const std::string& json_str, const std::string& output_dir) { std::cout << "add or update ledger" <type == cJSON_Array) { int data_size = cJSON_GetArraySize(data); for (int i = 0; i < data_size; i++) { @@ -1533,7 +1571,7 @@ void parse_control(const std::string& json_str, const std::string& output_dir) { std::cout << "delete ledger" <type == cJSON_Array) { int data_size = cJSON_GetArraySize(data); for (int i = 0; i < data_size; i++) { @@ -2201,7 +2239,8 @@ int json_block_create_data(char monid_char[], char* mms_str, double v, int flick // return transfer_json_block_data(&json_blkd); //} -int json_block_create_end(char monid_char[], int flicker_flag)//WW 2023年3月13日16:38:41 多ICD修改 +//lnk2024-8-16添加接线参数 +int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag)//WW 2023年3月13日16:38:41 多ICD修改 { json_block_data* pdata; if (flicker_flag == 1) { @@ -2250,7 +2289,8 @@ int json_block_create_end(char monid_char[], int flicker_flag)//WW 2023 printf("---------- json_block_create_end: pdata->mms_str_map.count() == 0 ----------\n"); return 1; } - int ret = transfer_json_block_data(pdata); + //lnk2024-8-16添加接线参数 + int ret = transfer_json_block_data(v_wiring_type, pdata); if (pdata != NULL) delete pdata; diff --git a/json/save2json.h b/json/save2json.h index 5b8e6de..2cde74b 100644 --- a/json/save2json.h +++ b/json/save2json.h @@ -246,7 +246,7 @@ private slots: clientSocket->write(helpText.toUtf8()); } - // 处理 TEST_NUM + // 设置多点模拟的个数 else if (command.startsWith("TEST_NUM=")) { bool ok; int num = command.mid(9).toInt(&ok); // 获取等号后面的数字部分 @@ -259,39 +259,42 @@ private slots: std::cout << "Invalid number\n"; } } - // 处理 rc 命令 + // 发送补招数据测试文本 else if (command.startsWith("rc")) { qDebug() << "Executing rocketmq_test_rc()"; std::cout << "Executing rocketmq_test_rc()\n"; rocketmq_test_rc(); // 调用 rc 函数 clientSocket->write("Executed rocketmq_test_rc\n> "); } - // 处理 rt 命令 + // 发送实时数据测试文本 else if (command.startsWith("rt")) { qDebug() << "Executing rocketmq_test_rt()"; std::cout << "Executing rocketmq_test_rt()\n"; rocketmq_test_rt(); // 调用 rt 函数 clientSocket->write("Executed rocketmq_test_rt\n> "); } - // 处理 ud 命令 + // 发送台账更新测试文本 else if (command.startsWith("ud")) { qDebug() << "Executing rocketmq_test_ud()"; std::cout << "Executing rocketmq_test_ud()\n"; rocketmq_test_ud(); // 调用 ud 函数 clientSocket->write("Executed rocketmq_test_ud\n> "); } + // 发送进程控制测试文本 else if (command.startsWith("set")) { qDebug() << "Executing rocketmq_test_set()"; std::cout << "Executing rocketmq_test_set()\n"; rocketmq_test_set(); // 调用 set 函数 clientSocket->write("Executed rocketmq_test_set\n> "); } + // 发送单连进程测试文本 else if (command.startsWith("only")) { qDebug() << "Executing rocketmq_test_only()"; std::cout << "Executing rocketmq_test_only()\n"; rocketmq_test_only(); // 调用 set 函数 clientSocket->write("Executed rocketmq_test_only\n> "); } + // 查看当前进程的台账 else if (command.startsWith("ledger")) { qDebug() << "Executing ledger()"; std::cout << "Executing ledger()\n"; @@ -315,6 +318,7 @@ private slots: clientSocket->write("Executed ledger without parameters\n> "); } } + // 查看当前进程的指定值 else if (command.startsWith("value")) { std::cout << "Executing value()" << std::endl; diff --git a/mms/db_interface.h b/mms/db_interface.h index 72bd8b5..03acb0e 100644 --- a/mms/db_interface.h +++ b/mms/db_interface.h @@ -72,7 +72,8 @@ int json_block_create_flag(char monid_char[], int flag, int flicker_flag); //2. json生成数据回调函数 int json_block_create_data(char monid_char[], char* mms_str , double v, int flicker_flag); //3. json生成结束函数 -int json_block_create_end(char monid_char[], int flicker_flag); //CZY 2023-08-17 测试 +//lnk2024-8-16添加参数 +int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag); //CZY 2023-08-17 测试 //int json_block_create_end(int MonitorId,int devkind);//CZY 2023-08-17 测试 //zw 2024-01-31 补招模式优化 diff --git a/mms/mmscli_log.c b/mms/mmscli_log.c index 2dc9056..3b023ee 100644 --- a/mms/mmscli_log.c +++ b/mms/mmscli_log.c @@ -250,9 +250,9 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t, { printf("\n newTime: %d %d %d %d %d %d", newTime.tm_year, newTime.tm_mon, newTime.tm_mday, newTime.tm_hour, newTime.tm_min, newTime.tm_sec); printf("\n preTime: %d %d %d %d %d %d", preTime.tm_year, preTime.tm_mon, preTime.tm_mday, preTime.tm_hour, preTime.tm_min, preTime.tm_sec); - json_block_create_end(loginfo->LD_info->mp_id, 0);//稳态 - json_block_create_end(loginfo->LD_info->mp_id, 1);//长闪 - json_block_create_end(loginfo->LD_info->mp_id, 2);//短闪 波动 + json_block_create_end(loginfo->LD_info->v_wiring_type,loginfo->LD_info->mp_id, 0);//稳态 + json_block_create_end(loginfo->LD_info->v_wiring_type,loginfo->LD_info->mp_id, 1);//长闪 + json_block_create_end(loginfo->LD_info->v_wiring_type,loginfo->LD_info->mp_id, 2);//短闪 波动 process_jou_entry_t = t;//调整至最新时标 ied_t* ied; @@ -559,9 +559,10 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n //start = sGetMsTime(); if ( jread_resp->more_follows == 0 && ((i + 1) == jread_resp->num_of_jou_entry)) { printf("\njread_resp->more_follows == 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - json_block_create_end(loginfo->LD_info->mp_id, 0);//more follows为0 数据接受最后一条 强行处理稳态数据的json防止遗留 - json_block_create_end(loginfo->LD_info->mp_id, 1); - json_block_create_end(loginfo->LD_info->mp_id, 2); + //lnk2024-8-16添加接线参数 + json_block_create_end(loginfo->LD_info->v_wiring_type, loginfo->LD_info->mp_id, 0);//more follows为0 数据接受最后一条 强行处理稳态数据的json防止遗留 + json_block_create_end(loginfo->LD_info->v_wiring_type, loginfo->LD_info->mp_id, 1); + json_block_create_end(loginfo->LD_info->v_wiring_type, loginfo->LD_info->mp_id, 2); ied_t* ied; ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code); diff --git a/mms/mmscli_rpt.c b/mms/mmscli_rpt.c index 0849a4b..681b63c 100644 --- a/mms/mmscli_rpt.c +++ b/mms/mmscli_rpt.c @@ -1127,13 +1127,13 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va, { //ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022年12月6日14:09:08 增加多个ICD支持 //int devkind = ied_usr->dev_flag; - json_block_create_end(LD_info->mp_id, rptinfo->flickerflag); + json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag); //lnk2024-8-16增加接线类型参数 } else if(rptinfo->flickerflag == 0){//CZY 2023-08-17 WW 2022-11-14 增加多个报告判断 if (LD_info->rptRecvFlag == LD_info->rptRecvCheckFlag) { //ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022年12月6日14:09:08 增加多个ICD支持 //int devkind = ied_usr->dev_flag; - json_block_create_end(LD_info->mp_id, rptinfo->flickerflag); + json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag); //lnk2024-8-16增加接线类型参数 LD_info->rptRecvCheckFlag = 0; } } @@ -1141,7 +1141,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va, if (LD_info->rptPstRecvFlag == LD_info->rptPstRecvCheckFlag) { //ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022年12月6日14:09:08 增加多个ICD支持 //int devkind = ied_usr->dev_flag; - json_block_create_end(LD_info->mp_id, rptinfo->flickerflag); + json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag); //lnk2024-8-16增加接线类型参数 LD_info->rptPstRecvCheckFlag = 0; } } @@ -1522,13 +1522,13 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va, { //ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022年12月6日14:09:08 增加多个ICD支持 //int devkind = ied_usr->dev_flag; - json_block_create_end(LD_info->mp_id, rptinfo->flickerflag); + json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag);//lnk角形处理 } else if (rptinfo->flickerflag == 0) {//CZY 2023-08-17 WW 2022-11-14 增加多个报告判断 if (LD_info->rptRecvFlag == LD_info->rptRecvCheckFlag) { //ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022年12月6日14:09:08 增加多个ICD支持 //int devkind = ied_usr->dev_flag; - json_block_create_end(LD_info->mp_id, rptinfo->flickerflag); + json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag);//lnk角形处理 LD_info->rptRecvCheckFlag = 0; } } @@ -1536,7 +1536,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va, if (LD_info->rptPstRecvFlag == LD_info->rptPstRecvCheckFlag) { //ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022年12月6日14:09:08 增加多个ICD支持 //int devkind = ied_usr->dev_flag; - json_block_create_end(LD_info->mp_id, rptinfo->flickerflag); + json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag);//lnk角形处理 LD_info->rptPstRecvCheckFlag = 0; } } diff --git a/mms/rdb_client.c b/mms/rdb_client.c index c78205b..69f25f4 100644 --- a/mms/rdb_client.c +++ b/mms/rdb_client.c @@ -255,6 +255,11 @@ apr_status_t run_protocol() // apr_thread_t* mms_thread; static apr_threadattr_t* worker_attr = NULL; + //lnk20250214//单连模式,进程先通过进程号0获取所有台账,然后再更新自己的进程号 + if (g_onlyIP[0] != 0 && g_front_seg_index == 0 && g_front_seg_num >= 10){ //这是web端控制打开的单连进程 + g_front_seg_index = g_front_seg_num; //更新进程号为:为这个单连进程设置的进程号,用来控制实时日志 + } + init_MMS(); if (worker_attr == NULL) @@ -274,7 +279,7 @@ apr_status_t run_protocol() if ((rv = apr_thread_create(&rtdb_thread, worker_attr, rtdb_worker, NULL, g_run_pool)) != APR_SUCCESS) return rv; - try_start_kafka_thread(); + try_start_kafka_thread();//mq线程 //lnk20241213添加mq消费者线程 try_start_mqconsumer_thread(); @@ -284,11 +289,10 @@ apr_status_t run_protocol() { printf("g_onlyIP[0] != 0!\n\a"); - //lnk20250211将前置的进程号设置为999,用于单连查看日志用,web一次只能开启一个单连查看 - g_front_seg_index = 999; + //单连进程不打开socket、http、测试线程 } - else + else //socket、http、测试线程的开启 { printf("g_onlyIP[0] == 0!\n\a"); if (1 == SOCKETENABLE)