Commit 523ad82b authored by Pavel Vainerman's avatar Pavel Vainerman

add processingThresholds function

parent dd3b30d8
...@@ -24,6 +24,5 @@ ...@@ -24,6 +24,5 @@
SensorInfo ObjectId. SensorInfo ObjectId.
---------- ----------
RTUExchabge: vtype="Byte"
smonit: processing "precision" smonit: processing "precision"
admin: processing "precision" admin: processing "precision"
\ No newline at end of file
...@@ -492,6 +492,9 @@ void IOControl::iopoll() ...@@ -492,6 +492,9 @@ void IOControl::iopoll()
unideb[Debug::LEVEL3] << myname << "(iopoll): catch ..." << endl; unideb[Debug::LEVEL3] << myname << "(iopoll): catch ..." << endl;
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&(*it),shm,force);
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
void IOControl::readConfiguration() void IOControl::readConfiguration()
......
...@@ -298,6 +298,9 @@ void MBMaster::poll() ...@@ -298,6 +298,9 @@ void MBMaster::poll()
dlog[Debug::LEVEL3] << myname << "(poll): catch ..." << endl; dlog[Debug::LEVEL3] << myname << "(poll): catch ..." << endl;
} }
} }
for( MBMap::iterator it=mbmap.begin(); it!=mbmap.end(); ++it )
IOBase::processingThreshold(&(*it),shm,force);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
long MBMaster::readReg( MBMap::iterator& p ) long MBMaster::readReg( MBMap::iterator& p )
......
...@@ -307,6 +307,9 @@ void MBSlave::execute_rtu() ...@@ -307,6 +307,9 @@ void MBSlave::execute_rtu()
<< "(execute_rtu): (hb) " << ex << std::endl; << "(execute_rtu): (hb) " << ex << std::endl;
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&it->second,shm,force);
} }
catch(...){} catch(...){}
} }
...@@ -355,6 +358,9 @@ void MBSlave::execute_tcp() ...@@ -355,6 +358,9 @@ void MBSlave::execute_tcp()
<< "(execute_tcp): (hb) " << ex << std::endl; << "(execute_tcp): (hb) " << ex << std::endl;
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&it->second,shm,force);
} }
catch(...){} catch(...){}
} }
......
...@@ -317,6 +317,18 @@ void RTUExchange::poll() ...@@ -317,6 +317,18 @@ void RTUExchange::poll()
// update SharedMemory... // update SharedMemory...
updateSM(); updateSM();
// check thresholds
for( RTUExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{
RTUDevice* d(it1->second);
for( RTUExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it )
{
RegInfo* r(it->second);
for( PList::iterator i=r->slst.begin(); i!=r->slst.end(); ++i )
IOBase::processingThreshold( &(*i),shm,force);
}
}
// printMap(rmap); // printMap(rmap);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -34,8 +34,7 @@ static const int NoSafety = -1; ...@@ -34,8 +34,7 @@ static const int NoSafety = -1;
jar_state(false), jar_state(false),
ondelay_state(false), ondelay_state(false),
offdelay_state(false), offdelay_state(false),
t_ai(UniSetTypes::DefaultObjectId), t_ai(UniSetTypes::DefaultObjectId)
initOK(false)
{} {}
......
...@@ -370,17 +370,10 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force ) ...@@ -370,17 +370,10 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
if( it->t_ai == DefaultObjectId ) if( it->t_ai == DefaultObjectId )
return; return;
if( !it->initOK )
{
shm->initAIterator(it->ait);
shm->initDIterator(it->dit);
it->initOK = true;
}
long val = shm->localGetValue(it->ait,it->t_ai); long val = shm->localGetValue(it->ait,it->t_ai);
bool set = it->value ? true : false; bool set = it->value ? true : false;
cout << "val=" << val << " set=" << set << endl; // cout << "val=" << val << " set=" << set << endl;
// //
// lowLimit- // lowLimit-
if( val <= (it->ti.lowlimit-it->ti.sensibility) ) if( val <= (it->ti.lowlimit-it->ti.sensibility) )
...@@ -388,8 +381,8 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force ) ...@@ -388,8 +381,8 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
else if( val >= (it->ti.hilimit+it->ti.sensibility) ) else if( val >= (it->ti.hilimit+it->ti.sensibility) )
set = true; set = true;
cout << "thresh: set=" << set << endl; // cout << "thresh: set=" << set << endl;
processingDI(it,set,shm,force); processingAsDI(it,set,shm,force);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
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