Commit fb5945ec authored by Pavel Vainerman's avatar Pavel Vainerman

(Modbus): Добавил параметр --xxx-reopen-timeout определяющий, через сколько msec…

(Modbus): Добавил параметр --xxx-reopen-timeout определяющий, через сколько msec после пропажи соединения, будет происходить попытка, переоткрыть соединение (TCP) или файл устройства (RTU). // close eterbug #9296
parent bf3fb32a
......@@ -7,7 +7,7 @@
Name: libuniset
Version: 1.6
Release: alt8
Release: alt9
Summary: UniSet - library for building distributed industrial control systems
......@@ -319,6 +319,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Tue May 14 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt9
- add for Modbus (RTU|TCP) exchange --xxx-reopen-timeout msec. (eterbug #9296)
* Wed May 08 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt8
- fixed minor bug in uniset-codegen (getValue)
......
......@@ -65,6 +65,9 @@ pollActivated(false)
tout = conf->getArgPInt("--" + prefix + "-all-timeout",it.getProp("all_timeout"), tout);
ptTimeout.setTiming(tout);
tout = conf->getArgPInt("--" + prefix + "-reopen-timeout",it.getProp("reopen_timeout"), 10000);
ptReopen.setTiming(tout);
noQueryOptimization = conf->getArgInt("--" + prefix + "-no-query-optimization",it.getProp("no_query_optimization"));
mbregFromID = conf->getArgInt("--" + prefix + "-reg-from-id",it.getProp("reg_from_id"));
......@@ -139,6 +142,7 @@ void MBExchange::help_print( int argc, const char* const* argv )
cout << "--prefix-polltime msec - Пауза между опросаом карт. По умолчанию 200 мсек." << endl;
cout << "--prefix-recv-timeout msec - Таймаут на приём одного сообщения" << endl;
cout << "--prefix-timeout msec - Таймаут для определения отсутсвия соединения" << endl;
cout << "--prefix-reopen-timeout msec - Таймаут для 'переоткрытия соединения' при отсутсвия соединения msec милисекунд. По умолчанию 10 сек." << endl;
cout << "--prefix-heartbeat-id name - Данный процесс связан с указанным аналоговым heartbeat-дачиком." << endl;
cout << "--prefix-heartbeat-max val - Максимальное значение heartbeat-счётчика для данного процесса. По умолчанию 10." << endl;
cout << "--prefix-ready-timeout msec - Время ожидания готовности SM к работе, мсек. (-1 - ждать 'вечно')" << endl;
......@@ -2656,6 +2660,8 @@ void MBExchange::poll()
if( !checkProcActive() )
return;
bool allNotRespond = true;
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{
RTUDevice* d(it1->second);
......@@ -2700,6 +2706,9 @@ void MBExchange::poll()
d->resp_real = true;
}
if( d->resp_real )
allNotRespond = false;
if( it==d->regmap.end() )
break;
......@@ -2744,6 +2753,19 @@ void MBExchange::poll()
}
}
if( trReopen.hi(allNotRespond) )
ptReopen.reset();
if( allNotRespond && ptReopen.checkTime() )
{
uniset_mutex_lock l(pollMutex, 300);
if( dlog.debugging(Debug::WARN) )
dlog[Debug::WARN] << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
mb = initMB(true);
ptReopen.reset();
}
// printMap(rmap);
}
// -----------------------------------------------------------------------------
......
......@@ -314,6 +314,9 @@ class MBExchange:
bool pollActivated;
int recv_timeout;
PassiveTimer ptReopen; /*!< таймер для переоткрытия соединения */
Trigger trReopen;
private:
MBExchange();
......
......@@ -67,7 +67,6 @@ rs_pre_clean(false)
else
ic->addReadItem( sigc::mem_fun(this,&RTUExchange::readItem) );
initMB(false);
if( dlog.debugging(Debug::INFO) )
......@@ -205,6 +204,7 @@ void RTUExchange::poll()
if( !checkProcActive() )
return;
bool allNotRespond = true;
ComPort::Speed s = mbrtu->getSpeed();
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
......@@ -291,6 +291,9 @@ void RTUExchange::poll()
return;
}
}
if( d->resp_real )
allNotRespond = false;
}
// update SharedMemory...
......@@ -308,6 +311,19 @@ void RTUExchange::poll()
}
}
if( trReopen.hi(allNotRespond) )
ptReopen.reset();
if( allNotRespond && ptReopen.checkTime() )
{
uniset_mutex_lock l(pollMutex, 300);
if( dlog.debugging(Debug::WARN) )
dlog[Debug::WARN] << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
mb = initMB(true);
ptReopen.reset();
}
// printMap(rmap);
}
// -----------------------------------------------------------------------------
......
......@@ -44,9 +44,6 @@ class RTUExchange:
UniSetTypes::uniset_mutex pollMutex;
bool rs_pre_clean;
bool allNotRespond;
Trigger trAllNotRespond;
// PassiveTimer ptAllNotRespond;
};
// -----------------------------------------------------------------------------
#endif // _RS_EXCHANGE_H_
......
......@@ -11,7 +11,7 @@
--mbtcp-gateway-port 2048 \
--mbtcp-recv-timeout 5000 \
--mbtcp-force-disconnect 1 \
--mbtcp-polltime 5000 \
--mbtcp-polltime 3000 \
--mbtcp-exchange-mode-id MB1_Mode_AS \
#--mbtcp-set-prop-prefix tcp_
#--mbtcp-filter-field mbtcp --mbtcp-filter-value 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment