Commit fbe49c87 authored by Pavel Vainerman's avatar Pavel Vainerman

minor optimization (SM,UniExchange)

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