Commit ee28e7bd authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил "синтаксический сахар" для логов (ucrit,uwarn,uinfo, и т.п.)

parent a155c412
...@@ -446,9 +446,9 @@ int omap() ...@@ -446,9 +446,9 @@ int omap()
conf->oind->printMap(cout); conf->oind->printMap(cout);
cout << "==========================================================================\n"; cout << "==========================================================================\n";
} }
catch(Exception& ex) catch( Exception& ex )
{ {
ulog.crit() << " configuration init FAILED!!! \n"; ucrit << " configuration init failed: " << ex << endl;
return 1; return 1;
} }
return 0; return 0;
......
...@@ -381,7 +381,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -381,7 +381,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK ); int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
if( fd <= 0 ) if( fd <= 0 )
{ {
dlog.warn() << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl; dwarn << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -393,7 +393,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -393,7 +393,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
int ret = ::read(fd,&buf,sizeof(buf)); int ret = ::read(fd,&buf,sizeof(buf));
if( ret < 0 ) if( ret < 0 )
{ {
dlog.warn() << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl; dwarn << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -407,7 +407,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -407,7 +407,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
struct stat fs; struct stat fs;
if( fstat(fd,&fs) < 0 ) if( fstat(fd,&fs) < 0 )
{ {
dlog.warn() << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl; dwarn << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -422,7 +422,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -422,7 +422,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) ) if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) )
{ {
dlog.warn() << "(fileTransfer): set date failed..." << endl; dwarn << "(fileTransfer): set date failed..." << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
......
...@@ -376,7 +376,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -376,7 +376,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK ); int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
if( fd <= 0 ) if( fd <= 0 )
{ {
dlog.warn() << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl; dwarn << "(fileTransfer): open '" << fname << "' with error: " << strerror(errno) << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -388,7 +388,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -388,7 +388,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
int ret = ::read(fd,&buf,sizeof(buf)); int ret = ::read(fd,&buf,sizeof(buf));
if( ret < 0 ) if( ret < 0 )
{ {
dlog.warn() << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl; dwarn << "(fileTransfer): read from '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -402,7 +402,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -402,7 +402,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
struct stat fs; struct stat fs;
if( fstat(fd,&fs) < 0 ) if( fstat(fd,&fs) < 0 )
{ {
dlog.warn() << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl; dwarn << "(fileTransfer): fstat for '" << fname << "' with error: " << strerror(errno) << endl;
close(fd); close(fd);
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
...@@ -417,7 +417,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -417,7 +417,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) ) if( !reply.set(query.numfile,numpacks,query.numpacket,buf,ret) )
{ {
dlog.warn() << "(fileTransfer): set date failed..." << endl; dwarn << "(fileTransfer): set date failed..." << endl;
return ModbusRTU::erOperationFailed; return ModbusRTU::erOperationFailed;
} }
......
...@@ -89,19 +89,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -89,19 +89,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -124,7 +121,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorM ...@@ -124,7 +121,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorM
if( _sm->id == <xsl:value-of select="../../@name"/> ) if( _sm->id == <xsl:value-of select="../../@name"/> )
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _sm->value; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _sm->value;
dlog.level( Debug::type(_sm->value) ); mylog.level( Debug::type(_sm->value) );
} }
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
...@@ -146,8 +143,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -146,8 +143,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
break; break;
} }
if( !activated &amp;&amp; ulog.is_crit() ) if( !activated )
ulog.crit() &lt;&lt; myname ucrit &lt;&lt; myname
&lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl; &lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl;
for( ;; ) for( ;; )
...@@ -165,18 +162,15 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -165,18 +162,15 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
} }
catch(SystemError&amp; err) catch(SystemError&amp; err)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl;
} }
msleep(askPause); msleep(askPause);
} }
...@@ -191,8 +185,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si ...@@ -191,8 +185,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( _sid == <xsl:value-of select="../../@name"/> ) if( _sid == <xsl:value-of select="../../@name"/> )
{ {
if( ulog.is_level2() ) ulog2 &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl;
ulog.level2() &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val;
<xsl:call-template name="setdata"/> <xsl:call-template name="setdata"/>
return; return;
...@@ -224,16 +217,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -224,16 +217,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
return 0; return 0;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
...@@ -299,8 +290,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -299,8 +290,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -335,8 +325,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -335,8 +325,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -351,8 +340,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -351,8 +340,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -365,7 +353,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -365,7 +353,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
if( prev_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> != <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> ) if( prev_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> != <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> )
</xsl:if> </xsl:if>
{ {
// приходится искуственно использовать третий параметр, // приходится искуственно использовать третий параметр,
// что-бы компилятор выбрал // что-бы компилятор выбрал
// правильный(для аналоговых) конструктор у SensorMessage // правильный(для аналоговых) конструктор у SensorMessage
IOController_i::CalibrateInfo _ci; IOController_i::CalibrateInfo _ci;
......
...@@ -94,19 +94,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -94,19 +94,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -157,8 +154,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si ...@@ -157,8 +154,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( _sid == <xsl:value-of select="../../@name"/> ) if( _sid == <xsl:value-of select="../../@name"/> )
{ {
if( ulog.is_level2() ) ulog2 &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl;
ulog.level2() &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = " &lt;&lt; _val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _val;
return; return;
} }
...@@ -180,8 +176,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -180,8 +176,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
return 0; return 0;
...@@ -232,8 +227,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -232,8 +227,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -268,8 +262,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -268,8 +262,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -284,8 +277,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -284,8 +277,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
......
...@@ -88,19 +88,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -88,19 +88,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -116,8 +113,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si ...@@ -116,8 +113,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( _sid == <xsl:value-of select="@name"/> ) if( _sid == <xsl:value-of select="@name"/> )
{ {
if( ulog.is_level2() ) ulog2 &lt;&lt; "(setState): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; _val &lt;&lt; endl;
ulog.level2() &lt;&lt; "(setState): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; _val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _val; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _val;
<xsl:call-template name="setdata"/> <xsl:call-template name="setdata"/>
return; return;
...@@ -163,7 +159,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorM ...@@ -163,7 +159,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( UniSetTypes::SensorM
if( _sm->id == <xsl:value-of select="@name"/> ) if( _sm->id == <xsl:value-of select="@name"/> )
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _sm->value; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _sm->value;
dlog.level( Debug::type(_sm->value) ); mylog.level( Debug::type(_sm->value) );
} }
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
...@@ -188,14 +184,12 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -188,14 +184,12 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
} }
</xsl:for-each> </xsl:for-each>
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
...@@ -214,8 +208,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -214,8 +208,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
break; break;
} }
if( !activated &amp;&amp; ulog.is_crit() ) if( !activated )
ulog.crit() &lt;&lt; myname ucrit &lt;&lt; myname
&lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl; &lt;&lt; "(preAskSensors): ************* don`t activated?! ************" &lt;&lt; endl;
for( ;; ) for( ;; )
...@@ -232,18 +226,15 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -232,18 +226,15 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
} }
catch(SystemError&amp; err) catch(SystemError&amp; err)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; err &lt;&lt; endl;
} }
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(preAskSensors): catch(...)" &lt;&lt; endl;
} }
msleep(askPause); msleep(askPause);
} }
...@@ -275,8 +266,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -275,8 +266,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
...@@ -293,8 +283,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -293,8 +283,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
...@@ -312,8 +301,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -312,8 +301,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
} }
......
...@@ -93,19 +93,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -93,19 +93,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
catch(CORBA::SystemException&amp; ex) catch(CORBA::SystemException&amp; ex)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl; &lt;&lt; ex.NP_minorString() &lt;&lt; endl;
} }
catch(...) catch(...)
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(execute): catch ..." &lt;&lt; endl;
} }
if( !active ) if( !active )
...@@ -121,8 +118,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid ...@@ -121,8 +118,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
if( sid == <xsl:value-of select="@name"/> ) if( sid == <xsl:value-of select="@name"/> )
{ {
if( ulog.is_level2() ) ulog2 &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; val &lt;&lt; endl;
ulog.level2() &lt;&lt; "(setValue): <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = " &lt;&lt; val &lt;&lt; endl;
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = val; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = val;
return; return;
} }
...@@ -178,8 +174,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -178,8 +174,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
</xsl:for-each> </xsl:for-each>
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
ulog.crit() &lt;&lt; myname &lt;&lt; "(getValue): Обращение к неизвестному датчику sid="
&lt;&lt; _sid &lt;&lt; endl; &lt;&lt; _sid &lt;&lt; endl;
return 0; return 0;
} }
...@@ -214,8 +209,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -214,8 +209,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -232,8 +226,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -232,8 +226,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -251,8 +244,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -251,8 +244,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
...@@ -269,8 +261,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code, ...@@ -269,8 +261,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
} }
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
if( ulog.is_crit() ) ucrit &lt;&lt; myname &lt;&lt; "(setmsg): " &lt;&lt; ex &lt;&lt; endl;
ulog.crit() &lt;&lt; myname &lt;&lt; "(setmsg): " &lt;&lt; ex &lt;&lt; endl;
throw; throw;
} }
</xsl:template> </xsl:template>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <xsl:call-template name="preinclude"/>LT_Object.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>LT_Object.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>UniXML.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>UniXML.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>Trigger.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>Trigger.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>UniversalInterface.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>UInterface.h<xsl:call-template name="postinclude"/>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
class <xsl:value-of select="$CLASSNAME"/>_SK: class <xsl:value-of select="$CLASSNAME"/>_SK:
<xsl:if test="normalize-space($BASECLASS)!=''">public <xsl:value-of select="normalize-space($BASECLASS)"/>,</xsl:if> <xsl:if test="normalize-space($BASECLASS)!=''">public <xsl:value-of select="normalize-space($BASECLASS)"/>,</xsl:if>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include &lt;sstream&gt; #include &lt;sstream&gt;
#include <xsl:call-template name="preinclude"/>Configuration.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>Configuration.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>ObjectsActivator.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>UniSetActivator.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>Debug.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>Debug.h<xsl:call-template name="postinclude"/>
#include "<xsl:value-of select="$CLASSNAME"/>.h" #include "<xsl:value-of select="$CLASSNAME"/>.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -53,10 +53,6 @@ int main( int argc,char* argv[] ) ...@@ -53,10 +53,6 @@ int main( int argc,char* argv[] )
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv,confile); conf = new Configuration(argc, argv,confile);
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename );
ulog.logFile( logname.c_str() );
// определяем ID объекта // определяем ID объекта
ObjectId ID(DefaultObjectId); ObjectId ID(DefaultObjectId);
...@@ -73,8 +69,12 @@ int main( int argc,char* argv[] ) ...@@ -73,8 +69,12 @@ int main( int argc,char* argv[] )
} }
<xsl:value-of select="$CLASSNAME"/> obj(ID); <xsl:value-of select="$CLASSNAME"/> obj(ID);
ObjectsActivator act; string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename );
obj.mylog.logFile( logname.c_str() );
UniSetActivator act;
act.addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj)); act.addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj));
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include &lt;sstream&gt; #include &lt;sstream&gt;
#include <xsl:call-template name="preinclude"/>Configuration.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>Configuration.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>ObjectsActivator.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>UniSetActivator.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>Debug.h<xsl:call-template name="postinclude"/> #include <xsl:call-template name="preinclude"/>Debug.h<xsl:call-template name="postinclude"/>
#include "<xsl:value-of select="$CLASSNAME"/>.h" #include "<xsl:value-of select="$CLASSNAME"/>.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -55,10 +55,6 @@ int main( int argc, const char** argv ) ...@@ -55,10 +55,6 @@ int main( int argc, const char** argv )
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile); conf = new Configuration(argc, argv, confile);
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename );
ulog.logFile( logname.c_str() );
<xsl:if test="not(normalize-space(//@OID))=''"> <xsl:if test="not(normalize-space(//@OID))=''">
<xsl:value-of select="$CLASSNAME"/> obj; <xsl:value-of select="$CLASSNAME"/> obj;
...@@ -79,9 +75,14 @@ int main( int argc, const char** argv ) ...@@ -79,9 +75,14 @@ int main( int argc, const char** argv )
} }
} }
<xsl:value-of select="$CLASSNAME"/> obj(ID); <xsl:value-of select="$CLASSNAME"/> obj(ID);
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename );
obj.mylog.logFile( logname.c_str() );
</xsl:if> </xsl:if>
ObjectsActivator act; UniSetActivator act;
act.addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj)); act.addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj));
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
......
...@@ -31,10 +31,10 @@ int main( int argc, const char **argv ) ...@@ -31,10 +31,10 @@ int main( int argc, const char **argv )
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act.broadcast( sm.transport_msg() );
ulog.ebug::ANY) << "\n\n\n"; ulog << "\n\n\n";
ulog.ebug::ANY] << "(Skel::main): -------------- Skel START -------------------------\n\n"; ulog << "(Skel::main): -------------- Skel START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n"; dlog << "\n\n\n";
dlog[Debug::ANY] << "(Skel::main): -------------- Skel START -------------------------\n\n"; dlog << "(Skel::main): -------------- Skel START -------------------------\n\n";
act.run(false); act.run(false);
} }
catch(SystemError& err) catch(SystemError& err)
......
...@@ -356,6 +356,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -356,6 +356,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- 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
......
...@@ -152,20 +152,17 @@ void DBServer_MySQL::parse( UniSetTypes::ConfirmMessage* cem ) ...@@ -152,20 +152,17 @@ void DBServer_MySQL::parse( UniSetTypes::ConfirmMessage* cem )
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( ulog.is_crit() ) ucrit << myname << "(update_confirm): db error: "<< db->error() << endl;
ulog.crit() << myname << "(update_confirm): db error: "<< db->error() << endl;
db->freeResult(); db->freeResult();
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(update_confirm): " << ex << endl;
ulog.crit() << myname << "(update_confirm): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
if( ulog.is_crit() ) ucrit << myname << "(update_confirm): catch..." << endl;
ulog.crit() << myname << "(update_confirm): catch..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -188,8 +185,7 @@ bool DBServer_MySQL::writeToBase( const string& query ) ...@@ -188,8 +185,7 @@ bool DBServer_MySQL::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
if( ulog.is_crit() ) ucrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
ulog.crit() << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -231,11 +227,9 @@ void DBServer_MySQL::flushBuffer() ...@@ -231,11 +227,9 @@ void DBServer_MySQL::flushBuffer()
string err(db->error()); string err(db->error());
if( err.empty() ) if( err.empty() )
db->freeResult(); db->freeResult();
else if( ulog.is_crit() ) else
{ ucrit << myname << "(writeToBase): error: " << err <<
ulog.crit() << myname << "(writeToBase): error: " << err <<
" lost query: " << qbuf.front() << endl; " lost query: " << qbuf.front() << endl;
}
qbuf.pop(); qbuf.pop();
} }
...@@ -269,20 +263,17 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si ) ...@@ -269,20 +263,17 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( ulog.is_crit() ) ucrit << myname << "(insert) sensor msg error: "<< db->error() << endl;
ulog.crit() << myname << "(insert) sensor msg error: "<< db->error() << endl;
db->freeResult(); db->freeResult();
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(insert_main_history): " << ex << endl;
ulog.crit() << myname << "(insert_main_history): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
if( ulog.is_crit() ) ucrit << myname << "(insert_main_history): catch ..." << endl;
ulog.crit() << myname << "(insert_main_history): catch ..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -346,8 +337,7 @@ void DBServer_MySQL::init_dbserver() ...@@ -346,8 +337,7 @@ void DBServer_MySQL::init_dbserver()
if( !db->connect(dbnode, user, password, dbname) ) if( !db->connect(dbnode, user, password, dbname) )
{ {
// ostringstream err; // ostringstream err;
if( ulog.is_crit() ) ucrit << myname
ulog.crit() << myname
<< "(init): DB connection error: " << "(init): DB connection error: "
<< db->error() << endl; << db->error() << endl;
// throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) ); // throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) );
...@@ -372,8 +362,7 @@ void DBServer_MySQL::createTables( DBInterface *db ) ...@@ -372,8 +362,7 @@ void DBServer_MySQL::createTables( DBInterface *db )
UniXML_iterator it( conf->getNode("Tables") ); UniXML_iterator it( conf->getNode("Tables") );
if(!it) if(!it)
{ {
if( ulog.is_crit() ) ucrit << myname << ": section <Tables> not found.."<< endl;
ulog.crit() << myname << ": section <Tables> not found.."<< endl;
throw Exception(); throw Exception();
} }
...@@ -385,8 +374,8 @@ void DBServer_MySQL::createTables( DBInterface *db ) ...@@ -385,8 +374,8 @@ void DBServer_MySQL::createTables( DBInterface *db )
ulog[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl; ulog[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl;
ostringstream query; ostringstream query;
query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")"; query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")";
if( !db->query(query.str()) && ulog.is_crit() ) if( !db->query(query.str()) )
ulog.crit() << myname << "(createTables): error: \t\t" << db->error() << endl; ucrit << myname << "(createTables): error: \t\t" << db->error() << endl;
} }
} }
} }
...@@ -399,8 +388,7 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -399,8 +388,7 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
{ {
if( !db->ping() ) if( !db->ping() )
{ {
if( ulog.is_warn() ) uwarn << myname << "(timerInfo): DB lost connection.." << endl;
ulog.warn() << myname << "(timerInfo): DB lost connection.." << endl;
connect_ok = false; connect_ok = false;
askTimer(DBServer_MySQL::PingTimer,0); askTimer(DBServer_MySQL::PingTimer,0);
askTimer(DBServer_MySQL::ReconnectTimer,ReconnectTime); askTimer(DBServer_MySQL::ReconnectTimer,ReconnectTime);
...@@ -427,8 +415,7 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -427,8 +415,7 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
askTimer(DBServer_MySQL::PingTimer,PingTime); askTimer(DBServer_MySQL::PingTimer,PingTime);
} }
connect_ok = false; connect_ok = false;
if( ulog.is_warn() ) uwarn << myname << "(timerInfo): DB no connection.." << endl;
ulog.warn() << myname << "(timerInfo): DB no connection.." << endl;
} }
else else
init_dbserver(); init_dbserver();
...@@ -436,8 +423,7 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -436,8 +423,7 @@ void DBServer_MySQL::timerInfo( UniSetTypes::TimerMessage* tm )
break; break;
default: default:
if( ulog.is_warn() ) uwarn << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl;
ulog.warn() << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl;
break; break;
} }
} }
......
...@@ -148,19 +148,16 @@ void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem ) ...@@ -148,19 +148,16 @@ void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem )
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( ulog.is_crit() ) ucrit << myname << "(update_confirm): db error: "<< db->error() << endl;
ulog.crit() << myname << "(update_confirm): db error: "<< db->error() << endl;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(update_confirm): " << ex << endl;
ulog.crit() << myname << "(update_confirm): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
if( ulog.is_crit() ) ucrit << myname << "(update_confirm): catch..." << endl;
ulog.crit() << myname << "(update_confirm): catch..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -183,8 +180,7 @@ bool DBServer_SQLite::writeToBase( const string& query ) ...@@ -183,8 +180,7 @@ bool DBServer_SQLite::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
if( ulog.is_crit() ) ucrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
ulog.crit() << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -207,9 +203,9 @@ void DBServer_SQLite::flushBuffer() ...@@ -207,9 +203,9 @@ void DBServer_SQLite::flushBuffer()
// Сперва пробуем очистить всё что накопилось в очереди до этого... // Сперва пробуем очистить всё что накопилось в очереди до этого...
while( !qbuf.empty() ) while( !qbuf.empty() )
{ {
if( !db->insert(qbuf.front()) && ulog.is_crit() ) if( !db->insert(qbuf.front()) )
{ {
ulog.crit() << myname << "(writeToBase): error: " << db->error() << ucrit << myname << "(writeToBase): error: " << db->error() <<
" lost query: " << qbuf.front() << endl; " lost query: " << qbuf.front() << endl;
} }
qbuf.pop(); qbuf.pop();
...@@ -244,17 +240,16 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si ) ...@@ -244,17 +240,16 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
if( !writeToBase(data.str()) ) if( !writeToBase(data.str()) )
{ {
if( ulog.is_crit() ) ucrit << myname << "(insert) sensor msg error: "<< db->error() << endl;
ulog.crit() << myname << "(insert) sensor msg error: "<< db->error() << endl;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
ulog.crit() << myname << "(insert_main_history): " << ex << endl; ucrit << myname << "(insert_main_history): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
ulog.crit() << myname << "(insert_main_history): catch ..." << endl; ucrit << myname << "(insert_main_history): catch ..." << endl;
} }
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -311,8 +306,7 @@ void DBServer_SQLite::init_dbserver() ...@@ -311,8 +306,7 @@ void DBServer_SQLite::init_dbserver()
if( !db->connect(dbfile,false) ) if( !db->connect(dbfile,false) )
{ {
// ostringstream err; // ostringstream err;
if( ulog.is_crit() ) ucrit << myname
ulog.crit() << myname
<< "(init): DB connection error: " << "(init): DB connection error: "
<< db->error() << endl; << db->error() << endl;
// throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) ); // throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) );
...@@ -337,8 +331,7 @@ void DBServer_SQLite::createTables( SQLiteInterface *db ) ...@@ -337,8 +331,7 @@ void DBServer_SQLite::createTables( SQLiteInterface *db )
UniXML_iterator it( conf->getNode("Tables") ); UniXML_iterator it( conf->getNode("Tables") );
if(!it) if(!it)
{ {
if( ulog.is_crit() ) ucrit << myname << ": section <Tables> not found.."<< endl;
ulog.crit() << myname << ": section <Tables> not found.."<< endl;
throw Exception(); throw Exception();
} }
...@@ -350,8 +343,8 @@ void DBServer_SQLite::createTables( SQLiteInterface *db ) ...@@ -350,8 +343,8 @@ void DBServer_SQLite::createTables( SQLiteInterface *db )
ulog[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl; ulog[DBLogInfoLevel] << myname << "(createTables): create " << it.getName() << endl;
ostringstream query; ostringstream query;
query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")"; query << "CREATE TABLE " << conf->getProp(it,"name") << "(" << conf->getProp(it,"create") << ")";
if( !db->query(query.str()) && ulog.is_crit() ) if( !db->query(query.str()) )
ulog.crit() << myname << "(createTables): error: \t\t" << db->error() << endl; ucrit << myname << "(createTables): error: \t\t" << db->error() << endl;
} }
} }
} }
...@@ -364,8 +357,7 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -364,8 +357,7 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
{ {
if( !db->ping() ) if( !db->ping() )
{ {
if( ulog.is_warn() ) uwarn << myname << "(timerInfo): DB lost connection.." << endl;
ulog.warn() << myname << "(timerInfo): DB lost connection.." << endl;
connect_ok = false; connect_ok = false;
askTimer(DBServer_SQLite::PingTimer,0); askTimer(DBServer_SQLite::PingTimer,0);
askTimer(DBServer_SQLite::ReconnectTimer,ReconnectTime); askTimer(DBServer_SQLite::ReconnectTimer,ReconnectTime);
...@@ -392,8 +384,7 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -392,8 +384,7 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
askTimer(DBServer_SQLite::PingTimer,PingTime); askTimer(DBServer_SQLite::PingTimer,PingTime);
} }
connect_ok = false; connect_ok = false;
if( ulog.is_warn() ) uwarn << myname << "(timerInfo): DB no connection.." << endl;
ulog.warn() << myname << "(timerInfo): DB no connection.." << endl;
} }
else else
init_dbserver(); init_dbserver();
...@@ -401,8 +392,7 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -401,8 +392,7 @@ void DBServer_SQLite::timerInfo( UniSetTypes::TimerMessage* tm )
break; break;
default: default:
if( ulog.is_warn() ) uwarn << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl;
ulog.warn() << myname << "(timerInfo): Unknown TimerID=" << tm->id << endl;
break; break;
} }
} }
......
...@@ -48,7 +48,7 @@ int main(int argc, const char **argv) ...@@ -48,7 +48,7 @@ int main(int argc, const char **argv)
IOControl* ic = IOControl::init_iocontrol(argc,argv,shmID); IOControl* ic = IOControl::init_iocontrol(argc,argv,shmID);
if( !ic ) if( !ic )
{ {
dlog.crit() << "(iocontrol): init не прошёл..." << endl; dcrit << "(iocontrol): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -69,15 +69,15 @@ int main(int argc, const char **argv) ...@@ -69,15 +69,15 @@ int main(int argc, const char **argv)
} }
catch(SystemError& err) catch(SystemError& err)
{ {
dlog.crit() << "(iocontrol): " << err << endl; dcrit << "(iocontrol): " << err << endl;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog.crit() << "(iocontrol): " << ex << endl; dcrit << "(iocontrol): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(iocontrol): catch(...)" << endl; dcrit << "(iocontrol): catch(...)" << endl;
} }
return 1; return 1;
......
...@@ -35,15 +35,15 @@ void LProcessor::execute( const string& lfile ) ...@@ -35,15 +35,15 @@ void LProcessor::execute( const string& lfile )
} }
catch( LogicException& ex ) catch( LogicException& ex )
{ {
dlog.crit() << logname << "(execute): " << ex << endl; dcrit << logname << "(execute): " << ex << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << logname << "(execute): " << ex << endl; dcrit << logname << "(execute): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << logname << "(execute): catch...\n"; dcrit << logname << "(execute): catch...\n";
} }
msleep(sleepTime); msleep(sleepTime);
} }
...@@ -54,12 +54,12 @@ void LProcessor::step() ...@@ -54,12 +54,12 @@ void LProcessor::step()
getInputs(); getInputs();
processing(); processing();
setOuts(); setOuts();
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LProcessor::build( const string& lfile ) void LProcessor::build( const string& lfile )
{ {
sch.read(lfile); sch.read(lfile);
// составляем карту внешних входов // составляем карту внешних входов
// считая, что в поле name записано название датчика // считая, что в поле name записано название датчика
for( Schema::EXTiterator it=sch.extBegin(); it!=sch.extEnd(); ++it ) for( Schema::EXTiterator it=sch.extBegin(); it!=sch.extEnd(); ++it )
...@@ -67,7 +67,7 @@ void LProcessor::build( const string& lfile ) ...@@ -67,7 +67,7 @@ void LProcessor::build( const string& lfile )
UniSetTypes::ObjectId sid = conf->getSensorID(it->name); UniSetTypes::ObjectId sid = conf->getSensorID(it->name);
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
dlog.crit() << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ДАТЧИКА: " << it->name << endl; dcrit << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ДАТЧИКА: " << it->name << endl;
continue; continue;
} }
...@@ -78,18 +78,18 @@ void LProcessor::build( const string& lfile ) ...@@ -78,18 +78,18 @@ void LProcessor::build( const string& lfile )
ei.iotype = conf->getIOType(sid); ei.iotype = conf->getIOType(sid);
if( ei.iotype == UniversalIO::UnknownIOType ) if( ei.iotype == UniversalIO::UnknownIOType )
{ {
dlog.crit() << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl; dcrit << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl;
continue; continue;
} }
extInputs.push_front(ei); extInputs.push_front(ei);
} }
for( Schema::OUTiterator it=sch.outBegin(); it!=sch.outEnd(); ++it ) for( Schema::OUTiterator it=sch.outBegin(); it!=sch.outEnd(); ++it )
{ {
UniSetTypes::ObjectId sid = conf->getSensorID(it->name); UniSetTypes::ObjectId sid = conf->getSensorID(it->name);
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
dlog.crit() << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ВЫХОДА: " << it->name << endl; dcrit << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ВЫХОДА: " << it->name << endl;
continue; continue;
} }
...@@ -99,13 +99,13 @@ void LProcessor::build( const string& lfile ) ...@@ -99,13 +99,13 @@ void LProcessor::build( const string& lfile )
ei.iotype = conf->getIOType(sid); ei.iotype = conf->getIOType(sid);
if( ei.iotype == UniversalIO::UnknownIOType ) if( ei.iotype == UniversalIO::UnknownIOType )
{ {
dlog.crit() << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl; dcrit << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl;
continue; continue;
} }
extOuts.push_front(ei); extOuts.push_front(ei);
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/*! /*!
...@@ -147,11 +147,11 @@ void LProcessor::setOuts() ...@@ -147,11 +147,11 @@ void LProcessor::setOuts()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(LProcessor::setOuts): " << ex << endl; dcrit << "(LProcessor::setOuts): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(LProcessor::setOuts): catch...\n"; dcrit << "(LProcessor::setOuts): catch...\n";
} }
} }
} }
......
...@@ -24,8 +24,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o ...@@ -24,8 +24,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
{ {
ostringstream err; ostringstream err;
err << myname << ": ID not found ('HeartBeat') for " << heart; err << myname << ": ID not found ('HeartBeat') for " << heart;
if( dlog.is_crit() ) dcrit << myname << "(init): " << err.str() << endl;
dlog.crit() << myname << "(init): " << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -52,8 +51,7 @@ void PassiveLProcessor::step() ...@@ -52,8 +51,7 @@ void PassiveLProcessor::step()
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
if( dlog.is_crit() ) dcrit << myname << "(step): (hb) " << ex << std::endl;
dlog.crit() << myname << "(step): (hb) " << ex << std::endl;
} }
if( sidHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() ) if( sidHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() )
...@@ -65,8 +63,7 @@ void PassiveLProcessor::step() ...@@ -65,8 +63,7 @@ void PassiveLProcessor::step()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
if( dlog.is_crit() ) dcrit << myname << "(step): (hb) " << ex << std::endl;
dlog.crit() << myname << "(step): (hb) " << ex << std::endl;
} }
} }
...@@ -86,8 +83,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -86,8 +83,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( dlog.is_crit() ) dcrit << myname << "(askSensors): " << ex << endl;
dlog.crit() << myname << "(askSensors): " << ex << endl;
throw SystemError(myname +"(askSensors): do not ask sensors" ); throw SystemError(myname +"(askSensors): do not ask sensors" );
} }
} }
...@@ -115,8 +111,7 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -115,8 +111,7 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
if( !shm->waitSMready(smReadyTimeout) ) if( !shm->waitSMready(smReadyTimeout) )
{ {
if( dlog.is_crit() ) dcrit << myname << "(ERR): SM not ready. Terminated... " << endl;
dlog.crit() << myname << "(ERR): SM not ready. Terminated... " << endl;
raise(SIGTERM); raise(SIGTERM);
return; return;
} }
...@@ -202,11 +197,11 @@ void PassiveLProcessor::setOuts() ...@@ -202,11 +197,11 @@ void PassiveLProcessor::setOuts()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << myname << "(setOuts): " << ex << endl; dcrit << myname << "(setOuts): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << myname << "(setOuts): catch...\n"; dcrit << myname << "(setOuts): catch...\n";
} }
} }
} }
...@@ -221,11 +216,11 @@ void PassiveLProcessor::sigterm( int signo ) ...@@ -221,11 +216,11 @@ void PassiveLProcessor::sigterm( int signo )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << myname << "(sigterm): " << ex << endl; dcrit << myname << "(sigterm): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << myname << "(sigterm): catch...\n"; dcrit << myname << "(sigterm): catch...\n";
} }
} }
} }
...@@ -263,7 +258,7 @@ void PassiveLProcessor::processingMessage( UniSetTypes::VoidMessage* msg ) ...@@ -263,7 +258,7 @@ void PassiveLProcessor::processingMessage( UniSetTypes::VoidMessage* msg )
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog.crit() << myname << "(processingMessage): " << ex << endl; dcrit << myname << "(processingMessage): " << ex << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -110,8 +110,7 @@ void Schema::extlink( const string& name, Element::ElementID childID, int numIn ...@@ -110,8 +110,7 @@ void Schema::extlink( const string& name, Element::ElementID childID, int numIn
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Element* Schema::manage( Element* el ) Element* Schema::manage( Element* el )
{ {
if( dlog.is_info() ) dinfo << "Schema: manage new element id=" << el->getId()
dlog.info() << "Schema: manage new element id=" << el->getId()
<< " type=" << el->getType() << " type=" << el->getType()
<< " inputs=" << el->inCount() << endl; << " inputs=" << el->inCount() << endl;
......
...@@ -23,8 +23,8 @@ void TAND::setIn( int num, bool state ) ...@@ -23,8 +23,8 @@ void TAND::setIn( int num, bool state )
{ {
if( it->state == state ) if( it->state == state )
return; // вход не менялся можно вообще прервать проверку return; // вход не менялся можно вообще прервать проверку
it->state = state; it->state = state;
break; break;
} }
} }
...@@ -47,8 +47,7 @@ void TAND::setIn( int num, bool state ) ...@@ -47,8 +47,7 @@ void TAND::setIn( int num, bool state )
if( !brk ) if( !brk )
myout = true; myout = true;
if( dlog.is_info() ) dinfo << this << ": myout " << myout << endl;
dlog.info() << this << ": myout " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
......
...@@ -30,8 +30,7 @@ void TDelay::setIn( int num, bool state ) ...@@ -30,8 +30,7 @@ void TDelay::setIn( int num, bool state )
{ {
pt.setTiming(0); // reset timer pt.setTiming(0); // reset timer
myout = false; myout = false;
if( dlog.is_info() ) dinfo << this << ": set " << myout << endl;
dlog.info() << this << ": set " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
return; return;
...@@ -44,8 +43,7 @@ void TDelay::setIn( int num, bool state ) ...@@ -44,8 +43,7 @@ void TDelay::setIn( int num, bool state )
{ {
pt.setTiming(0); // reset timer pt.setTiming(0); // reset timer
myout = true; myout = true;
if( dlog.is_info() ) dinfo << this << ": set " << myout << endl;
dlog.info() << this << ": set " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
return; return;
...@@ -54,8 +52,7 @@ void TDelay::setIn( int num, bool state ) ...@@ -54,8 +52,7 @@ void TDelay::setIn( int num, bool state )
// засекаем, если ещё не установлен таймер // засекаем, если ещё не установлен таймер
if( !myout && !prev ) // т.е. !myout && prev != myout if( !myout && !prev ) // т.е. !myout && prev != myout
{ {
if( dlog.is_info() ) dinfo << this << ": set timer " << delay << " [msec]" << endl;
dlog.info() << this << ": set timer " << delay << " [msec]" << endl;
pt.setTiming(delay); pt.setTiming(delay);
} }
} }
...@@ -66,15 +63,14 @@ void TDelay::tick() ...@@ -66,15 +63,14 @@ void TDelay::tick()
{ {
myout = true; myout = true;
pt.setTiming(0); // reset timer pt.setTiming(0); // reset timer
if( dlog.is_info() ) dinfo << getType() << "(" << myid << "): TIMER!!!! myout=" << myout << endl;
dlog.info() << getType() << "(" << myid << "): TIMER!!!! myout=" << myout << endl;
Element::setChildOut(); Element::setChildOut();
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool TDelay::getOut() bool TDelay::getOut()
{ {
return myout; return myout;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void TDelay::setDelay( int timeMS ) void TDelay::setDelay( int timeMS )
......
...@@ -22,9 +22,6 @@ void TNOT::setIn( int num, bool state ) ...@@ -22,9 +22,6 @@ void TNOT::setIn( int num, bool state )
bool prev = myout; bool prev = myout;
myout = !state; myout = !state;
if( dlog.is_info() )
dlog.info() << this << ": myout " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
} }
......
...@@ -29,15 +29,15 @@ TOR::~TOR() ...@@ -29,15 +29,15 @@ TOR::~TOR()
void TOR::setIn( int num, bool state ) void TOR::setIn( int num, bool state )
{ {
// cout << getType() << "(" << myid << "): input " << num << " set " << state << endl; // cout << getType() << "(" << myid << "): input " << num << " set " << state << endl;
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it )
{ {
if( it->num == num ) if( it->num == num )
{ {
if( it->state == state ) if( it->state == state )
return; // вход не менялся можно вообще прервать проверку return; // вход не менялся можно вообще прервать проверку
it->state = state; it->state = state;
break; break;
} }
} }
...@@ -60,8 +60,7 @@ void TOR::setIn( int num, bool state ) ...@@ -60,8 +60,7 @@ void TOR::setIn( int num, bool state )
if( !brk ) if( !brk )
myout = false; myout = false;
if( dlog.is_info() ) dinfo << this << ": myout " << myout << endl;
dlog.info() << this << ": myout " << myout << endl;
if( prev != myout ) if( prev != myout )
Element::setChildOut(); Element::setChildOut();
} }
......
...@@ -29,7 +29,7 @@ int main(int argc, const char **argv) ...@@ -29,7 +29,7 @@ int main(int argc, const char **argv)
string schema = conf->getArgParam("--schema"); string schema = conf->getArgParam("--schema");
if( schema.empty() ) if( schema.empty() )
{ {
dlog.crit() << "schema-file not defined. Use --schema" << endl; dcrit << "schema-file not defined. Use --schema" << endl;
return 1; return 1;
} }
......
...@@ -38,7 +38,7 @@ pollThread(0) ...@@ -38,7 +38,7 @@ pollThread(0)
prop_prefix = ""; prop_prefix = "";
} }
dlog.info() << myname << "(init): prop_prefix=" << prop_prefix << endl; dinfo << myname << "(init): prop_prefix=" << prop_prefix << endl;
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
...@@ -55,7 +55,7 @@ pollThread(0) ...@@ -55,7 +55,7 @@ pollThread(0)
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;
dlog.info() << myname << "(init): persisten-connection=" << (!force_disconnect) << endl; dinfo << myname << "(init): persisten-connection=" << (!force_disconnect) << endl;
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
...@@ -103,19 +103,17 @@ ModbusClient* MBTCPMaster::initMB( bool reopen ) ...@@ -103,19 +103,17 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
mbtcp->setTimeout(recv_timeout); mbtcp->setTimeout(recv_timeout);
mbtcp->setSleepPause(sleepPause_usec); mbtcp->setSleepPause(sleepPause_usec);
mbtcp->setAfterSendPause(aftersend_pause); mbtcp->setAfterSendPause(aftersend_pause);
if( dlog.is_info() ) dinfo << myname << "(init): ipaddr=" << iaddr << " port=" << port << endl;
dlog.info() << myname << "(init): ipaddr=" << iaddr << " port=" << port << endl;
if( dlog.is_level9() )
if( dlog.debugging(Debug::LEVEL9) )
mbtcp->setLog(dlog); mbtcp->setLog(dlog);
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( dlog.is_warn() ) dwarn << "(init): " << ex << endl;
dlog.warn() << "(init): " << ex << endl;
} }
catch(...) catch(...)
{ {
...@@ -182,23 +180,20 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv, ...@@ -182,23 +180,20 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1");
if( name.empty() ) if( name.empty() )
{ {
if( dlog.debugging(Debug::CRIT) ) dcrit << "(MBTCPMaster): Не задан name'" << endl;
dlog.crit() << "(MBTCPMaster): Не задан name'" << endl;
return 0; return 0;
} }
ObjectId ID = conf->getObjectID(name); ObjectId ID = conf->getObjectID(name);
if( ID == UniSetTypes::DefaultObjectId ) if( ID == UniSetTypes::DefaultObjectId )
{ {
if( dlog.debugging(Debug::CRIT) ) dcrit << "(MBTCPMaster): идентификатор '" << name
dlog.crit() << "(MBTCPMaster): идентификатор '" << name
<< "' не найден в конф. файле!" << "' не найден в конф. файле!"
<< " в секции " << conf->getObjectsSection() << endl; << " в секции " << conf->getObjectsSection() << endl;
return 0; return 0;
} }
if( dlog.is_info() ) dinfo << "(MBTCPMaster): name = " << name << "(" << ID << ")" << endl;
dlog.info() << "(MBTCPMaster): name = " << name << "(" << ID << ")" << endl;
return new MBTCPMaster(ID,icID,ic,prefix); return new MBTCPMaster(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -40,8 +40,7 @@ checkThread(0) ...@@ -40,8 +40,7 @@ checkThread(0)
prop_prefix = ""; prop_prefix = "";
} }
if( dlog.is_info() ) dinfo << myname << "(init): prop_prefix=" << prop_prefix << endl;
dlog.info() << myname << "(init): prop_prefix=" << prop_prefix << endl;
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
...@@ -53,8 +52,7 @@ checkThread(0) ...@@ -53,8 +52,7 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): not found <GateList>"; err << myname << "(init): not found <GateList>";
if( dlog.is_crit() ) dcrit << err.str() << endl;
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -62,8 +60,7 @@ checkThread(0) ...@@ -62,8 +60,7 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): empty <GateList> ?!"; err << myname << "(init): empty <GateList> ?!";
if( dlog.is_crit() ) dcrit << err.str() << endl;
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -75,8 +72,7 @@ checkThread(0) ...@@ -75,8 +72,7 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): ip='' in <GateList>"; err << myname << "(init): ip='' in <GateList>";
if( dlog.is_crit() ) dcrit << err.str() << endl;
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -85,8 +81,7 @@ checkThread(0) ...@@ -85,8 +81,7 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): ERROR: port=''" << sinf.port << " for ip='" << sinf.ip << "' in <GateList>"; err << myname << "(init): ERROR: port=''" << sinf.port << " for ip='" << sinf.ip << "' in <GateList>";
if( dlog.is_crit() ) dcrit << err.str() << endl;
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -97,8 +92,7 @@ checkThread(0) ...@@ -97,8 +92,7 @@ checkThread(0)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): ERROR: Unknown SensorID for '" << it1.getProp("respond") << "' in <GateList>"; err << myname << "(init): ERROR: Unknown SensorID for '" << it1.getProp("respond") << "' in <GateList>";
if( dlog.is_crit() ) dcrit << err.str() << endl;
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
} }
...@@ -117,21 +111,19 @@ checkThread(0) ...@@ -117,21 +111,19 @@ checkThread(0)
n << sinf.ip << ":" << sinf.port; n << sinf.ip << ":" << sinf.port;
sinf.myname = n.str(); sinf.myname = n.str();
if( dlog.debugging(Debug::LEVEL9) ) if( dlog.is_level9() )
sinf.mbtcp->setLog(dlog); sinf.mbtcp->setLog(dlog);
mblist.push_back(sinf); mblist.push_back(sinf);
if( dlog.is_info() ) dinfo << myname << "(init): add slave channel " << sinf.myname << endl;
dlog.info() << myname << "(init): add slave channel " << sinf.myname << endl;
} }
if( mblist.empty() ) if( mblist.empty() )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): empty <GateList>!"; err << myname << "(init): empty <GateList>!";
if( dlog.is_crit() ) dcrit << err.str() << endl;
dlog.crit() << err.str() << endl;
throw UniSetTypes::SystemError(err.str()); throw UniSetTypes::SystemError(err.str());
} }
...@@ -234,8 +226,7 @@ bool MBTCPMultiMaster::MBSlaveInfo::init() ...@@ -234,8 +226,7 @@ bool MBTCPMultiMaster::MBSlaveInfo::init()
{ {
// ost::Thread::setException(ost::Thread::throwException); // ost::Thread::setException(ost::Thread::throwException);
if( dlog.is_info() ) dinfo << myname << "(init): connect..." << endl;
dlog.info() << myname << "(init): connect..." << endl;
mbtcp->connect(ip,port); mbtcp->connect(ip,port);
mbtcp->setForceDisconnect(force_disconnect); mbtcp->setForceDisconnect(force_disconnect);
...@@ -248,22 +239,20 @@ bool MBTCPMultiMaster::MBSlaveInfo::init() ...@@ -248,22 +239,20 @@ bool MBTCPMultiMaster::MBSlaveInfo::init()
mbtcp->setSleepPause(sleepPause_usec); mbtcp->setSleepPause(sleepPause_usec);
mbtcp->setAfterSendPause(aftersend_pause); mbtcp->setAfterSendPause(aftersend_pause);
if( mbtcp->isConnection() && dlog.is_info() ) if( mbtcp->isConnection() )
dlog.info() << "(init): " << myname << " connect OK" << endl; dinfo << "(init): " << myname << " connect OK" << endl;
initOK = true; initOK = true;
} }
return mbtcp->isConnection(); return mbtcp->isConnection();
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( dlog.is_warn() ) dwarn << "(init): " << ex << endl;
dlog.warn() << "(init): " << ex << endl;
} }
catch(...) catch(...)
{ {
if( dlog.is_warn() ) dwarn << "(init): " << myname << " catch ..." << endl;
dlog.warn() << "(init): " << myname << " catch ..." << endl;
} }
initOK = false; initOK = false;
...@@ -318,8 +307,7 @@ void MBTCPMultiMaster::check_thread() ...@@ -318,8 +307,7 @@ void MBTCPMultiMaster::check_thread()
try try
{ {
bool r = it->check(); bool r = it->check();
if( dlog.is_info() ) dinfo << myname << "(check): " << it->myname << " " << ( r ? "OK" : "FAIL" ) << endl;
dlog.info() << myname << "(check): " << it->myname << " " << ( r ? "OK" : "FAIL" ) << endl;
try try
{ {
...@@ -331,8 +319,7 @@ void MBTCPMultiMaster::check_thread() ...@@ -331,8 +319,7 @@ void MBTCPMultiMaster::check_thread()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( dlog.debugging(Debug::CRIT) ) dcrit << myname << "(check): (respond) " << ex << std::endl;
dlog.crit() << myname << "(check): (respond) " << ex << std::endl;
} }
catch(...){} catch(...){}
...@@ -382,20 +369,20 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const* ...@@ -382,20 +369,20 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const*
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1");
if( name.empty() ) if( name.empty() )
{ {
dlog.crit() << "(MBTCPMultiMaster): Не задан name'" << endl; dcrit << "(MBTCPMultiMaster): Не задан name'" << endl;
return 0; return 0;
} }
ObjectId ID = conf->getObjectID(name); ObjectId ID = conf->getObjectID(name);
if( ID == UniSetTypes::DefaultObjectId ) if( ID == UniSetTypes::DefaultObjectId )
{ {
dlog.crit() << "(MBTCPMultiMaster): идентификатор '" << name dcrit << "(MBTCPMultiMaster): идентификатор '" << name
<< "' не найден в конф. файле!" << "' не найден в конф. файле!"
<< " в секции " << conf->getObjectsSection() << endl; << " в секции " << conf->getObjectsSection() << endl;
return 0; return 0;
} }
dlog.info() << "(MBTCPMultiMaster): name = " << name << "(" << ID << ")" << endl; dinfo << "(MBTCPMultiMaster): name = " << name << "(" << ID << ")" << endl;
return new MBTCPMultiMaster(ID,icID,ic,prefix); return new MBTCPMultiMaster(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -29,7 +29,7 @@ rs_pre_clean(false) ...@@ -29,7 +29,7 @@ rs_pre_clean(false)
// если "принудительно" задан префикс // если "принудительно" задан префикс
// используем его. // используем его.
{ {
string p("--" + prefix + "-set-prop-prefix"); string p("--" + prefix + "-set-prop-prefix");
string v = conf->getArgParam(p,""); string v = conf->getArgParam(p,"");
if( !v.empty() && v[0] != '-' ) if( !v.empty() && v[0] != '-' )
prop_prefix = v; prop_prefix = v;
...@@ -38,7 +38,7 @@ rs_pre_clean(false) ...@@ -38,7 +38,7 @@ rs_pre_clean(false)
prop_prefix = ""; prop_prefix = "";
} }
dlog.info() << myname << "(init): prop_prefix=" << prop_prefix << endl; dinfo << myname << "(init): prop_prefix=" << prop_prefix << endl;
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
...@@ -108,7 +108,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -108,7 +108,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
{ {
if( !reopen ) if( !reopen )
return mbrtu; return mbrtu;
delete mbrtu; delete mbrtu;
mbrtu = 0; mbrtu = 0;
mb = 0; mb = 0;
...@@ -130,7 +130,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -130,7 +130,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
mbrtu->setSleepPause(sleepPause_usec); mbrtu->setSleepPause(sleepPause_usec);
mbrtu->setAfterSendPause(aftersend_pause); mbrtu->setAfterSendPause(aftersend_pause);
dlog.info() << myname << "(init): dev=" << devname << " speed=" << ComPort::getSpeed( mbrtu->getSpeed() ) << endl; dinfo << myname << "(init): dev=" << devname << " speed=" << ComPort::getSpeed( mbrtu->getSpeed() ) << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
...@@ -138,7 +138,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -138,7 +138,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
delete mbrtu; delete mbrtu;
mbrtu = 0; mbrtu = 0;
dlog.warn() << myname << "(init): " << ex << endl; dwarn << myname << "(init): " << ex << endl;
} }
catch(...) catch(...)
{ {
...@@ -146,7 +146,7 @@ ModbusClient* RTUExchange::initMB( bool reopen ) ...@@ -146,7 +146,7 @@ ModbusClient* RTUExchange::initMB( bool reopen )
delete mbrtu; delete mbrtu;
mbrtu = 0; mbrtu = 0;
dlog.info() << myname << "(init): catch...." << endl; dinfo << myname << "(init): catch...." << endl;
} }
mb = mbrtu; mb = mbrtu;
...@@ -204,14 +204,14 @@ void RTUExchange::poll() ...@@ -204,14 +204,14 @@ void RTUExchange::poll()
bool allNotRespond = true; bool allNotRespond = true;
ComPort::Speed s = mbrtu->getSpeed(); ComPort::Speed s = mbrtu->getSpeed();
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 ) for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{ {
RTUDevice* d(it1->second); RTUDevice* d(it1->second);
if( d->mode_id != DefaultObjectId && d->mode == emSkipExchange ) if( d->mode_id != DefaultObjectId && d->mode == emSkipExchange )
continue; continue;
if( d->speed != s ) if( d->speed != s )
{ {
s = d->speed; s = d->speed;
...@@ -223,12 +223,9 @@ void RTUExchange::poll() ...@@ -223,12 +223,9 @@ void RTUExchange::poll()
if( !d->rtu ) if( !d->rtu )
continue; continue;
if( dlog.debugging(Debug::LEVEL3) ) dlog3 << myname << "(pollRTU188): poll RTU188 "
{
dlog[Debug::LEVEL3] << myname << "(pollRTU188): poll RTU188 "
<< " mbaddr=" << ModbusRTU::addr2str(d->mbaddr) << " mbaddr=" << ModbusRTU::addr2str(d->mbaddr)
<< endl; << endl;
}
try try
{ {
...@@ -239,22 +236,18 @@ void RTUExchange::poll() ...@@ -239,22 +236,18 @@ void RTUExchange::poll()
d->resp_real = true; d->resp_real = true;
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( d->resp_real ) if( d->resp_real )
{ {
if( dlog.debugging(Debug::LEVEL3) ) dlog3 << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
{
dlog.crit() << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " -> " << ex << endl; << " -> " << ex << endl;
}
d->resp_real = false; d->resp_real = false;
} }
} }
} }
else else
{ {
if( dlog.debugging(Debug::LEVEL3) ) dlog3 << myname << "(poll): ask addr=" << ModbusRTU::addr2str(d->mbaddr)
dlog[Debug::LEVEL3] << myname << "(poll): ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " regs=" << d->regmap.size() << endl; << " regs=" << d->regmap.size() << endl;
d->resp_real = false; d->resp_real = false;
...@@ -271,16 +264,14 @@ void RTUExchange::poll() ...@@ -271,16 +264,14 @@ void RTUExchange::poll()
} }
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
// if( d->resp_real ) // if( d->resp_real )
// { // {
if( dlog.debugging(Debug::LEVEL3) ) dlog3 << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
{
dlog[Debug::LEVEL3] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " reg=" << ModbusRTU::dat2str(it->second->mbreg) << " reg=" << ModbusRTU::dat2str(it->second->mbreg)
<< " for sensors: "; print_plist(dlog(Debug::LEVEL3), it->second->slst); << " for sensors: "; print_plist(dlog(Debug::LEVEL3), it->second->slst);
dlog(Debug::LEVEL3) << " err: " << ex << endl; dlog(Debug::LEVEL3) << " err: " << ex << endl;
}
// d->resp_real = false; // d->resp_real = false;
// } // }
} }
...@@ -299,7 +290,7 @@ void RTUExchange::poll() ...@@ -299,7 +290,7 @@ void RTUExchange::poll()
// update SharedMemory... // update SharedMemory...
updateSM(); updateSM();
// check thresholds // check thresholds
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 ) for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{ {
...@@ -311,15 +302,14 @@ void RTUExchange::poll() ...@@ -311,15 +302,14 @@ void RTUExchange::poll()
IOBase::processingThreshold( &(*i),shm,force); IOBase::processingThreshold( &(*i),shm,force);
} }
} }
if( trReopen.hi(allNotRespond) ) if( trReopen.hi(allNotRespond) )
ptReopen.reset(); ptReopen.reset();
if( allNotRespond && ptReopen.checkTime() ) if( allNotRespond && ptReopen.checkTime() )
{ {
uniset_mutex_lock l(pollMutex, 300); uniset_mutex_lock l(pollMutex, 300);
if( dlog.is_warn() ) dwarn << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
dlog.warn() << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
mb = initMB(true); mb = initMB(true);
ptReopen.reset(); ptReopen.reset();
...@@ -347,7 +337,7 @@ RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, U ...@@ -347,7 +337,7 @@ RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, U
return 0; return 0;
} }
dlog.info() << "(rtuexchange): name = " << name << "(" << ID << ")" << endl; dinfo << "(rtuexchange): name = " << name << "(" << ID << ")" << endl;
return new RTUExchange(ID,icID,ic,prefix); return new RTUExchange(ID,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -355,14 +345,14 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -355,14 +345,14 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
{ {
if( !MBExchange::initDeviceInfo(m,a,it) ) if( !MBExchange::initDeviceInfo(m,a,it) )
return false; return false;
RTUDeviceMap::iterator d = m.find(a); RTUDeviceMap::iterator d = m.find(a);
if( d == m.end() ) if( d == m.end() )
{ {
dlog.warn() << myname << "(initDeviceInfo): not found device for addr=" << ModbusRTU::addr2str(a) << endl; dwarn << myname << "(initDeviceInfo): not found device for addr=" << ModbusRTU::addr2str(a) << endl;
return false; return false;
} }
string s = it.getProp("speed"); string s = it.getProp("speed");
if( !s.empty() ) if( !s.empty() )
{ {
...@@ -370,7 +360,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -370,7 +360,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
if( d->second->speed == ComPort::ComSpeed0 ) if( d->second->speed == ComPort::ComSpeed0 )
{ {
d->second->speed = defSpeed; d->second->speed = defSpeed;
dlog.crit() << myname << "(initDeviceInfo): Unknown speed=" << s << dcrit << myname << "(initDeviceInfo): Unknown speed=" << s <<
" for addr=" << ModbusRTU::addr2str(a) << endl; " for addr=" << ModbusRTU::addr2str(a) << endl;
return false; return false;
} }
......
...@@ -55,7 +55,7 @@ int main( int argc, const char** argv ) ...@@ -55,7 +55,7 @@ int main( int argc, const char** argv )
MBTCPMaster* mb = MBTCPMaster::init_mbmaster(argc,argv,shmID); MBTCPMaster* mb = MBTCPMaster::init_mbmaster(argc,argv,shmID);
if( !mb ) if( !mb )
{ {
dlog.crit() << "(mbmaster): init MBTCPMaster failed." << endl; dcrit << "(mbmaster): init MBTCPMaster failed." << endl;
return 1; return 1;
} }
...@@ -75,11 +75,11 @@ int main( int argc, const char** argv ) ...@@ -75,11 +75,11 @@ int main( int argc, const char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(mbtcpmaster): " << ex << std::endl; dcrit << "(mbtcpmaster): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(mbtcpmaster): catch ..." << std::endl; dcrit << "(mbtcpmaster): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -55,7 +55,7 @@ int main( int argc, const char** argv ) ...@@ -55,7 +55,7 @@ int main( int argc, const char** argv )
MBTCPMultiMaster* mb = MBTCPMultiMaster::init_mbmaster(argc,argv,shmID); MBTCPMultiMaster* mb = MBTCPMultiMaster::init_mbmaster(argc,argv,shmID);
if( !mb ) if( !mb )
{ {
dlog.crit() << "(mbmaster): init MBTCPMaster failed." << endl; dcrit << "(mbmaster): init MBTCPMaster failed." << endl;
return 1; return 1;
} }
...@@ -77,11 +77,11 @@ int main( int argc, const char** argv ) ...@@ -77,11 +77,11 @@ int main( int argc, const char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(mbtcpmultimaster): " << ex << std::endl; dcrit << "(mbtcpmultimaster): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(mbtcpmultimaster): catch ..." << std::endl; dcrit << "(mbtcpmultimaster): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -53,7 +53,7 @@ int main( int argc, char** argv ) ...@@ -53,7 +53,7 @@ int main( int argc, char** argv )
RTUExchange* rs = RTUExchange::init_rtuexchange(argc,argv,shmID,0,"rs"); RTUExchange* rs = RTUExchange::init_rtuexchange(argc,argv,shmID,0,"rs");
if( !rs ) if( !rs )
{ {
dlog.crit() << "(rtuexchange): init не прошёл..." << endl; dcrit << "(rtuexchange): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -75,11 +75,11 @@ int main( int argc, char** argv ) ...@@ -75,11 +75,11 @@ int main( int argc, char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(rtuexchange): " << ex << std::endl; dcrit << "(rtuexchange): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(rtuexchange): catch ..." << std::endl; dcrit << "(rtuexchange): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -60,7 +60,7 @@ int main(int argc, const char **argv) ...@@ -60,7 +60,7 @@ int main(int argc, const char **argv)
MBSlave* s = MBSlave::init_mbslave(argc,argv,shmID); MBSlave* s = MBSlave::init_mbslave(argc,argv,shmID);
if( !s ) if( !s )
{ {
dlog.crit() << "(mbslave): init не прошёл..." << endl; dcrit << "(mbslave): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -80,19 +80,19 @@ int main(int argc, const char **argv) ...@@ -80,19 +80,19 @@ int main(int argc, const char **argv)
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
dlog.crit() << "(mbslave): " << err << endl; dcrit << "(mbslave): " << err << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(mbslave): " << ex << endl; dcrit << "(mbslave): " << ex << endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
dlog.crit() << "(mbslave): " << e.what() << endl; dcrit << "(mbslave): " << e.what() << endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(mbslave): catch(...)" << endl; dcrit << "(mbslave): catch(...)" << endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -17,7 +17,7 @@ UObject_SK(objId,cnode), ...@@ -17,7 +17,7 @@ UObject_SK(objId,cnode),
shm( new SMInterface(shmId,&ui,objId,ic) ), shm( new SMInterface(shmId,&ui,objId,ic) ),
prefix(prefix) prefix(prefix)
{ {
dlog = log; mylog = log;
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
UniXML::iterator it1(cnode); UniXML::iterator it1(cnode);
...@@ -25,8 +25,7 @@ prefix(prefix) ...@@ -25,8 +25,7 @@ prefix(prefix)
{ {
ostringstream err; ostringstream err;
err << myname << "(init): empty rrd list..."; err << myname << "(init): empty rrd list...";
if( RRDServer::dlog.is_crit() ) mylog << err.str() << endl;
RRDServer::dlog.crit() << err.str() << endl;
throw NameNotFound(err.str()); throw NameNotFound(err.str());
} }
...@@ -58,8 +57,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -58,8 +57,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
int lastup = it.getPIntProp("lastup",0); int lastup = it.getPIntProp("lastup",0);
bool overwrite = it.getPIntProp("overwrite",0); bool overwrite = it.getPIntProp("overwrite",0);
if( RRDServer::dlog.is_info() ) myinfo << myname << "(init): add rrd: file='" << fname
RRDServer::dlog.info() << myname << "(init): add rrd: file='" << fname
<< " " << ff << "='" << fv << " " << ff << "='" << fv
<< "' create='" << cf << "'" << "' create='" << cf << "'"
<< " step=" << rrdstep << " step=" << rrdstep
...@@ -72,7 +70,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -72,7 +70,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): rrd='" << fname << "' Unknown RRA list"; err << myname << "(init): rrd='" << fname << "' Unknown RRA list";
RRDServer::dlog.crit() << err.str(); mycrit << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -83,8 +81,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -83,8 +81,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): rrd='" << fname << "' Unkown RRA item.. <item rra='...'"; err << myname << "(init): rrd='" << fname << "' Unkown RRA item.. <item rra='...'";
if( RRDServer::dlog.is_crit() ) mycrit << err.str();
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -95,8 +92,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -95,8 +92,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Not found RRA items..."; err << myname << "(init): Not found RRA items...";
if( RRDServer::dlog.is_crit() ) mycrit << err.str() << endl;
RRDServer::dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -108,8 +104,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -108,8 +104,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Not found section <sensors>"; err << myname << "(init): Not found section <sensors>";
if( RRDServer::dlog.is_crit() ) mycrit << err.str();
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -118,8 +113,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -118,8 +113,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): section <sensors> empty?!"; err << myname << "(init): section <sensors> empty?!";
if( RRDServer::dlog.is_crit() ) mycrit << err.str();
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -138,8 +132,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -138,8 +132,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Unknown create parameters ('" << cf << "')"; err << myname << "(init): Unknown create parameters ('" << cf << "')";
if( RRDServer::dlog.is_crit() ) mycrit << err.str();
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -153,8 +146,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -153,8 +146,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Unknown SensorID for '" << dsname << "'"; err << myname << "(init): Unknown SensorID for '" << dsname << "'";
if( RRDServer::dlog.is_crit() ) mycrit << err.str();
RRDServer::dlog.crit() << err.str();
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -166,8 +158,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -166,8 +158,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Not found RRD items..."; err << myname << "(init): Not found RRD items...";
if( RRDServer::dlog.is_crit() ) mycrit << err.str() << endl;
RRDServer::dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -187,8 +178,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -187,8 +178,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
// Собственно создаём RRD // Собственно создаём RRD
if( !overwrite && file_exist(fname) ) if( !overwrite && file_exist(fname) )
{ {
if( RRDServer::dlog.is_info() ) myinfo << myname << "(init): ignore create file='" << fname
RRDServer::dlog.info() << myname << "(init): ignore create file='" << fname
<< "'. File exist... overwrite=0." << endl; << "'. File exist... overwrite=0." << endl;
} }
else else
...@@ -198,8 +188,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -198,8 +188,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
{ {
ostringstream err; ostringstream err;
err << myname << "(init): Can`t create RRD ('" << fname << "'): err: " << string(rrd_get_error()); err << myname << "(init): Can`t create RRD ('" << fname << "'): err: " << string(rrd_get_error());
if( RRDServer::dlog.is_crit() ) mycrit << err.str() << endl;
RRDServer::dlog.crit() << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
} }
...@@ -215,11 +204,11 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -215,11 +204,11 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
} }
/* catch( Exception& ex ) /* catch( Exception& ex )
{ {
RRDServer::dlog.crit() << myname << "(init) " << ex << std::endl; mycrit << myname << "(init) " << ex << std::endl;
} }
catch( ... ) catch( ... )
{ {
RRDServer::dlog.crit() << myname << "(init): catch ..." << std::endl; mycrit << myname << "(init): catch ..." << std::endl;
} }
*/ */
} }
...@@ -240,14 +229,14 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv, ...@@ -240,14 +229,14 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
string name = conf->getArgParam("--" + prefix + "-name","RRDServer"); string name = conf->getArgParam("--" + prefix + "-name","RRDServer");
if( name.empty() ) if( name.empty() )
{ {
UniSetExtensions::dlog.crit() << "(RRDServer): Unknown name. Usage: --" << prefix << "-name" << endl; dcrit << "(RRDServer): Unknown name. Usage: --" << prefix << "-name" << endl;
return 0; return 0;
} }
ObjectId ID = conf->getObjectID(name); ObjectId ID = conf->getObjectID(name);
if( ID == UniSetTypes::DefaultObjectId ) if( ID == UniSetTypes::DefaultObjectId )
{ {
UniSetExtensions::dlog.crit() << "(RRDServer): Not found ID for '" << name dcrit << "(RRDServer): Not found ID for '" << name
<< " in '" << conf->getObjectsSection() << "' section" << endl; << " in '" << conf->getObjectsSection() << "' section" << endl;
return 0; return 0;
} }
...@@ -256,12 +245,11 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv, ...@@ -256,12 +245,11 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
xmlNode* cnode = conf->getNode(confname); xmlNode* cnode = conf->getNode(confname);
if( !cnode ) if( !cnode )
{ {
UniSetExtensions::dlog.crit() << "(RRDServer): " << name << "(init): Not found <" + confname + ">" << endl; dcrit << "(RRDServer): " << name << "(init): Not found <" + confname + ">" << endl;
return 0; return 0;
} }
if( UniSetExtensions::dlog.is_info() ) dinfo << "(RRDServer): name = " << name << "(" << ID << ")" << endl;
UniSetExtensions::dlog.info() << "(RRDServer): name = " << name << "(" << ID << ")" << endl;
return new RRDServer(ID,cnode,icID,ic,prefix); return new RRDServer(ID,cnode,icID,ic,prefix);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -279,8 +267,7 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -279,8 +267,7 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd )
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
if( RRDServer::dlog.is_crit() ) mycrit << myname << "(askSensors): " << ex.what() << endl;
RRDServer::dlog.crit() << myname << "(askSensors): " << ex.what() << endl;
} }
} }
} }
...@@ -299,8 +286,7 @@ void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm ) ...@@ -299,8 +286,7 @@ void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm )
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
if( RRDServer::dlog.is_crit() ) mycrit << myname << "(askTimer): " << ex.what() << endl;
RRDServer::dlog.crit() << myname << "(askTimer): " << ex.what() << endl;
} }
} }
} }
...@@ -330,8 +316,7 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -330,8 +316,7 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm )
for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s ) for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s )
v << ":" << s->second.value; v << ":" << s->second.value;
if( RRDServer::dlog.is_info() ) myinfo << myname << "(update): '" << it->filename << "' " << v.str() << endl;
RRDServer::dlog.info() << myname << "(update): '" << it->filename << "' " << v.str() << endl;
rrd_clear_error(); rrd_clear_error();
const char* argv = v.str().c_str(); const char* argv = v.str().c_str();
...@@ -339,8 +324,7 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -339,8 +324,7 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm )
{ {
ostringstream err; ostringstream err;
err << myname << "(update): Can`t update RRD ('" << it->filename << "'): err: " << string(rrd_get_error()); err << myname << "(update): Can`t update RRD ('" << it->filename << "'): err: " << string(rrd_get_error());
if( RRDServer::dlog.is_crit() ) mycrit << err.str() << endl;
RRDServer::dlog.crit() << err.str() << endl;
} }
break; break;
......
...@@ -54,7 +54,7 @@ int main( int argc, const char** argv ) ...@@ -54,7 +54,7 @@ int main( int argc, const char** argv )
RRDServer* db = RRDServer::init_rrdstorage(argc,argv,shmID); RRDServer* db = RRDServer::init_rrdstorage(argc,argv,shmID);
if( !db ) if( !db )
{ {
dlog.crit() << "(rrdstorage): init не прошёл..." << endl; dcrit << "(rrdstorage): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -73,11 +73,11 @@ int main( int argc, const char** argv ) ...@@ -73,11 +73,11 @@ int main( int argc, const char** argv )
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
dlog.crit() << "(rrdstorage): " << ex << std::endl; dcrit << "(rrdstorage): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(rrdstorage): catch ..." << std::endl; dcrit << "(rrdstorage): catch ..." << std::endl;
} }
return 1; return 1;
......
...@@ -54,7 +54,7 @@ int main( int argc, const char** argv ) ...@@ -54,7 +54,7 @@ int main( int argc, const char** argv )
SMDBServer* db = SMDBServer::init_smdbserver(argc,argv,shmID); SMDBServer* db = SMDBServer::init_smdbserver(argc,argv,shmID);
if( !db ) if( !db )
{ {
dlog.crit() << "(smdbserver): init не прошёл..." << endl; dcrit << "(smdbserver): init не прошёл..." << endl;
return 1; return 1;
} }
...@@ -73,11 +73,11 @@ int main( int argc, const char** argv ) ...@@ -73,11 +73,11 @@ int main( int argc, const char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(smdbserver): " << ex << std::endl; dcrit << "(smdbserver): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(smdbserver): catch ..." << std::endl; dcrit << "(smdbserver): catch ..." << std::endl;
} }
return 1; return 1;
......
...@@ -50,7 +50,7 @@ a_cache_init_ok(false) ...@@ -50,7 +50,7 @@ a_cache_init_ok(false)
s << "R(" << setw(15) << s_host << ":" << setw(4) << port << ")"; s << "R(" << setw(15) << s_host << ":" << setw(4) << port << ")";
myname = s.str(); myname = s.str();
} }
ost::Thread::setException(ost::Thread::throwException); ost::Thread::setException(ost::Thread::throwException);
try try
{ {
...@@ -64,14 +64,14 @@ a_cache_init_ok(false) ...@@ -64,14 +64,14 @@ a_cache_init_ok(false)
{ {
ostringstream s; ostringstream s;
s << myname << ": " << e.what(); s << myname << ": " << e.what();
dlog.crit() << s.str() << std::endl; dcrit << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
catch( ... ) catch( ... )
{ {
ostringstream s; ostringstream s;
s << myname << ": catch..."; s << myname << ": catch...";
dlog.crit() << s.str() << std::endl; dcrit << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
...@@ -144,7 +144,7 @@ void UNetReceiver::setLostPacketsID( UniSetTypes::ObjectId id ) ...@@ -144,7 +144,7 @@ void UNetReceiver::setLostPacketsID( UniSetTypes::ObjectId id )
void UNetReceiver::setLockUpdate( bool st ) void UNetReceiver::setLockUpdate( bool st )
{ {
uniset_rwmutex_wrlock l(lockMutex); uniset_rwmutex_wrlock l(lockMutex);
lockUpdate = st; lockUpdate = st;
if( !st ) if( !st )
ptPrepare.reset(); ptPrepare.reset();
} }
...@@ -152,8 +152,8 @@ void UNetReceiver::setLockUpdate( bool st ) ...@@ -152,8 +152,8 @@ void UNetReceiver::setLockUpdate( bool st )
void UNetReceiver::resetTimeout() void UNetReceiver::resetTimeout()
{ {
uniset_rwmutex_wrlock l(tmMutex); uniset_rwmutex_wrlock l(tmMutex);
ptRecvTimeout.reset(); ptRecvTimeout.reset();
trTimeout.change(false); trTimeout.change(false);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::start() void UNetReceiver::start()
...@@ -177,11 +177,11 @@ void UNetReceiver::update() ...@@ -177,11 +177,11 @@ void UNetReceiver::update()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog.crit() << myname << "(update): " << ex << std::endl; dcrit << myname << "(update): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << myname << "(update): catch ..." << std::endl; dcrit << myname << "(update): catch ..." << std::endl;
} }
if( sidRespond!=DefaultObjectId ) if( sidRespond!=DefaultObjectId )
...@@ -193,7 +193,7 @@ void UNetReceiver::update() ...@@ -193,7 +193,7 @@ void UNetReceiver::update()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog.crit() << myname << "(step): (respond) " << ex << std::endl; dcrit << myname << "(step): (respond) " << ex << std::endl;
} }
} }
...@@ -205,10 +205,10 @@ void UNetReceiver::update() ...@@ -205,10 +205,10 @@ void UNetReceiver::update()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
dlog.crit() << myname << "(step): (lostPackets) " << ex << std::endl; dcrit << myname << "(step): (lostPackets) " << ex << std::endl;
} }
} }
msleep(updatepause); msleep(updatepause);
} }
} }
...@@ -286,7 +286,7 @@ void UNetReceiver::real_update() ...@@ -286,7 +286,7 @@ void UNetReceiver::real_update()
ItemInfo& ii(d_icache[i]); ItemInfo& ii(d_icache[i]);
if( ii.id != id ) if( ii.id != id )
{ {
dlog.warn() << myname << "(update): reinit cache for sid=" << id << endl; dwarn << myname << "(update): reinit cache for sid=" << id << endl;
ii.id = id; ii.id = id;
shm->initIterator(ii.ioit); shm->initIterator(ii.ioit);
} }
...@@ -302,11 +302,11 @@ void UNetReceiver::real_update() ...@@ -302,11 +302,11 @@ void UNetReceiver::real_update()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog.crit() << myname << "(update): " << ex << std::endl; dcrit << myname << "(update): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << myname << "(update): catch ..." << std::endl; dcrit << myname << "(update): catch ..." << std::endl;
} }
} }
...@@ -319,7 +319,7 @@ void UNetReceiver::real_update() ...@@ -319,7 +319,7 @@ void UNetReceiver::real_update()
ItemInfo& ii(a_icache[i]); ItemInfo& ii(a_icache[i]);
if( ii.id != d.id ) if( ii.id != d.id )
{ {
dlog.warn() << myname << "(update): reinit cache for sid=" << d.id << endl; dwarn << myname << "(update): reinit cache for sid=" << d.id << endl;
ii.id = d.id; ii.id = d.id;
shm->initIterator(ii.ioit); shm->initIterator(ii.ioit);
} }
...@@ -335,11 +335,11 @@ void UNetReceiver::real_update() ...@@ -335,11 +335,11 @@ void UNetReceiver::real_update()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog.crit() << myname << "(update): " << ex << std::endl; dcrit << myname << "(update): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << myname << "(update): catch ..." << std::endl; dcrit << myname << "(update): catch ..." << std::endl;
} }
} }
} }
...@@ -356,8 +356,7 @@ void UNetReceiver::stop() ...@@ -356,8 +356,7 @@ void UNetReceiver::stop()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::receive() void UNetReceiver::receive()
{ {
if( dlog.is_info() ) dinfo << myname << ": ******************* receive start" << endl;
dlog.info() << myname << ": ******************* receive start" << endl;
{ {
uniset_rwmutex_wrlock l(tmMutex); uniset_rwmutex_wrlock l(tmMutex);
...@@ -377,18 +376,15 @@ void UNetReceiver::receive() ...@@ -377,18 +376,15 @@ void UNetReceiver::receive()
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
if( dlog.is_warn() ) dwarn << myname << "(receive): " << ex << std::endl;
dlog.warn() << myname << "(receive): " << ex << std::endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
if( dlog.is_warn() ) dwarn << myname << "(receive): " << e.what()<< std::endl;
dlog.warn() << myname << "(receive): " << e.what()<< std::endl;
} }
catch(...) catch(...)
{ {
if( dlog.is_warn() ) dwarn << myname << "(receive): catch ..." << std::endl;
dlog.warn() << myname << "(receive): catch ..." << std::endl;
} }
// делаем через промежуточную переменную // делаем через промежуточную переменную
...@@ -397,7 +393,7 @@ void UNetReceiver::receive() ...@@ -397,7 +393,7 @@ void UNetReceiver::receive()
uniset_rwmutex_rlock l(tmMutex); uniset_rwmutex_rlock l(tmMutex);
tout = ptRecvTimeout.checkTime(); tout = ptRecvTimeout.checkTime();
} }
// только если "режим подготовки закончился, то можем генерировать "события" // только если "режим подготовки закончился, то можем генерировать "события"
if( ptPrepare.checkTime() && trTimeout.change(tout) ) if( ptPrepare.checkTime() && trTimeout.change(tout) )
{ {
...@@ -410,8 +406,7 @@ void UNetReceiver::receive() ...@@ -410,8 +406,7 @@ void UNetReceiver::receive()
msleep(recvpause); msleep(recvpause);
} }
if( dlog.is_info() ) dinfo << myname << ": ************* receive FINISH **********" << endl;
dlog.info() << myname << ": ************* receive FINISH **********" << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UNetReceiver::recv() bool UNetReceiver::recv()
...@@ -424,7 +419,7 @@ bool UNetReceiver::recv() ...@@ -424,7 +419,7 @@ bool UNetReceiver::recv()
size_t sz = UniSetUDP::UDPMessage::getMessage(pack,r_buf); size_t sz = UniSetUDP::UDPMessage::getMessage(pack,r_buf);
if( sz == 0 ) if( sz == 0 )
{ {
dlog.crit() << myname << "(receive): FAILED RECEIVE DATA ret=" << ret << endl; dcrit << myname << "(receive): FAILED RECEIVE DATA ret=" << ret << endl;
return false; return false;
} }
...@@ -439,7 +434,7 @@ bool UNetReceiver::recv() ...@@ -439,7 +434,7 @@ bool UNetReceiver::recv()
// Обычно "кольцевой". Т.е. если не успели обработать и "вынуть" из буфера информацию.. он будет переписан новыми данными // Обычно "кольцевой". Т.е. если не успели обработать и "вынуть" из буфера информацию.. он будет переписан новыми данными
if( waitClean ) if( waitClean )
{ {
dlog.crit() << myname << "(receive): reset qtmp.." << endl; dcrit << myname << "(receive): reset qtmp.." << endl;
while( !qtmp.empty() ) while( !qtmp.empty() )
qtmp.pop(); qtmp.pop();
} }
...@@ -510,7 +505,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -510,7 +505,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
if( !force && pack.dcount == d_icache.size() ) if( !force && pack.dcount == d_icache.size() )
return; return;
dlog.info() << myname << ": init icache.." << endl; dinfo << myname << ": init icache.." << endl;
d_cache_init_ok = true; d_cache_init_ok = true;
d_icache.resize(pack.dcount); d_icache.resize(pack.dcount);
...@@ -532,7 +527,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -532,7 +527,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
if( !force && pack.acount == a_icache.size() ) if( !force && pack.acount == a_icache.size() )
return; return;
dlog.info() << myname << ": init icache.." << endl; dinfo << myname << ": init icache.." << endl;
a_cache_init_ok = true; a_cache_init_ok = true;
a_icache.resize(pack.acount); a_icache.resize(pack.acount);
......
...@@ -31,11 +31,10 @@ s_thr(0) ...@@ -31,11 +31,10 @@ s_thr(0)
// определяем фильтр // определяем фильтр
// s_field = conf->getArgParam("--udp-filter-field"); // s_field = conf->getArgParam("--udp-filter-field");
// s_fvalue = conf->getArgParam("--udp-filter-value"); // s_fvalue = conf->getArgParam("--udp-filter-value");
dlog.info() << myname << "(init): read filter-field='" << s_field dinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
if( dlog.is_info() ) dinfo << "(UNetSender): UDP set to " << s_host << ":" << port << endl;
dlog.info() << "(UNetSender): UDP set to " << s_host << ":" << port << endl;
ost::Thread::setException(ost::Thread::throwException); ost::Thread::setException(ost::Thread::throwException);
try try
...@@ -47,14 +46,14 @@ s_thr(0) ...@@ -47,14 +46,14 @@ s_thr(0)
{ {
ostringstream s; ostringstream s;
s << myname << ": " << e.what(); s << myname << ": " << e.what();
dlog.crit() << s.str() << std::endl; dcrit << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
catch( ... ) catch( ... )
{ {
ostringstream s; ostringstream s;
s << myname << ": catch..."; s << myname << ": catch...";
dlog.crit() << s.str() << std::endl; dcrit << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
...@@ -65,7 +64,7 @@ s_thr(0) ...@@ -65,7 +64,7 @@ s_thr(0)
{ {
readConfiguration(); readConfiguration();
dlist.resize(maxItem); dlist.resize(maxItem);
dlog.info() << myname << "(init): dlist size = " << dlist.size() << endl; dinfo << myname << "(init): dlist size = " << dlist.size() << endl;
} }
else else
ic->addReadItem( sigc::mem_fun(this,&UNetSender::readItem) ); ic->addReadItem( sigc::mem_fun(this,&UNetSender::readItem) );
...@@ -130,18 +129,18 @@ void UNetSender::updateItem( DMap::iterator& it, long value ) ...@@ -130,18 +129,18 @@ void UNetSender::updateItem( DMap::iterator& it, long value )
void UNetSender::send() void UNetSender::send()
{ {
dlist.resize(maxItem); dlist.resize(maxItem);
dlog.info() << myname << "(send): dlist size = " << dlist.size() << endl; dinfo << myname << "(send): dlist size = " << dlist.size() << endl;
/* /*
ost::IPV4Broadcast h = s_host.c_str(); ost::IPV4Broadcast h = s_host.c_str();
try try
{ {
udp->setPeer(h,port); udp->setPeer(h,port);
} }
catch( ost::SockException& e ) catch( ost::SockException& e )
{ {
ostringstream s; ostringstream s;
s << e.getString() << ": " << e.getSystemErrorString(); s << e.getString() << ": " << e.getSystemErrorString();
dlog.crit() << myname << "(poll): " << s.str() << endl; dcrit << myname << "(poll): " << s.str() << endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
*/ */
...@@ -156,25 +155,25 @@ void UNetSender::send() ...@@ -156,25 +155,25 @@ void UNetSender::send()
} }
catch( ost::SockException& e ) catch( ost::SockException& e )
{ {
dlog.warn() << myname << "(send): " << e.getString() << endl; dwarn << myname << "(send): " << e.getString() << endl;
} }
catch( UniSetTypes::Exception& ex) catch( UniSetTypes::Exception& ex)
{ {
dlog.warn() << myname << "(send): " << ex << std::endl; dwarn << myname << "(send): " << ex << std::endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
dlog.warn() << myname << "(send): " << e.what() << std::endl; dwarn << myname << "(send): " << e.what() << std::endl;
} }
catch(...) catch(...)
{ {
dlog.warn() << myname << "(send): catch ..." << std::endl; dwarn << myname << "(send): catch ..." << std::endl;
} }
msleep(sendpause); msleep(sendpause);
} }
dlog.info() << "************* execute FINISH **********" << endl; dinfo << "************* execute FINISH **********" << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::real_send() void UNetSender::real_send()
...@@ -191,7 +190,7 @@ void UNetSender::real_send() ...@@ -191,7 +190,7 @@ void UNetSender::real_send()
mypack.transport_msg(s_msg); mypack.transport_msg(s_msg);
size_t ret = udp->send( (char*)s_msg.data, s_msg.len ); size_t ret = udp->send( (char*)s_msg.data, s_msg.len );
if( ret < s_msg.len ) if( ret < s_msg.len )
dlog.crit() << myname << "(real_send): FAILED ret=" << ret << " < sizeof=" << s_msg.len << endl; dcrit << myname << "(real_send): FAILED ret=" << ret << " < sizeof=" << s_msg.len << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::stop() void UNetSender::stop()
...@@ -245,7 +244,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -245,7 +244,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
string sname( it.getProp("name") ); string sname( it.getProp("name") );
string tid(it.getProp("id")); string tid(it.getProp("id"));
ObjectId sid; ObjectId sid;
if( !tid.empty() ) if( !tid.empty() )
{ {
...@@ -258,8 +257,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -258,8 +257,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
if( dlog ) dcrit << myname << "(readItem): ID not found for "
dlog.crit() << myname << "(readItem): ID not found for "
<< sname << endl; << sname << endl;
return false; return false;
} }
...@@ -269,7 +267,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -269,7 +267,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
if( p.iotype == UniversalIO::UnknownIOType ) if( p.iotype == UniversalIO::UnknownIOType )
{ {
dlog.crit() << myname << "(readItem): Unknown iotype for sid=" << sid << endl; dcrit << myname << "(readItem): Unknown iotype for sid=" << sid << endl;
return false; return false;
} }
...@@ -280,8 +278,8 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -280,8 +278,8 @@ bool UNetSender::initItem( UniXML_iterator& it )
p.pack_ind = mypack.addDData(sid,0); p.pack_ind = mypack.addDData(sid,0);
if ( p.pack_ind >= UniSetUDP::MaxDCount ) if ( p.pack_ind >= UniSetUDP::MaxDCount )
{ {
dlog.crit() << myname dcrit << myname
<< "(readItem): OVERFLOW! MAX UDP DIGITAL DATA LIMIT! max=" << "(readItem): OVERFLOW! MAX UDP DIGITAL DATA LIMIT! max="
<< UniSetUDP::MaxDCount << endl; << UniSetUDP::MaxDCount << endl;
raise(SIGTERM); raise(SIGTERM);
...@@ -293,8 +291,8 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -293,8 +291,8 @@ bool UNetSender::initItem( UniXML_iterator& it )
p.pack_ind = mypack.addAData(sid,0); p.pack_ind = mypack.addAData(sid,0);
if ( p.pack_ind >= UniSetUDP::MaxACount ) if ( p.pack_ind >= UniSetUDP::MaxACount )
{ {
dlog.crit() << myname dcrit << myname
<< "(readItem): OVERFLOW! MAX UDP ANALOG DATA LIMIT! max=" << "(readItem): OVERFLOW! MAX UDP ANALOG DATA LIMIT! max="
<< UniSetUDP::MaxACount << endl; << UniSetUDP::MaxACount << endl;
raise(SIGTERM); raise(SIGTERM);
return false; return false;
...@@ -307,8 +305,7 @@ bool UNetSender::initItem( UniXML_iterator& it ) ...@@ -307,8 +305,7 @@ bool UNetSender::initItem( UniXML_iterator& it )
dlist[maxItem] = p; dlist[maxItem] = p;
maxItem++; maxItem++;
if( dlog.is_info() ) dinfo << myname << "(initItem): add " << p << endl;
dlog.info() << myname << "(initItem): add " << p << endl;
return true; return true;
} }
......
...@@ -52,7 +52,7 @@ int main( int argc, const char** argv ) ...@@ -52,7 +52,7 @@ int main( int argc, const char** argv )
UNetExchange* unet = UNetExchange::init_unetexchange(argc,argv,shmID); UNetExchange* unet = UNetExchange::init_unetexchange(argc,argv,shmID);
if( !unet ) if( !unet )
{ {
dlog.crit() << "(unetexchange): init failed.." << endl; dcrit << "(unetexchange): init failed.." << endl;
return 1; return 1;
} }
...@@ -72,11 +72,11 @@ int main( int argc, const char** argv ) ...@@ -72,11 +72,11 @@ int main( int argc, const char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.crit() << "(unetexchange): " << ex << std::endl; dcrit << "(unetexchange): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
dlog.crit() << "(unetexchange): catch ..." << std::endl; dcrit << "(unetexchange): catch ..." << std::endl;
} }
while( waitpid(-1, 0, 0) > 0 ); while( waitpid(-1, 0, 0) > 0 );
......
...@@ -36,18 +36,18 @@ smReadyTimeout(15000) ...@@ -36,18 +36,18 @@ smReadyTimeout(15000)
s_field = conf->getArgParam("--" + prefix + "-filter-field"); s_field = conf->getArgParam("--" + prefix + "-filter-field");
s_fvalue = conf->getArgParam("--" + prefix + "-filter-value"); s_fvalue = conf->getArgParam("--" + prefix + "-filter-value");
dlog.info() << myname << "(init): read fileter-field='" << s_field dinfo << myname << "(init): read fileter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
polltime = conf->getArgInt("--" + prefix + "-polltime",it.getProp("polltime")); polltime = conf->getArgInt("--" + prefix + "-polltime",it.getProp("polltime"));
if( polltime <= 0 ) if( polltime <= 0 )
polltime = 200; polltime = 200;
dlog.info() << myname << "(init): polltime=" << polltime << endl; dinfo << myname << "(init): polltime=" << polltime << endl;
int updatetime = conf->getArgInt("--" + prefix + "-updatetime",it.getProp("updatetime")); int updatetime = conf->getArgInt("--" + prefix + "-updatetime",it.getProp("updatetime"));
if( updatetime <= 0 ) if( updatetime <= 0 )
updatetime = 200; updatetime = 200;
dlog.info() << myname << "(init): updatetime=" << polltime << endl; dinfo << myname << "(init): updatetime=" << polltime << endl;
ptUpdate.setTiming(updatetime); ptUpdate.setTiming(updatetime);
...@@ -57,7 +57,7 @@ smReadyTimeout(15000) ...@@ -57,7 +57,7 @@ smReadyTimeout(15000)
else if( smReadyTimeout < 0 ) else if( smReadyTimeout < 0 )
smReadyTimeout = UniSetTimer::WaitUpTime; smReadyTimeout = UniSetTimer::WaitUpTime;
dlog.info() << myname << "(init): smReadyTimeout=" << smReadyTimeout << endl; dinfo << myname << "(init): smReadyTimeout=" << smReadyTimeout << endl;
if( it.goChildren() ) if( it.goChildren() )
{ {
...@@ -97,7 +97,7 @@ smReadyTimeout(15000) ...@@ -97,7 +97,7 @@ smReadyTimeout(15000)
ni.node = node; ni.node = node;
ni.sidConnection = conf->getSensorID(it.getProp("sid_connection")); ni.sidConnection = conf->getSensorID(it.getProp("sid_connection"));
dlog.info() << myname << ": add point " << n << ":" << n1 << endl; dinfo << myname << ": add point " << n << ":" << n1 << endl;
nlst.push_back(ni); nlst.push_back(ni);
} }
} }
...@@ -150,23 +150,21 @@ void UniExchange::execute() ...@@ -150,23 +150,21 @@ void UniExchange::execute()
bool ok = false; bool ok = false;
try try
{ {
if( dlog.is_info() ) dinfo << myname << ": connect to id=" << it->id << " node=" << it->node << endl;
dlog.info() << myname << ": connect to id=" << it->id << " node=" << it->node << endl;
IOController_i::ShortMapSeq_var sseq = ui.getSensors( it->id, it->node ); IOController_i::ShortMapSeq_var sseq = ui.getSensors( it->id, it->node );
ok = true; ok = true;
if( dlog.is_info() ) dinfo << myname << " update sensors from id=" << it->id << " node=" << it->node << endl;
dlog.info() << myname << " update sensors from id=" << it->id << " node=" << it->node << endl;
it->update(sseq,shm); it->update(sseq,shm);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.info() << myname << "(execute): " << ex << endl; dwarn << myname << "(execute): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
dlog.info() << myname << "(execute): catch ..." << endl; dwarn << myname << "(execute): catch ..." << endl;
} }
if( it->sidConnection != DefaultObjectId ) if( it->sidConnection != DefaultObjectId )
...@@ -177,15 +175,14 @@ void UniExchange::execute() ...@@ -177,15 +175,14 @@ void UniExchange::execute()
} }
catch(...) catch(...)
{ {
if( dlog.is_crit() ) dcrit << myname << "(execute): sensor not avalible "
dlog.crit()<< myname << "(execute): sensor not avalible "
<< conf->oind->getNameById( it->sidConnection) << conf->oind->getNameById( it->sidConnection)
<< endl; << endl;
} }
} }
if( !ok && dlog.is_info() ) if( !ok )
dlog.info() << myname << ": ****** cannot connect with node=" << it->node << endl; dinfo << myname << ": ****** cannot connect with node=" << it->node << endl;
} }
if( ptUpdate.checkTime() ) if( ptUpdate.checkTime() )
...@@ -234,11 +231,11 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI ...@@ -234,11 +231,11 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.info() << "(update): " << ex << endl; dwarn << "(update): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
dlog.info() << "(update): catch ..." << endl; dwarn << "(update): catch ..." << endl;
} }
} }
} }
...@@ -278,11 +275,11 @@ void UniExchange::updateLocalData() ...@@ -278,11 +275,11 @@ void UniExchange::updateLocalData()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.warn() << "(update): " << ex << endl; dwarn << "(update): " << ex << endl;
} }
catch( ... ) catch( ... )
{ {
dlog.warn() << "(update): catch ..." << endl; dwarn << "(update): catch ..." << endl;
} }
} }
...@@ -443,8 +440,7 @@ bool UniExchange::initItem( UniXML_iterator& it ) ...@@ -443,8 +440,7 @@ bool UniExchange::initItem( UniXML_iterator& it )
if( i.id == DefaultObjectId ) if( i.id == DefaultObjectId )
{ {
if( dlog ) dcrit << myname << "(initItem): Unknown ID for "
dlog.crit() << myname << "(initItem): Unknown ID for "
<< it.getProp("name") << endl; << it.getProp("name") << endl;
return false; return false;
} }
...@@ -452,8 +448,7 @@ bool UniExchange::initItem( UniXML_iterator& it ) ...@@ -452,8 +448,7 @@ bool UniExchange::initItem( UniXML_iterator& it )
i.type = UniSetTypes::getIOType(it.getProp("iotype")); i.type = UniSetTypes::getIOType(it.getProp("iotype"));
if( i.type == UniversalIO::UnknownIOType ) if( i.type == UniversalIO::UnknownIOType )
{ {
if( dlog ) dcrit << myname << "(initItem): Unknown iotype= "
dlog.crit() << myname << "(initItem): Unknown iotype= "
<< it.getProp("iotype") << " for " << it.getProp("name") << endl; << it.getProp("iotype") << " for " << it.getProp("name") << endl;
return false; return false;
} }
......
...@@ -31,4 +31,21 @@ namespace UniSetExtensions ...@@ -31,4 +31,21 @@ namespace UniSetExtensions
extern DebugStream dlog; extern DebugStream dlog;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// "синтаксический сахар"..для логов
#define dinfo if( UniSetExtensions::dlog.debugging(Debug::INFO) ) UniSetExtensions::dlog
#define dwarn if( UniSetExtensions::dlog.debugging(Debug::WARN) ) UniSetExtensions::dlog
#define dcrit if( UniSetExtensions::dlog.debugging(Debug::CRIT) ) UniSetExtensions::dlog
#define dlog1 if( UniSetExtensions::dlog.debugging(Debug::LEVEL1) ) UniSetExtensions::dlog
#define dlog2 if( UniSetExtensions::dlog.debugging(Debug::LEVEL2) ) UniSetExtensions::dlog
#define dlog3 if( UniSetExtensions::dlog.debugging(Debug::LEVEL3) ) UniSetExtensions::dlog
#define dlog4 if( UniSetExtensions::dlog.debugging(Debug::LEVEL4) ) UniSetExtensions::dlog
#define dlog5 if( UniSetExtensions::dlog.debugging(Debug::LEVEL5) ) UniSetExtensions::dlog
#define dlog6 if( UniSetExtensions::dlog.debugging(Debug::LEVEL6) ) UniSetExtensions::dlog
#define dlog7 if( UniSetExtensions::dlog.debugging(Debug::LEVEL7) ) UniSetExtensions::dlog
#define dlog8 if( UniSetExtensions::dlog.debugging(Debug::LEVEL8) ) UniSetExtensions::dlog
#define dlog9 if( UniSetExtensions::dlog.debugging(Debug::LEVEL9) ) UniSetExtensions::dlog
#define dlogsys if( UniSetExtensions::dlog.debugging(Debug::SYSTEM) ) UniSetExtensions::dlog
#define dlogrep if( UniSetExtensions::dlog.debugging(Debug::REPOSITORY) ) UniSetExtensions::dlog
// -------------------------------------------------------------------------
#endif // Extensions_H_ #endif // Extensions_H_
// -------------------------------------------------------------------------
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
/* /*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE. DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST. ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ. НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2013-12-17+04:00 // generate timestamp: 2014-01-23+04:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -21,106 +21,120 @@ ...@@ -21,106 +21,120 @@
#include "DebugStream.h" #include "DebugStream.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
class UObject_SK: class UObject_SK:
public UniSetObject, public UniSetObject,
public LT_Object public LT_Object
{ {
public: public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::conf->getNode("UObject"), const std::string& argprefix="" ); UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::conf->getNode("UObject"), const std::string& argprefix="" );
UObject_SK(); UObject_SK();
virtual ~UObject_SK(); virtual ~UObject_SK();
bool alarm( UniSetTypes::ObjectId sid, bool state );
long getValue( UniSetTypes::ObjectId sid );
void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() );
void updateValues();
void setMsg( UniSetTypes::ObjectId code, bool state );
bool alarm( UniSetTypes::ObjectId sid, bool state ); DebugStream mylog;
long getValue( UniSetTypes::ObjectId sid ); void init_mylog( DebugStream& d );
void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() );
void updateValues();
void setMsg( UniSetTypes::ObjectId code, bool state );
DebugStream dlog; // "синтаксический сахар"..для логов
void init_dlog(DebugStream& dlog); #define myinfo if( mylog.debugging(Debug::INFO) ) mylog
#define mywarn if( mylog.debugging(Debug::WARN) ) mylog
#define mycrit if( mylog.debugging(Debug::CRIT) ) mylog
#define mylog1 if( mylog.debugging(Debug::LEVEL1) ) mylog
#define mylog2 if( mylog.debugging(Debug::LEVEL2) ) mylog
#define mylog3 if( mylog.debugging(Debug::LEVEL3) ) mylog
#define mylog4 if( mylog.debugging(Debug::LEVEL4) ) mylog
#define mylog5 if( mylog.debugging(Debug::LEVEL5) ) mylog
#define mylog6 if( mylog.debugging(Debug::LEVEL6) ) mylog
#define mylog7 if( mylog.debugging(Debug::LEVEL7) ) mylog
#define mylog8 if( mylog.debugging(Debug::LEVEL8) ) mylog
#define mylog9 if( mylog.debugging(Debug::LEVEL9) ) mylog
// Используемые идентификаторы // Используемые идентификаторы
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
// Текущее значение и предыдущее значение // Текущее значение и предыдущее значение
// --- public variables --- // --- public variables ---
// --- end of public variables --- // --- end of public variables ---
protected: protected:
// --- protected variables --- // --- protected variables ---
// ---- end of protected variables ---- // ---- end of protected variables ----
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( UniSetTypes::SystemMessage* sm );
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( UniSetTypes::SensorMessage* sm ){} virtual void sensorInfo( UniSetTypes::SensorMessage* sm ){}
virtual void timerInfo( UniSetTypes::TimerMessage* tm ){} virtual void timerInfo( 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 );
void updatePreviousValues(); void updatePreviousValues();
void checkSensors(); void checkSensors();
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( UniSetTypes::SensorMessage* sm );
void preTimerInfo( UniSetTypes::TimerMessage* tm ); void preTimerInfo( 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();
Trigger trResetMsg; Trigger trResetMsg;
PassiveTimer ptResetMsg; PassiveTimer ptResetMsg;
int resetMsgTime; int resetMsgTime;
// Выполнение очередного шага программы // Выполнение очередного шага программы
virtual void step()=0; virtual void step()=0;
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
UniSetTypes::ObjectId smTestID; /*!< идентификатор датчика для тестирования готовности SM */ UniSetTypes::ObjectId smTestID; /*!< идентификатор датчика для тестирования готовности SM */
// управление датчиком "сердцебиения" // управление датчиком "сердцебиения"
PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */ PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */
UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */ UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */
int maxHeartBeat; /*! < сохраняемое значение */ int maxHeartBeat; /*! < сохраняемое значение */
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */ /*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::conf->getIntProp(confnode, name); } int getIntProp(const std::string& name) { return UniSetTypes::conf->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */ /*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name) { return UniSetTypes::conf->getProp(confnode, name); } inline const std::string getProp(const std::string& name) { return UniSetTypes::conf->getProp(confnode, name); }
int smReadyTimeout; /*!< время ожидания готовности SM */ int smReadyTimeout; /*!< время ожидания готовности SM */
bool activated; bool activated;
int activateTimeout; /*!< время ожидания готовности UniSetObject к работе */ int activateTimeout; /*!< время ожидания готовности UniSetObject к работе */
PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */ PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int askPause; /*!< пауза между неудачными попытками заказать датчики */ int askPause; /*!< пауза между неудачными попытками заказать датчики */
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
private: private:
// --- private variables --- // --- private variables ---
// --- end of private variables --- // --- end of private variables ---
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода) bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -24,7 +24,7 @@ namespace UniSetExtensions ...@@ -24,7 +24,7 @@ namespace UniSetExtensions
{ {
ostringstream err; ostringstream err;
err << ": Unknown ID for '" << sname << "'" << endl; err << ": Unknown ID for '" << sname << "'" << endl;
dlog.crit() << err.str() << endl; dcrit << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -53,11 +53,10 @@ namespace UniSetExtensions ...@@ -53,11 +53,10 @@ namespace UniSetExtensions
if( heartBeatTime <= 0 ) if( heartBeatTime <= 0 )
{ {
heartBeatTime = 0; heartBeatTime = 0;
dlog.warn() << "(getHeartBeatTime): механизм 'HEARTBEAT' ОТКЛЮЧЁН!" << endl; dwarn << "(getHeartBeatTime): механизм 'HEARTBEAT' ОТКЛЮЧЁН!" << endl;
} }
if( dlog.is_info() ) dinfo << "(getHeartBeatTime): heartbeat time = " << heartBeatTime << endl;
dlog.info() << "(getHeartBeatTime): heartbeat time = " << heartBeatTime << endl;
return heartBeatTime; return heartBeatTime;
} }
...@@ -114,7 +113,7 @@ namespace UniSetExtensions ...@@ -114,7 +113,7 @@ namespace UniSetExtensions
{ {
ostringstream err; ostringstream err;
err << "(buildCalibrationDiagram): НЕ НАЙДЕН корневой узел для калибровочных диаграмм"; err << "(buildCalibrationDiagram): НЕ НАЙДЕН корневой узел для калибровочных диаграмм";
dlog.crit() << err.str() << endl; dcrit << err.str() << endl;
throw SystemError( err.str()); throw SystemError( err.str());
} }
...@@ -123,7 +122,7 @@ namespace UniSetExtensions ...@@ -123,7 +122,7 @@ namespace UniSetExtensions
{ {
ostringstream err; ostringstream err;
err << "(buildCalibrationDiagram): НЕ НАЙДЕНА калибровочная диаграмма '" << dname << "'"; err << "(buildCalibrationDiagram): НЕ НАЙДЕНА калибровочная диаграмма '" << dname << "'";
dlog.crit() << err.str() << endl; dcrit << err.str() << endl;
throw SystemError( err.str()); throw SystemError( err.str());
} }
......
...@@ -51,24 +51,24 @@ using namespace UniSetTypes; ...@@ -51,24 +51,24 @@ using namespace UniSetTypes;
} \ } \
catch( IOController_i::NameNotFound &ex ) \ catch( IOController_i::NameNotFound &ex ) \
{ \ { \
ulog.warn() << "(" << __STRING(fname) << "): " << ex.err << endl; \ uwarn << "(" << __STRING(fname) << "): " << ex.err << endl; \
} \ } \
catch( IOController_i::IOBadParam &ex ) \ catch( IOController_i::IOBadParam &ex ) \
{ \ { \
ulog.warn() << "(" << __STRING(fname) << "): " << ex.err << endl; \ uwarn << "(" << __STRING(fname) << "): " << ex.err << endl; \
} \ } \
catch( Exception& ex ) \ catch( Exception& ex ) \
{ \ { \
ulog.warn() << "(" << __STRING(fname) << "): " << ex << endl; \ uwarn << "(" << __STRING(fname) << "): " << ex << endl; \
} \ } \
catch(CORBA::SystemException& ex) \ catch(CORBA::SystemException& ex) \
{ \ { \
ulog.warn() << "(" << __STRING(fname) << "): CORBA::SystemException: " \ uwarn << "(" << __STRING(fname) << "): CORBA::SystemException: " \
<< ex.NP_minorString() << endl; \ << ex.NP_minorString() << endl; \
} \ } \
catch(...) \ catch(...) \
{ \ { \
ulog.warn() << "(" << __STRING(fname) << "): catch ..." << endl; \ uwarn << "(" << __STRING(fname) << "): catch ..." << endl; \
} \ } \
\ \
oref = CORBA::Object::_nil(); \ oref = CORBA::Object::_nil(); \
...@@ -77,7 +77,7 @@ using namespace UniSetTypes; ...@@ -77,7 +77,7 @@ using namespace UniSetTypes;
#define CHECK_IC_PTR(fname) \ #define CHECK_IC_PTR(fname) \
if( !ic ) \ if( !ic ) \
{ \ { \
ulog.warn() << "(" << __STRING(fname) << "): function NOT DEFINED..." << endl; \ uwarn << "(" << __STRING(fname) << "): function NOT DEFINED..." << endl; \
throw UniSetTypes::TimeOut(); \ throw UniSetTypes::TimeOut(); \
} \ } \
......
...@@ -53,7 +53,7 @@ void TestProc::sysCommand( UniSetTypes::SystemMessage* sm ) ...@@ -53,7 +53,7 @@ void TestProc::sysCommand( UniSetTypes::SystemMessage* sm )
void TestProc::sensorInfo( SensorMessage *sm ) void TestProc::sensorInfo( SensorMessage *sm )
{ {
/* /*
dlog.level2() << myname << "(sensorInfo): id=" << sm->id << " val=" << sm->value mylog2 << myname << "(sensorInfo): id=" << sm->id << " val=" << sm->value
<< " " << timeToString(sm->sm_tv_sec,":") << " " << timeToString(sm->sm_tv_sec,":")
<< "(" << setw(6) << sm->sm_tv_usec << "): " << "(" << setw(6) << sm->sm_tv_usec << "): "
<< endl; << endl;
...@@ -83,7 +83,7 @@ void TestProc::timerInfo( TimerMessage *tm ) ...@@ -83,7 +83,7 @@ void TestProc::timerInfo( TimerMessage *tm )
{ {
state^=true; state^=true;
out_lamp_c = ( state ? lmpBLINK : lmpOFF ); out_lamp_c = ( state ? lmpBLINK : lmpOFF );
dlog.level2() << myname << ": state=" << state << " lmp=" << out_lamp_c << endl; mylog2 << myname << ": state=" << state << " lmp=" << out_lamp_c << endl;
askTimer(tmCheckWorking,checkTime); // reset timer askTimer(tmCheckWorking,checkTime); // reset timer
} }
else if( tm->id == tmCheckWorking ) else if( tm->id == tmCheckWorking )
...@@ -102,7 +102,7 @@ void TestProc::timerInfo( TimerMessage *tm ) ...@@ -102,7 +102,7 @@ void TestProc::timerInfo( TimerMessage *tm )
cerr << "======= TEST LOG PRINT ======" << endl; cerr << "======= TEST LOG PRINT ======" << endl;
cerr << "LOGLEVEL: [" << (int)(*lit) << "] " << (*lit) << endl; cerr << "LOGLEVEL: [" << (int)(*lit) << "] " << (*lit) << endl;
for( std::vector<Debug::type>::iterator it=loglevels.begin(); it!=loglevels.end(); ++it ) for( std::vector<Debug::type>::iterator it=loglevels.begin(); it!=loglevels.end(); ++it )
dlog[*it] << myname << ": test log print..." << endl; mylog[*it] << myname << ": test log print..." << endl;
cerr << "======= END LOG PRINT ======" << endl; cerr << "======= END LOG PRINT ======" << endl;
} }
...@@ -111,16 +111,16 @@ void TestProc::timerInfo( TimerMessage *tm ) ...@@ -111,16 +111,16 @@ void TestProc::timerInfo( TimerMessage *tm )
void TestProc::test_depend() void TestProc::test_depend()
{ {
cerr << myname << ": Check depend..." << endl; cerr << myname << ": Check depend..." << endl;
long test_val = 100; long test_val = 100;
// set depend 0... // set depend 0...
setValue(depend_c,0); setValue(depend_c,0);
setValue(set_d1_check_s,test_val); setValue(set_d1_check_s,test_val);
setValue(set_d2_check_s,test_val); setValue(set_d2_check_s,test_val);
cerr << myname << ": check depend OFF: d1: " << ( getValue(d1_check_s) == 0 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend OFF: d1: " << ( getValue(d1_check_s) == 0 ? "OK" : "FAIL" ) << endl;
cerr << myname << ": check depend OFF: d2: " << ( getValue(d2_check_s) == -50 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend OFF: d2: " << ( getValue(d2_check_s) == -50 ? "OK" : "FAIL" ) << endl;
// set depend 1 // set depend 1
setValue(depend_c,1); setValue(depend_c,1);
cerr << myname << ": check depend ON: d1: " << ( getValue(d1_check_s) == test_val ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend ON: d1: " << ( getValue(d1_check_s) == test_val ? "OK" : "FAIL" ) << endl;
...@@ -132,10 +132,10 @@ void TestProc::test_undefined_state() ...@@ -132,10 +132,10 @@ void TestProc::test_undefined_state()
// ---------------- Проверка выставления неопределённого состояния --------------------- // ---------------- Проверка выставления неопределённого состояния ---------------------
cerr << myname << ": Check undef state..." << endl; cerr << myname << ": Check undef state..." << endl;
undef ^= true; undef ^= true;
si.id = undef_c; si.id = undef_c;
si.node = conf->getLocalNode(); si.node = conf->getLocalNode();
cerr << myname << ": set undefined=" << undef << endl; cerr << myname << ": set undefined=" << undef << endl;
ui.setUndefinedState( si, undef, getId() ); ui.setUndefinedState( si, undef, getId() );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -149,7 +149,7 @@ void TestProc::test_thresholds() ...@@ -149,7 +149,7 @@ void TestProc::test_thresholds()
setValue(t_set_c,378); setValue(t_set_c,378);
cerr << myname << ": check threshold ON value: " << ( getValue(t_check_s) == 1 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check threshold ON value: " << ( getValue(t_check_s) == 1 ? "OK" : "FAIL" ) << endl;
cerr << myname << ": ask threshold and check.. " << endl; cerr << myname << ": ask threshold and check.. " << endl;
try try
...@@ -166,7 +166,7 @@ void TestProc::test_thresholds() ...@@ -166,7 +166,7 @@ void TestProc::test_thresholds()
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog.level2() << myname << ": CHECK 'ask and get threshold' FAILED: " << ex << endl; mylog2 << myname << ": CHECK 'ask and get threshold' FAILED: " << ex << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -49,19 +49,19 @@ int main(int argc, const char **argv) ...@@ -49,19 +49,19 @@ int main(int argc, const char **argv)
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
ulog.crit() << "(smemory): " << err << endl; ucrit << "(smemory): " << err << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
ulog.crit() << "(smemory): " << ex << endl; ucrit << "(smemory): " << ex << endl;
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
ulog.crit() << "(smemory): " << e.what() << endl; ucrit << "(smemory): " << e.what() << endl;
} }
catch(...) catch(...)
{ {
ulog.crit() << "(smemory): catch(...)" << endl; ucrit << "(smemory): catch(...)" << endl;
} }
return 1; return 1;
......
...@@ -73,7 +73,7 @@ namespace UniSetTypes ...@@ -73,7 +73,7 @@ namespace UniSetTypes
int getPIntField(const std::string& path, int def); int getPIntField(const std::string& path, int def);
xmlNode* findNode(xmlNode* node, const std::string& searchnode, const std::string& name="" ); xmlNode* findNode(xmlNode* node, const std::string& searchnode, const std::string& name="" );
// Получить узел // Получить узел
xmlNode* getNode(const std::string& path); xmlNode* getNode(const std::string& path);
// Получить указанное свойство пути // Получить указанное свойство пути
...@@ -92,7 +92,7 @@ namespace UniSetTypes ...@@ -92,7 +92,7 @@ namespace UniSetTypes
inline ObjectId getLocalNode() const { return localNode; } /*!< получение идентификатора локального узла */ inline ObjectId getLocalNode() const { return localNode; } /*!< получение идентификатора локального узла */
inline std::string getLocalNodeName() const { return localNodeName; } /*!< получение название локального узла */ inline std::string getLocalNodeName() const { return localNodeName; } /*!< получение название локального узла */
inline const std::string getNSName() const { return NSName; } inline const std::string getNSName() const { return NSName; }
// repository // repository
inline std::string getRootSection() const { return secRoot; } inline std::string getRootSection() const { return secRoot; }
inline std::string getSensorsSection() const { return secSensors; } inline std::string getSensorsSection() const { return secSensors; }
...@@ -108,7 +108,7 @@ namespace UniSetTypes ...@@ -108,7 +108,7 @@ namespace UniSetTypes
xmlNode* getXMLObjectNode( UniSetTypes::ObjectId ); xmlNode* getXMLObjectNode( UniSetTypes::ObjectId );
UniversalIO::IOType getIOType( UniSetTypes::ObjectId ); UniversalIO::IOType getIOType( UniSetTypes::ObjectId );
UniversalIO::IOType getIOType( const std::string& name ); UniversalIO::IOType getIOType( const std::string& name );
// net // net
inline unsigned int getCountOfNet() const { return countOfNet; } inline unsigned int getCountOfNet() const { return countOfNet; }
inline unsigned int getRepeatTimeout() const { return repeatTimeout; } inline unsigned int getRepeatTimeout() const { return repeatTimeout; }
...@@ -136,7 +136,7 @@ namespace UniSetTypes ...@@ -136,7 +136,7 @@ namespace UniSetTypes
inline bool isLocalIOR(){ return localIOR; } inline bool isLocalIOR(){ return localIOR; }
inline bool isTransientIOR(){ return transientIOR; } inline bool isTransientIOR(){ return transientIOR; }
/*! получить значение указанного параметра, или значение по умолчанию */ /*! получить значение указанного параметра, или значение по умолчанию */
std::string getArgParam(const std::string& name, const std::string& defval=""); std::string getArgParam(const std::string& name, const std::string& defval="");
/*! получить числовое значение параметра, если не число, то 0. Если параметра нет, используется значение defval */ /*! получить числовое значение параметра, если не число, то 0. Если параметра нет, используется значение defval */
...@@ -240,13 +240,28 @@ namespace UniSetTypes ...@@ -240,13 +240,28 @@ namespace UniSetTypes
/*! Глобальный объект для вывода логов */ /*! Глобальный объект для вывода логов */
extern DebugStream ulog; extern DebugStream ulog;
// Инициализация UniSetTypes::conf. // Инициализация UniSetTypes::conf.
// ( учитываются параметры командной строки --confile и --id-from-config ) // ( учитываются параметры командной строки --confile и --id-from-config )
void uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml" ); void uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml" );
} // end of UniSetTypes namespace } // end of UniSetTypes namespace
// --------------------------------------------------------------------------
// "синтаксический сахар"..для логов
#define uinfo if( UniSetTypes::ulog.debugging(Debug::INFO) ) UniSetTypes::ulog
#define uwarn if( UniSetTypes::ulog.debugging(Debug::WARN) ) UniSetTypes::ulog
#define ucrit if( UniSetTypes::ulog.debugging(Debug::CRIT) ) UniSetTypes::ulog
#define ulog1 if( UniSetTypes::ulog.debugging(Debug::LEVEL1) ) UniSetTypes::ulog
#define ulog2 if( UniSetTypes::ulog.debugging(Debug::LEVEL2) ) UniSetTypes::ulog
#define ulog3 if( UniSetTypes::ulog.debugging(Debug::LEVEL3) ) UniSetTypes::ulog
#define ulog4 if( UniSetTypes::ulog.debugging(Debug::LEVEL4) ) UniSetTypes::ulog
#define ulog5 if( UniSetTypes::ulog.debugging(Debug::LEVEL5) ) UniSetTypes::ulog
#define ulog6 if( UniSetTypes::ulog.debugging(Debug::LEVEL6) ) UniSetTypes::ulog
#define ulog7 if( UniSetTypes::ulog.debugging(Debug::LEVEL7) ) UniSetTypes::ulog
#define ulog8 if( UniSetTypes::ulog.debugging(Debug::LEVEL8) ) UniSetTypes::ulog
#define ulog9 if( UniSetTypes::ulog.debugging(Debug::LEVEL9) ) UniSetTypes::ulog
#define ulogsys if( UniSetTypes::ulog.debugging(Debug::SYSTEM) ) UniSetTypes::ulog
#define ulogrep if( UniSetTypes::ulog.debugging(Debug::REPOSITORY) ) UniSetTypes::ulog
// --------------------------------------------------------------------------
#endif // Configuration_H_ #endif // Configuration_H_
...@@ -54,7 +54,7 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior ...@@ -54,7 +54,7 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior
if( !ior_file ) if( !ior_file )
{ {
ulog.crit() << "(IORFile): не смог открыть файл "+fname << endl; ucrit << "(IORFile): не смог открыть файл "+fname << endl;
throw TimeOut("(IORFile): не смог создать ior-файл "+fname); throw TimeOut("(IORFile): не смог создать ior-файл "+fname);
} }
......
...@@ -35,18 +35,17 @@ using namespace std; ...@@ -35,18 +35,17 @@ using namespace std;
namespace ORepHelpers namespace ORepHelpers
{ {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/*! /*!
* \param cname - полное имя контекста ссылку на который, возвратит функция. * \param cname - полное имя контекста ссылку на который, возвратит функция.
* \param argc, argv - параметры инициализации ORB * \param argc, argv - параметры инициализации ORB
*/ */
CosNaming::NamingContext_ptr getContext(const string& cname, int argc, const char* const* argv, const string& nsName )throw(ORepFailed) CosNaming::NamingContext_ptr getContext(const string& cname, int argc, const char* const* argv, const string& nsName )throw(ORepFailed)
{ {
CORBA::ORB_var orb = CORBA::ORB_init( argc, (char**)argv ); CORBA::ORB_var orb = CORBA::ORB_init( argc, (char**)argv );
if( ulog.is_repository() ) ulogrep << "OREPHELP: orb init ok"<< endl;
ulog.repository() << "OREPHELP: orb init ok"<< endl;
return getContext(orb, cname, nsName); return getContext(orb, cname, nsName);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -54,26 +53,22 @@ namespace ORepHelpers ...@@ -54,26 +53,22 @@ namespace ORepHelpers
{ {
CosNaming::NamingContext_var rootC; CosNaming::NamingContext_var rootC;
if( ulog.is_repository() ) ulogrep << "OREPHELPER(getContext): get rootcontext...(servname = "<< servname << ")" <<endl;
ulog.repository() << "OREPHELPER(getContext): get rootcontext...(servname = "<< servname << ")" <<endl;
rootC = getRootNamingContext(orb, servname); rootC = getRootNamingContext(orb, servname);
if( ulog.is_repository() ) ulogrep << "OREPHELPER(getContext): get rootContect ok " << endl;
ulog.repository() << "OREPHELPER(getContext): get rootContect ok " << endl;
if( CORBA::is_nil(rootC) ) if( CORBA::is_nil(rootC) )
{ {
if( ulog.is_warn() ) uwarn << "OREPHELPER: не смог получить ссылку на NameServices"<< endl;
ulog.warn() << "OREPHELPER: не смог получить ссылку на NameServices"<< endl;
throw ORepFailed("OREPHELPER(getContext): не смог получить ссылку на NameServices"); throw ORepFailed("OREPHELPER(getContext): не смог получить ссылку на NameServices");
} }
if ( cname.empty() ) if ( cname.empty() )
return rootC._retn(); return rootC._retn();
if( ulog.is_repository() ) ulogrep << "OREPHELPER(getContext): get ref context " << cname << endl;
ulog.repository() << "OREPHELPER(getContext): get ref context " << cname << endl;
CosNaming::Name_var ctxName = omniURI::stringToName(cname.c_str()); CosNaming::Name_var ctxName = omniURI::stringToName(cname.c_str());
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
...@@ -91,16 +86,14 @@ namespace ORepHelpers ...@@ -91,16 +86,14 @@ namespace ORepHelpers
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): не смог получить ссылку на контекст " << cname; err << "OREPHELPER(getContext): не смог получить ссылку на контекст " << cname;
if( ulog.is_warn() ) uwarn << err.str() << endl;
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(const CosNaming::NamingContext::NotFound &nf) catch(const CosNaming::NamingContext::NotFound &nf)
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): не найден контекст " << cname; err << "OREPHELPER(getContext): не найден контекст " << cname;
if( ulog.warn() ) uwarn << err.str() << endl;
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(const CosNaming::NamingContext::CannotProceed &np) catch(const CosNaming::NamingContext::CannotProceed &np)
...@@ -108,40 +101,33 @@ namespace ORepHelpers ...@@ -108,40 +101,33 @@ namespace ORepHelpers
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): catch CannotProced " << cname; err << "OREPHELPER(getContext): catch CannotProced " << cname;
err << " bad part=" << omniURI::nameToString(np.rest_of_name); err << " bad part=" << omniURI::nameToString(np.rest_of_name);
if( ulog.is_warn() ) uwarn << err.str() << endl;
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): поймали CORBA::SystemException: " << ex.NP_minorString(); err << "OREPHELPER(getContext): поймали CORBA::SystemException: " << ex.NP_minorString();
if( ulog.is_warn() ) uwarn << err.str() << endl;
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch(CORBA::Exception&) catch(CORBA::Exception&)
{ {
if( ulog.is_warn() ) uwarn << "OREPHELPER(getContext): поймали CORBA::Exception." << endl;
ulog.warn() << "OREPHELPER(getContext): поймали CORBA::Exception." << endl;
throw ORepFailed(); throw ORepFailed();
} }
catch(omniORB::fatalException& fe) catch(omniORB::fatalException& fe)
{ {
ostringstream err; ostringstream err;
err << "OREPHELPER(getContext): поймали omniORB::fatalException:"; err << "OREPHELPER(getContext): поймали omniORB::fatalException:";
if( ulog.is_warn() ) uwarn << err << endl;
{ uwarn << " file: " << fe.file() << endl;
ulog.warn() << err << endl; uwarn << " line: " << fe.line() << endl;
ulog.warn() << " file: " << fe.file() << endl; uwarn << " mesg: " << fe.errmsg() << endl;
ulog.warn() << " line: " << fe.line() << endl;
ulog.warn() << " mesg: " << fe.errmsg() << endl;
}
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
if( ulog.is_repository() ) ulogrep << "getContext: получили "<< cname << endl;
ulog.repository() << "getContext: получили "<< cname << endl;
// Если _var // Если _var
// return CosNaming::NamingContext::_duplicate(ctx); // return CosNaming::NamingContext::_duplicate(ctx);
...@@ -160,8 +146,7 @@ namespace ORepHelpers ...@@ -160,8 +146,7 @@ namespace ORepHelpers
{ {
// cout << "ORepHelpers(getRootNamingContext): nsName->" << nsName << endl; // cout << "ORepHelpers(getRootNamingContext): nsName->" << nsName << endl;
CORBA::Object_var initServ = orb->resolve_initial_references(nsName.c_str()); CORBA::Object_var initServ = orb->resolve_initial_references(nsName.c_str());
if( ulog.is_repository() ) ulogrep << "OREPHELP: get rootcontext...(nsName = "<< nsName << ")" <<endl;
ulog.repository() << "OREPHELP: get rootcontext...(nsName = "<< nsName << ")" <<endl;
rootContext = CosNaming::NamingContext::_narrow(initServ); rootContext = CosNaming::NamingContext::_narrow(initServ);
if (CORBA::is_nil(rootContext)) if (CORBA::is_nil(rootContext))
...@@ -170,15 +155,13 @@ namespace ORepHelpers ...@@ -170,15 +155,13 @@ namespace ORepHelpers
throw ORepFailed(err.c_str()); throw ORepFailed(err.c_str());
} }
if( ulog.is_repository() ) ulogrep << "OREPHELP: init NameService ok"<< endl;
ulog.repository() << "OREPHELP: init NameService ok"<< endl;
} }
catch(CORBA::ORB::InvalidName& ex) catch(CORBA::ORB::InvalidName& ex)
{ {
ostringstream err; ostringstream err;
err << "ORepHelpers(getRootNamingContext): InvalidName=" << nsName; err << "ORepHelpers(getRootNamingContext): InvalidName=" << nsName;
if( ulog.is_warn() ) uwarn << err.str() << endl;
ulog.warn() << err.str() << endl;
throw ORepFailed(err.str()); throw ORepFailed(err.str());
} }
catch (CORBA::COMM_FAILURE& ex) catch (CORBA::COMM_FAILURE& ex)
...@@ -198,8 +181,7 @@ namespace ORepHelpers ...@@ -198,8 +181,7 @@ namespace ORepHelpers
throw ORepFailed(err); throw ORepFailed(err);
} }
if( ulog.is_repository() ) ulogrep << "OREPHELP: get root context ok"<< endl;
ulog.repository() << "OREPHELP: get root context ok"<< endl;
// // Если создан как _ptr // // Если создан как _ptr
// return rootContext; // return rootContext;
...@@ -210,7 +192,7 @@ namespace ORepHelpers ...@@ -210,7 +192,7 @@ namespace ORepHelpers
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
/*! /*!
* \param fname - полное имя включающее в себя путь ("Root/Section1/name|Node:Alias") * \param fname - полное имя включающее в себя путь ("Root/Section1/name|Node:Alias")
* \param brk - используемый символ разделитель * \param brk - используемый символ разделитель
*/ */
const string getShortName( const string& fname, const std::string& brk ) const string getShortName( const string& fname, const std::string& brk )
{ {
...@@ -226,10 +208,10 @@ namespace ORepHelpers ...@@ -226,10 +208,10 @@ namespace ORepHelpers
if( pos2 == string::npos && pos1 == string::npos ) if( pos2 == string::npos && pos1 == string::npos )
return fname; return fname;
if( pos1 == string::npos ) if( pos1 == string::npos )
return fname.substr( 0, pos2 ); return fname.substr( 0, pos2 );
if( pos2 == string::npos ) if( pos2 == string::npos )
return fname.substr( pos1+1, fname.length() ); return fname.substr( pos1+1, fname.length() );
...@@ -239,7 +221,7 @@ namespace ORepHelpers ...@@ -239,7 +221,7 @@ namespace ORepHelpers
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
/*! /*!
* \param fullName - полное имя включающее в себя путь * \param fullName - полное имя включающее в себя путь
* \param brk - используемый символ разделитель * \param brk - используемый символ разделитель
* \note Функция возвращает путь без последнего символа разделителя ("Root/Section1/name" -> "Root/Section1") * \note Функция возвращает путь без последнего символа разделителя ("Root/Section1/name" -> "Root/Section1")
*/ */
const string getSectionName( const string& fullName, const std::string& brk ) const string getSectionName( const string& fullName, const std::string& brk )
...@@ -249,7 +231,7 @@ namespace ORepHelpers ...@@ -249,7 +231,7 @@ namespace ORepHelpers
return ""; return "";
return fullName.substr(0, pos); return fullName.substr(0, pos);
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
/* /*
...@@ -259,7 +241,7 @@ namespace ORepHelpers ...@@ -259,7 +241,7 @@ namespace ORepHelpers
char checkBadSymbols(const string& str) char checkBadSymbols(const string& str)
{ {
using namespace UniSetTypes; using namespace UniSetTypes;
for ( unsigned int i=0;i<str.length();i++) for ( unsigned int i=0;i<str.length();i++)
{ {
for(unsigned int k=0; k<sizeof(BadSymbols); k++) for(unsigned int k=0; k<sizeof(BadSymbols); k++)
...@@ -269,7 +251,7 @@ namespace ORepHelpers ...@@ -269,7 +251,7 @@ namespace ORepHelpers
} }
} }
return 0; return 0;
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
string BadSymbolsToStr() string BadSymbolsToStr()
......
...@@ -55,7 +55,7 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name ) ...@@ -55,7 +55,7 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name )
MapObjectKey::iterator it = mok.find(name); MapObjectKey::iterator it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return it->second; return it->second;
return DefaultObjectId; return DefaultObjectId;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
...@@ -66,7 +66,7 @@ string ObjectIndex_XML::getMapName( const ObjectId id ) ...@@ -66,7 +66,7 @@ string ObjectIndex_XML::getMapName( const ObjectId id )
return ""; return "";
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex_XML::getTextName( const ObjectId id ) string ObjectIndex_XML::getTextName( const ObjectId id )
{ {
if( (unsigned)id<omap.size() && (unsigned)id>=0 && (unsigned)id<omap.size() ) if( (unsigned)id<omap.size() && (unsigned)id>=0 && (unsigned)id<omap.size() )
...@@ -88,9 +88,9 @@ std::ostream& ObjectIndex_XML::printMap( std::ostream& os ) ...@@ -88,9 +88,9 @@ std::ostream& ObjectIndex_XML::printMap( std::ostream& os )
if( it->repName == NULL ) if( it->repName == NULL )
continue; continue;
os << setw(5) << it->id << " " os << setw(5) << it->id << " "
// << setw(45) << ORepHelpers::getShortName(it->repName,'/') // << setw(45) << ORepHelpers::getShortName(it->repName,'/')
<< setw(45) << it->repName << setw(45) << it->repName
<< " " << it->textName << endl; << " " << it->textName << endl;
} }
...@@ -107,8 +107,8 @@ void ObjectIndex_XML::build(UniXML& xml) ...@@ -107,8 +107,8 @@ void ObjectIndex_XML::build(UniXML& xml)
ind = read_section(xml,"controllers",ind); ind = read_section(xml,"controllers",ind);
ind = read_section(xml,"services",ind); ind = read_section(xml,"services",ind);
ind = read_nodes(xml,"nodes",ind); ind = read_nodes(xml,"nodes",ind);
// //
omap.resize(ind); omap.resize(ind);
// omap[ind].repName=NULL; // omap[ind].repName=NULL;
// omap[ind].textName=NULL; // omap[ind].textName=NULL;
...@@ -119,13 +119,8 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec, ...@@ -119,13 +119,8 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
{ {
if( (unsigned)ind >= omap.size() ) if( (unsigned)ind >= omap.size() )
{ {
if( ulog.is_info() ) uwarn << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size()
{ << "... Делаем resize + 100" << endl;
ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str());
ulog.warn() << msg.str() << "... Делаем resize + 100\n";
}
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
...@@ -135,7 +130,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec, ...@@ -135,7 +130,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build):: не нашли параметр RootSection в конф. файле "; msg << "(ObjectIndex_XML::build):: не нашли параметр RootSection в конф. файле ";
ulog.crit() << msg.str() << endl; ucrit << msg.str() << endl;
throw SystemError(msg.str()); throw SystemError(msg.str());
} }
...@@ -144,6 +139,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec, ...@@ -144,6 +139,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не нашли корневого раздела " << sec; msg << "(ObjectIndex_XML::build): не нашли корневого раздела " << sec;
ucrit << msg.str() << endl;
throw NameNotFound(msg.str()); throw NameNotFound(msg.str());
} }
...@@ -153,6 +149,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec, ...@@ -153,6 +149,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не удалось перейти к списку элементов " << sec; msg << "(ObjectIndex_XML::build): не удалось перейти к списку элементов " << sec;
ucrit << msg.str() << endl;
throw NameNotFound(msg.str()); throw NameNotFound(msg.str());
} }
...@@ -164,6 +161,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec, ...@@ -164,6 +161,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): у секции " << sec << " не указано свойство 'name' "; msg << "(ObjectIndex_XML::build): у секции " << sec << " не указано свойство 'name' ";
ucrit << msg.str() << endl;
throw NameNotFound(msg.str()); throw NameNotFound(msg.str());
} }
...@@ -199,14 +197,9 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec, ...@@ -199,14 +197,9 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
if( (unsigned)ind >= omap.size() ) if( (unsigned)ind >= omap.size() )
{ {
if( ulog.is_info() ) uinfo << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size()
{ << "... Делаем resize + 100" << endl;
ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str());
if( ulog.is_info() )
ulog.info() << msg.str() << "... Делаем resize + 100\n";
}
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
} }
...@@ -220,8 +213,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -220,8 +213,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size(); msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str()); uinfo << msg.str() << "... Делаем resize + 100\n";
ulog.warn() << msg.str() << "... Делаем resize + 100\n";
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
...@@ -251,7 +243,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -251,7 +243,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
string alias(xml.getProp(it,"alias")); string alias(xml.getProp(it,"alias"));
if( alias.empty() ) if( alias.empty() )
alias = name; alias = name;
string nodename = mkFullNodeName(name,alias); string nodename = mkFullNodeName(name,alias);
delete[] omap[ind].repName; delete[] omap[ind].repName;
omap[ind].repName = new char[nodename.size()+1]; omap[ind].repName = new char[nodename.size()+1];
...@@ -267,7 +259,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -267,7 +259,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
strcpy( omap[ind].textName, textname.c_str() ); strcpy( omap[ind].textName, textname.c_str() );
omap[ind].data = (void*)(xmlNode*)(it); omap[ind].data = (void*)(xmlNode*)(it);
// //
mok[omap[ind].repName] = ind; mok[omap[ind].repName] = ind;
// cout << "read: " << "(" << ind << ") " << omap[ind].repName << "\t" << omap[ind].textName << endl; // cout << "read: " << "(" << ind << ") " << omap[ind].repName << "\t" << omap[ind].textName << endl;
...@@ -276,8 +268,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -276,8 +268,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size(); msg << "(ObjectIndex_XML::build): не хватило размера массива maxSize=" << omap.size();
// throw OutOfRange(msg.str()); uwarn << msg.str() << "... Делаем resize + 100" << endl;
ulog.warn() << msg.str() << "... Делаем resize + 100\n";
omap.resize(omap.size()+100); omap.resize(omap.size()+100);
} }
} }
......
...@@ -93,7 +93,7 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string& sec ) ...@@ -93,7 +93,7 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string& sec )
{ {
ostringstream msg; ostringstream msg;
msg << "(ObjectIndex_idXML::build):: не нашли параметр RootSection в конф. файле "; msg << "(ObjectIndex_idXML::build):: не нашли параметр RootSection в конф. файле ";
ulog.crit() << msg.str() << endl; ucrit << msg.str() << endl;
throw SystemError(msg.str()); throw SystemError(msg.str());
} }
......
...@@ -37,7 +37,7 @@ using namespace std; ...@@ -37,7 +37,7 @@ using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/* /*
ObjectRepository::ObjectRepository(int* argc, char* **argv, const char* NSName): ObjectRepository::ObjectRepository(int* argc, char* **argv, const char* NSName):
argc(*argc), argc(*argc),
argv(*argv), argv(*argv),
nsName(NSName) nsName(NSName)
{ {
...@@ -81,7 +81,7 @@ bool ObjectRepository::init() ...@@ -81,7 +81,7 @@ bool ObjectRepository::init()
localctx=0; localctx=0;
return false; return false;
} }
return true; return true;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -98,8 +98,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -98,8 +98,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
{ {
ostringstream err; ostringstream err;
if( ulog.is_info() ) uinfo << "ObjectRepository(registration): регистрируем " << name << endl;
ulog.info() << "ObjectRepository(registration): регистрируем " << name << endl;
// Проверка корректности имени // Проверка корректности имени
char bad = ORepHelpers::checkBadSymbols(name); char bad = ORepHelpers::checkBadSymbols(name);
...@@ -110,7 +109,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -110,7 +109,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
err << " содержит недопустимый символ " << bad; err << " содержит недопустимый символ " << bad;
throw ( InvalidObjectName(err.str().c_str()) ); throw ( InvalidObjectName(err.str().c_str()) );
} }
CosNaming::Name_var oName = omniURI::stringToName(name.c_str()); CosNaming::Name_var oName = omniURI::stringToName(name.c_str());
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
for( int i=0; i<2; i++ ) for( int i=0; i<2; i++ )
...@@ -118,17 +117,15 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -118,17 +117,15 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
try try
{ {
// Добавляем в репозиторий новую ссылку (заменяя если есть старую) // Добавляем в репозиторий новую ссылку (заменяя если есть старую)
CORBA::ORB_var orb = uconf->getORB(); CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName); ctx = ORepHelpers::getContext(orb, section, nsName);
ctx->bind(oName, oRef); ctx->bind(oName, oRef);
return; return;
} }
catch(const CosNaming::NamingContext::AlreadyBound &nf) catch(const CosNaming::NamingContext::AlreadyBound &nf)
{ {
if( ulog.is_warn() ) uwarn << "(registration): "<< name <<" уже зарегестрирован в "<< section << "!!!" << endl;
ulog.warn() << "(registration): "<< name <<" уже зарегестрирован в "<< section << "!!!" << endl;
if( !force ) if( !force )
throw ObjectNameAlready(); throw ObjectNameAlready();
...@@ -139,7 +136,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -139,7 +136,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
} }
catch(ORepFailed) catch(ORepFailed)
{ {
string er("ObjectRepository(registrartion): (getContext) не смог зарегистрировать "+name); string er("ObjectRepository(registrartion): (getContext) не смог зарегистрировать "+name);
throw ORepFailed(er.c_str()); throw ORepFailed(er.c_str());
} }
catch(CosNaming::NamingContext::NotFound) catch(CosNaming::NamingContext::NotFound)
...@@ -157,16 +154,11 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -157,16 +154,11 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
if( ulog.is_warn() ) uwarn << "ObjectRepository(registrartion): поймали CORBA::SystemException: "
ulog.warn() << "ObjectRepository(registrartion): поймали CORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
err << "ObjectRepository(registrartion): поймали CORBA::SystemException: " << ex.NP_minorString(); err << "ObjectRepository(registrartion): поймали CORBA::SystemException: " << ex.NP_minorString();
} }
// catch(...)
// {
// ulog.warn() << "поймали что-то неизвестное..."<< endl;
// }
} }
throw ORepFailed(err.str().c_str()); throw ORepFailed(err.str().c_str());
...@@ -178,7 +170,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -178,7 +170,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
* \note При этом надо иметь ввиду, что задается полное имя объекта. * \note При этом надо иметь ввиду, что задается полное имя объекта.
* Пример: registration("Root/SensorSection/sens1", oRef); * Пример: registration("Root/SensorSection/sens1", oRef);
* \param fullName - полное имя регистрируемого объекта (т.е. включающее в себя имя секции) * \param fullName - полное имя регистрируемого объекта (т.е. включающее в себя имя секции)
* \param oRef - ссылка на объект * \param oRef - ссылка на объект
* \exception ORepFailed - генерируется если произошла ошибка при регистрации * \exception ORepFailed - генерируется если произошла ошибка при регистрации
* \sa registration(const string name, const ObjectPtr oRef, const string section) * \sa registration(const string name, const ObjectPtr oRef, const string section)
*/ */
...@@ -203,25 +195,18 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy ...@@ -203,25 +195,18 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy
void ObjectRepository::unregistration(const string& name, const string& section) void ObjectRepository::unregistration(const string& name, const string& section)
throw(ORepFailed, NameNotFound) throw(ORepFailed, NameNotFound)
{ {
// ulog.info() << "OREP: unregistration "<< name << " из "<< section << endl;
ostringstream err; ostringstream err;
CosNaming::Name_var oName = omniURI::stringToName(name.c_str()); CosNaming::Name_var oName = omniURI::stringToName(name.c_str());
// ulog.info() << "OREP: string to name ok"<< endl;
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
CORBA::ORB_var orb = uconf->getORB(); CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName); ctx = ORepHelpers::getContext(orb, section, nsName);
// ulog.info() << "OREP: get context " << section <<" ok"<< endl;
try try
{ {
// Удаляем запись об объекте // Удаляем запись об объекте
ctx->unbind(oName); ctx->unbind(oName);
// ulog.info() << "OREP: ok" << endl;
return; return;
} }
catch(const CosNaming::NamingContext::NotFound &nf) catch(const CosNaming::NamingContext::NotFound &nf)
{ {
err << "ObjectRepository(unregistrartion): не найден объект ->" << name; err << "ObjectRepository(unregistrartion): не найден объект ->" << name;
...@@ -269,7 +254,7 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName ) ...@@ -269,7 +254,7 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName )
CosNaming::Name_var nc = omniURI::stringToName(name.c_str()); CosNaming::Name_var nc = omniURI::stringToName(name.c_str());
oRef=localctx->resolve(nc); oRef=localctx->resolve(nc);
if ( !CORBA::is_nil(oRef) ) if ( !CORBA::is_nil(oRef) )
return oRef._retn(); return oRef._retn();
err << "ObjectRepository(resolve): не смог получить ссылку на объект " << name.c_str(); err << "ObjectRepository(resolve): не смог получить ссылку на объект " << name.c_str();
} }
...@@ -297,8 +282,8 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName ) ...@@ -297,8 +282,8 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName )
} }
if(err.str().empty()) if(err.str().empty())
err << "ObjectRepository(resolve): ??? для " << name; err << "ObjectRepository(resolve): ??? для " << name;
throw ORepFailed(err.str().c_str()); throw ORepFailed(err.str().c_str());
} }
...@@ -344,23 +329,21 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName *ls ...@@ -344,23 +329,21 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName *ls
bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned int how_many, ObjectType type) bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned int how_many, ObjectType type)
{ {
// Возвращает false если вынут не весь список... // Возвращает false если вынут не весь список...
// ulog.info() << "получаем список из "<< section << endl;
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
try try
{ {
CORBA::ORB_var orb = uconf->getORB(); CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName); ctx = ORepHelpers::getContext(orb, section, nsName);
} }
catch(ORepFailed) catch(ORepFailed)
{ {
ulog.warn() << "ORepository(list): не смог получить ссылку на "<< section << endl; uwarn << "ORepository(list): не смог получить ссылку на "<< section << endl;
throw; throw;
// return false;
} }
if( CORBA::is_nil(ctx) ) if( CORBA::is_nil(ctx) )
{ {
ulog.warn() << "ORepository(list): не смог получить ссылку на "<< section << endl; uwarn << "ORepository(list): не смог получить ссылку на "<< section << endl;
throw ORepFailed(); throw ORepFailed();
} }
...@@ -383,7 +366,7 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned ...@@ -383,7 +366,7 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned
for( unsigned int i=0; i<how_many;i++) for( unsigned int i=0; i<how_many;i++)
{ {
switch( type ) switch( type )
{ {
case ObjectRef: case ObjectRef:
{ {
if(bl[i].binding_type == CosNaming::nobject) if(bl[i].binding_type == CosNaming::nobject)
...@@ -413,7 +396,7 @@ bool ObjectRepository::isExist( const string& fullName ) ...@@ -413,7 +396,7 @@ bool ObjectRepository::isExist( const string& fullName )
{ {
try try
{ {
CORBA::Object_var oRef = resolve(fullName, nsName); CORBA::Object_var oRef = resolve(fullName, nsName);
return isExist(oRef); return isExist(oRef);
} }
catch(...){} catch(...){}
...@@ -435,10 +418,10 @@ bool ObjectRepository::isExist( ObjectPtr oref ) ...@@ -435,10 +418,10 @@ bool ObjectRepository::isExist( ObjectPtr oref )
catch(CORBA::Exception&){} catch(CORBA::Exception&){}
catch(omniORB::fatalException& fe) catch(omniORB::fatalException& fe)
{ {
ulog.warn() << "ObjectRepository(isExist): "<< "поймали omniORB::fatalException:" << endl; uwarn << "ObjectRepository(isExist): "<< "поймали omniORB::fatalException:" << endl;
ulog.warn() << " file: " << fe.file() << endl; uwarn << " file: " << fe.file() << endl;
ulog.warn() << " line: " << fe.line() << endl; uwarn << " line: " << fe.line() << endl;
ulog.warn() << " mesg: " << fe.errmsg() << endl; uwarn << " mesg: " << fe.errmsg() << endl;
} }
catch(...){} catch(...){}
......
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
* \author Pavel Vainerman * \author Pavel Vainerman
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <iomanip>
#include "ProxyManager.h" #include "ProxyManager.h"
#include "PassiveObject.h" #include "PassiveObject.h"
#include "ORepHelpers.h" #include "ORepHelpers.h"
#include "Configuration.h" #include "Configuration.h"
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
PassiveObject::PassiveObject(): PassiveObject::PassiveObject():
...@@ -117,14 +117,12 @@ void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg ) ...@@ -117,14 +117,12 @@ void PassiveObject::processingMessage( UniSetTypes::VoidMessage* msg )
} }
default: default:
//ulog.warn() << myname << ": неизвестное сообщение " << msg->type << endl;
break; break;
} }
} }
catch(Exception& ex) catch( Exception& ex )
{ {
// ulog.warn() uwarn << myname << "(processingMessage): " << ex << endl;
// cerr << myname << "(processingMessage): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -48,7 +48,7 @@ void ProxyManager::attachObject( PassiveObject* po, UniSetTypes::ObjectId id ) ...@@ -48,7 +48,7 @@ void ProxyManager::attachObject( PassiveObject* po, UniSetTypes::ObjectId id )
{ {
if( id == DefaultObjectId ) if( id == DefaultObjectId )
{ {
ulog.warn() << myname << "(attachObject): попытка добавить объект с id=" uwarn << myname << "(attachObject): попытка добавить объект с id="
<< DefaultObjectId << " PassiveObject=" << po->getName() << endl; << DefaultObjectId << " PassiveObject=" << po->getName() << endl;
return; return;
...@@ -78,39 +78,34 @@ bool ProxyManager::activateObject() ...@@ -78,39 +78,34 @@ bool ProxyManager::activateObject()
try try
{ {
for( int i=0; i<2; i++ ) for( int i=0; i<2; i++ )
{ {
try try
{ {
if( ulog.is_info() ) uinfo << myname << "(registered): попытка "
{ << i+1 << " регистриую (id=" << it->first << ") "
ulog.info() << myname << "(registered): попытка " << " (pname=" << it->second->getName() << ") "
<< i+1 << " регистриую (id=" << it->first << ") " << conf->oind->getNameById(it->first) << endl;
<< " (pname=" << it->second->getName() << ") "
<< conf->oind->getNameById(it->first) << endl;
}
ui.registered(it->first, getRef(),true); ui.registered(it->first, getRef(),true);
break; break;
} }
catch( UniSetTypes::ObjectNameAlready& ex ) catch( UniSetTypes::ObjectNameAlready& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl;
ulog.crit() << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl;
try try
{ {
ui.unregister(it->first); ui.unregister(it->first);
} }
catch(Exception & ex) catch(Exception & ex)
{ {
if( ulog.is_crit() ) ucrit << myname << "(unregistered): " << ex << endl;
ulog.crit() << myname << "(unregistered): " << ex << endl;
} }
} }
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(activate): " << ex << endl;
ulog.crit() << myname << "(activate): " << ex << endl;
} }
} }
...@@ -127,8 +122,7 @@ bool ProxyManager::disactivateObject() ...@@ -127,8 +122,7 @@ bool ProxyManager::disactivateObject()
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(activate): " << ex << endl;
ulog.crit() << myname << "(activate): " << ex << endl;
} }
} }
...@@ -150,19 +144,16 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg ) ...@@ -150,19 +144,16 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg )
PObjectMap::iterator it = omap.find(msg->consumer); PObjectMap::iterator it = omap.find(msg->consumer);
if( it!=omap.end() ) if( it!=omap.end() )
it->second->processingMessage(msg); it->second->processingMessage(msg);
else if( ulog.is_crit() ) else
{ ucrit << myname << "(processingMessage): не найден объект "
ulog.crit() << myname << "(processingMessage): не найден объект "
<< " consumer= " << msg->consumer << endl; << " consumer= " << msg->consumer << endl;
}
} }
break; break;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(processingMessage): " << ex << endl;
ulog.crit() << myname << "(processingMessage): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -176,8 +167,7 @@ void ProxyManager::allMessage( UniSetTypes::VoidMessage* msg ) ...@@ -176,8 +167,7 @@ void ProxyManager::allMessage( UniSetTypes::VoidMessage* msg )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_crit() ) ucrit << myname << "(allMessage): " << ex << endl;
ulog.crit() << myname << "(allMessage): " << ex << endl;
} }
} }
} }
......
...@@ -59,9 +59,9 @@ void UniSetManager_LT::callback() ...@@ -59,9 +59,9 @@ void UniSetManager_LT::callback()
sleepTime=lt.checkTimers(this); sleepTime=lt.checkTimers(this);
} }
catch(Exception& ex) catch( Exception& ex )
{ {
ulog.crit() << myname << "(callback): " << ex << endl; ucrit << myname << "(callback): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
......
...@@ -61,7 +61,7 @@ void UniSetObject_LT::callback() ...@@ -61,7 +61,7 @@ void UniSetObject_LT::callback()
} }
catch(Exception& ex) catch(Exception& ex)
{ {
ulog.crit() << myname << "(callback): " << ex << endl; ucrit << myname << "(callback): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
......
...@@ -60,9 +60,9 @@ void IONotifyController_LT::callback() ...@@ -60,9 +60,9 @@ void IONotifyController_LT::callback()
sleepTime=lt.checkTimers(this); sleepTime=lt.checkTimers(this);
} }
catch(Exception& ex) catch( Exception& ex )
{ {
ulog.crit() << myname << "(callback): " << ex << endl; ucrit << myname << "(callback): " << ex << endl;
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
/*! \file /*! \file
* \author Pavel Vainerman * \author Pavel Vainerman
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include "Debug.h" #include "Debug.h"
#include "Configuration.h" #include "Configuration.h"
...@@ -44,7 +44,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -44,7 +44,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
{ {
UniSetTypes::KeyType k( key(inf.si.id,inf.si.node) ); UniSetTypes::KeyType k( key(inf.si.id,inf.si.node) );
// Проверка зарегистрирован-ли данный датчик // Проверка зарегистрирован-ли данный датчик
// если такого дискретного датчика нет, то здесь сработает исключение... // если такого дискретного датчика нет, то здесь сработает исключение...
if( !force ) if( !force )
{ {
...@@ -63,18 +63,17 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -63,18 +63,17 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
case UniversalIO::AO: case UniversalIO::AO:
ic->ioRegistration(inf); ic->ioRegistration(inf);
break; break;
default: default:
if( ulog.is_crit() ) ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
ulog.crit() << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << conf->oind->getNameById(inf.si.id,inf.si.node) << endl;
return; return;
break; break;
} }
} }
} }
switch(inf.type) switch(inf.type)
{ {
case UniversalIO::DI: case UniversalIO::DI:
...@@ -85,8 +84,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -85,8 +84,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
break; break;
default: default:
if( ulog.is_crit() ) ucrit << ic->getName() << "(NCRestorer::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА!-> "
ulog.crit() << ic->getName() << "(NCRestorer::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА!-> "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << conf->oind->getNameById(inf.si.id,inf.si.node) << endl;
break; break;
} }
...@@ -94,7 +92,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -94,7 +92,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyController::ThresholdExtList& lst, bool force ) void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyController::ThresholdExtList& lst, bool force )
{ {
// Проверка зарегистрирован-ли данный датчик // Проверка зарегистрирован-ли данный датчик
// если такого дискретного датчика нет сдесь сработает исключение... // если такого дискретного датчика нет сдесь сработает исключение...
if( !force ) if( !force )
{ {
...@@ -154,15 +152,13 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC ...@@ -154,15 +152,13 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
if( ulog.is_warn() ) uwarn << ic->getName() << "(NCRestorer::addthresholdlist): " << ex
ulog.warn() << ic->getName() << "(NCRestorer::addthresholdlist): " << ex
<< " для " << conf->oind->getNameById(inf.si.id, inf.si.node) << endl; << " для " << conf->oind->getNameById(inf.si.id, inf.si.node) << endl;
throw; throw;
} }
catch( CORBA::SystemException& ex ) catch( CORBA::SystemException& ex )
{ {
if( ulog.is_warn() ) uwarn << ic->getName() << "(NCRestorer::addthresholdlist): "
ulog.warn() << ic->getName() << "(NCRestorer::addthresholdlist): "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << " недоступен!!(CORBA::SystemException): " << conf->oind->getNameById(inf.si.id,inf.si.node) << " недоступен!!(CORBA::SystemException): "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
throw; throw;
...@@ -198,14 +194,13 @@ void NCRestorer::init_depends_signals( IONotifyController* ic ) ...@@ -198,14 +194,13 @@ void NCRestorer::init_depends_signals( IONotifyController* ic )
if( it->second.d_si.id == DefaultObjectId ) if( it->second.d_si.id == DefaultObjectId )
continue; continue;
if( ulog.is_info() ) uinfo << ic->getName() << "(NCRestorer::init_depends_signals): "
ulog.info() << ic->getName() << "(NCRestorer::init_depends_signals): "
<< " init depend: '" << conf->oind->getMapName(it->second.si.id) << "'" << " init depend: '" << conf->oind->getMapName(it->second.si.id) << "'"
<< " dep_name=(" << it->second.d_si.id << ")'" << conf->oind->getMapName(it->second.d_si.id) << "'" << " dep_name=(" << it->second.d_si.id << ")'" << conf->oind->getMapName(it->second.d_si.id) << "'"
<< endl; << endl;
IOController::ChangeSignal s = ic->signal_change_value(it->second.d_si); IOController::ChangeSignal s = ic->signal_change_value(it->second.d_si);
s.connect( sigc::mem_fun( &it->second, &IOController::USensorInfo::checkDepend) ); s.connect( sigc::mem_fun( &it->second, &IOController::USensorInfo::checkDepend) );
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -50,7 +50,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -50,7 +50,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
{ {
{ // lock { // lock
uniset_rwmutex_rlock lock(lstMutex); uniset_rwmutex_rlock lock(lstMutex);
if( tlst.empty() ) if( tlst.empty() )
{ {
sleepTime = UniSetTimer::WaitUpTime; sleepTime = UniSetTimer::WaitUpTime;
...@@ -69,18 +69,18 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -69,18 +69,18 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
return sleepTime; return sleepTime;
} }
} }
{ // lock { // lock
uniset_rwmutex_wrlock lock(lstMutex); uniset_rwmutex_wrlock lock(lstMutex);
sleepTime = UniSetTimer::WaitUpTime; sleepTime = UniSetTimer::WaitUpTime;
for( TimersList::iterator li=tlst.begin();li!=tlst.end();++li) for( TimersList::iterator li=tlst.begin();li!=tlst.end();++li)
{ {
if( li->tmr.checkTime() ) if( li->tmr.checkTime() )
{ {
// помещаем себе в очередь сообщение // помещаем себе в очередь сообщение
TransportMessage tm = TimerMessage(li->id, li->priority, obj->getId()).transport_msg(); TransportMessage tm = TimerMessage(li->id, li->priority, obj->getId()).transport_msg();
obj->push(tm); obj->push(tm);
// Проверка на количество заданных тактов // Проверка на количество заданных тактов
if( !li->curTick ) if( !li->curTick )
{ {
...@@ -102,19 +102,19 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -102,19 +102,19 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
// ищем минимальное оставшееся время // ищем минимальное оставшееся время
if( li->curTimeMS < sleepTime || sleepTime == UniSetTimer::WaitUpTime ) if( li->curTimeMS < sleepTime || sleepTime == UniSetTimer::WaitUpTime )
sleepTime = li->curTimeMS; sleepTime = li->curTimeMS;
} }
if( sleepTime < UniSetTimer::MinQuantityTime ) if( sleepTime < UniSetTimer::MinQuantityTime )
sleepTime=UniSetTimer::MinQuantityTime; sleepTime=UniSetTimer::MinQuantityTime;
} // unlock } // unlock
tmLast.reset(); tmLast.reset();
} }
catch(Exception& ex) catch(Exception& ex)
{ {
ulog.crit() << "(checkTimers): " << ex << endl; ucrit << "(checkTimers): " << ex << endl;
} }
return sleepTime; return sleepTime;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -125,7 +125,7 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -125,7 +125,7 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{ {
if( timeMS < UniSetTimer::MinQuantityTime ) if( timeMS < UniSetTimer::MinQuantityTime )
{ {
ulog.crit() << "(LT_askTimer): [мс] попытка заказть таймер со временем срабатыания " ucrit << "(LT_askTimer): [мс] попытка заказть таймер со временем срабатыания "
<< " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl; << " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl;
timeMS = UniSetTimer::MinQuantityTime; timeMS = UniSetTimer::MinQuantityTime;
} }
...@@ -141,11 +141,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -141,11 +141,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{ {
li->curTick = ticks; li->curTick = ticks;
li->tmr.setTiming(timeMS); li->tmr.setTiming(timeMS);
if( ulog.is_info() ) uinfo << "(LT_askTimer): заказ на таймер(id="
{
ulog.info() << "(LT_askTimer): заказ на таймер(id="
<< timerid << ") " << timeMS << " [мс] уже есть..." << endl; << timerid << ") " << timeMS << " [мс] уже есть..." << endl;
}
return sleepTime; return sleepTime;
} }
} }
...@@ -156,19 +153,17 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -156,19 +153,17 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
newti.reset(); newti.reset();
} // unlock } // unlock
if( ulog.is_info() ) uinfo << "(LT_askTimer): поступил заказ на таймер(id="<< timerid << ") " << timeMS << " [мс]\n";
ulog.info() << "(LT_askTimer): поступил заказ на таймер(id="<< timerid << ") " << timeMS << " [мс]\n";
} }
else // отказ (при timeMS == 0) else // отказ (при timeMS == 0)
{ {
if( ulog.is_info() ) uinfo << "(LT_askTimer): поступил отказ по таймеру id="<< timerid << endl;
ulog.info() << "(LT_askTimer): поступил отказ по таймеру id="<< timerid << endl;
{ // lock { // lock
uniset_rwmutex_wrlock lock(lstMutex); uniset_rwmutex_wrlock lock(lstMutex);
tlst.remove_if(Timer_eq(timerid)); // STL - способ tlst.remove_if(Timer_eq(timerid)); // STL - способ
} // unlock } // unlock
} }
{ // lock { // lock
uniset_rwmutex_rlock lock(lstMutex); uniset_rwmutex_rlock lock(lstMutex);
......
...@@ -42,7 +42,7 @@ uniset_mutex::uniset_mutex(): ...@@ -42,7 +42,7 @@ uniset_mutex::uniset_mutex():
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
uniset_mutex::uniset_mutex( string name ): uniset_mutex::uniset_mutex( string name ):
cnd(0), cnd(0),
nm(name), nm(name),
locked(0) locked(0)
{ {
...@@ -112,9 +112,9 @@ uniset_mutex_lock::uniset_mutex_lock( uniset_mutex& m, int timeMS ): ...@@ -112,9 +112,9 @@ uniset_mutex_lock::uniset_mutex_lock( uniset_mutex& m, int timeMS ):
mutex->mtx.lock(); mutex->mtx.lock();
if( !mutex->cnd->timedwait(sec, msec) ) if( !mutex->cnd->timedwait(sec, msec) )
{ {
if( !mutex->name().empty() && ulog.is_level9() ) if( !mutex->name().empty() )
{ {
ulog.level9() << "(mutex_lock): вышло заданное время ожидания " ulog9 << "(mutex_lock): вышло заданное время ожидания "
<< timeMS << " msec для " << mutex->name() << endl; << timeMS << " msec для " << mutex->name() << endl;
} }
...@@ -134,7 +134,7 @@ bool uniset_mutex_lock::lock_ok() ...@@ -134,7 +134,7 @@ bool uniset_mutex_lock::lock_ok()
} }
uniset_mutex_lock::~uniset_mutex_lock() uniset_mutex_lock::~uniset_mutex_lock()
{ {
if( mlock ) if( mlock )
{ {
mlock = 0; mlock = 0;
...@@ -181,7 +181,7 @@ const uniset_rwmutex &uniset_rwmutex::operator=( const uniset_rwmutex& r ) ...@@ -181,7 +181,7 @@ const uniset_rwmutex &uniset_rwmutex::operator=( const uniset_rwmutex& r )
nm = s.str(); nm = s.str();
unlock(); unlock();
} }
return *this; return *this;
} }
...@@ -209,7 +209,7 @@ void uniset_rwmutex::wrlock() ...@@ -209,7 +209,7 @@ void uniset_rwmutex::wrlock()
void uniset_rwmutex::rlock() void uniset_rwmutex::rlock()
{ {
MUTEX_DEBUG(cerr << nm << " prepare RLocked.." << endl;) MUTEX_DEBUG(cerr << nm << " prepare RLocked.." << endl;)
while( wr_wait > 0 ) while( wr_wait > 0 )
msleep(2); msleep(2);
......
...@@ -42,6 +42,7 @@ c_filterValue("") ...@@ -42,6 +42,7 @@ c_filterValue("")
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Restorer_XML::~Restorer_XML() Restorer_XML::~Restorer_XML()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Restorer_XML::setItemFilter( const string& field, const string& val ) void Restorer_XML::setItemFilter( const string& field, const string& val )
...@@ -65,8 +66,7 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it, ...@@ -65,8 +66,7 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it,
string cname( it.getProp("name")); string cname( it.getProp("name"));
if( cname.empty() ) if( cname.empty() )
{ {
if( ulog.is_warn() ) uwarn << "(Restorer_XML:getConsumerInfo): не указано имя заказчика..." << endl;
ulog.warn() << "(Restorer_XML:getConsumerInfo): не указано имя заказчика..." << endl;
return false; return false;
} }
...@@ -79,19 +79,15 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it, ...@@ -79,19 +79,15 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it,
cname = conf->getServicesSection()+"/"+cname; cname = conf->getServicesSection()+"/"+cname;
else else
{ {
if( ulog.is_warn() ) uwarn << "(Restorer_XML:getConsumerInfo): неизвестный тип объекта "
{
ulog.warn() << "(Restorer_XML:getConsumerInfo): неизвестный тип объекта "
<< otype << endl; << otype << endl;
}
return false; return false;
} }
cid = conf->oind->getIdByName(cname); cid = conf->oind->getIdByName(cname);
if( cid == UniSetTypes::DefaultObjectId ) if( cid == UniSetTypes::DefaultObjectId )
{ {
if( ulog.is_crit() ) ucrit << "(Restorer_XML:getConsumerInfo): НЕ НАЙДЕН ИДЕНТИФИКАТОР заказчика -->"
ulog.crit() << "(Restorer_XML:getConsumerInfo): НЕ НАЙДЕН ИДЕНТИФИКАТОР заказчика -->"
<< cname << endl; << cname << endl;
return false; return false;
} }
...@@ -110,17 +106,12 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it, ...@@ -110,17 +106,12 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it,
if( cnode == UniSetTypes::DefaultObjectId ) if( cnode == UniSetTypes::DefaultObjectId )
{ {
if( ulog.is_crit() ) ucrit << "(Restorer_XML:getConsumerInfo): НЕ НАЙДЕН ИДЕНТИФИКАТОР узла -->"
ulog.crit() << "(Restorer_XML:getConsumerInfo): НЕ НАЙДЕН ИДЕНТИФИКАТОР узла -->"
<< cnodename << endl; << cnodename << endl;
return false; return false;
} }
if( ulog.is_info() ) uinfo << "(Restorer_XML:getConsumerInfo): " << cname << ":" << cnodename << endl;
{
ulog.info() << "(Restorer_XML:getConsumerInfo): "
<< cname << ":" << cnodename << endl;
}
return true; return true;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -42,18 +42,18 @@ RunLock::~RunLock() ...@@ -42,18 +42,18 @@ RunLock::~RunLock()
bool RunLock::isLocked(const string& name) bool RunLock::isLocked(const string& name)
{ {
FILE *out = fopen( string(name + ".lock" ).c_str(), "r" ); FILE *out = fopen( string(name + ".lock" ).c_str(), "r" );
if( out ) if( out )
{ {
char ptr[10]; char ptr[10];
fscanf( out, "%9s", ptr ); fscanf( out, "%9s", ptr );
DIR *d = opendir( "/proc" ); DIR *d = opendir( "/proc" );
dirent *dir; dirent *dir;
while((dir = readdir(d))) while((dir = readdir(d)))
{ {
if( !strcmp( ptr, dir->d_name ) ) if( !strcmp( ptr, dir->d_name ) )
{ {
// по хорошему здесь надо бы проверять // по хорошему здесь надо бы проверять
// статус на зомби // статус на зомби
/* /*
string path(dir->d_name); string path(dir->d_name);
...@@ -70,20 +70,19 @@ bool RunLock::isLocked(const string& name) ...@@ -70,20 +70,19 @@ bool RunLock::isLocked(const string& name)
break; break;
} }
} }
*/ */
if( ulog.is_info() ) uinfo << "(RunLock): programm " << name << " already run" << endl;
ulog.info() << "(RunLock): programm " << name << " already run" << endl;
fclose(out); fclose(out);
closedir(d); closedir(d);
return true; return true;
} }
} }
fclose(out); fclose(out);
closedir(d); closedir(d);
} }
return false; return false;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -91,7 +90,7 @@ bool RunLock::lock( const string& name ) ...@@ -91,7 +90,7 @@ bool RunLock::lock( const string& name )
{ {
if( !isLocked(name) ) if( !isLocked(name) )
{ {
FILE *out = fopen( string(name + ".lock" ).c_str(), "w+" ); FILE *out = fopen( string(name + ".lock" ).c_str(), "w+" );
if(out) if(out)
{ {
fprintf( out, "%d\n", getpid() ); fprintf( out, "%d\n", getpid() );
...@@ -99,14 +98,14 @@ bool RunLock::lock( const string& name ) ...@@ -99,14 +98,14 @@ bool RunLock::lock( const string& name )
return true; return true;
} }
} }
return false; return false;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
bool RunLock::unlock(const string& name) bool RunLock::unlock(const string& name)
{ {
string fname(name + ".lock"); string fname(name + ".lock");
FILE *out = fopen( fname.c_str(), "r" ); FILE *out = fopen( fname.c_str(), "r" );
if( out ) if( out )
{ {
fclose(out); fclose(out);
......
...@@ -60,7 +60,6 @@ UniXML::UniXML(): ...@@ -60,7 +60,6 @@ UniXML::UniXML():
UniXML::~UniXML() UniXML::~UniXML()
{ {
//ulog.< "UniXML destr" << endl;
close(); close();
} }
......
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