Commit 712fbe5a authored by Pavel Vainerman's avatar Pavel Vainerman

- Оптимизация обработка сообщений (правда "опасным" способом с использованием…

- Оптимизация обработка сообщений (правда "опасным" способом с использованием reinterpret_cast<>). - перенёс в UniSetObject базовые реализации функций processingMessage, sensorInfo,sysCommand,timerInfo. - исправил ошибку в IONotifyController (при водившую к SEGFAULT при интенсивном сохранении датчиков)
parent ee28e7bd
...@@ -107,7 +107,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -107,7 +107,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
msleep( sleep_msec ); msleep( sleep_msec );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorMessage* _sm ) void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm )
{ {
<xsl:for-each select="//sensors/item/consumers/consumer"> <xsl:for-each select="//sensors/item/consumers/consumer">
<xsl:if test="normalize-space(../../@msg)!='1'"> <xsl:if test="normalize-space(../../@msg)!='1'">
......
...@@ -125,7 +125,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -125,7 +125,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorMessage* _sm ) void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm )
{ {
sensorInfo(_sm); sensorInfo(_sm);
} }
......
...@@ -147,7 +147,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force ) ...@@ -147,7 +147,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
--> -->
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorMessage* _sm ) void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm )
{ {
<xsl:for-each select="//smap/item"> <xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@vartype)='in'"> <xsl:if test="normalize-space(@vartype)='in'">
......
...@@ -179,7 +179,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -179,7 +179,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return 0; return 0;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorMessage* sm ) void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
sensorInfo(sm); sensorInfo(sm);
} }
......
...@@ -184,10 +184,10 @@ ...@@ -184,10 +184,10 @@
<xsl:template name="COMMON-HEAD-PROTECTED"> <xsl:template name="COMMON-HEAD-PROTECTED">
virtual void callback(); virtual void callback();
virtual void processingMessage( UniSetTypes::VoidMessage* msg ); virtual void processingMessage( UniSetTypes::VoidMessage* msg );
virtual void sysCommand( UniSetTypes::SystemMessage* sm ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( UniSetTypes::SensorMessage* sm ){} virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ){}
virtual void timerInfo( UniSetTypes::TimerMessage* tm ){} virtual void timerInfo( const UniSetTypes::TimerMessage* tm ){}
virtual void sigterm( int signo ); virtual void sigterm( int signo );
virtual bool activateObject(); virtual bool activateObject();
virtual void testMode( bool state ); virtual void testMode( bool state );
...@@ -198,8 +198,8 @@ ...@@ -198,8 +198,8 @@
bool checkTestMode(); bool checkTestMode();
</xsl:if> </xsl:if>
void preAskSensors( UniversalIO::UIOCommand cmd ); void preAskSensors( UniversalIO::UIOCommand cmd );
void preSensorInfo( UniSetTypes::SensorMessage* sm ); void preSensorInfo( const UniSetTypes::SensorMessage* sm );
void preTimerInfo( UniSetTypes::TimerMessage* tm ); void preTimerInfo( const UniSetTypes::TimerMessage* tm );
void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId ); void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void resetMsg(); void resetMsg();
...@@ -260,25 +260,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( UniSetTypes::Voi ...@@ -260,25 +260,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( UniSetTypes::Voi
switch( _msg->type ) switch( _msg->type )
{ {
case Message::SensorInfo: case Message::SensorInfo:
{ preSensorInfo( reinterpret_cast&lt;SensorMessage*&gt;(_msg) );
SensorMessage _sm( _msg ); break;
preSensorInfo( &amp;_sm );
break;
}
case Message::Timer: case Message::Timer:
{ preTimerInfo( reinterpret_cast&lt;TimerMessage*&gt;(_msg) );
TimerMessage _tm(_msg); break;
preTimerInfo(&amp;_tm);
break;
}
case Message::SysCommand: case Message::SysCommand:
{ sysCommand( reinterpret_cast&lt;SystemMessage*&gt;(_msg) );
SystemMessage _sm( _msg ); break;
sysCommand( &amp;_sm );
break;
}
default: default:
break; break;
...@@ -290,7 +281,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( UniSetTypes::Voi ...@@ -290,7 +281,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( UniSetTypes::Voi
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::sysCommand( SystemMessage* _sm ) void <xsl:value-of select="$CLASSNAME"/>_SK::sysCommand( const SystemMessage* _sm )
{ {
switch( _sm->command ) switch( _sm->command )
{ {
...@@ -368,7 +359,7 @@ bool <xsl:value-of select="$CLASSNAME"/>_SK::activateObject() ...@@ -368,7 +359,7 @@ bool <xsl:value-of select="$CLASSNAME"/>_SK::activateObject()
return true; return true;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::preTimerInfo( UniSetTypes::TimerMessage* _tm ) void <xsl:value-of select="$CLASSNAME"/>_SK::preTimerInfo( const UniSetTypes::TimerMessage* _tm )
{ {
timerInfo(_tm); timerInfo(_tm);
} }
......
...@@ -23,11 +23,11 @@ void Skel::step() ...@@ -23,11 +23,11 @@ void Skel::step()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Skel::sensorInfo( SensorMessage *sm ) void Skel::sensorInfo( const SensorMessage *sm )
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Skel::timerInfo( TimerMessage *tm ) void Skel::timerInfo( const TimerMessage *tm )
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Name: libuniset Name: libuniset
Version: 2.0 Version: 2.0
Release: alt0.1 Release: alt0.2
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -333,6 +333,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -333,6 +333,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Fri Jan 24 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.2
- oprimization processing message (warning: use reinterpret_cast<> )
* Tue Dec 24 2013 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.1 * Tue Dec 24 2013 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.1
- rename "IOTypes" --> "IOType" - rename "IOTypes" --> "IOType"
- rename DigitalInput --> DI - rename DigitalInput --> DI
...@@ -350,13 +353,12 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -350,13 +353,12 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- add iofront=[01,10] to IOBase - add iofront=[01,10] to IOBase
- remove deprecated interfaces (Storages,CycleStorage,TableStorage,TextIndex,..) - remove deprecated interfaces (Storages,CycleStorage,TableStorage,TextIndex,..)
- rename unideb --> ulog - rename unideb --> ulog
- DebugStream refactoring (add new function) - DebugStream refactoring (add new function, add syntax sugar for ulog, dlog /dcrit,dwarn,dlog1,ulog1,ucrit,.../)
- UniversalInterface --> UInterface - UniversalInterface --> UInterface
- ObjectsManager --> UniSetManager - ObjectsManager --> UniSetManager
- ObjectsActitvator --> UniSetActivator - ObjectsActitvator --> UniSetActivator
- remove deprecated property: "sensebility" - remove deprecated property: "sensebility"
- rename property "inverse" --> "threshold_invert" - rename property "inverse" --> "threshold_invert"
- add syntax sugar for ulog, dlog (dcrit,dwarn,dlog1,ulog1,ucrit,...)
* Tue Dec 10 2013 Pavel Vainerman <pv@altlinux.ru> 1.7-alt3 * Tue Dec 10 2013 Pavel Vainerman <pv@altlinux.ru> 1.7-alt3
- add RRDServer - add RRDServer
......
...@@ -88,24 +88,7 @@ DBServer_MySQL::~DBServer_MySQL() ...@@ -88,24 +88,7 @@ DBServer_MySQL::~DBServer_MySQL()
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_MySQL::processingMessage( UniSetTypes::VoidMessage *msg ) void DBServer_MySQL::sysCommand( const UniSetTypes::SystemMessage *sm )
{
switch(msg->type)
{
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
default:
DBServer::processingMessage(msg);
break;
}
}
//--------------------------------------------------------------------------------------------
void DBServer_MySQL::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -134,7 +117,7 @@ void DBServer_MySQL::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -134,7 +117,7 @@ void DBServer_MySQL::sysCommand( UniSetTypes::SystemMessage *sm )
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_MySQL::parse( UniSetTypes::ConfirmMessage* cem ) void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
{ {
try try
{ {
...@@ -235,7 +218,7 @@ void DBServer_MySQL::flushBuffer() ...@@ -235,7 +218,7 @@ void DBServer_MySQL::flushBuffer()
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si ) void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
{ {
try try
{ {
...@@ -243,7 +226,7 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si ) ...@@ -243,7 +226,7 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
if( !si->tm.tv_sec ) if( !si->tm.tv_sec )
{ {
struct timezone tz; struct timezone tz;
gettimeofday(&si->tm,&tz); gettimeofday( const_cast<struct timeval*>(&si->tm),&tz);
} }
// см. DBTABLE AnalogSensors, DigitalSensors // см. DBTABLE AnalogSensors, DigitalSensors
...@@ -380,7 +363,7 @@ void DBServer_MySQL::createTables( DBInterface *db ) ...@@ -380,7 +363,7 @@ void DBServer_MySQL::createTables( DBInterface *db )
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) void DBServer_MySQL::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
switch( tm->id ) switch( tm->id )
{ {
......
...@@ -147,13 +147,10 @@ class DBServer_MySQL: ...@@ -147,13 +147,10 @@ class DBServer_MySQL:
virtual void initDB(DBInterface *db){}; virtual void initDB(DBInterface *db){};
virtual void initDBTableMap(DBTableMap& tblMap){}; virtual void initDBTableMap(DBTableMap& tblMap){};
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void timerInfo( const UniSetTypes::TimerMessage* tm );
virtual void timerInfo( UniSetTypes::TimerMessage* tm ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void sysCommand( UniSetTypes::SystemMessage* sm ); virtual void sensorInfo( const UniSetTypes::SensorMessage* sm );
virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg );
// Функции обработки пришедших сообщений
virtual void parse( UniSetTypes::SensorMessage* sm );
virtual void parse( UniSetTypes::ConfirmMessage* cmsg );
bool writeToBase( const string& query ); bool writeToBase( const string& query );
virtual void init_dbserver(); virtual void init_dbserver();
......
...@@ -84,25 +84,7 @@ DBServer_SQLite::~DBServer_SQLite() ...@@ -84,25 +84,7 @@ DBServer_SQLite::~DBServer_SQLite()
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_SQLite::processingMessage( UniSetTypes::VoidMessage *msg ) void DBServer_SQLite::sysCommand( const UniSetTypes::SystemMessage *sm )
{
DBServer::processingMessage(msg);
switch(msg->type)
{
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
default:
break;
}
}
//--------------------------------------------------------------------------------------------
void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
DBServer::sysCommand(sm); DBServer::sysCommand(sm);
...@@ -130,7 +112,7 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -130,7 +112,7 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem ) void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
{ {
try try
{ {
...@@ -212,7 +194,7 @@ void DBServer_SQLite::flushBuffer() ...@@ -212,7 +194,7 @@ void DBServer_SQLite::flushBuffer()
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si ) void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage *si )
{ {
try try
{ {
...@@ -220,7 +202,7 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si ) ...@@ -220,7 +202,7 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
if( !si->tm.tv_sec ) if( !si->tm.tv_sec )
{ {
struct timezone tz; struct timezone tz;
gettimeofday(&si->tm,&tz); gettimeofday(const_cast<struct timeval*>(&si->tm),&tz);
} }
// см. DBTABLE AnalogSensors, DigitalSensors // см. DBTABLE AnalogSensors, DigitalSensors
...@@ -349,7 +331,7 @@ void DBServer_SQLite::createTables( SQLiteInterface *db ) ...@@ -349,7 +331,7 @@ void DBServer_SQLite::createTables( SQLiteInterface *db )
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
switch( tm->id ) switch( tm->id )
{ {
......
...@@ -147,13 +147,10 @@ class DBServer_SQLite: ...@@ -147,13 +147,10 @@ class DBServer_SQLite:
virtual void initDB( SQLiteInterface *db ){}; virtual void initDB( SQLiteInterface *db ){};
virtual void initDBTableMap(DBTableMap& tblMap){}; virtual void initDBTableMap(DBTableMap& tblMap){};
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void timerInfo( const UniSetTypes::TimerMessage* tm );
virtual void timerInfo( UniSetTypes::TimerMessage* tm ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void sysCommand( UniSetTypes::SystemMessage* sm ); virtual void sensorInfo( const UniSetTypes::SensorMessage* sm );
virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg );
// Функции обработки пришедших сообщений
virtual void parse( UniSetTypes::SensorMessage* sm );
virtual void parse( UniSetTypes::ConfirmMessage* cmsg );
bool writeToBase( const string& query ); bool writeToBase( const string& query );
virtual void init_dbserver(); virtual void init_dbserver();
......
...@@ -1154,44 +1154,7 @@ void IOControl::help_print( int argc, const char* const* argv ) ...@@ -1154,44 +1154,7 @@ void IOControl::help_print( int argc, const char* const* argv )
cout << "--prefix-sm-ready-test-sid - Использовать указанный датчик, для проверки готовности SharedMemory" << endl; cout << "--prefix-sm-ready-test-sid - Использовать указанный датчик, для проверки готовности SharedMemory" << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOControl::processingMessage( UniSetTypes::VoidMessage* msg ) void IOControl::sysCommand( const SystemMessage* sm )
{
try
{
switch( msg->type )
{
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo( &sm );
break;
}
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
case Message::SysCommand:
{
SystemMessage sm( msg );
sysCommand( &sm );
break;
}
default:
break;
}
}
catch(Exception& ex)
{
dcrit << myname << "(processingMessage): " << ex << endl;
}
}
// -----------------------------------------------------------------------------
void IOControl::sysCommand( SystemMessage* sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -1346,7 +1309,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -1346,7 +1309,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm ) void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
dlog1 << myname << "(sensorInfo): sm->id=" << sm->id dlog1 << myname << "(sensorInfo): sm->id=" << sm->id
<< " val=" << sm->value << endl; << " val=" << sm->value << endl;
...@@ -1451,7 +1414,7 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm ) ...@@ -1451,7 +1414,7 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm )
// (так комфортнее выглядит для оператора) // (так комфортнее выглядит для оператора)
if( it->ignore || it->subdev==DefaultSubdev || it->channel==DefaultChannel ) if( it->ignore || it->subdev==DefaultSubdev || it->channel==DefaultChannel )
break; break;
ComediInterface* card = cards.getCard(it->ncard); ComediInterface* card = cards.getCard(it->ncard);
if( card != NULL ) if( card != NULL )
...@@ -1478,7 +1441,7 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm ) ...@@ -1478,7 +1441,7 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOControl::timerInfo( UniSetTypes::TimerMessage* tm ) void IOControl::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
} }
......
...@@ -281,11 +281,10 @@ class IOControl: ...@@ -281,11 +281,10 @@ class IOControl:
void blink(); void blink();
// действия при завершении работы // действия при завершении работы
virtual void processingMessage( UniSetTypes::VoidMessage* msg ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void sysCommand( UniSetTypes::SystemMessage* sm );
virtual void askSensors( UniversalIO::UIOCommand cmd ); virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void sensorInfo( UniSetTypes::SensorMessage* sm ); virtual void sensorInfo( const UniSetTypes::SensorMessage* sm );
virtual void timerInfo( UniSetTypes::TimerMessage* tm ); virtual void timerInfo( const UniSetTypes::TimerMessage* tm );
virtual void sigterm( int signo ); virtual void sigterm( int signo );
virtual bool activateObject(); virtual bool activateObject();
......
...@@ -88,7 +88,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -88,7 +88,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::sensorInfo( UniSetTypes::SensorMessage*sm ) void PassiveLProcessor::sensorInfo( const UniSetTypes::SensorMessage*sm )
{ {
for( EXTList::iterator it=extInputs.begin(); it!=extInputs.end(); ++it ) for( EXTList::iterator it=extInputs.begin(); it!=extInputs.end(); ++it )
{ {
...@@ -97,13 +97,13 @@ void PassiveLProcessor::sensorInfo( UniSetTypes::SensorMessage*sm ) ...@@ -97,13 +97,13 @@ void PassiveLProcessor::sensorInfo( UniSetTypes::SensorMessage*sm )
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::timerInfo( UniSetTypes::TimerMessage *tm ) void PassiveLProcessor::timerInfo( const UniSetTypes::TimerMessage *tm )
{ {
if( tm->id == tidStep ) if( tm->id == tidStep )
step(); step();
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm ) void PassiveLProcessor::sysCommand( const UniSetTypes::SystemMessage *sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -225,40 +225,3 @@ void PassiveLProcessor::sigterm( int signo ) ...@@ -225,40 +225,3 @@ void PassiveLProcessor::sigterm( int signo )
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::processingMessage( UniSetTypes::VoidMessage* msg )
{
try
{
switch( msg->type )
{
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo( &sm );
break;
}
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
case Message::SysCommand:
{
SystemMessage sm( msg );
sysCommand( &sm );
break;
}
default:
break;
}
}
catch(Exception& ex)
{
dcrit << myname << "(processingMessage): " << ex << endl;
}
}
// -----------------------------------------------------------------------------
...@@ -33,11 +33,10 @@ class PassiveLProcessor: ...@@ -33,11 +33,10 @@ class PassiveLProcessor:
virtual void getInputs(); virtual void getInputs();
virtual void setOuts(); virtual void setOuts();
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); void sysCommand( const UniSetTypes::SystemMessage *msg );
void sysCommand( UniSetTypes::SystemMessage *msg ); void sensorInfo( const UniSetTypes::SensorMessage*sm );
void sensorInfo( UniSetTypes::SensorMessage*sm ); void timerInfo( const UniSetTypes::TimerMessage *tm );
void timerInfo( UniSetTypes::TimerMessage *tm ); void askSensors( const UniversalIO::UIOCommand cmd );
void askSensors( UniversalIO::UIOCommand cmd );
// void initOutput(); // void initOutput();
// действия при завершении работы // действия при завершении работы
......
...@@ -2386,53 +2386,7 @@ bool MBExchange::activateObject() ...@@ -2386,53 +2386,7 @@ bool MBExchange::activateObject()
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void MBExchange::processingMessage(UniSetTypes::VoidMessage *msg) void MBExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
{
try
{
switch(msg->type)
{
case UniSetTypes::Message::SysCommand:
{
UniSetTypes::SystemMessage sm( msg );
sysCommand( &sm );
}
break;
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
}
break;
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo(&sm);
}
break;
default:
break;
}
}
catch( SystemError& ex )
{
dcrit << myname << "(SystemError): " << ex << std::endl;
// throw SystemError(ex);
}
catch( Exception& ex )
{
dcrit << myname << "(processingMessage): " << ex << std::endl;
}
catch(...)
{
dcrit << myname << "(processingMessage): catch ...\n";
}
}
// -----------------------------------------------------------------------------
void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -2608,7 +2562,7 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -2608,7 +2562,7 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void MBExchange::sensorInfo( UniSetTypes::SensorMessage* sm ) void MBExchange::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
if( sm->id == sidExchangeMode ) if( sm->id == sidExchangeMode )
{ {
...@@ -2653,7 +2607,7 @@ void MBExchange::sensorInfo( UniSetTypes::SensorMessage* sm ) ...@@ -2653,7 +2607,7 @@ void MBExchange::sensorInfo( UniSetTypes::SensorMessage* sm )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void MBExchange::timerInfo( TimerMessage *tm ) void MBExchange::timerInfo( const TimerMessage *tm )
{ {
if( tm->id == tmExchange ) if( tm->id == tmExchange )
{ {
......
...@@ -200,10 +200,9 @@ class MBExchange: ...@@ -200,10 +200,9 @@ class MBExchange:
protected: protected:
virtual void step(); virtual void step();
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void sysCommand( const UniSetTypes::SystemMessage *msg );
virtual void sysCommand( UniSetTypes::SystemMessage *msg ); virtual void sensorInfo( const UniSetTypes::SensorMessage*sm );
virtual void sensorInfo( UniSetTypes::SensorMessage*sm ); virtual void timerInfo( const UniSetTypes::TimerMessage *tm );
virtual void timerInfo( UniSetTypes::TimerMessage *tm );
virtual void askSensors( UniversalIO::UIOCommand cmd ); virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void initOutput(); virtual void initOutput();
virtual void sigterm( int signo ); virtual void sigterm( int signo );
......
...@@ -53,6 +53,7 @@ pollThread(0) ...@@ -53,6 +53,7 @@ pollThread(0)
if( port <= 0 ) if( port <= 0 )
throw UniSetTypes::SystemError(myname+"(MBMaster): Unknown inet port...(Use: " + tmp +")" ); throw UniSetTypes::SystemError(myname+"(MBMaster): Unknown inet port...(Use: " + tmp +")" );
dinfo << myname << "(init): gateway " << iaddr << ":" << port << endl;
force_disconnect = conf->getArgInt("--" + prefix + "-persistent-connection",it.getProp("persistent_connection")) ? false : true; force_disconnect = conf->getArgInt("--" + prefix + "-persistent-connection",it.getProp("persistent_connection")) ? false : true;
dinfo << myname << "(init): persisten-connection=" << (!force_disconnect) << endl; dinfo << myname << "(init): persisten-connection=" << (!force_disconnect) << endl;
...@@ -127,7 +128,7 @@ ModbusClient* MBTCPMaster::initMB( bool reopen ) ...@@ -127,7 +128,7 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
return mbtcp; return mbtcp;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void MBTCPMaster::sysCommand( UniSetTypes::SystemMessage *sm ) void MBTCPMaster::sysCommand( const UniSetTypes::SystemMessage *sm )
{ {
MBExchange::sysCommand(sm); MBExchange::sysCommand(sm);
if( sm->command == SystemMessage::StartUp ) if( sm->command == SystemMessage::StartUp )
......
...@@ -205,7 +205,7 @@ class MBTCPMaster: ...@@ -205,7 +205,7 @@ class MBTCPMaster:
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
protected: protected:
virtual void sysCommand( UniSetTypes::SystemMessage *sm ); virtual void sysCommand( const UniSetTypes::SystemMessage *sm );
UniSetTypes::uniset_rwmutex mbMutex; UniSetTypes::uniset_rwmutex mbMutex;
std::string iaddr; std::string iaddr;
......
...@@ -259,7 +259,7 @@ bool MBTCPMultiMaster::MBSlaveInfo::init() ...@@ -259,7 +259,7 @@ bool MBTCPMultiMaster::MBSlaveInfo::init()
return false; return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void MBTCPMultiMaster::sysCommand( UniSetTypes::SystemMessage *sm ) void MBTCPMultiMaster::sysCommand( const UniSetTypes::SystemMessage *sm )
{ {
MBExchange::sysCommand(sm); MBExchange::sysCommand(sm);
if( sm->command == SystemMessage::StartUp ) if( sm->command == SystemMessage::StartUp )
......
...@@ -227,7 +227,7 @@ class MBTCPMultiMaster: ...@@ -227,7 +227,7 @@ class MBTCPMultiMaster:
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
protected: protected:
virtual void sysCommand( UniSetTypes::SystemMessage *sm ); virtual void sysCommand( const UniSetTypes::SystemMessage *sm );
virtual void initIterators(); virtual void initIterators();
virtual ModbusClient* initMB( bool reopen=false ); virtual ModbusClient* initMB( bool reopen=false );
void poll_thread(); void poll_thread();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
--mbtcp-set-prop-prefix \ --mbtcp-set-prop-prefix \
--mbtcp-filter-field rs \ --mbtcp-filter-field rs \
--mbtcp-filter-value 5 \ --mbtcp-filter-value 5 \
--mbtcp-gateway-iaddr 127.0.0.1 \ --mbtcp-gateway-iaddr localhost \
--mbtcp-gateway-port 2048 \ --mbtcp-gateway-port 2048 \
--mbtcp-recv-timeout 5000 \ --mbtcp-recv-timeout 5000 \
--mbtcp-force-disconnect 1 \ --mbtcp-force-disconnect 1 \
......
...@@ -529,48 +529,7 @@ void MBSlave::execute_tcp() ...@@ -529,48 +529,7 @@ void MBSlave::execute_tcp()
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void MBSlave::sysCommand( const UniSetTypes::SystemMessage *sm )
void MBSlave::processingMessage(UniSetTypes::VoidMessage *msg)
{
try
{
switch(msg->type)
{
case UniSetTypes::Message::SysCommand:
{
UniSetTypes::SystemMessage sm( msg );
sysCommand( &sm );
}
break;
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo(&sm);
}
break;
default:
break;
}
}
catch( SystemError& ex )
{
dcrit << myname << "(SystemError): " << ex << std::endl;
// throw SystemError(ex);
raise(SIGTERM);
}
catch( Exception& ex )
{
dcrit << myname << "(processingMessage): " << ex << std::endl;
}
catch(...)
{
dcrit << myname << "(processingMessage): catch ...\n";
}
}
// -----------------------------------------------------------------------------
void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -598,7 +557,9 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm) ...@@ -598,7 +557,9 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
} }
if( !activated ) if( !activated )
{
dcrit << myname << "(sysCommand): ************* don`t activate?! ************" << endl; dcrit << myname << "(sysCommand): ************* don`t activate?! ************" << endl;
}
else else
{ {
UniSetTypes::uniset_rwmutex_rlock l(mutex_start); UniSetTypes::uniset_rwmutex_rlock l(mutex_start);
...@@ -685,7 +646,7 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -685,7 +646,7 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void MBSlave::sensorInfo( UniSetTypes::SensorMessage* sm ) void MBSlave::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
IOMap::iterator it=iomap.begin(); IOMap::iterator it=iomap.begin();
for( ; it!=iomap.end(); ++it ) for( ; it!=iomap.end(); ++it )
......
...@@ -138,9 +138,8 @@ class MBSlave: ...@@ -138,9 +138,8 @@ class MBSlave:
SMInterface* shm; SMInterface* shm;
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void sysCommand( const UniSetTypes::SystemMessage *msg );
void sysCommand( UniSetTypes::SystemMessage *msg ); virtual void sensorInfo( const UniSetTypes::SensorMessage* sm );
void sensorInfo( UniSetTypes::SensorMessage* sm );
void askSensors( UniversalIO::UIOCommand cmd ); void askSensors( UniversalIO::UIOCommand cmd );
void waitSMReady(); void waitSMReady();
void execute_rtu(); void execute_rtu();
......
...@@ -273,7 +273,7 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -273,7 +273,7 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm ) void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm )
{ {
UObject_SK::sysCommand(sm); UObject_SK::sysCommand(sm);
if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog ) if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog )
...@@ -292,7 +292,7 @@ void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm ) ...@@ -292,7 +292,7 @@ void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RRDServer::sensorInfo( UniSetTypes::SensorMessage* sm ) void RRDServer::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it ) for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it )
{ {
...@@ -304,7 +304,7 @@ void RRDServer::sensorInfo( UniSetTypes::SensorMessage* sm ) ...@@ -304,7 +304,7 @@ void RRDServer::sensorInfo( UniSetTypes::SensorMessage* sm )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm ) void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it ) for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it )
{ {
......
...@@ -74,9 +74,9 @@ class RRDServer: ...@@ -74,9 +74,9 @@ class RRDServer:
RRDServer(); RRDServer();
virtual void askSensors( UniversalIO::UIOCommand cmd ); virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void sensorInfo( UniSetTypes::SensorMessage* sm ); virtual void sensorInfo( const UniSetTypes::SensorMessage* sm );
virtual void timerInfo( UniSetTypes::TimerMessage* tm ); virtual void timerInfo( const UniSetTypes::TimerMessage* tm );
virtual void sysCommand( UniSetTypes::SystemMessage* sm ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void initRRD( xmlNode* cnode, int tmID ); virtual void initRRD( xmlNode* cnode, int tmID );
void step(); void step();
......
...@@ -134,75 +134,7 @@ SharedMemory::~SharedMemory() ...@@ -134,75 +134,7 @@ SharedMemory::~SharedMemory()
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
void SharedMemory::processingMessage( UniSetTypes::VoidMessage *msg ) void SharedMemory::timerInfo( const TimerMessage *tm )
{
try
{
switch( msg->type )
{
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo( &sm );
break;
}
case Message::SysCommand:
{
SystemMessage sm( msg );
sysCommand( &sm );
break;
}
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
default:
break;
}
}
catch( Exception& ex )
{
dcrit << myname << "(processingMessage): " << ex << endl;
}
catch(CORBA::SystemException& ex)
{
dcrit << myname << "(processingMessage): CORBA::SystemException: " << ex.NP_minorString() << endl;
}
catch(CORBA::Exception& ex)
{
dwarn << myname << "(processingMessage): CORBA::Exception: " << ex._name() << endl;
}
catch( omniORB::fatalException& fe )
{
if( dlog.is_crit() )
{
dlog.crit() << myname << "(processingMessage): Caught omniORB::fatalException:" << endl;
dlog.crit() << myname << "(processingMessage): file: " << fe.file()
<< " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl;
}
}
catch(...)
{
dcrit << myname << "(processingMessage): catch..." << endl;
}
}
// ------------------------------------------------------------------------------------------
void SharedMemory::sensorInfo( SensorMessage *sm )
{
}
// ------------------------------------------------------------------------------------------
void SharedMemory::timerInfo( TimerMessage *tm )
{ {
if( tm->id == tmHeartBeatCheck ) if( tm->id == tmHeartBeatCheck )
checkHeartBeat(); checkHeartBeat();
...@@ -228,8 +160,7 @@ void SharedMemory::timerInfo( TimerMessage *tm ) ...@@ -228,8 +160,7 @@ void SharedMemory::timerInfo( TimerMessage *tm )
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SharedMemory::sysCommand( const SystemMessage *sm )
void SharedMemory::sysCommand( SystemMessage *sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -237,7 +168,7 @@ void SharedMemory::sysCommand( SystemMessage *sm ) ...@@ -237,7 +168,7 @@ void SharedMemory::sysCommand( SystemMessage *sm )
{ {
PassiveTimer ptAct(activateTimeout); PassiveTimer ptAct(activateTimeout);
while( !isActivated() && !ptAct.checkTime() ) while( !isActivated() && !ptAct.checkTime() )
{ {
cout << myname << "(sysCommand): wait activate..." << endl; cout << myname << "(sysCommand): wait activate..." << endl;
msleep(100); msleep(100);
} }
...@@ -258,11 +189,11 @@ void SharedMemory::sysCommand( SystemMessage *sm ) ...@@ -258,11 +189,11 @@ void SharedMemory::sysCommand( SystemMessage *sm )
askTimer(tmPulsar,msecPulsar); askTimer(tmPulsar,msecPulsar);
} }
break; break;
case SystemMessage::FoldUp: case SystemMessage::FoldUp:
case SystemMessage::Finish: case SystemMessage::Finish:
break; break;
case SystemMessage::WatchDog: case SystemMessage::WatchDog:
break; break;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
\section sec_SM_Common Задачи решаемые объектом SharedMemory \section sec_SM_Common Задачи решаемые объектом SharedMemory
Класс SharedMemory расширяет набор задач класса IONotifyController. Класс SharedMemory расширяет набор задач класса IONotifyController.
Для ознакомления с базовыми функциями см. \ref page_IONotifyController Для ознакомления с базовыми функциями см. \ref page_IONotifyController
...@@ -343,10 +343,8 @@ class SharedMemory: ...@@ -343,10 +343,8 @@ class SharedMemory:
typedef std::list<Restorer_XML::ReaderSlot> ReadSlotList; typedef std::list<Restorer_XML::ReaderSlot> ReadSlotList;
ReadSlotList lstRSlot; ReadSlotList lstRSlot;
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void sysCommand( const UniSetTypes::SystemMessage *sm );
virtual void sysCommand( UniSetTypes::SystemMessage *sm ); virtual void timerInfo( const UniSetTypes::TimerMessage *tm );
virtual void sensorInfo( UniSetTypes::SensorMessage *sm );
virtual void timerInfo( UniSetTypes::TimerMessage *tm );
virtual void askSensors( UniversalIO::UIOCommand cmd ); virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void sendEvent( UniSetTypes::SystemMessage& sm ); virtual void sendEvent( UniSetTypes::SystemMessage& sm );
......
...@@ -4,7 +4,7 @@ export LD_LIBRARY_PATH="../../lib/.libs;../lib/.libs" ...@@ -4,7 +4,7 @@ export LD_LIBRARY_PATH="../../lib/.libs;../lib/.libs"
ulimit -Sc 10000000000 ulimit -Sc 10000000000
./uniset-start.sh -f ./uniset-smemory --smemory-id SharedMemory --pulsar-id DO_C --pulsar-iotype DO \ ./uniset-start.sh -g ./uniset-smemory --smemory-id SharedMemory --pulsar-id DO_C --pulsar-iotype DO \
--confile test.xml --datfile test.xml \ --confile test.xml --datfile test.xml \
--unideb-add-levels info,crit,warn,level9,system \ --unideb-add-levels info,crit,warn,level9,system \
--dlog-add-levels info,crit,warn \ --dlog-add-levels info,crit,warn \
......
...@@ -391,7 +391,7 @@ void UNetExchange::waitSMReady() ...@@ -391,7 +391,7 @@ void UNetExchange::waitSMReady()
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetExchange::timerInfo( TimerMessage *tm ) void UNetExchange::timerInfo( const TimerMessage *tm )
{ {
if( !activated ) if( !activated )
return; return;
...@@ -460,53 +460,7 @@ void UNetExchange::ReceiverInfo::step( SMInterface* shm, const std::string& myna ...@@ -460,53 +460,7 @@ void UNetExchange::ReceiverInfo::step( SMInterface* shm, const std::string& myna
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetExchange::processingMessage( UniSetTypes::VoidMessage *msg ) void UNetExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
{
try
{
switch(msg->type)
{
case UniSetTypes::Message::SysCommand:
{
UniSetTypes::SystemMessage sm( msg );
sysCommand( &sm );
}
break;
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo(&sm);
}
break;
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
}
break;
default:
break;
}
}
catch( SystemError& ex )
{
dcrit << myname << "(SystemError): " << ex << std::endl;
raise(SIGTERM);
}
catch( Exception& ex )
{
dcrit << myname << "(processingMessage): " << ex << std::endl;
}
catch(...)
{
dcrit << myname << "(processingMessage): catch ..." << std::endl;
}
}
// -----------------------------------------------------------------------------
void UNetExchange::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -608,7 +562,7 @@ void UNetExchange::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -608,7 +562,7 @@ void UNetExchange::askSensors( UniversalIO::UIOCommand cmd )
sender2->askSensors(cmd); sender2->askSensors(cmd);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UNetExchange::sensorInfo( UniSetTypes::SensorMessage* sm ) void UNetExchange::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
if( sender ) if( sender )
sender->updateSensor( sm->id , sm->value ); sender->updateSensor( sm->id , sm->value );
......
...@@ -100,10 +100,9 @@ class UNetExchange: ...@@ -100,10 +100,9 @@ class UNetExchange:
SMInterface* shm; SMInterface* shm;
void step(); void step();
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); void sysCommand( const UniSetTypes::SystemMessage *msg );
void sysCommand( UniSetTypes::SystemMessage *msg ); void sensorInfo( const UniSetTypes::SensorMessage*sm );
void sensorInfo( UniSetTypes::SensorMessage*sm ); void timerInfo( const UniSetTypes::TimerMessage *tm );
void timerInfo( UniSetTypes::TimerMessage *tm );
void askSensors( UniversalIO::UIOCommand cmd ); void askSensors( UniversalIO::UIOCommand cmd );
void waitSMReady(); void waitSMReady();
void receiverEvent( UNetReceiver* r, UNetReceiver::Event ev ); void receiverEvent( UNetReceiver* r, UNetReceiver::Event ev );
......
...@@ -297,44 +297,7 @@ void UniExchange::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -297,44 +297,7 @@ void UniExchange::askSensors( UniversalIO::UIOCommand cmd )
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UniExchange::processingMessage( UniSetTypes::VoidMessage* msg ) void UniExchange::sysCommand( const SystemMessage* sm )
{
try
{
switch( msg->type )
{
case Message::SensorInfo:
{
SensorMessage sm( msg );
sensorInfo( &sm );
break;
}
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
case Message::SysCommand:
{
SystemMessage sm( msg );
sysCommand( &sm );
break;
}
default:
break;
}
}
catch(Exception& ex)
{
cout << myname << "(processingMessage): " << ex << endl;
}
}
// -----------------------------------------------------------------------------
void UniExchange::sysCommand( SystemMessage* sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
...@@ -343,12 +306,12 @@ void UniExchange::sysCommand( SystemMessage* sm ) ...@@ -343,12 +306,12 @@ void UniExchange::sysCommand( SystemMessage* sm )
askSensors(UniversalIO::UIONotify); askSensors(UniversalIO::UIONotify);
break; break;
} }
case SystemMessage::FoldUp: case SystemMessage::FoldUp:
case SystemMessage::Finish: case SystemMessage::Finish:
askSensors(UniversalIO::UIODontNotify); askSensors(UniversalIO::UIODontNotify);
break; break;
case SystemMessage::WatchDog: case SystemMessage::WatchDog:
askSensors(UniversalIO::UIONotify); askSensors(UniversalIO::UIONotify);
break; break;
...@@ -362,16 +325,6 @@ void UniExchange::sigterm( int signo ) ...@@ -362,16 +325,6 @@ void UniExchange::sigterm( int signo )
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UniExchange::sensorInfo( UniSetTypes::SensorMessage* sm )
{
}
// -----------------------------------------------------------------------------
void UniExchange::timerInfo( UniSetTypes::TimerMessage* tm )
{
}
// -----------------------------------------------------------------------------
UniExchange* UniExchange::init_exchange( int argc, const char* const* argv, UniExchange* UniExchange::init_exchange( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix ) const std::string& prefix )
......
...@@ -53,11 +53,8 @@ class UniExchange: ...@@ -53,11 +53,8 @@ class UniExchange:
protected: protected:
virtual void processingMessage( UniSetTypes::VoidMessage* msg ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void sysCommand( UniSetTypes::SystemMessage* sm );
virtual void askSensors( UniversalIO::UIOCommand cmd ); virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void sensorInfo( UniSetTypes::SensorMessage* sm );
virtual void timerInfo( UniSetTypes::TimerMessage* tm );
virtual void sigterm( int signo ); virtual void sigterm( int signo );
xmlNode* cnode; xmlNode* cnode;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2014-01-23+04:00 // generate timestamp: 2014-01-24+04:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -38,7 +38,7 @@ class UObject_SK: ...@@ -38,7 +38,7 @@ class UObject_SK:
void setMsg( UniSetTypes::ObjectId code, bool state ); void setMsg( UniSetTypes::ObjectId code, bool state );
DebugStream mylog; DebugStream mylog;
void init_mylog( DebugStream& d ); void init_dlog( DebugStream& d );
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#define myinfo if( mylog.debugging(Debug::INFO) ) mylog #define myinfo if( mylog.debugging(Debug::INFO) ) mylog
...@@ -78,10 +78,10 @@ class UObject_SK: ...@@ -78,10 +78,10 @@ class UObject_SK:
virtual void callback(); virtual void callback();
virtual void processingMessage( UniSetTypes::VoidMessage* msg ); virtual void processingMessage( UniSetTypes::VoidMessage* msg );
virtual void sysCommand( UniSetTypes::SystemMessage* sm ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( UniSetTypes::SensorMessage* sm ){} virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ){}
virtual void timerInfo( UniSetTypes::TimerMessage* tm ){} virtual void timerInfo( const UniSetTypes::TimerMessage* tm ){}
virtual void sigterm( int signo ); virtual void sigterm( int signo );
virtual bool activateObject(); virtual bool activateObject();
virtual void testMode( bool state ); virtual void testMode( bool state );
...@@ -90,8 +90,8 @@ class UObject_SK: ...@@ -90,8 +90,8 @@ class UObject_SK:
void updateOutputs( bool force ); void updateOutputs( bool force );
void preAskSensors( UniversalIO::UIOCommand cmd ); void preAskSensors( UniversalIO::UIOCommand cmd );
void preSensorInfo( UniSetTypes::SensorMessage* sm ); void preSensorInfo( const UniSetTypes::SensorMessage* sm );
void preTimerInfo( UniSetTypes::TimerMessage* tm ); void preTimerInfo( const UniSetTypes::TimerMessage* tm );
void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId ); void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void resetMsg(); void resetMsg();
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2014-01-23+04:00 // generate timestamp: 2014-01-24+04:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include "Configuration.h" #include "Configuration.h"
#include "Exceptions.h" #include "Exceptions.h"
...@@ -202,7 +202,7 @@ void UObject_SK::testMode( bool _state ) ...@@ -202,7 +202,7 @@ void UObject_SK::testMode( bool _state )
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UObject_SK::init_mylog( DebugStream& d ) void UObject_SK::init_dlog( DebugStream& d )
{ {
UObject_SK::mylog = d; UObject_SK::mylog = d;
} }
...@@ -214,25 +214,16 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg ) ...@@ -214,25 +214,16 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
switch( _msg->type ) switch( _msg->type )
{ {
case Message::SensorInfo: case Message::SensorInfo:
{ preSensorInfo( reinterpret_cast<SensorMessage*>(_msg) );
SensorMessage _sm( _msg ); break;
preSensorInfo( &_sm );
break;
}
case Message::Timer: case Message::Timer:
{ preTimerInfo( reinterpret_cast<TimerMessage*>(_msg) );
TimerMessage _tm(_msg); break;
preTimerInfo(&_tm);
break;
}
case Message::SysCommand: case Message::SysCommand:
{ sysCommand( reinterpret_cast<SystemMessage*>(_msg) );
SystemMessage _sm( _msg ); break;
sysCommand( &_sm );
break;
}
default: default:
break; break;
...@@ -244,7 +235,7 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg ) ...@@ -244,7 +235,7 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::sysCommand( SystemMessage* _sm ) void UObject_SK::sysCommand( const SystemMessage* _sm )
{ {
switch( _sm->command ) switch( _sm->command )
{ {
...@@ -314,7 +305,7 @@ bool UObject_SK::activateObject() ...@@ -314,7 +305,7 @@ bool UObject_SK::activateObject()
return true; return true;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::preTimerInfo( UniSetTypes::TimerMessage* _tm ) void UObject_SK::preTimerInfo( const UniSetTypes::TimerMessage* _tm )
{ {
timerInfo(_tm); timerInfo(_tm);
} }
...@@ -423,7 +414,7 @@ void UObject_SK::updateOutputs( bool _force ) ...@@ -423,7 +414,7 @@ void UObject_SK::updateOutputs( bool _force )
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::preSensorInfo( UniSetTypes::SensorMessage* _sm ) void UObject_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm )
{ {
......
...@@ -57,11 +57,7 @@ class DBServer: ...@@ -57,11 +57,7 @@ class DBServer:
protected: protected:
virtual void processingMessage( UniSetTypes::VoidMessage* msg ); virtual void processingMessage( UniSetTypes::VoidMessage* msg );
virtual void sysCommand( UniSetTypes::SystemMessage* sm ){}; virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ){}
// Функции обработки пришедших сообщений
virtual void parse( UniSetTypes::SensorMessage* sm ){};
virtual void parse( UniSetTypes::ConfirmMessage* cmsg ){};
virtual bool activateObject(); virtual bool activateObject();
virtual void init_dbserver(){}; virtual void init_dbserver(){};
......
...@@ -150,14 +150,17 @@ class IOController: ...@@ -150,14 +150,17 @@ class IOController:
// Дополнительные (вспомогательные поля) // Дополнительные (вспомогательные поля)
UniSetTypes::uniset_rwmutex val_lock; /*!< флаг блокирующий работу со значением */ UniSetTypes::uniset_rwmutex val_lock; /*!< флаг блокирующий работу со значением */
IOStateList::iterator it; IOStateList::iterator it;
void* any; /*!< расширение для возможности хранения своей информации */ void* any; /*!< расширение для возможности хранения своей информации */
// сигнал для реализации механизма зависимостией.. // сигнал для реализации механизма зависимостией..
// (все зависимые датчики подключаются к нему (см. NCRestorer::init_depends_signals) // (все зависимые датчики подключаются к нему (см. NCRestorer::init_depends_signals)
UniSetTypes::uniset_rwmutex changeMutex;
ChangeSignal sigChange; ChangeSignal sigChange;
UniSetTypes::uniset_rwmutex undefMutex;
ChangeUndefinedStateSignal sigUndefChange; ChangeUndefinedStateSignal sigUndefChange;
IOController_i::SensorInfo d_si; /*!< идентификатор датчика, от которого зависит данный */ IOController_i::SensorInfo d_si; /*!< идентификатор датчика, от которого зависит данный */
...@@ -276,15 +279,19 @@ class IOController: ...@@ -276,15 +279,19 @@ class IOController:
inline bool iofiltersEmpty(){ return iofilters.empty(); } inline bool iofiltersEmpty(){ return iofilters.empty(); }
inline int iodiltersSize(){ return iofilters.size(); } inline int iodiltersSize(){ return iofilters.size(); }
private: private:
friend class NCRestorer; friend class NCRestorer;
UniSetTypes::uniset_mutex siganyMutex;
ChangeSignal sigAnyChange; ChangeSignal sigAnyChange;
UniSetTypes::uniset_mutex siganyundefMutex;
ChangeSignal sigAnyUndefChange; ChangeSignal sigAnyUndefChange;
InitSignal sigInit; InitSignal sigInit;
IOStateList ioList; /*!< список с текущим состоянием аналоговых входов/выходов */ IOStateList ioList; /*!< список с текущим состоянием аналоговых входов/выходов */
UniSetTypes::uniset_rwmutex ioMutex; /*!< замок для блокирования совместного доступа к ioList */ UniSetTypes::uniset_rwmutex ioMutex; /*!< замок для блокирования совместного доступа к ioList */
bool isPingDBServer; // флаг связи с DBServer-ом bool isPingDBServer; // флаг связи с DBServer-ом
IOFilterSlotList iofilters; /*!< список фильтров для аналоговых значений */ IOFilterSlotList iofilters; /*!< список фильтров для аналоговых значений */
......
...@@ -54,10 +54,10 @@ class PassiveObject ...@@ -54,10 +54,10 @@ class PassiveObject
inline std::string getName(){ return myname; } inline std::string getName(){ return myname; }
protected: protected:
virtual void sysCommand( UniSetTypes::SystemMessage *sm ); virtual void sysCommand( const UniSetTypes::SystemMessage *sm );
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void timerInfo( UniSetTypes::TimerMessage *tm ){} virtual void timerInfo( const UniSetTypes::TimerMessage *tm ){}
virtual void sensorInfo( UniSetTypes::SensorMessage *sm ){} virtual void sensorInfo( const UniSetTypes::SensorMessage *sm ){}
std::string myname; std::string myname;
......
...@@ -15,10 +15,9 @@ class SMonitor: ...@@ -15,10 +15,9 @@ class SMonitor:
// ----- // -----
protected: protected:
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void sysCommand( const UniSetTypes::SystemMessage *sm );
virtual void sysCommand( UniSetTypes::SystemMessage *sm ); virtual void sensorInfo( const UniSetTypes::SensorMessage *si );
virtual void sensorInfo( UniSetTypes::SensorMessage *si ); virtual void timerInfo( const UniSetTypes::TimerMessage *tm );
virtual void timerInfo( UniSetTypes::TimerMessage *tm );
virtual void sigterm( int signo ); virtual void sigterm( int signo );
SMonitor(); SMonitor();
......
...@@ -59,7 +59,6 @@ class UniSetActivator: ...@@ -59,7 +59,6 @@ class UniSetActivator:
virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::getObjectType("UniSetActivator"); } virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::getObjectType("UniSetActivator"); }
protected: protected:
...@@ -88,8 +87,7 @@ class UniSetActivator: ...@@ -88,8 +87,7 @@ class UniSetActivator:
return orb; return orb;
} }
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void sysCommand( const UniSetTypes::SystemMessage *sm );
virtual void sysCommand( UniSetTypes::SystemMessage *sm );
private: private:
......
...@@ -90,10 +90,13 @@ class UniSetObject: ...@@ -90,10 +90,13 @@ class UniSetObject:
protected: protected:
/*! обработка приходящих сообщений */ /*! обработка приходящих сообщений */
virtual void processingMessage(UniSetTypes::VoidMessage *msg); virtual void processingMessage( UniSetTypes::VoidMessage *msg );
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ){}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ){}
/*! Получить сообщение */ /*! Получить сообщение */
bool receiveMessage(UniSetTypes::VoidMessage& vm); bool receiveMessage( UniSetTypes::VoidMessage& vm );
/*! текущее количесво сообщений в очереди */ /*! текущее количесво сообщений в очереди */
unsigned int countMessages(); unsigned int countMessages();
......
...@@ -89,32 +89,23 @@ void PassiveObject::init( ProxyManager* _mngr ) ...@@ -89,32 +89,23 @@ void PassiveObject::init( ProxyManager* _mngr )
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg ) void PassiveObject::processingMessage( UniSetTypes::VoidMessage *msg )
{ {
try try
{ {
switch( msg->type ) switch( msg->type )
{ {
case Message::SensorInfo: case Message::SensorInfo:
{ sensorInfo( reinterpret_cast<SensorMessage*>(msg) );
SensorMessage sm( msg ); break;
sensorInfo( &sm );
break;
}
case Message::SysCommand:
{
SystemMessage sm( msg );
sysCommand( &sm );
break;
}
case Message::Timer: case Message::Timer:
{ timerInfo( reinterpret_cast<TimerMessage*>(msg) );
TimerMessage tm(msg); break;
timerInfo(&tm);
break; case Message::SysCommand:
} sysCommand( reinterpret_cast<SystemMessage*>(msg) );
break;
default: default:
break; break;
...@@ -122,11 +113,33 @@ void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg ) ...@@ -122,11 +113,33 @@ void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
uwarn << myname << "(processingMessage): " << ex << endl; ucrit << myname << "(processingMessage): " << ex << endl;
}
catch(CORBA::SystemException& ex)
{
ucrit << myname << "(processingMessage): CORBA::SystemException: " << ex.NP_minorString() << endl;
}
catch(CORBA::Exception& ex)
{
uwarn << myname << "(processingMessage): CORBA::Exception: " << ex._name() << endl;
}
catch( omniORB::fatalException& fe )
{
if( ulog.is_crit() )
{
ulog.crit() << myname << "(processingMessage): Caught omniORB::fatalException:" << endl;
ulog.crit() << myname << "(processingMessage): file: " << fe.file()
<< " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl;
}
}
catch(...)
{
ucrit << myname << "(processingMessage): catch..." << endl;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveObject::sysCommand( SystemMessage *sm ) void PassiveObject::sysCommand( const SystemMessage *sm )
{ {
switch( sm->command ) switch( sm->command )
{ {
......
...@@ -323,31 +323,7 @@ void UniSetActivator::getinfo() ...@@ -323,31 +323,7 @@ void UniSetActivator::getinfo()
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetActivator::processingMessage( UniSetTypes::VoidMessage *msg ) void UniSetActivator::sysCommand( const UniSetTypes::SystemMessage *sm )
{
try
{
switch( msg->type )
{
case Message::SysCommand:
{
SystemMessage sm( msg );
sysCommand(&sm);
}
break;
default:
break;
}
}
catch(Exception& ex)
{
ucrit << myname << "(processingMessage): " << ex << endl;
}
}
// -------------------------------------------------------------------------
void UniSetActivator::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
switch(sm->command) switch(sm->command)
{ {
......
...@@ -781,9 +781,55 @@ void UniSetObject::callback() ...@@ -781,9 +781,55 @@ void UniSetObject::callback()
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::processingMessage( UniSetTypes::VoidMessage *msg ) void UniSetObject::processingMessage( UniSetTypes::VoidMessage *msg )
{ {
uinfo << myname << ": default processing messages..." << endl; try
{
switch( msg->type )
{
case Message::SensorInfo:
sensorInfo( reinterpret_cast<SensorMessage*>(msg) );
break;
case Message::Timer:
timerInfo( reinterpret_cast<TimerMessage*>(msg) );
break;
case Message::SysCommand:
sysCommand( reinterpret_cast<SystemMessage*>(msg) );
break;
default:
break;
}
}
catch( Exception& ex )
{
ucrit << myname << "(processingMessage): " << ex << endl;
}
catch(CORBA::SystemException& ex)
{
ucrit << myname << "(processingMessage): CORBA::SystemException: " << ex.NP_minorString() << endl;
}
catch(CORBA::Exception& ex)
{
uwarn << myname << "(processingMessage): CORBA::Exception: " << ex._name() << endl;
}
catch( omniORB::fatalException& fe )
{
if( ulog.is_crit() )
{
ulog.crit() << myname << "(processingMessage): Caught omniORB::fatalException:" << endl;
ulog.crit() << myname << "(processingMessage): file: " << fe.file()
<< " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl;
}
}
catch(...)
{
ucrit << myname << "(processingMessage): catch..." << endl;
}
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UniSetTypes::SimpleInfo* UniSetObject::getInfo() UniSetTypes::SimpleInfo* UniSetObject::getInfo()
{ {
ostringstream info; ostringstream info;
......
...@@ -186,31 +186,43 @@ void IOController::localSetUndefinedState( IOStateList::iterator& li, ...@@ -186,31 +186,43 @@ void IOController::localSetUndefinedState( IOStateList::iterator& li,
try try
{ {
if( changed ) if( changed )
{
uniset_rwmutex_wrlock l(li->second.undefMutex);
li->second.sigUndefChange.emit(li, this); li->second.sigUndefChange.emit(li, this);
}
} }
catch(...){} catch(...){}
// потом глобольное, но конкретно для 'undefchange' // потом глобольное, но конкретно для 'undefchange'
try try
{ {
if( changed ) if( changed )
{
uniset_mutex_lock l(siganyundefMutex);
sigAnyUndefChange.emit(li, this); sigAnyUndefChange.emit(li, this);
}
} }
catch(...){} catch(...){}
// теперь просто событие по изменению состояния // теперь просто событие по изменению состояния
try try
{ {
if( changed ) if( changed )
{
uniset_rwmutex_wrlock(li->second.changeMutex);
li->second.sigChange.emit(li, this); li->second.sigChange.emit(li, this);
}
} }
catch(...){} catch(...){}
// глобальное по всем.. // глобальное по всем..
try try
{ {
if( changed ) if( changed )
{
uniset_mutex_lock l(siganyMutex);
sigAnyChange.emit(li, this); sigAnyChange.emit(li, this);
}
} }
catch(...){} catch(...){}
} }
...@@ -295,16 +307,22 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -295,16 +307,22 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li,
} // unlock } // unlock
try try
{ {
if( changed ) if( changed )
{
uniset_rwmutex_wrlock l(li->second.changeMutex);
li->second.sigChange.emit(li, this); li->second.sigChange.emit(li, this);
}
} }
catch(...){} catch(...){}
try try
{ {
if( changed ) if( changed )
{
uniset_mutex_lock l(siganyMutex);
sigAnyChange.emit(li, this); sigAnyChange.emit(li, this);
}
} }
catch(...){} catch(...){}
} }
......
...@@ -271,7 +271,7 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s ...@@ -271,7 +271,7 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s
if( removeConsumer(askIterator->second, cons) ) if( removeConsumer(askIterator->second, cons) )
{ {
if( askIterator->second.empty() ) if( askIterator->second.empty() )
askLst.erase(askIterator); askLst.erase(askIterator);
else else
{ {
try try
...@@ -414,6 +414,7 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm) ...@@ -414,6 +414,7 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
if( maxAttemtps>0 && (--li->attempt <= 0) ) if( maxAttemtps>0 && (--li->attempt <= 0) )
{ {
li = lst.erase(li); li = lst.erase(li);
if( li == lst.end() ) --li;
break; break;
} }
......
...@@ -76,28 +76,12 @@ void DBServer::processingMessage( UniSetTypes::VoidMessage *msg ) ...@@ -76,28 +76,12 @@ void DBServer::processingMessage( UniSetTypes::VoidMessage *msg )
{ {
switch(msg->type) switch(msg->type)
{ {
case Message::SysCommand:
{
SystemMessage sm(msg);
sysCommand(&sm);
break;
}
case Message::Confirm: case Message::Confirm:
{ confirmInfo( reinterpret_cast<ConfirmMessage*>(msg) );
ConfirmMessage cm(msg); break;
parse(&cm);
break;
}
case Message::SensorInfo:
{
SensorMessage sm(msg);
parse(&sm);
break;
}
default: default:
UniSetObject_LT::processingMessage(msg);
break; break;
} }
......
...@@ -85,6 +85,8 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -85,6 +85,8 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
if( !li->curTick ) if( !li->curTick )
{ {
li = tlst.erase(li); li = tlst.erase(li);
if( li == tlst.end() ) --li;
if( tlst.empty() ) if( tlst.empty() )
sleepTime = UniSetTimer::WaitUpTime; sleepTime = UniSetTimer::WaitUpTime;
continue; continue;
......
...@@ -35,56 +35,12 @@ SMonitor::~SMonitor() ...@@ -35,56 +35,12 @@ SMonitor::~SMonitor()
{ {
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SMonitor::processingMessage( UniSetTypes::VoidMessage *msg)
{
try
{
switch(msg->type)
{
case Message::SensorInfo:
{
// cout << myname << "(sensorMessage): type="<< msg->type << " prior=" << msg->priority;
// cout << " sec=" << msg->tm.tv_sec << " usec=" << msg->tm.tv_usec << endl;
SensorMessage sm(msg);
sensorInfo(&sm);
break;
}
case Message::SysCommand:
{
SystemMessage sm(msg);
sysCommand(&sm);
break;
}
case Message::Timer:
{
TimerMessage tm(msg);
timerInfo(&tm);
break;
}
default:
cout << myname << ": неизвестное сообщение "<< msg->type << endl;
break;
}
}
catch(Exception& ex)
{
cerr << myname << ":(processing): " << ex << endl;
}
catch(...){}
}
// ------------------------------------------------------------------------------------------
void SMonitor::sigterm( int signo ) void SMonitor::sigterm( int signo )
{ {
cout << myname << "SMonitor: sigterm "<< endl; cout << myname << "SMonitor: sigterm "<< endl;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SMonitor::sysCommand( SystemMessage *sm ) void SMonitor::sysCommand( const SystemMessage *sm )
{ {
switch(sm->command) switch(sm->command)
{ {
...@@ -126,7 +82,7 @@ void SMonitor::sysCommand( SystemMessage *sm ) ...@@ -126,7 +82,7 @@ void SMonitor::sysCommand( SystemMessage *sm )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SMonitor::sensorInfo( SensorMessage *si ) void SMonitor::sensorInfo( const SensorMessage* si )
{ {
cout << "(" << setw(6) << si->id << "): " << setw(8) << timeToString(si->sm_tv_sec,":") cout << "(" << setw(6) << si->id << "): " << setw(8) << timeToString(si->sm_tv_sec,":")
<< "(" << setw(6) << si->sm_tv_usec << "): "; << "(" << setw(6) << si->sm_tv_usec << "): ";
...@@ -153,7 +109,7 @@ void SMonitor::sensorInfo( SensorMessage *si ) ...@@ -153,7 +109,7 @@ void SMonitor::sensorInfo( SensorMessage *si )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SMonitor::timerInfo( UniSetTypes::TimerMessage *tm ) void SMonitor::timerInfo( const UniSetTypes::TimerMessage *tm )
{ {
} }
......
...@@ -14,12 +14,11 @@ int main( int argc, const char **argv ) ...@@ -14,12 +14,11 @@ int main( int argc, const char **argv )
tlog[Debug::INFO] << ": [info] ..." << endl; tlog[Debug::INFO] << ": [info] ..." << endl;
tlog(Debug::INFO) << ": (info) ..." << endl; tlog(Debug::INFO) << ": (info) ..." << endl;
cout << endl; cout << endl;
tlog.d_level1() << ": (level1) ..." << endl;
tlog.level1() << ": [level1] ..." << endl; tlog.level1() << ": [level1] ..." << endl;
tlog.info() << ": [info] ..." << endl; tlog.info() << ": [info] ..." << endl;
if( tlog.is_level1() ) if( tlog.is_level1() )
tlog.d_level1() << ": is level1..." << endl; tlog.level1() << ": is level1..." << endl;
return 0; return 0;
} }
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