Commit fbe49c87 authored by Pavel Vainerman's avatar Pavel Vainerman

minor optimization (SM,UniExchange)

parent 85170e8f
......@@ -12,7 +12,7 @@ using namespace UniSetExtensions;
SharedMemory::SharedMemory( ObjectId id, string datafile ):
IONotifyController_LT(id),
heartbeatCheckTime(5000),
histSaveTime(200),
histSaveTime(0),
wdt(0),
activated(false),
workready(false),
......@@ -214,7 +214,8 @@ void SharedMemory::sysCommand( SystemMessage *sm )
UniSetTypes::uniset_mutex_lock l(mutex_start, 10000);
askTimer(tmHeartBeatCheck,heartbeatCheckTime);
askTimer(tmEvent,evntPause,1);
askTimer(tmHistory,histSaveTime);
if( histSaveTime > 0 )
askTimer(tmHistory,histSaveTime);
if( msecPulsar > 0 )
askTimer(tmPulsar,msecPulsar);
}
......@@ -310,6 +311,13 @@ void SharedMemory::sigterm( int signo )
// ------------------------------------------------------------------------------------------
void SharedMemory::checkHeartBeat()
{
if( hlist.empty() )
{
if( wdt && workready )
wdt->ping();
return;
}
IOController_i::SensorInfo si;
si.node = conf->getLocalNode();
......@@ -594,8 +602,8 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
UniXML_iterator it(n);
histSaveTime = it.getIntProp("savetime");
if( histSaveTime < 0 )
histSaveTime = 200;
if( histSaveTime <= 0 )
histSaveTime = 0;
if( !it.goChildren() )
{
......@@ -683,6 +691,8 @@ SharedMemory::HistorySlot SharedMemory::signal_history()
// -----------------------------------------------------------------------------
void SharedMemory::saveHistory()
{
if( hist.empty() )
return;
// if( dlog.debugging(Debug::INFO) )
// dlog[Debug::INFO] << myname << "(saveHistory): ..." << endl;
......
......@@ -212,26 +212,28 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI
int size = map->length();
for( int i=0; i<size; i++ )
{
SInfo* s = &(smap[i]);
IOController_i::ShortMap* m = &(map[i]);
if( reinit )
{
shm->initDIterator(smap[i].dit);
shm->initAIterator(smap[i].ait);
smap[i].type = map[i].type;
smap[i].id = map[i].id;
shm->initDIterator(s->dit);
shm->initAIterator(s->ait);
s->type = m->type;
s->id = m->id;
}
smap[i].val = map[i].value;
s->val = m->value;
try
{
if( map[i].type == UniversalIO::DigitalInput )
shm->localSaveState( smap[i].dit, map[i].id, (map[i].value ? true : false ), shm->ID() );
else if( map[i].type == UniversalIO::DigitalOutput )
shm->localSetState( smap[i].dit, map[i].id, (map[i].value ? true : false ), shm->ID() );
if( m->type == UniversalIO::DigitalInput )
shm->localSaveState( s->dit, m->id, (m->value ? true : false ), shm->ID() );
else if( m->type == UniversalIO::DigitalOutput )
shm->localSetState( s->dit, m->id, (m->value ? true : false ), shm->ID() );
else if( map[i].type == UniversalIO::AnalogInput )
shm->localSaveValue( smap[i].ait, map[i].id, map[i].value, shm->ID() );
shm->localSaveValue( s->ait, m->id, m->value, shm->ID() );
else if( map[i].type == UniversalIO::AnalogOutput )
shm->localSetValue( smap[i].ait, map[i].id, map[i].value, shm->ID() );
shm->localSetValue( s->ait, m->id, m->value, shm->ID() );
}
catch( Exception& ex )
{
......
......@@ -108,7 +108,6 @@ namespace UniSetTypes
void lock( int check_pause_msec=0 );
void unlock();
protected:
uniset_spin_mutex (const uniset_spin_mutex& r);
const uniset_spin_mutex &operator=(const uniset_spin_mutex& r);
......
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