Commit 0d882a8c authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил возможность задавать пороговые датчики для процесса обмена

Modbus TCP|RTU
parent fa6d6a5f
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Name: libuniset Name: libuniset
Version: 1.7 Version: 1.7
Release: alt8 Release: alt9
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -335,6 +335,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -335,6 +335,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Wed Mar 19 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt9
- add thresholds processing for ModbusMaster (TCP and RTU)
- minor fixes
* Fri Mar 07 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt8 * Fri Mar 07 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt8
- fixed bug in ComPort class (getTimeout. eterbug #9890) - fixed bug in ComPort class (getTimeout. eterbug #9890)
......
...@@ -309,9 +309,17 @@ void MBExchange::initIterators() ...@@ -309,9 +309,17 @@ void MBExchange::initIterators()
{ {
shm->initDIterator(it2->dit); shm->initDIterator(it2->dit);
shm->initAIterator(it2->ait); shm->initAIterator(it2->ait);
shm->initAIterator(it2->t_ait);
} }
} }
} }
for( ThresholdList::iterator t=thrlist.begin(); t!=thrlist.end(); ++t )
{
shm->initDIterator(t->dit);
shm->initAIterator(t->ait);
shm->initAIterator(t->t_ait);
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool MBExchange::checkUpdateSM( bool wrFunc, long mdev ) bool MBExchange::checkUpdateSM( bool wrFunc, long mdev )
...@@ -1832,6 +1840,15 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it ) ...@@ -1832,6 +1840,15 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
if( !IOBase::initItem(&p,it,shm,&dlog,myname) ) if( !IOBase::initItem(&p,it,shm,&dlog,myname) )
return false; return false;
// проверяем не пороговый ли это датчик (т.е. не связанный с обменом)
// тогда заносим его в отдельный список
if( p.t_ai != DefaultObjectId )
{
thrlist.push_back(p);
return true;
}
if( it.getIntProp(prop_prefix + "rawdata") ) if( it.getIntProp(prop_prefix + "rawdata") )
{ {
p.cal.minRaw = 0; p.cal.minRaw = 0;
...@@ -2838,18 +2855,12 @@ void MBExchange::poll() ...@@ -2838,18 +2855,12 @@ void MBExchange::poll()
updateSM(); updateSM();
// check thresholds // check thresholds
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 ) for( ThresholdList::iterator t=thrlist.begin(); t!=thrlist.end(); ++t )
{ {
RTUDevice* d(it1->second); if( !checkProcActive() )
for( MBExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it ) return;
{
if( !checkProcActive() ) IOBase::processingThreshold(&(*t),shm,force);
return;
RegInfo* r(it->second);
for( PList::iterator i=r->slst.begin(); i!=r->slst.end(); ++i )
IOBase::processingThreshold( &(*i),shm,force);
}
} }
if( trReopen.hi(allNotRespond) ) if( trReopen.hi(allNotRespond) )
......
...@@ -325,6 +325,11 @@ class MBExchange: ...@@ -325,6 +325,11 @@ class MBExchange:
PassiveTimer ptReopen; /*!< таймер для переоткрытия соединения */ PassiveTimer ptReopen; /*!< таймер для переоткрытия соединения */
Trigger trReopen; Trigger trReopen;
// т.к. пороговые датчики не связаны напрямую с обменом, создаём для них отдельный список
// и отдельно его проверяем потом
typedef std::list<IOBase> ThresholdList;
ThresholdList thrlist;
private: private:
MBExchange(); MBExchange();
......
...@@ -301,17 +301,14 @@ void RTUExchange::poll() ...@@ -301,17 +301,14 @@ void RTUExchange::poll()
updateSM(); updateSM();
// check thresholds // check thresholds
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 ) for( ThresholdList::iterator t=thrlist.begin(); t!=thrlist.end(); ++t )
{ {
RTUDevice* d(it1->second); if( !checkProcActive() )
for( RTUExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it ) return;
{
RegInfo* r(it->second); IOBase::processingThreshold(&(*t),shm,force);
for( PList::iterator i=r->slst.begin(); i!=r->slst.end(); ++i )
IOBase::processingThreshold( &(*i),shm,force);
}
} }
if( trReopen.hi(allNotRespond) ) if( trReopen.hi(allNotRespond) )
ptReopen.reset(); ptReopen.reset();
......
...@@ -101,7 +101,7 @@ static const int NoSafety = -1; ...@@ -101,7 +101,7 @@ static const int NoSafety = -1;
хранится идентификатор аналогового датчика хранится идентификатор аналогового датчика
с которым он связан */ с которым он связан */
IONotifyController_i::ThresholdInfo ti; IONotifyController_i::ThresholdInfo ti;
IOController::AIOStateList::iterator t_ait; /*! итератор на датчик по которому формируется порог */
IOController::AIOStateList::iterator ait; IOController::AIOStateList::iterator ait;
IOController::DIOStateList::iterator dit; IOController::DIOStateList::iterator dit;
......
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