This commit is contained in:
zhouhuang 2024-12-26 10:08:40 +08:00
parent 8d20d95bde
commit 42af041cf4
2 changed files with 9 additions and 1 deletions

View File

@ -893,6 +893,7 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id)
m_turbine = NULL; m_turbine = NULL;
m_bRouteAdded = FALSE; m_bRouteAdded = FALSE;
m_connect_count = 0;
m_apdu_t0_begin = 10; m_apdu_t0_begin = 10;
SetLocalAmsNetId(AmsNetId(m_localNetId)); SetLocalAmsNetId(AmsNetId(m_localNetId));
#if 0 #if 0
@ -982,6 +983,7 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
if (ret != 0) return TRUE; if (ret != 0) return TRUE;
} }
m_bRouteAdded = TRUE; m_bRouteAdded = TRUE;
m_connect_count = 0;
//添加成功 //添加成功
vLog(LOG_DEBUG, "%s start to connect(%s:%d)\n", m_pidName.c_str(), m_remoteIp.c_str(), m_remotePort); vLog(LOG_DEBUG, "%s start to connect(%s:%d)\n", m_pidName.c_str(), m_remoteIp.c_str(), m_remotePort);
m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort}; m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
@ -999,7 +1001,12 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
if (!m_turbine->IsConnected()) if (!m_turbine->IsConnected())
{ {
vLog(LOG_DEBUG, "%s device not connected.\n", m_pidName.c_str()); vLog(LOG_DEBUG, "%s device not connected.\n", m_pidName.c_str());
m_bRouteAdded = FALSE; m_connect_count++;
if (m_connect_count >= 10)
{
m_connect_count = 10;
m_bRouteAdded = FALSE;
}
delete m_turbine; delete m_turbine;
m_turbine = NULL; m_turbine = NULL;
return TRUE; return TRUE;

View File

@ -48,6 +48,7 @@ private:
AdsDevice *m_turbine; AdsDevice *m_turbine;
BOOLEAN m_bRouteAdded; //路由是否添加成功 BOOLEAN m_bRouteAdded; //路由是否添加成功
DWORD m_connect_count;
DWORD m_apdu_t0_begin; DWORD m_apdu_t0_begin;
int m_total_length; int m_total_length;