From 5c2ff8bb3d360b527ca64c42a92930a41458409c Mon Sep 17 00:00:00 2001 From: zhouhuang Date: Fri, 10 Jan 2025 09:12:01 +0800 Subject: [PATCH] update --- das-dn/CMakeLists.txt | 2 +- das-dn/cmg/ry.cpp | 8 ++++++ das-dn/comm/process.cpp | 13 +++------- das-dn/hostadsbf/hostadsbf.cpp | 25 ++++++++----------- das-dn/hostadsbf/hostadsbf.h | 2 +- das-dn/hostmodbustcpbf/host_modbus_tcp_bf.cpp | 12 ++++----- das-dn/hostmodbustcpbf/host_modbus_tcp_bf.h | 1 + 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/das-dn/CMakeLists.txt b/das-dn/CMakeLists.txt index 00ec2e22..7d1f7e6b 100644 --- a/das-dn/CMakeLists.txt +++ b/das-dn/CMakeLists.txt @@ -20,7 +20,7 @@ if (USE_SQLITE3) endif () endif () -set (CMAKE_BUILD_TYPE Release) +# set (CMAKE_BUILD_TYPE Release) option (USE_32BITS "Build 32Bits application?" OFF) if (USE_32BITS) diff --git a/das-dn/cmg/ry.cpp b/das-dn/cmg/ry.cpp index 007f22b6..6ca930e9 100644 --- a/das-dn/cmg/ry.cpp +++ b/das-dn/cmg/ry.cpp @@ -2829,10 +2829,12 @@ void CRYDevice::heart_beat(int status) #endif jsonValue["linkId"] = linkId; jsonValue["online"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true; +#if 1 jsonValue["real"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true; if ((config.processes[i].state & 0x20) == 0x20) { jsonValue["ftp"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true; } +#endif jsonLink.append(jsonValue); } } @@ -2853,6 +2855,12 @@ void CRYDevice::heart_beat(int status) #endif jsonValue["deviceId"] = deviceId; jsonValue["online"] = (config.units[i].real_softdog >= UNIT_WATCHDOG_TIME) ? false : true; +#if 0 + jsonValue["real"] = (config.units[i].real_softdog >= UNIT_WATCHDOG_TIME) ? false : true; + if ((config.units[i].state & 0x20) == 0x20) { + jsonValue["ftp"] = (config.units[i].real_softdog >= UNIT_WATCHDOG_TIME) ? false : true; + } +#endif jsonDevice.append(jsonValue); } } diff --git a/das-dn/comm/process.cpp b/das-dn/comm/process.cpp index 994baf0b..0f1b3905 100644 --- a/das-dn/comm/process.cpp +++ b/das-dn/comm/process.cpp @@ -1740,15 +1740,8 @@ BOOLEAN CProcess::OnCreated(int id) void CProcess::Destroy(void) { m_bRunFlag = FALSE; - - char name[16]; - memset(name, '\0', sizeof(name)); - if (pthread_getname_np(m_pid, name, sizeof(name)) != 0) - { - memset(name, '\0', sizeof(name)); - } - - vLog(LOG_DEBUG, "waiting for protocol thread [%d,%s] destroy.\n", m_nProcess, (name[0] != '\0') ? name : "unknow"); + + vLog(LOG_DEBUG, "waiting for protocol thread [%d,%s] destroy.\n", m_nProcess, config.processes[m_nProcess].name); pthread_join(m_pid, NULL); int i = 0; @@ -1757,7 +1750,7 @@ void CProcess::Destroy(void) DestroyItem(i, FALSE); } - vLog(LOG_DEBUG, "current protocol thread [%d,%s] is destroyed.\n", m_nProcess, (name[0] != '\0') ? name : "unknow"); + vLog(LOG_DEBUG, "current protocol thread [%d,%s] is destroyed.\n", m_nProcess, config.processes[m_nProcess].name); } BOOLEAN CProcess::Run(void) diff --git a/das-dn/hostadsbf/hostadsbf.cpp b/das-dn/hostadsbf/hostadsbf.cpp index ffb32b54..2e13f739 100644 --- a/das-dn/hostadsbf/hostadsbf.cpp +++ b/das-dn/hostadsbf/hostadsbf.cpp @@ -703,15 +703,10 @@ CHostADSBFProcess::~CHostADSBFProcess() fwrite(&m_currentDirStartFileNo, sizeof(LONG), 1, pf); fclose(pf); } - char name[16]; - memset(name, '\0', sizeof(name)); - if (pthread_getname_np(m_cpid, name, sizeof(name)) != 0) - { - memset(name, '\0', sizeof(name)); - } - vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (name[0] != '\0') ? name : "unknow"); + + vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow"); pthread_join(m_cpid, NULL); - vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (name[0] != '\0') ? name : "unknow"); + vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow"); } } @@ -857,14 +852,17 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id) //需要给单元添加一个是否有ftp数据的标识 int uid = GetCurUnitID(); - if (uid < 0 || uid >= UNIT_NUM) return FALSE; + //if (uid < 0 || uid >= UNIT_NUM) return FALSE; if (m_bHaveFTP) { - config.units[uid].state |= 0x20; //存在ftp标识 + if (uid >= 0 && uid < UNIT_NUM) + { + config.units[uid].state |= 0x20; //存在ftp标识 + } config.processes[id].state |= 0x20; } calc(); - //vLog(LOG_DEBUG, "%s local ip is: %s, netid is: %s, remote ip is: %s, and netid is: %s\n", m_pidName.c_str(), m_localIp.c_str(), m_localNetId.c_str(), m_remoteIp.c_str(), m_remoteNetId.c_str()); + vLog(LOG_DEBUG, "%s local ip is: %s, netid is: %s, remote ip is: %s, and netid is: %s\n", m_pidName.c_str(), m_localIp.c_str(), m_localNetId.c_str(), m_remoteIp.c_str(), m_remoteNetId.c_str()); m_turbine = NULL; m_bRouteAdded = FALSE; @@ -911,9 +909,8 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id) vLog(LOG_ERROR, "ads create ryftp_process error(%d,%s).\n", errno, strerror(errno)); return TRUE; } - char name[17]; - snprintf(name, 16, "%s_ftp", m_pidName.c_str()); - pthread_setname_np(m_cpid, name); + snprintf(m_cpidName, 16, "%s_ftp", m_pidName.c_str()); + pthread_setname_np(m_cpid, m_cpidName); pthread_attr_destroy(&attr); } diff --git a/das-dn/hostadsbf/hostadsbf.h b/das-dn/hostadsbf/hostadsbf.h index 176429a3..e273c1cf 100644 --- a/das-dn/hostadsbf/hostadsbf.h +++ b/das-dn/hostadsbf/hostadsbf.h @@ -103,8 +103,8 @@ private: public: std::string m_pidName; - BOOLEAN m_bHaveFTP; //存在FTP协议 + char m_cpidName[16]; //ftp参数信息 char m_user[64]; diff --git a/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.cpp b/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.cpp index 8ebf3ae4..2f855c1a 100644 --- a/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.cpp +++ b/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.cpp @@ -794,9 +794,9 @@ CHostModbusTcpBFProcess::~CHostModbusTcpBFProcess() { memset(name, '\0', sizeof(name)); } - vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (name[0] != '\0') ? name : "unknow"); + vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow"); pthread_join(m_cpid, NULL); - vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (name[0] != '\0') ? name : "unknow"); + vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow"); } } @@ -1175,13 +1175,13 @@ BOOLEAN CHostModbusTcpBFProcess::OnPreCreate(int id) pthread_attr_setstacksize(&attr, MEMERY_1M); pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); - if (pthread_create(&m_cpid, &attr, ryftp_process, this) < 0) { + if (pthread_create(&m_cpid, &attr, ryftp_process, this) < 0) + { vLog(LOG_ERROR, "rymodbus create ryftp_process error(%d,%s).\n", errno, strerror(errno)); return TRUE; } - char name[17]; - snprintf(name, 16, "%s_ftp", m_pidName.c_str()); - pthread_setname_np(m_cpid, name); + snprintf(m_cpidName, 16, "%s_ftp", m_pidName.c_str()); + pthread_setname_np(m_cpid, m_cpidName); pthread_attr_destroy(&attr); } diff --git a/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.h b/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.h index 770ca85a..a8afce0b 100644 --- a/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.h +++ b/das-dn/hostmodbustcpbf/host_modbus_tcp_bf.h @@ -65,6 +65,7 @@ private: public: std::string m_pidName; BOOLEAN m_bHaveFTP; //存在FTP协议 + char m_cpidName[16]; //ftp参数信息 char m_user[64];