update ads connect time
This commit is contained in:
parent
c4705541ea
commit
05b3f71b4e
@ -853,6 +853,7 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id)
|
|||||||
|
|
||||||
m_turbine = NULL;
|
m_turbine = NULL;
|
||||||
m_bRouteAdded = FALSE;
|
m_bRouteAdded = FALSE;
|
||||||
|
m_apdu_t0_begin = 10;
|
||||||
SetLocalAmsNetId(AmsNetId(m_localNetId));
|
SetLocalAmsNetId(AmsNetId(m_localNetId));
|
||||||
#if 0
|
#if 0
|
||||||
m_threadRun = TRUE;
|
m_threadRun = TRUE;
|
||||||
@ -927,56 +928,43 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
|
|||||||
}
|
}
|
||||||
if (sec_changed)
|
if (sec_changed)
|
||||||
{
|
{
|
||||||
if (m_turbine == NULL) {
|
if (m_turbine == NULL)
|
||||||
#if 0
|
{
|
||||||
m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
|
if ((m_apdu_t0_begin + 20) < system32.timers)
|
||||||
const auto state = m_turbine->GetState();
|
|
||||||
if ((uint16_t)state.ads >= ADSSTATE::ADSSTATE_MAXSTATES || (uint16_t)state.device >= ADSSTATE::ADSSTATE_MAXSTATES)
|
|
||||||
{
|
{
|
||||||
vLog(LOG_DEBUG, "read device state error.\n");
|
m_apdu_t0_begin = system32.timers;
|
||||||
long ret = AddRemoteRoute(m_remoteIp, m_localNetId, m_localIp, std::string("isoftstone"), std::string("admin"), std::string("admin"));
|
//先添加一条路由
|
||||||
vLog(LOG_DEBUG, "bbb %s add route return value is: %d\n", m_pidName.c_str(), ret);
|
if (m_bRouteAdded == FALSE)
|
||||||
delete m_turbine;
|
{
|
||||||
m_turbine = NULL;
|
long ret = AddRemoteRoute(m_remoteIp, AmsNetId(m_localNetId), m_localIp, std::string("isoftstone"), std::string("admin"), std::string("admin"));
|
||||||
|
vLog(LOG_DEBUG, "%s add route(%s to %s) return value is: %d\n", m_pidName.c_str(), m_localIp.c_str(), m_remoteIp.c_str(), ret);
|
||||||
|
if (ret != 0) return TRUE;
|
||||||
|
}
|
||||||
|
m_bRouteAdded = TRUE;
|
||||||
|
//添加成功
|
||||||
|
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};
|
||||||
|
const auto state = m_turbine->GetState();
|
||||||
|
if ((uint16_t)state.ads >= ADSSTATE::ADSSTATE_MAXSTATES || (uint16_t)state.device >= ADSSTATE::ADSSTATE_MAXSTATES)
|
||||||
|
{
|
||||||
|
vLog(LOG_DEBUG, "%s read device state error.\n", m_pidName.c_str());
|
||||||
|
delete m_turbine;
|
||||||
|
m_turbine = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
//先添加一条路由
|
|
||||||
if (m_bRouteAdded == FALSE)
|
|
||||||
{
|
|
||||||
long ret = AddRemoteRoute(m_remoteIp, AmsNetId(m_localNetId), m_localIp, std::string("isoftstone"), std::string("admin"), std::string("admin"));
|
|
||||||
vLog(LOG_DEBUG, "%s add route(%s to %s) return value is: %d\n", m_localIp.c_str(), m_remoteIp.c_str(), m_pidName.c_str(), ret);
|
|
||||||
if (ret != 0) return TRUE;
|
|
||||||
}
|
|
||||||
m_bRouteAdded = TRUE;
|
|
||||||
//添加成功
|
|
||||||
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};
|
|
||||||
const auto state = m_turbine->GetState();
|
|
||||||
if ((uint16_t)state.ads >= ADSSTATE::ADSSTATE_MAXSTATES || (uint16_t)state.device >= ADSSTATE::ADSSTATE_MAXSTATES)
|
|
||||||
{
|
|
||||||
vLog(LOG_DEBUG, "%s read device state error.\n", m_pidName.c_str());
|
|
||||||
delete m_turbine;
|
|
||||||
m_turbine = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (!m_turbine->IsConnected()) return TRUE;
|
if (!m_turbine->IsConnected()) return TRUE;
|
||||||
//try {
|
m_apdu_t0_begin = system32.timers;
|
||||||
if (m_bHaveFTP)
|
if (m_bHaveFTP)
|
||||||
{ //启动时读取一次,后面自己维护序号
|
{ //启动时读取一次,后面自己维护序号
|
||||||
if ((m_currentDirNo == -1) && (m_currentFileNo == -1))
|
if ((m_currentDirNo == -1) && (m_currentFileNo == -1))
|
||||||
{ //当前文件和目录都为-1,程序第一次启动。需要获取ftp目录及文件ID
|
{ //当前文件和目录都为-1,程序第一次启动。需要获取ftp目录及文件ID
|
||||||
readFileID();
|
readFileID();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
readRealData();
|
}
|
||||||
FeedDog();
|
readRealData();
|
||||||
// } catch (const AdsException& ex) {
|
FeedDog();
|
||||||
// vLog(LOG_ERROR, "%s AdsException message: %s, remote is: %s:%d\n", m_pidName.c_str(), ex.what(), m_remoteIp.c_str(), m_remotePort);
|
|
||||||
// } catch (const std::runtime_error& ex) {
|
|
||||||
// vLog(LOG_ERROR, "%s %s\n", m_pidName.c_str(), ex.what());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ private:
|
|||||||
|
|
||||||
AdsDevice *m_turbine;
|
AdsDevice *m_turbine;
|
||||||
BOOLEAN m_bRouteAdded; //路由是否添加成功
|
BOOLEAN m_bRouteAdded; //路由是否添加成功
|
||||||
|
DWORD m_apdu_t0_begin;
|
||||||
|
|
||||||
int m_total_length;
|
int m_total_length;
|
||||||
DWORD last_sec;
|
DWORD last_sec;
|
||||||
|
Loading…
Reference in New Issue
Block a user