Commit 868dce1e authored by Pavel Vainerman's avatar Pavel Vainerman

Вторая проверка статическим анализатором, make style

parent fe60ba5a
......@@ -348,7 +348,7 @@ int main(int argc, char** argv)
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cout << "admin(main): " << ex << endl;
......@@ -517,7 +517,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
}
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << setw(55) << ob << " <--- " << ex << endl;
......@@ -574,7 +574,7 @@ int omap()
uniset_conf()->oind->printMap(cout);
cout << "==========================================================================\n";
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << " configuration init failed: " << ex << endl;
......@@ -639,7 +639,7 @@ int setValue( const string& args, UInterface& ui )
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << "(setValue): " << ex << endl;;
......@@ -706,7 +706,7 @@ int getValue( const string& args, UInterface& ui )
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << "(getValue): " << ex << endl;
......@@ -755,7 +755,7 @@ int getCalibrate( const std::string& args, UInterface& ui )
else
cout << ci;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << "(getCalibrate): " << ex << endl;;
......@@ -800,7 +800,7 @@ int getRawValue( const std::string& args, UInterface& ui )
else
cout << ui.getRawValue(it.si);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << "(getRawValue): " << ex << endl;;
......@@ -845,7 +845,7 @@ int getChangedTime( const std::string& args, UInterface& ui )
else
cout << ui.getChangedTime(it.si.id, it.si.node);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cerr << "(getChangedTime): " << ex << endl;;
......@@ -913,9 +913,11 @@ int logRotate( const string& arg, UInterface& ui )
else // посылка определённому объекту
{
UniSetTypes::ObjectId id = conf->getObjectID(arg);
if( id == DefaultObjectId )
id = conf->getControllerID(arg);
else if( id == DefaultObjectId )
if( id == DefaultObjectId )
id = conf->getServiceID(arg);
if( id == DefaultObjectId )
......@@ -953,6 +955,7 @@ int configure( const string& arg, UInterface& ui )
else // посылка определённому объекту
{
UniSetTypes::ObjectId id = conf->getObjectID(arg);
if( id == DefaultObjectId )
id = conf->getControllerID(arg);
......@@ -1004,7 +1007,7 @@ int oinfo( const string& args, UInterface& ui, int userparam )
cout << inf->info << endl;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( !quiet )
cout << "ID='" << it.id << "' ERROR: " << ex << endl;
......
......@@ -215,7 +215,7 @@ int main( int argc, char** argv )
{
cerr << "(mbtester): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(mbtester): " << ex << endl;
}
......
......@@ -713,7 +713,7 @@ int main( int argc, char** argv )
{
cerr << "(mbtester): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(mbtester): " << ex << endl;
}
......
......@@ -135,7 +135,7 @@ int main( int argc, char** argv )
{
ui.setValue(it.si, j, DefaultObjectId);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << endl << "save id=" << it.fname << " " << ex << endl;
}
......@@ -162,7 +162,7 @@ int main( int argc, char** argv )
{
ui.setValue(it->si, i, DefaultObjectId);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << endl << "save id=" << it->fname << " " << ex << endl;
}
......@@ -172,7 +172,7 @@ int main( int argc, char** argv )
msleep(amsec);
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << endl << "(simitator): " << ex << endl;
return 1;
......
......@@ -47,7 +47,7 @@ int main( int argc, const char** argv )
act->run(false);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cout << "(main):" << ex << endl;
}
......
......@@ -94,7 +94,7 @@ int main( int argc, char* argv[], char* envp[] )
cerr << "(log-stdin): " << err << endl;
return 1;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(log-stdin): " << ex << endl;
return 1;
......
......@@ -105,7 +105,7 @@ int main( int argc, char* argv[], char* envp[] )
cerr << "(logserver-wrap): " << err << endl;
return 1;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(logserver-wrap): " << ex << endl;
return 1;
......
......@@ -317,7 +317,7 @@ int main( int argc, char** argv )
{
cerr << "(log): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(log): " << ex << endl;
}
......
......@@ -209,7 +209,7 @@ int main( int argc, char** argv )
{
cerr << "(logserver): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(logserver): " << ex << endl;
}
......
......@@ -85,7 +85,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexcept
ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -95,7 +95,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexcept
updateOutputs(forceOut);
updatePreviousValues();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -206,7 +206,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
</xsl:for-each>
return;
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -267,7 +267,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return ui->getValue(_sid);
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -321,7 +321,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
</xsl:if>
</xsl:if>
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -356,7 +356,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
si.node = node_<xsl:value-of select="../../@name"/>;
ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -371,7 +371,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
si.node = node_<xsl:value-of select="../../@name"/>;
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......
......@@ -88,7 +88,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexept
ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -100,7 +100,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexept
// обновление списка предыдущих состояний
updatePreviousValues();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -109,7 +109,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexept
mycrit &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl;
}
catch( const std::exception&amp;ex )
catch( const std::exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): catch " &lt;&lt; ex.what() &lt;&lt; endl;
}
......@@ -261,7 +261,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID()
</xsl:if>
</xsl:if>
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -296,7 +296,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID()
si.node = node_<xsl:value-of select="../../@name"/>;
ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -311,7 +311,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID()
si.node = node_<xsl:value-of select="../../@name"/>;
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......
......@@ -85,7 +85,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexcept
ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -95,7 +95,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexcept
updateOutputs(forceOut);
updatePreviousValues();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -104,7 +104,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexcept
mycrit &lt;&lt; myname &lt;&lt; "(execute): СORBA::SystemException: "
&lt;&lt; ex.NP_minorString() &lt;&lt; endl;
}
catch( const std::exception&amp;ex )
catch( const std::exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): catch " &lt;&lt; ex.what() &lt;&lt; endl;
}
......@@ -221,7 +221,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return ui->getValue(_sid);
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(getValue): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
</xsl:for-each>
return;
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(preAskSensors): " &lt;&lt; ex &lt;&lt; endl;
}
......
......@@ -88,7 +88,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexept
ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -98,7 +98,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexept
updateOutputs(forceOut);
updatePreviousValues();
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
}
......@@ -221,7 +221,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
if( <xsl:value-of select="@name"/> != DefaultObjectId )
priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>);
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -238,7 +238,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
}
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw;
......@@ -273,7 +273,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
ui->setValue( si,(long)m_<xsl:value-of select="@name"/>, getId() );
}
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
mycrit &lt;&lt; myname &lt;&lt; "(setmsg): " &lt;&lt; ex &lt;&lt; endl;
throw;
......
......@@ -73,7 +73,7 @@
</xsl:when>
<xsl:when test="$GENTYPE='CHECK'">
<xsl:if test="normalize-space(@vartype)!='io'">
<xsl:if test="normalize-space(../../@id)=''">throw SystemException("Not Found ID for <xsl:value-of select="../../@name"/>");</xsl:if>
<xsl:if test="normalize-space(../../@id)=''">throw UniSetTypes::SystemError("Not Found ID for <xsl:value-of select="../../@name"/>");</xsl:if>
</xsl:if>
</xsl:when>
</xsl:choose>
......@@ -672,7 +672,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
// abort();
// raise(SIGTERM);
std::terminate();
// throw SystemError(err.str());
// throw UniSetTypes::SystemError(err.str());
}
if( !ui->waitWorking(_testID,wait_msec) )
......@@ -687,7 +687,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
// abort();
//raise(SIGTERM);
std::terminate();
// throw SystemError(err.str());
// throw UniSetTypes::SystemError(err.str());
}
}
// ----------------------------------------------------------------------------
......@@ -864,7 +864,7 @@ forceOut(false),
end_private(false)
{
mycrit &lt;&lt; "<xsl:value-of select="$CLASSNAME"/>: init failed!!!!!!!!!!!!!!!" &lt;&lt; endl;
throw Exception( string(myname+": init failed!!!") );
throw UniSetTypes::Exception( string(myname+": init failed!!!") );
}
// -----------------------------------------------------------------------------
// ( val, confval, default val )
......@@ -952,7 +952,7 @@ end_private(false)
{
ostringstream err;
err &lt;&lt; "(<xsl:value-of select="$CLASSNAME"/>::init): Unknown ObjectID!";
throw SystemError( err.str() );
throw UniSetTypes::SystemError( err.str() );
}
mylog = make_shared&lt;DebugStream&gt;();
......@@ -973,13 +973,13 @@ end_private(false)
<xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@no_check_id)!='1'">
if( <xsl:value-of select="normalize-space(@name)"/> == UniSetTypes::DefaultObjectId )
throw Exception( myname + ": Not found ID for (<xsl:value-of select="@name"/>) " + conf->getProp(cnode,"<xsl:value-of select="@name"/>") );
throw UniSetTypes::SystemError( myname + ": Not found ID for (<xsl:value-of select="@name"/>) " + conf->getProp(cnode,"<xsl:value-of select="@name"/>") );
</xsl:if>
<xsl:if test="normalize-space(@no_check_id)!='1'">
if( node_<xsl:value-of select="normalize-space(@name)"/> == UniSetTypes::DefaultObjectId )
throw Exception( myname + ": Not found NodeID for (node='node_<xsl:value-of select="normalize-space(@name)"/>') " + conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>") );
throw UniSetTypes::SystemError( myname + ": Not found NodeID for (node='node_<xsl:value-of select="normalize-space(@name)"/>') " + conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>") );
</xsl:if>
<xsl:if test="normalize-space($VARMAP)='1'">
......@@ -999,11 +999,11 @@ end_private(false)
if( <xsl:value-of select="normalize-space(@name)"/> == UniSetTypes::DefaultObjectId )
{
if( !conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>").empty() )
throw Exception( myname + ": Not found Message::NodeID for (node='node_<xsl:value-of select="normalize-space(@name)"/>') " + conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>") );
throw UniSetTypes::SystemError( myname + ": Not found Message::NodeID for (node='node_<xsl:value-of select="normalize-space(@name)"/>') " + conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>") );
}
if( node_<xsl:value-of select="normalize-space(@name)"/> == UniSetTypes::DefaultObjectId )
throw Exception( myname + ": Not found Message::NodeID for (node='node_<xsl:value-of select="normalize-space(@name)"/>') " + conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>") );
throw UniSetTypes::SystemError( myname + ": Not found Message::NodeID for (node='node_<xsl:value-of select="normalize-space(@name)"/>') " + conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>") );
</xsl:for-each>
UniXML::iterator it(cnode);
......@@ -1025,7 +1025,7 @@ end_private(false)
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; ": не найден идентификатор для датчика 'HeartBeat' " &lt;&lt; heart;
throw SystemError(err.str());
throw UniSetTypes::SystemError(err.str());
}
int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time",it.getProp("heartbeatTime"),conf-&gt;getHeartBeatTime());
......@@ -1401,7 +1401,7 @@ askPause(2000),
forceOut(false)
{
mycrit &lt;&lt; "<xsl:value-of select="$CLASSNAME"/>: init failed!!!!!!!!!!!!!!!" &lt;&lt; endl;
throw Exception( string(myname+": init failed!!!") );
throw UniSetTypes::SystemError( string(myname+": init failed!!!") );
}
// -----------------------------------------------------------------------------
<xsl:value-of select="$CLASSNAME"/>_SK::<xsl:value-of select="$CLASSNAME"/>_SK( ObjectId id, xmlNode* cnode, const string&amp; _argprefix ):
......@@ -1441,7 +1441,7 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
{
ostringstream err;
err &lt;&lt; "(<xsl:value-of select="$CLASSNAME"/>::init): Unknown ObjectID!";
throw SystemError( err.str() );
throw UniSetTypes::SystemError( err.str() );
}
mylog = make_shared&lt;DebugStream&gt;();
......@@ -1486,7 +1486,7 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; ": не найден идентификатор для датчика 'HeartBeat' " &lt;&lt; heart;
throw SystemError(err.str());
throw UniSetTypes::SystemError(err.str());
}
int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time",it.getProp("heartbeatTime"),conf-&gt;getHeartBeatTime());
......
......@@ -75,7 +75,7 @@ int main( int argc,char* argv[] )
act-&gt;run(false);
return 0;
}
catch( const Exception&amp; ex )
catch( const UniSetTypes::Exception&amp; ex )
{
cerr &lt;&lt; "(main): " &lt;&lt; ex &lt;&lt; endl;
}
......
......@@ -82,7 +82,7 @@ int main( int argc, const char** argv )
act-&gt;run(false);
return 0;
}
catch( const Exception&amp; ex)
catch( const UniSetTypes::Exception&amp; ex)
{
cerr &lt;&lt; "(main): " &lt;&lt; ex &lt;&lt; endl;
}
......
......@@ -115,7 +115,7 @@ void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
dbcrit << myname << "(update_confirm): db error: " << db->error() << endl;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dbcrit << myname << "(update_confirm): " << ex << endl;
}
......@@ -230,7 +230,7 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
dbcrit << myname << "(insert) sensor msg error: " << db->error() << endl;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dbcrit << myname << "(insert_main_history): " << ex << endl;
}
......
......@@ -48,7 +48,7 @@ int main(int argc, char** argv)
db.close();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(test): " << ex << endl;
}
......
......@@ -129,7 +129,7 @@ void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
dbcrit << myname << "(update_confirm): db error: " << db->error() << endl;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dbcrit << myname << "(update_confirm): " << ex << endl;
}
......@@ -222,7 +222,7 @@ void DBServer_PostgreSQL::flushInsertBuffer()
ibuf.erase(beg, end);
// ibufSize - беззнаковое, так что надо аккуратно
ibufSize = (delnum < ibufSize) ? (ibufSize-delnum) : 0;
ibufSize = (delnum < ibufSize) ? (ibufSize - delnum) : 0;
dbwarn << myname << "(flushInsertBuffer): overflow: clear data " << delnum << " records." << endl;
return;
......@@ -275,7 +275,7 @@ void DBServer_PostgreSQL::sensorInfo( const UniSetTypes::SensorMessage* si )
if( ibufSize >= ibufMaxSize )
flushInsertBuffer();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dbcrit << myname << "(insert_main_history): " << ex << endl;
}
......
......@@ -26,7 +26,7 @@ int main(int argc, char** argv)
act->add(dbs);
act->run(false);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(DBServer_PosgreSQL::main): " << ex << endl;
}
......
......@@ -101,7 +101,7 @@ int main(int argc, char** argv)
db.close();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(test): " << ex << endl;
}
......
......@@ -112,7 +112,7 @@ void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
dbcrit << myname << "(update_confirm): db error: " << db->error() << endl;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dbcrit << myname << "(update_confirm): " << ex << endl;
}
......@@ -213,7 +213,7 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
dbcrit << myname << "(insert) sensor msg error: " << db->error() << endl;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dbcrit << myname << "(insert_main_history): " << ex << endl;
}
......
......@@ -435,7 +435,7 @@ void IOControl::execute()
ptHeartBeat.reset();
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iolog3 << myname << "(execute): " << ex << endl;
}
......@@ -690,7 +690,7 @@ void IOControl::ioread( IOInfo* it )
{
iolog3 << myname << "(iopoll): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iolog3 << myname << "(iopoll): " << ex << endl;
}
......@@ -938,7 +938,7 @@ void IOControl::initOutputs()
else if( it.stype == UniversalIO::AO )
card->setAnalogChannel(it.subdev, it.channel, it.defval, it.range, it.aref);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iolog3 << myname << "(initOutput): " << ex << endl;
}
......@@ -979,7 +979,7 @@ void IOControl::initIOCard()
card->configureChannel(it.subdev, it.channel, ComediInterface::AO);
}
catch( const Exception& ex)
catch( const UniSetTypes::Exception& ex)
{
iocrit << myname << "(initIOCard): sid=" << it.si.id << " " << ex << endl;
}
......@@ -1005,7 +1005,7 @@ void IOControl::blink( BlinkList& lst, bool& bstate )
{
card->setDigitalChannel(io->subdev, io->channel, bstate);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iocrit << myname << "(blink): " << ex << endl;
}
......@@ -1091,7 +1091,7 @@ void IOControl::check_testmode()
card->setAnalogChannel(it.subdev, it.channel, it.safety, it.range, it.aref);
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iolog3 << myname << "(sigterm): " << ex << endl;
}
......@@ -1100,7 +1100,7 @@ void IOControl::check_testmode()
}
}
catch( const Exception& ex)
catch( const UniSetTypes::Exception& ex)
{
iocrit << myname << "(check_testmode): " << ex << endl;
}
......@@ -1165,7 +1165,7 @@ void IOControl::check_testlamp()
}
}
}
catch( const Exception& ex)
catch( const UniSetTypes::Exception& ex)
{
iocrit << myname << "(check_testlamp): " << ex << endl;
}
......@@ -1369,7 +1369,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
if( testLamp_s != DefaultObjectId )
shm->askSensor(testLamp_s, cmd);
}
catch( const Exception& ex)
catch( const UniSetTypes::Exception& ex)
{
iocrit << myname << "(askSensors): " << ex << endl;
}
......@@ -1379,7 +1379,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
if( testMode_as != DefaultObjectId )
shm->askSensor(testMode_as, cmd);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iocrit << myname << "(askSensors): " << ex << endl;
}
......@@ -1400,7 +1400,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
{
shm->askSensor(it.si.id, cmd, myid);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iocrit << myname << "(askSensors): " << ex << endl;
}
......@@ -1682,7 +1682,7 @@ void IOControl::buildCardsList()
cards[cardnum] = new ComediInterface(iodev);
noCards = false;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
iocrit << myname << "(buildCardsList): " << ex << endl;
throw;
......
......@@ -74,7 +74,7 @@ void LProcessor::execute( const std::string& lfile )
{
dcrit << logname << "(execute): " << ex << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << logname << "(execute): " << ex << endl;
}
......@@ -192,7 +192,7 @@ void LProcessor::setOuts()
{
ui.setValue(it.sid, it.el->getOut(), DefaultObjectId);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(LProcessor::setOuts): " << ex << endl;
}
......
......@@ -88,7 +88,7 @@ void PassiveLProcessor::step()
{
LProcessor::step();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(step): (hb) " << ex << std::endl;
}
......@@ -100,7 +100,7 @@ void PassiveLProcessor::step()
shm->localSetValue(itHeartBeat, sidHeartBeat, maxHeartBeat, getId());
ptHeartBeat.reset();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(step): (hb) " << ex << std::endl;
}
......@@ -120,7 +120,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
for( auto& it : extInputs )
shm->askSensor(it.sid, cmd);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(askSensors): " << ex << endl;
throw SystemError(myname + "(askSensors): do not ask sensors" );
......@@ -236,7 +236,7 @@ void PassiveLProcessor::setOuts()
{
shm->setValue( it.sid, it.el->getOut() );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(setOuts): " << ex << endl;
}
......@@ -255,7 +255,7 @@ void PassiveLProcessor::sigterm( int signo )
{
shm->setValue(it.sid, 0);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(sigterm): " << ex << endl;
}
......
......@@ -58,7 +58,7 @@ int main(int argc, const char** argv)
{
cerr << ex << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << ex << endl;
}
......
......@@ -95,7 +95,7 @@ int main(int argc, const char** argv)
{
cerr << ex << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << ex << endl;
}
......
......@@ -66,7 +66,7 @@ int main(int argc, const char* argv[] )
{
cerr << "(tests): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests): " << ex << endl;
}
......
......@@ -319,7 +319,7 @@ void MBExchange::step()
shm->localSetValue(itHeartBeat, sidHeartBeat, maxHeartBeat, getId());
ptHeartBeat.reset();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(step): (hb) " << ex << std::endl;
}
......@@ -928,7 +928,7 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
{
mblog3 << myname << "(initSMValue): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mblog3 << myname << "(initSMValue): " << ex << endl;
}
......@@ -1188,7 +1188,7 @@ void MBExchange::updateSM()
{
mblog3 << myname << "(updateSM): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mblog3 << myname << "(updateSM): " << ex << endl;
}
......@@ -1236,7 +1236,7 @@ void MBExchange::updateSM()
{
mblog3 << myname << "(updateSM): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mblog3 << myname << "(updateSM): " << ex << endl;
}
......@@ -1651,7 +1651,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
mblog3 << myname << "(updateRSProperty): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mblog3 << myname << "(updateRSProperty): " << ex << endl;
}
......@@ -1911,7 +1911,7 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
{
mblog3 << myname << "(updateMTR): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mblog3 << myname << "(updateMTR): " << ex << endl;
}
......@@ -2002,7 +2002,7 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
{
mblog3 << myname << "(updateRTU188): (BadRange)..." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mblog3 << myname << "(updateRTU188): " << ex << endl;
}
......@@ -3223,7 +3223,7 @@ void MBExchange::updateRespondSensors()
shm->localSetValue(d->resp_it, d->resp_id, ( set ? 1 : 0 ), getId());
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(step): (respond) " << ex << std::endl;
}
......@@ -3251,7 +3251,7 @@ void MBExchange::execute()
{
step();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(execute): " << ex << std::endl;
}
......
......@@ -124,6 +124,7 @@ MBTCPMultiMaster::MBTCPMultiMaster( UniSetTypes::ObjectId objId, UniSetTypes::Ob
sinf->respond_force = it1.getPIntProp("force", 0);
int fn = conf->getArgPInt("--" + prefix + "-check-func", it.getProp("checkFunc"), ModbusRTU::fnUnknown);
if( fn != ModbusRTU::fnUnknown &&
fn != ModbusRTU::fnReadCoilStatus &&
fn != ModbusRTU::fnReadInputStatus &&
......@@ -248,7 +249,7 @@ std::shared_ptr<ModbusClient> MBTCPMultiMaster::initMB( bool reopen )
{
// сперва надо обновить все ignore
// т.к. фактически флаги выставляются и сбрасываются только здесь
for( auto&& it: mblist )
for( auto && it : mblist )
it->ignore = !it->ptIgnoreTimeout.checkTime();
// если reopen=true - значит почему-то по текущему каналу связи нет (хотя соединение есть)
......@@ -289,6 +290,7 @@ std::shared_ptr<ModbusClient> MBTCPMultiMaster::initMB( bool reopen )
for( auto it = mblist.rbegin(); it != mblist.rend(); ++it )
{
auto m = (*it);
if( m->respond && !m->ignore && m->init(mblog) )
{
mbi = it;
......@@ -306,6 +308,7 @@ std::shared_ptr<ModbusClient> MBTCPMultiMaster::initMB( bool reopen )
for( auto it = mblist.rbegin(); it != mblist.rend(); ++it )
{
auto& m = (*it);
if( m->respond && m->check() && m->init(mblog) )
{
mbi = it;
......@@ -348,41 +351,42 @@ bool MBTCPMultiMaster::MBSlaveInfo::check()
if( use )
return true;
// cerr << myname << "(check): check connection..." << ip << ":" << port
// << " mbfunc=" << checkFunc
// << " mbaddr=" << ModbusRTU::addr2str(checkAddr)
// << " mbreg=" << (int)checkReg << "(" << ModbusRTU::dat2str(checkReg) << ")"
// << endl;
// cerr << myname << "(check): check connection..." << ip << ":" << port
// << " mbfunc=" << checkFunc
// << " mbaddr=" << ModbusRTU::addr2str(checkAddr)
// << " mbreg=" << (int)checkReg << "(" << ModbusRTU::dat2str(checkReg) << ")"
// << endl;
try
{
mbtcp->connect(ip,port,false);
mbtcp->connect(ip, port, false);
switch(checkFunc)
{
case ModbusRTU::fnReadCoilStatus:
{
auto ret = mbtcp->read01(checkAddr,checkReg,1);
auto ret = mbtcp->read01(checkAddr, checkReg, 1);
return true;
}
break;
case ModbusRTU::fnReadInputStatus:
{
auto ret = mbtcp->read02(checkAddr,checkReg,1);
auto ret = mbtcp->read02(checkAddr, checkReg, 1);
return true;
}
break;
case ModbusRTU::fnReadOutputRegisters:
{
auto ret = mbtcp->read03(checkAddr,checkReg,1);
auto ret = mbtcp->read03(checkAddr, checkReg, 1);
return true;
}
break;
case ModbusRTU::fnReadInputRegisters:
{
auto ret = mbtcp->read04(checkAddr,checkReg,1);
auto ret = mbtcp->read04(checkAddr, checkReg, 1);
return true;
}
break;
......@@ -391,7 +395,7 @@ bool MBTCPMultiMaster::MBSlaveInfo::check()
return mbtcp->checkConnection(ip, port, recv_timeout);
}
}
catch(...){}
catch(...) {}
return false;
}
......@@ -482,7 +486,7 @@ void MBTCPMultiMaster::check_thread()
{
while( checkProcActive() )
{
for( auto&& it: mblist )
for( auto && it : mblist )
{
try
{
......@@ -516,7 +520,7 @@ void MBTCPMultiMaster::check_thread()
it->respond_init = true;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(check): (respond) " << it->myname << " : " << ex << std::endl;
}
......@@ -613,6 +617,7 @@ void MBTCPMultiMaster::initCheckConnectionParameters()
auto conf = uniset_conf();
bool initFromRegMap = ( findArgParam("--" + prefix + "-check-init-from-regmap", conf->getArgc(), conf->getArgv()) != -1 );
if( !initFromRegMap )
return;
......@@ -635,16 +640,17 @@ void MBTCPMultiMaster::initCheckConnectionParameters()
}
// идём по устройствам
for( const auto& d: devices )
for( const auto& d : devices )
{
checkAddr = d.second->mbaddr;
if( d.second->pollmap.empty() )
continue;
// идём по списку опрашиваемых регистров
for( auto p = d.second->pollmap.begin(); p != d.second->pollmap.end(); ++p )
{
for( auto r = p->second->begin(); r!=p->second->end(); ++r )
for( auto r = p->second->begin(); r != p->second->end(); ++r )
{
if( ModbusRTU::isReadFunction(r->second->mbfunc) )
{
......@@ -681,7 +687,7 @@ void MBTCPMultiMaster::initCheckConnectionParameters()
<< endl;
// инициализируем..
for( auto&& m: mblist )
for( auto && m : mblist )
{
m->checkFunc = checkFunc;
m->checkAddr = checkAddr;
......
......@@ -160,7 +160,7 @@ std::shared_ptr<ModbusClient> RTUExchange::initMB( bool reopen )
mbinfo << myname << "(init): dev=" << devname << " speed=" << ComPort::getSpeed( mbrtu->getSpeed() ) << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
//if( mbrtu )
// delete mbrtu;
......
......@@ -61,7 +61,7 @@ int main( int argc, const char** argv )
act->run(false);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(mbtcpmaster): " << ex << std::endl;
}
......
......@@ -81,7 +81,7 @@ int main( int argc, const char** argv )
act->run(false);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(mbtcpmultimaster): " << ex << std::endl;
}
......
......@@ -76,7 +76,7 @@ int main( int argc, const char** argv )
act->run(false);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(mbtcpmultimaster): " << ex << std::endl;
}
......
......@@ -76,7 +76,7 @@ int main( int argc, char** argv )
act->run(false);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(rtuexchange): " << ex << std::endl;
}
......
......@@ -74,7 +74,7 @@ int main( int argc, const char* argv[] )
return session.run();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_mbtcpmaster): " << ex << endl;
}
......
......@@ -74,7 +74,7 @@ int main(int argc, const char* argv[] )
{
cerr << "(tests_mbtcpmultimaster): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_mbtcpmultimaster): " << ex << endl;
}
......
......@@ -96,7 +96,7 @@ TEST_CASE("MBTCPMaster: reconnect", "[modbus][mbmaster][mbtcpmaster]")
REQUIRE_FALSE(mb.isConnection());
// нормальное подключение
REQUIRE(mb.connect(iaddr,port));
REQUIRE(mb.connect(iaddr, port));
REQUIRE(mb.isConnection());
// переподключение (при активном текущем)
......@@ -116,7 +116,7 @@ TEST_CASE("MBTCPMaster: reconnect", "[modbus][mbmaster][mbtcpmaster]")
REQUIRE_FALSE(mb.isConnection());
// нормальное подключение
REQUIRE(mb.connect(iaddr,port));
REQUIRE(mb.connect(iaddr, port));
REQUIRE(mb.isConnection());
// принудительное отключение
......@@ -130,15 +130,17 @@ TEST_CASE("MBTCPMaster: forceDisconnect", "[modbus][mbmaster][mbtcpmaster][force
ModbusTCPMaster mb;
mb.setTimeout(500);
for( size_t i=0; i<1000; i++ )
for( size_t i = 0; i < 1000; i++ )
{
// подключение к несуществующему адресу
REQUIRE_FALSE(mb.connect(iaddr, 2048));
try
{
mb.read03(slaveADDR,10,1);
mb.read03(slaveADDR, 10, 1);
}
catch(...){}
catch(...) {}
REQUIRE_FALSE(mb.isConnection());
mb.forceDisconnect();
}
......@@ -151,15 +153,17 @@ TEST_CASE("MBTCPMaster: disconnect", "[modbus][mbmaster][mbtcpmaster][disconnect
mb.setTimeout(500);
mb.setForceDisconnect(true);
for( size_t i=0; i<1000; i++ )
for( size_t i = 0; i < 1000; i++ )
{
// подключение к несуществующему адресу
REQUIRE_FALSE(mb.connect(iaddr, 2048));
try
{
mb.read03(slaveADDR,10,1);
mb.read03(slaveADDR, 10, 1);
}
catch(...){}
catch(...) {}
REQUIRE_FALSE(mb.isConnection());
mb.disconnect();
}
......
......@@ -683,7 +683,7 @@ void MBSlave::updateStatistics()
shm->localSetValue(itHeartBeat, sidHeartBeat, maxHeartBeat, getId());
ptHeartBeat.reset();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(updateStatistics): (hb) " << ex << std::endl;
}
......@@ -700,7 +700,7 @@ void MBSlave::updateStatistics()
{
shm->localSetValue(itRespond, respond_id, (state ? 1 : 0), getId());
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(updateStatistics): (respond) " << ex << std::endl;
}
......@@ -712,7 +712,7 @@ void MBSlave::updateStatistics()
{
shm->localSetValue(itAskCount, askcount_id, askCount, getId());
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(updateStatistics): (askCount) " << ex << std::endl;
}
......@@ -724,7 +724,7 @@ void MBSlave::updateStatistics()
{
shm->localSetValue(sesscount_it, sesscount_id, tcpserver->getCountSessions(), getId());
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(updateStatistics): (sessCount) " << ex << std::endl;
}
......@@ -797,7 +797,7 @@ void MBSlave::updateTCPStatistics()
bool st = c.invert ? c.ptTimeout.checkTime() : !c.ptTimeout.checkTime();
shm->localSetValue(c.respond_it, c.respond_s, st, getId());
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(updateStatistics): " << ex << std::endl;
}
......@@ -809,7 +809,7 @@ void MBSlave::updateTCPStatistics()
{
shm->localSetValue(c.askcount_it, c.askcount_s, c.askCount, getId());
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mbcrit << myname << "(updateStatistics): " << ex << std::endl;
}
......@@ -1961,7 +1961,7 @@ ModbusRTU::mbErrCode MBSlave::real_write_prop( IOProperty* p, ModbusRTU::ModbusD
mbwarn << myname << "(real_write_prop): " << ex << endl;
return ModbusRTU::erBadDataValue;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( pingOK )
mbcrit << myname << "(real_write_prop): " << ex << endl;
......@@ -2214,7 +2214,7 @@ ModbusRTU::mbErrCode MBSlave::real_read_prop( IOProperty* p, ModbusRTU::ModbusDa
mbwarn << myname << "(real_read_prop): " << ex << endl;
return ModbusRTU::erBadDataValue;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( pingOK )
mbcrit << myname << "(real_read_prop): " << ex << endl;
......@@ -2354,7 +2354,7 @@ ModbusRTU::mbErrCode MBSlave::readCoilStatus( ReadCoilMessage& query,
mbwarn << myname << "(readCoilStatus): " << ex << endl;
return ModbusRTU::erBadDataAddress;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( pingOK )
mbcrit << myname << "(readCoilStatus): " << ex << endl;
......@@ -2427,7 +2427,7 @@ ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query,
mbwarn << myname << "(readInputStatus): " << ex << endl;
return ModbusRTU::erBadDataAddress;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( pingOK )
mbcrit << myname << "(readInputStatus): " << ex << endl;
......
......@@ -84,7 +84,7 @@ int main(int argc, const char** argv)
{
dcrit << "(mbslave): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(mbslave): " << ex << endl;
}
......
......@@ -95,7 +95,7 @@ int main(int argc, const char** argv)
{
dcrit << "(mbmultislave): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(mbmultislave): " << ex << endl;
}
......
......@@ -80,7 +80,7 @@ int main(int argc, const char* argv[] )
{
cerr << "(tests_with_sm): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_with_sm): " << ex << endl;
}
......
......@@ -59,6 +59,7 @@ RRDServer::RRDServer(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::O
{
// берём первый датчик из списка
const auto& lst = rrdlist.begin()->dslist;
if( !lst.empty() )
{
const auto& dsi = *(lst.begin());
......@@ -280,7 +281,7 @@ void RRDServer::help_print( int argc, const char* const* argv )
cout << " logfile filanme " << endl;
cout << " no-debug " << endl;
cout << " Base oprtions: " << endl;
// cout << UObject_SK::help() << endl;
// cout << UObject_SK::help() << endl;
cout << " LogServer: " << endl;
cout << "--prefix-run-logserver - run logserver. Default: localhost:id" << endl;
cout << "--prefix-logserver-host ip - listen ip. Default: localhost" << endl;
......
......@@ -127,7 +127,7 @@ void SMDBServer::step()
shm->localSaveValue(aitHeartBeat, sidHeartBeat, maxHeartBeat, getId());
ptHeartBeat.reset();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(step): (hb) " << ex << std::endl;
}
......@@ -183,7 +183,7 @@ void SMDBServer::initDB( DBInterface* db )
}
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << myname << "(filling ObjectsMap): " << ex << std::endl;
}
......
......@@ -71,7 +71,7 @@ int main( int argc, const char** argv )
act->run(false);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(smdbserver): " << ex << std::endl;
}
......
......@@ -38,7 +38,7 @@ int main( int argc, const char** argv )
smv.run();
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cout << "(main):" << ex << endl;
}
......
......@@ -398,7 +398,7 @@ void SharedMemory::checkHeartBeat()
}
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
smcrit << myname << "(checkHeartBeat): " << ex << endl;
}
......@@ -973,7 +973,7 @@ bool SharedMemory::initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectI
#endif
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
smcrit << myname << "(initFromSM): " << ex << endl;
}
......
......@@ -56,7 +56,7 @@ int main(int argc, const char** argv)
{
dcrit << "(smemory): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(smemory): " << ex << endl;
}
......
......@@ -97,7 +97,7 @@ int main(int argc, const char* argv[] )
{
cerr << "(tests): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests): " << ex << endl;
}
......
......@@ -224,7 +224,7 @@ int main( int argc, const char** argv )
on_sigchild(SIGTERM);
return 0;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(smemory-plus): " << ex << endl;
}
......
......@@ -85,7 +85,7 @@ UNetExchange::UNetExchange(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId sh
int maxProcessingCount = conf->getArgPInt("--" + prefix + "-maxprocessingcount", it.getProp("maxProcessingCount"), 100);
int checkConnectionPause = conf->getArgPInt("--" + prefix + "-checkconnection-pause", it.getProp("checkConnectionPause"), 10000);
std::string updateStrategy = conf->getArg2Param("--" + prefix + "-update-strategy", it.getProp("updateStartegy"),"evloop");
std::string updateStrategy = conf->getArg2Param("--" + prefix + "-update-strategy", it.getProp("updateStartegy"), "evloop");
no_sender = conf->getArgInt("--" + prefix + "-nosender", it.getProp("nosender"));
......@@ -312,11 +312,12 @@ UNetExchange::UNetExchange(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId sh
}
}
UNetReceiver::UpdateStrategy r_upStrategy = UNetReceiver::strToUpdateStrategy( n_it.getProp2("unet_update_strategy",updateStrategy) );
UNetReceiver::UpdateStrategy r_upStrategy = UNetReceiver::strToUpdateStrategy( n_it.getProp2("unet_update_strategy", updateStrategy) );
if( r_upStrategy == UNetReceiver::useUpdateUnknown )
{
ostringstream err;
err << myname << ": Unknown update strategy!!! '" << n_it.getProp2("unet_update_startegy",updateStrategy) << "'" << endl;
err << myname << ": Unknown update strategy!!! '" << n_it.getProp2("unet_update_startegy", updateStrategy) << "'" << endl;
unetcrit << myname << "(init): " << err.str() << endl;
throw SystemError(err.str());
}
......
......@@ -126,7 +126,7 @@ void UNetReceiver::setUpdatePause( timeout_t msec ) noexcept
updatepause = msec;
if( upStrategy == useUpdateEventLoop && evUpdate.is_active() )
evUpdate.start(0, (float)updatepause/1000.);
evUpdate.start(0, (float)updatepause / 1000.);
}
// -----------------------------------------------------------------------------
void UNetReceiver::setMaxProcessingCount( int set ) noexcept
......@@ -178,6 +178,7 @@ bool UNetReceiver::createConnection( bool throwEx )
udp = make_shared<UDPReceiveU>(addr, port);
udp->setBlocking(false); // делаем неблокирующее чтение (нужно для libev)
evReceive.set<UNetReceiver, &UNetReceiver::callback>(this);
if( upStrategy == useUpdateEventLoop )
evUpdate.set<UNetReceiver, &UNetReceiver::updateEvent>(this);
......@@ -241,7 +242,7 @@ void UNetReceiver::evprepare( const ev::loop_ref& eloop ) noexcept
{
evUpdate.set(eloop);
evUpdate.start();
evUpdate.start( 0, ((float)updatepause/1000.) );
evUpdate.start( 0, ((float)updatepause / 1000.) );
}
if( !udp )
......@@ -282,7 +283,7 @@ void UNetReceiver::evfinish( const ev::loop_ref& eloop ) noexcept
// -----------------------------------------------------------------------------
void UNetReceiver::forceUpdate() noexcept
{
pack_guard l(packMutex,upStrategy);
pack_guard l(packMutex, upStrategy);
pnum = 0; // сбрасываем запомненый номер последнего обработанного пакета
// и тем самым заставляем обновить данные в SM (см. update)
}
......@@ -298,10 +299,10 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents) noexcept
statRecvPerSec = recvCount;
statUpPerSec = upCount;
// unetlog9 << myname << "(statisctics):"
// << " recvCount=" << recvCount << "[per sec]"
// << " upCount=" << upCount << "[per sec]"
// << endl;
// unetlog9 << myname << "(statisctics):"
// << " recvCount=" << recvCount << "[per sec]"
// << " upCount=" << upCount << "[per sec]"
// << endl;
recvCount = 0;
upCount = 0;
......@@ -321,7 +322,7 @@ void UNetReceiver::update() noexcept
{
{
// lock qpack
pack_guard l(packMutex,upStrategy);
pack_guard l(packMutex, upStrategy);
if( qpack.empty() )
return;
......@@ -720,7 +721,7 @@ bool UNetReceiver::receive() noexcept
{
// lock qpack
pack_guard l(packMutex,upStrategy);
pack_guard l(packMutex, upStrategy);
if( !waitClean )
{
......@@ -878,6 +879,7 @@ string UNetReceiver::to_string( UNetReceiver::UpdateStrategy s ) noexcept
{
if( s == useUpdateThread )
return "thread";
if( s == useUpdateEventLoop )
return "evloop";
......
......@@ -323,7 +323,7 @@ class UNetReceiver:
struct CacheInfo
{
CacheInfo():
cache_init_ok(false){}
cache_init_ok(false) {}
bool cache_init_ok = { false };
CacheVec cache;
......
......@@ -146,7 +146,7 @@ bool UNetSender::createConnection( bool throwEx )
// -----------------------------------------------------------------------------
void UNetSender::updateFromSM()
{
for( auto&& it: items )
for( auto && it : items )
{
UItem& i = it.second;
long value = shm->localGetValue(i.ioit, i.id);
......@@ -160,6 +160,7 @@ void UNetSender::updateSensor( UniSetTypes::ObjectId id, long value )
return;
auto it = items.find(id);
if( it != items.end() )
updateItem( it->second, value );
}
......@@ -170,6 +171,7 @@ void UNetSender::updateItem( UItem& it, long value )
auto& mypack(pk[it.pack_num]);
UniSetTypes::uniset_rwmutex_wrlock l(mypack.mut);
if( it.iotype == UniversalIO::DI || it.iotype == UniversalIO::DO )
mypack.msg.setDData(it.pack_ind, value);
else if( it.iotype == UniversalIO::AI || it.iotype == UniversalIO::AO )
......@@ -280,6 +282,7 @@ void UNetSender::real_send( PackMessage& mypack ) noexcept
mypack.msg.num = packetnum++;
lastcrc = crc;
}
#endif
// при переходе через ноль (когда счётчик перевалит через UniSetUDP::MaxPacketNum..
......@@ -482,6 +485,7 @@ bool UNetSender::initItem( UniXML::iterator& it )
unetinfo << myname << "(initItem): add " << p << endl;
auto i = items.find(p.id);
if( i != items.end() )
{
unetcrit << myname
......@@ -535,8 +539,9 @@ const std::string UNetSender::getShortInfo() const
for( auto i = mypacks.begin(); i != mypacks.end(); ++i )
{
s << " \t[" << i->first << "]=" << i->second.size() << endl;
size_t n=0;
for( const auto& p: i->second )
size_t n = 0;
for( const auto& p : i->second )
{
//uniset_rwmutex_rlock l(p->mut);
s << " \t\t[" << (n++) << "]=" << p.msg.sizeOf() << " bytes"
......
......@@ -91,7 +91,7 @@ class UNetSender
friend std::ostream& operator<<( std::ostream& os, UItem& p );
};
typedef std::unordered_map<UniSetTypes::ObjectId,UItem> UItemMap;
typedef std::unordered_map<UniSetTypes::ObjectId, UItem> UItemMap;
size_t getDataPackCount() const;
......@@ -102,7 +102,7 @@ class UNetSender
struct PackMessage
{
PackMessage( UniSetUDP::UDPMessage&& m ) noexcept:msg(std::move(m)){}
PackMessage( UniSetUDP::UDPMessage&& m ) noexcept: msg(std::move(m)) {}
PackMessage( const UniSetUDP::UDPMessage& m ) = delete;
PackMessage() noexcept {}
......
......@@ -187,7 +187,7 @@ TEST_CASE("[UNetUDP]: sizeOf", "[unetudp][sizeof]")
m.addAData(8, 70);
REQUIRE( m.sizeOf() == sizeof(UniSetUDP::UDPHeader)+sizeof(UniSetUDP::UDPAData) );
REQUIRE( m.sizeOf() == sizeof(UniSetUDP::UDPHeader) + sizeof(UniSetUDP::UDPAData) );
UniSetUDP::UDPPacket p;
size_t len = m.transport_msg(p);
......
......@@ -69,7 +69,7 @@ int main(int argc, char* argv[] )
{
cerr << "(tests_with_sm): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_with_sm): " << ex << endl;
}
......
......@@ -74,7 +74,7 @@ int main(int argc, const char* argv[] )
{
cerr << "(tests_with_sm): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_with_sm): " << ex << endl;
}
......
......@@ -187,7 +187,7 @@ int main(int argc, char* argv[] )
{
cerr << "(urecv-perf-test): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(urecv-perf-test): " << ex << endl;
}
......
......@@ -312,8 +312,9 @@ int main(int argc, char* argv[])
if( !a_data.empty() )
{
auto vlist = UniSetTypes::getSInfoList(a_data,nullptr);
for( const auto& v: vlist )
auto vlist = UniSetTypes::getSInfoList(a_data, nullptr);
for( const auto& v : vlist )
{
UDPAData d(v.si.id, v.val);
mypack.addAData(d);
......@@ -330,9 +331,10 @@ int main(int argc, char* argv[])
if( !d_data.empty() )
{
auto vlist = UniSetTypes::getSInfoList(d_data,nullptr);
for( const auto& v: vlist )
mypack.addDData(v.si.id,v.val);
auto vlist = UniSetTypes::getSInfoList(d_data, nullptr);
for( const auto& v : vlist )
mypack.addDData(v.si.id, v.val);
}
else
{
......
......@@ -60,7 +60,7 @@ int main( int argc, const char** argv )
act->run(false);
on_sigchild(SIGTERM);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dcrit << "(unetexchange): " << ex << std::endl;
}
......
......@@ -184,7 +184,7 @@ void UniExchange::execute()
dinfo << myname << " update sensors from id=" << it.id << " node=" << it.node << endl;
it.update(sseq, shm);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dwarn << myname << "(execute): " << ex << endl;
}
......@@ -258,7 +258,7 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, con
*/
shm->localSetValue( s->ioit, m->id, m->value, shm->ID() );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dwarn << "(update): " << ex << endl;
}
......@@ -303,7 +303,7 @@ void UniExchange::updateLocalData()
uniset_rwmutex_wrlock lock(it.val_lock);
it.val = shm->localGetValue( it.ioit, it.id );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dwarn << "(update): " << ex << endl;
}
......
......@@ -77,8 +77,8 @@ class Calibration
{
public:
Calibration();
Calibration( const std::string& name, const std::string& confile = "calibration.xml", size_t reserv=50 );
Calibration( xmlNode* node, size_t reserv=50 );
Calibration( const std::string& name, const std::string& confile = "calibration.xml", size_t reserv = 50 );
Calibration( xmlNode* node, size_t reserv = 50 );
~Calibration();
/*! Тип для хранения значения */
......
......@@ -244,10 +244,11 @@ namespace MTR
// ------------------------------------------
// конструкторы на разные случаи...
T4(): sval(""), raw(0) {}
T4( unsigned short v1 ): raw(v1)
T4( uint16_t v1 ): raw(v1)
{
char c[3];
memcpy(c, &v1, sizeof(c));
char c[sizeof(v1) + 1];
memcpy(c, &v1, sizeof(v1));
c[sizeof(v1)] = '\0';
sval = std::string(c);
}
......@@ -255,7 +256,8 @@ namespace MTR
raw(data[0])
{
char c[3];
memcpy(c, &(data[0]), sizeof(c));
memcpy(c, &(data[0]), 2);
c[2] = '\0';
sval = std::string(c);
}
......
......@@ -29,7 +29,7 @@ class UObject_SK:
public UniSetObject
{
public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node = UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix = "" );
UObject_SK();
virtual ~UObject_SK();
......@@ -43,54 +43,60 @@ class UObject_SK:
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true ) noexcept;
inline std::shared_ptr<DebugStream> log() noexcept { return mylog; }
inline std::shared_ptr<LogAgregator> logAgregator() noexcept { return loga; }
inline std::shared_ptr<DebugStream> log() noexcept
{
return mylog;
}
inline std::shared_ptr<LogAgregator> logAgregator() noexcept
{
return loga;
}
void init_dlog( std::shared_ptr<DebugStream> d ) noexcept;
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
......@@ -107,16 +113,19 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
std::string str( UniSetTypes::ObjectId id, bool showLinkName = true ) const;
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
std::string strval( UniSetTypes::ObjectId id, bool showLinkName = true ) const;
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
inline std::string dumpVars()
{
return std::move(vmon.pretty_str());
}
// ------------------------------------------------------------
std::string help() noexcept;
......@@ -145,16 +154,19 @@ class UObject_SK:
virtual void callback() noexcept override;
virtual void processingMessage( const UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){};
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override {}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override {}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
virtual std::string getMonitInfo()
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
// Выполнение очередного шага программы
virtual void step(){}
virtual void step() {}
void preAskSensors( UniversalIO::UIOCommand cmd );
void preSysCommand( const UniSetTypes::SystemMessage* sm );
......@@ -183,9 +195,15 @@ class UObject_SK:
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
int getIntProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getIntProp(confnode, name);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
inline const std::string getProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getProp(confnode, name);
}
timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
......
......@@ -114,7 +114,10 @@ namespace VTypes
// ------------------------------------------
// конструкторы на разные случаи...
F2r() noexcept { raw_backorder.val = 0; }
F2r() noexcept
{
raw_backorder.val = 0;
}
F2r( const float& f ) noexcept: F2(f)
{
......@@ -383,7 +386,10 @@ namespace VTypes
public I2
{
public:
I2r() noexcept { raw_backorder.val = 0; }
I2r() noexcept
{
raw_backorder.val = 0;
}
I2r( const int v ) noexcept: I2(v)
{
......@@ -457,7 +463,10 @@ namespace VTypes
public U2
{
public:
U2r() noexcept { raw_backorder.val = 0; }
U2r() noexcept
{
raw_backorder.val = 0;
}
U2r( int v ) noexcept: U2(v)
{
......
......@@ -41,7 +41,7 @@ Calibration::Part::Part( const Point& pleft, const Point& pright ) noexcept:
k(0)
{
if( p_right.x < p_left.x )
std::swap(p_right,p_left);
std::swap(p_right, p_left);
// вычисление коэффициента наклона (один раз в конструкторе)
// k = (y2-y1)/(x2-x1)
......
......@@ -32,28 +32,28 @@ using namespace UniSetTypes;
// -----------------------------------------------------------------------------
UObject_SK::UObject_SK():
// Инициализация идентификаторов (имена берутся из конф. файла)
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables (public and proteced)
// variables (public and proteced)
// ------------------
active(false),
// ------------------
active(false),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(0),
smReadyTimeout(0),
activated(false),
askPause(2000),
forceOut(false),
// private variables
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(0),
smReadyTimeout(0),
activated(false),
askPause(2000),
forceOut(false),
// private variables
end_private(false)
end_private(false)
{
mycrit << "UObject: init failed!!!!!!!!!!!!!!!" << endl;
throw Exception( string(myname+": init failed!!!") );
throw Exception( string(myname + ": init failed!!!") );
}
// -----------------------------------------------------------------------------
// ( val, confval, default val )
......@@ -61,6 +61,7 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{
if( !s1.empty() )
return s1;
if( !s2.empty() )
return s2;
......@@ -74,41 +75,41 @@ static UniSetTypes::ObjectId init_node( xmlNode* cnode, const std::string& prop
auto conf = uniset_conf();
if( conf->getProp(cnode,prop).empty() )
if( conf->getProp(cnode, prop).empty() )
return conf->getLocalNode();
return conf->getNodeID(conf->getProp(cnode,prop));
return conf->getNodeID(conf->getProp(cnode, prop));
}
// -----------------------------------------------------------------------------
UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argprefix ):
UniSetObject(id),
// Инициализация идентификаторов (имена берутся из конф. файла)
UniSetObject(id),
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables
// variables
sleep_msec(150),
active(true),
argprefix( (_argprefix.empty() ? myname+"-" : _argprefix) ),
sleep_msec(150),
active(true),
argprefix( (_argprefix.empty() ? myname + "-" : _argprefix) ),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(cnode),
smReadyTimeout(0),
activated(false),
askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)),
forceOut(false),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(cnode),
smReadyTimeout(0),
activated(false),
askPause(uniset_conf()->getPIntProp(cnode, "askPause", 2000)),
forceOut(false),
end_private(false)
end_private(false)
{
auto conf = uniset_conf();
if( UniSetTypes::findArgParam("--print-id-list",uniset_conf()->getArgc(),uniset_conf()->getArgv()) != -1 )
if( UniSetTypes::findArgParam("--print-id-list", uniset_conf()->getArgc(), uniset_conf()->getArgv()) != -1 )
{
// abort();
// abort();
}
......@@ -124,10 +125,10 @@ end_private(false)
{
ostringstream s;
s << argprefix << "log";
conf->initLogStream(mylog,s.str());
conf->initLogStream(mylog, s.str());
}
loga = make_shared<LogAgregator>(myname+"-loga");
loga = make_shared<LogAgregator>(myname + "-loga");
loga->add(mylog);
loga->add(ulog());
......@@ -145,12 +146,14 @@ end_private(false)
logserv_port = conf->getArgPInt("--" + argprefix + "logserver-port", it.getProp("logserverPort"), getId());
}
forceOut = conf->getArgPInt("--" + argprefix + "force-out",it.getProp("forceOut"),false);
forceOut = conf->getArgPInt("--" + argprefix + "force-out", it.getProp("forceOut"), false);
string heart = conf->getArgParam("--" + argprefix + "heartbeat-id", it.getProp("heartbeat_id"));
string heart = conf->getArgParam("--" + argprefix + "heartbeat-id",it.getProp("heartbeat_id"));
if( !heart.empty() )
{
idHeartBeat = conf->getSensorID(heart);
if( idHeartBeat == DefaultObjectId )
{
ostringstream err;
......@@ -158,13 +161,14 @@ end_private(false)
throw SystemError(err.str());
}
int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time",it.getProp("heartbeatTime"),conf->getHeartBeatTime());
if( heartbeatTime>0 )
int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time", it.getProp("heartbeatTime"), conf->getHeartBeatTime());
if( heartbeatTime > 0 )
ptHeartBeat.setTiming(heartbeatTime);
else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgPInt("--" + argprefix + "heartbeat-max",it.getProp("heartbeat_max"), 10);
maxHeartBeat = conf->getArgPInt("--" + argprefix + "heartbeat-max", it.getProp("heartbeat_max"), 10);
}
// Инициализация значений
......@@ -173,16 +177,18 @@ end_private(false)
si.id = UniSetTypes::DefaultObjectId;
si.node = conf->getLocalNode();
sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec","150", 150);
sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec", "150", 150);
string s_resetTime("");
if( s_resetTime.empty() )
s_resetTime = "500";
resetMsgTime = uni_atoi(init3_str(conf->getArgParam("--" + argprefix + "resetMsgTime"),conf->getProp(cnode,"resetMsgTime"),s_resetTime));
resetMsgTime = uni_atoi(init3_str(conf->getArgParam("--" + argprefix + "resetMsgTime"), conf->getProp(cnode, "resetMsgTime"), s_resetTime));
ptResetMsg.setTiming(resetMsgTime);
int sm_tout = conf->getArgInt("--" + argprefix + "sm-ready-timeout","");
int sm_tout = conf->getArgInt("--" + argprefix + "sm-ready-timeout", "");
if( sm_tout == 0 )
smReadyTimeout = 60000;
else if( sm_tout < 0 )
......@@ -190,7 +196,7 @@ end_private(false)
else
smReadyTimeout = sm_tout;
smTestID = conf->getSensorID(init3_str(conf->getArgParam("--" + argprefix + "sm-test-id"),conf->getProp(cnode,"smTestID"),""));
smTestID = conf->getSensorID(init3_str(conf->getArgParam("--" + argprefix + "sm-test-id"), conf->getProp(cnode, "smTestID"), ""));
if( smTestID == DefaultObjectId )
......@@ -216,7 +222,7 @@ end_private(false)
// help надо выводить в конце, когда уже все переменные инициализированы по умолчанию
if( UniSetTypes::findArgParam("--" + argprefix + "help",uniset_conf()->getArgc(),uniset_conf()->getArgv()) != -1 )
if( UniSetTypes::findArgParam("--" + argprefix + "help", uniset_conf()->getArgc(), uniset_conf()->getArgv()) != -1 )
cout << help() << endl;
}
......@@ -268,7 +274,7 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state ) noexcept
void UObject_SK::resetMsg()
{
mylog8 << myname << "(resetMsg): reset messages.." << endl;
// reset messages
// reset messages
}
// -----------------------------------------------------------------------------
......@@ -306,19 +312,23 @@ std::string UObject_SK::dumpIO()
s << endl;
int n = 0;
for( const auto& e: v_in )
for( const auto& e : v_in )
{
s << e;
if( (n++)%2 )
if( (n++) % 2 )
s << std::endl;
}
s << endl;
n = 0;
for( const auto& e: v_out )
for( const auto& e : v_out )
{
s << e;
if( (n++)%2 )
if( (n++) % 2 )
s << std::endl;
}
......@@ -382,11 +392,13 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
{
case SystemMessage::WatchDog:
myinfo << myname << "(preSysCommand): WatchDog" << endl;
if( !active || !ptStartUpTimeout.checkTime() )
{
mywarn << myname << "(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl;
break;
}
case SystemMessage::StartUp:
{
if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() )
......@@ -419,9 +431,10 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
// переоткрываем логи
mylogany << myname << "(preSysCommand): logRotate" << endl;
string fname( log()->getLogFile() );
if( !fname.empty() )
{
mylog->logFile(fname.c_str(),true);
mylog->logFile(fname.c_str(), true);
mylogany << myname << "(preSysCommand): ***************** mylog LOG ROTATE *****************" << endl;
}
......@@ -445,6 +458,7 @@ UniSetTypes::SimpleInfo* UObject_SK::getInfo( CORBA::Long userparam )
ostringstream inf;
inf << i->info << endl;
if( logserv /* && userparam < 0 */ )
{
inf << "LogServer: " << logserv_host << ":" << logserv_port
......@@ -459,14 +473,16 @@ UniSetTypes::SimpleInfo* UObject_SK::getInfo( CORBA::Long userparam )
inf << endl;
auto timers = getTimersList();
inf << "Timers[" << timers.size() << "]:" << endl;
for( const auto& t: timers )
for( const auto& t : timers )
{
inf << " " << setw(15) << getTimerName(t.id) << "[" << t.id << "]: msec="
<< setw(6) << t.tmr.getInterval()
<< " timeleft=" << setw(6) << t.curTimeMS
<< " tick=" << setw(3) << ( t.curTick>=0 ? t.curTick : -1 )
<< " tick=" << setw(3) << ( t.curTick >= 0 ? t.curTick : -1 )
<< endl;
}
inf << endl;
inf << vmon.pretty_str() << endl;
inf << endl;
......@@ -520,7 +536,7 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<< " testID=" << _testID << endl;
// waitReady можно использовать т.к. датчик это по сути IONotifyController
if( !ui->waitReady(_testID,wait_msec) )
if( !ui->waitReady(_testID, wait_msec) )
{
ostringstream err;
err << myname
......@@ -528,14 +544,14 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<< wait_msec << " мсек";
mycrit << err.str() << endl;
// terminate();
// abort();
// terminate();
// abort();
raise(SIGTERM);
terminate();
// throw SystemError(err.str());
// throw SystemError(err.str());
}
if( !ui->waitWorking(_testID,wait_msec) )
if( !ui->waitWorking(_testID, wait_msec) )
{
ostringstream err;
err << myname
......@@ -543,10 +559,10 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<< wait_msec << " мсек";
mycrit << err.str() << endl;
// terminate();
// abort();
// terminate();
// abort();
raise(SIGTERM);
// throw SystemError(err.str());
// throw SystemError(err.str());
}
}
// ----------------------------------------------------------------------------
......@@ -582,39 +598,42 @@ void UObject_SK::callback() noexcept
{
if( !active )
return;
try
{
// проверка таймеров
checkTimers(this);
if( resetMsgTime>0 && trResetMsg.hi(ptResetMsg.checkTime()) )
if( resetMsgTime > 0 && trResetMsg.hi(ptResetMsg.checkTime()) )
{
// cout << myname << ": ********* reset messages *********" << endl;
// cout << myname << ": ********* reset messages *********" << endl;
resetMsg();
}
// обработка сообщений (таймеров и т.п.)
for( unsigned int i=0; i<20; i++ )
for( unsigned int i = 0; i < 20; i++ )
{
auto m = receiveMessage();
if( !m )
break;
processingMessage(m.get());
updateOutputs(forceOut);
// updatePreviousValues();
// updatePreviousValues();
}
// Выполнение шага программы
step();
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() )
if( idHeartBeat != DefaultObjectId && ptHeartBeat.checkTime() )
{
try
{
ui->setValue(idHeartBeat,maxHeartBeat);
ui->setValue(idHeartBeat, maxHeartBeat);
ptHeartBeat.reset();
}
catch( const Exception& ex )
......@@ -636,7 +655,7 @@ void UObject_SK::callback() noexcept
mycrit << myname << "(execute): СORBA::SystemException: "
<< ex.NP_minorString() << endl;
}
catch( const std::exception&ex )
catch( const std::exception& ex )
{
mycrit << myname << "(execute): catch " << ex.what() << endl;
}
......@@ -654,7 +673,7 @@ void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
ui->setValue(_sid,_val);
ui->setValue(_sid, _val);
}
// -----------------------------------------------------------------------------
void UObject_SK::updateOutputs( bool _force )
......@@ -676,7 +695,7 @@ void UObject_SK::initFromSM()
// -----------------------------------------------------------------------------
void UObject_SK::askSensor( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node )
{
ui->askRemoteSensor(_sid,_cmd,_node,getId());
ui->askRemoteSensor(_sid, _cmd, _node, getId());
}
// -----------------------------------------------------------------------------
long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
......@@ -687,7 +706,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
return ui->getValue(_sid);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mycrit << myname << "(getValue): " << ex << endl;
throw;
......@@ -698,10 +717,12 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
{
PassiveTimer ptAct(activateTimeout);
while( !activated && !ptAct.checkTime() )
{
cout << myname << "(preAskSensors): wait activate..." << endl;
msleep(300);
if( activated )
break;
}
......@@ -717,11 +738,11 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
return;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mycrit << myname << "(preAskSensors): " << ex << endl;
}
catch( const std::exception&ex )
catch( const std::exception& ex )
{
mycrit << myname << "(execute): catch " << ex.what() << endl;
}
......
......@@ -200,7 +200,7 @@ void TestProc::test_thresholds()
ti = ui->getThresholdInfo(t_set_c, tid);
cerr << myname << ": ask ON threshold: " << ( ti.state == IONotifyController_i::HiThreshold ? "ok" : "FAIL" ) << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mylog2 << myname << ": CHECK 'ask and get threshold' FAILED: " << ex << endl;
}
......
......@@ -36,8 +36,8 @@ class TestProc:
void test_loglevel();
private:
bool state;
bool undef;
bool state = { false };
bool undef = { false };
std::vector<Debug::type> loglevels;
std::vector<Debug::type>::iterator lit;
......
......@@ -50,11 +50,11 @@ int main(int argc, const char** argv)
return 0;
}
catch( const SystemError& err )
catch( const UniSetTypes::SystemError& err )
{
ucrit << "(smemory): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << "(smemory): " << ex << endl;
}
......
......@@ -49,11 +49,11 @@ int main(int argc, const char** argv)
return 0;
}
catch( const SystemError& err )
catch( const UniSetTypes::SystemError& err )
{
cerr << "(mq-test): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(mq-test): " << ex << endl;
}
......
......@@ -53,8 +53,8 @@ void TestProc::sysCommand( const UniSetTypes::SystemMessage* sm )
// -----------------------------------------------------------------------------
string TestProc::getMonitInfo()
{
// int* p = 0;
// (*p) = 10;
// int* p = 0;
// (*p) = 10;
return "";
}
......@@ -176,7 +176,7 @@ void TestProc::test_thresholds()
ti = ui->getThresholdInfo(t_set_c, tid);
cerr << myname << ": ask ON threshold: " << ( ti.state == IONotifyController_i::HiThreshold ? "ok" : "FAIL" ) << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
mylog2 << myname << ": CHECK 'ask and get threshold' FAILED: " << ex << endl;
}
......
......@@ -54,7 +54,7 @@ int main(int argc, const char** argv)
{
ucrit << "(smemory): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << "(smemory): " << ex << endl;
}
......
......@@ -117,11 +117,11 @@ int main(int argc, char* argv[] )
std::cerr << "elapsed time: " << elapsed_seconds << " ms\n";
return 0;
}
catch( const SystemError& err )
catch( const UniSetTypes::SystemError& err )
{
cerr << "(tests_with_sm): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_with_sm): " << ex << endl;
}
......
......@@ -92,11 +92,11 @@ int main(int argc, const char* argv[] )
return session.run();
}
catch( const SystemError& err )
catch( const UniSetTypes::SystemError& err )
{
cerr << "(tests_with_sm): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(tests_with_sm): " << ex << endl;
}
......
......@@ -27,10 +27,10 @@
class DelayTimer
{
public:
DelayTimer(){}
DelayTimer() {}
DelayTimer( timeout_t on_msec, timeout_t off_msec ) noexcept:
onDelay(on_msec), offDelay(off_msec){}
onDelay(on_msec), offDelay(off_msec) {}
~DelayTimer() noexcept {}
......
......@@ -260,7 +260,7 @@ class IOController:
USensorInfo( USensorInfo&& ) = default;
USensorInfo& operator=(USensorInfo&& ) = default;
USensorInfo(): d_value(0), d_off_value(0)
USensorInfo(): d_value(1), d_off_value(0)
{
d_si.id = UniSetTypes::DefaultObjectId;
d_si.node = UniSetTypes::DefaultObjectId;
......@@ -298,8 +298,8 @@ class IOController:
ChangeUndefinedStateSignal sigUndefChange;
IOController_i::SensorInfo d_si; /*!< идентификатор датчика, от которого зависит данный */
long d_value; /*!< разрешающее работу значение датчика от которого зависит данный */
long d_off_value; /*!< блокирующее значение */
long d_value = { 1 }; /*!< разрешающее работу значение датчика от которого зависит данный */
long d_off_value = { 0 }; /*!< блокирующее значение */
std::shared_ptr<USensorInfo> d_usi; // shared_ptr на датчик от которого зависит этот.
// функция обработки информации об изменении состояния датчика, от которого зависит данный
......
......@@ -139,8 +139,8 @@ class LT_Object
/*! Информация о таймере */
struct TimerInfo
{
TimerInfo(): id(0), curTimeMS(0), priority(UniSetTypes::Message::High) {};
TimerInfo(UniSetTypes::TimerId id, timeout_t timeMS, clock_t cnt, UniSetTypes::Message::Priority p):
TimerInfo() {};
TimerInfo( UniSetTypes::TimerId id, timeout_t timeMS, clock_t cnt, UniSetTypes::Message::Priority p ):
id(id),
curTimeMS(timeMS),
priority(p),
......@@ -155,15 +155,15 @@ class LT_Object
tmr.reset();
}
UniSetTypes::TimerId id; /*!< идентификатор таймера */
timeout_t curTimeMS; /*!< остаток времени */
UniSetTypes::Message::Priority priority; /*!< приоритет посылаемого сообщения */
UniSetTypes::TimerId id = { 0 }; /*!< идентификатор таймера */
timeout_t curTimeMS = { 0 }; /*!< остаток времени */
UniSetTypes::Message::Priority priority = { UniSetTypes::Message::High }; /*!< приоритет посылаемого сообщения */
/*!
* текущий такт
* \note Если задано количество -1 то сообщения будут поылатся постоянно
* \note Если задано количество -1 то сообщения будут посылатся постоянно
*/
clock_t curTick;
clock_t curTick = { -1 };
// таймер с меньшим временем ожидания имеет больший приоритет
bool operator < ( const TimerInfo& ti ) const
......
......@@ -178,12 +178,12 @@ class NCRestorer_XML:
static xmlNode* bind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
static xmlNode* rebind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
std::string s_filterField;
std::string s_filterValue;
std::string t_filterField;
std::string t_filterValue;
std::string s_filterField = { "" };
std::string s_filterValue = { "" };
std::string t_filterField = { "" };
std::string t_filterValue = { "" };
std::string fname;
std::string fname = { "" };
std::shared_ptr<UniXML> uxml;
ReaderSlot rtslot;
NCReaderSlot ncrslot;
......
......@@ -62,11 +62,11 @@ class PassiveObject
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) {}
std::string myname;
std::string myname = { "" };
ProxyManager* mngr = { nullptr };
ProxyManager* mngr;
private:
UniSetTypes::ObjectId id;
UniSetTypes::ObjectId id = { UniSetTypes::DefaultObjectId };
};
// -------------------------------------------------------------------------
......
......@@ -55,7 +55,7 @@ class UniSetTimer
// некоторые классы могут не иметь подобных
// свойств.
virtual bool wait(timeout_t timeMS); /*!< заснуть ожидая наступления времени */
virtual void terminate(){} /*!< прервать работу таймера */
virtual void terminate() {} /*!< прервать работу таймера */
/*! завершить работу таймера */
virtual void stop() noexcept;
......
......@@ -105,10 +105,10 @@ class Restorer_XML
ReaderSlot rslot;
ReaderSlot cslot;
std::string i_filterField;
std::string i_filterValue;
std::string c_filterField;
std::string c_filterValue;
std::string i_filterField = { "" };
std::string i_filterValue = { "" };
std::string c_filterField = { "" };
std::string c_filterValue = { "" };
};
// --------------------------------------------------------------------------
#endif
......
......@@ -279,8 +279,8 @@ class UInterface
typedef std::unordered_map<UniSetTypes::KeyType, Item> CacheMap;
mutable CacheMap mcache;
mutable UniSetTypes::uniset_rwmutex cmutex;
size_t MaxSize; /*!< максимальный размер кэша */
size_t minCallCount; /*!< минимальное количество вызовов, меньше которого ссылка считается устаревшей */
size_t MaxSize = { 20 }; /*!< максимальный размер кэша */
size_t minCallCount = { 20 }; /*!< минимальное количество вызовов, меньше которого ссылка считается устаревшей */
};
void initBackId( UniSetTypes::ObjectId backid );
......
......@@ -114,7 +114,7 @@ class UniSetActivator:
TerminateEvent_Signal s_term;
std::atomic_bool omDestroy;
pid_t thid; // id orb потока
pid_t thid = { 0 }; // id orb потока
bool _noUseGdbForStackTrace = { false };
......
......@@ -18,8 +18,8 @@ class ModbusTCPMaster:
ModbusTCPMaster();
virtual ~ModbusTCPMaster();
bool connect( const std::string& addr, int port, bool closeOldConnection=true ) noexcept;
bool connect( const Poco::Net::SocketAddress& addr, int _port, bool closeOldConnection=true ) noexcept;
bool connect( const std::string& addr, int port, bool closeOldConnection = true ) noexcept;
bool connect( const Poco::Net::SocketAddress& addr, int _port, bool closeOldConnection = true ) noexcept;
void disconnect();
void forceDisconnect();
......
......@@ -191,7 +191,7 @@ size_t ComPort485F::sendBlock(unsigned char* msg, size_t len )
m_read(2000);
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( tmit_ctrl_on )
{
......@@ -234,7 +234,7 @@ void ComPort485F::sendByte( unsigned char x )
wq.push(x);
m_read(2000);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
if( tmit_ctrl_on )
{
......
......@@ -391,7 +391,7 @@ mbErrCode ModbusClient::recv( ModbusAddr addr, ModbusByte qfunc,
cleanupChannel();
return erTimeOut;
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
if( dlog->is_crit() )
dlog->crit() << "(recv): " << ex << endl;
......@@ -1326,7 +1326,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
return erTimeOut;
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
if( dlog->is_crit() )
dlog->crit() << "(recv): " << ex << endl;
......@@ -1367,7 +1367,7 @@ mbErrCode ModbusClient::send( ModbusMessage& msg )
msg.swapHead();
return ex.err;
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
if( dlog->is_crit() )
dlog->crit() << "(send): " << ex << endl;
......
......@@ -142,7 +142,7 @@ mbErrCode ModbusRTUMaster::sendData(unsigned char* buf, size_t len )
{
port->sendBlock(buf, len);
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
dlog->crit() << "(send): " << ex << endl;
return erHardwareError;
......
......@@ -120,7 +120,7 @@ mbErrCode ModbusRTUSlave::sendData( unsigned char* buf, int len )
{
port->sendBlock(buf, len);
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
if( dlog->is_crit() )
dlog->crit() << "(send): " << ex << endl;
......
......@@ -63,7 +63,7 @@ void ModbusServer::setRecvTimeout( timeout_t msec )
timeout_t ModbusServer::setReplyTimeout( timeout_t msec )
{
// #warning "Why msec can be 0?"
assert(msec>0);
assert(msec > 0);
if( msec == UniSetTimer::WaitUpTime )
return replyTimeout_ms;
......@@ -638,7 +638,7 @@ mbErrCode ModbusServer::recv( const std::unordered_set<ModbusRTU::ModbusAddr>& v
cleanupChannel();
return erSessionClosed;
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
dlog->crit() << "(recv): " << ex << endl;
cleanupChannel();
......@@ -1775,7 +1775,7 @@ mbErrCode ModbusServer::send( ModbusMessage& msg )
sendData(msg.buf(), len);
msg.swapHead(); // обратно, т.к. потом ещё будет post_send_request
}
catch( const Exception& ex ) // SystemError
catch( const UniSetTypes::Exception& ex ) // SystemError
{
if( dlog->is_crit() )
dlog->crit() << "(ModbusServer::send): " << ex << endl;
......
......@@ -186,11 +186,11 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
{
try
{
Poco::Net::SocketAddress iaddr = tcp->peerAddress();
Poco::Net::SocketAddress ia = tcp->peerAddress();
dlog->warn() << "(ModbusTCPMaster::query): ret=" << ret
<< " < rmh=" << sizeof(reply.aduhead)
<< " perr: " << iaddr.host().toString() << ":" << iaddr.port()
<< " perr: " << ia.host().toString() << ":" << ia.port()
<< endl;
}
catch( const Poco::Net::NetException& ex )
......@@ -201,8 +201,10 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
}
cleanInputStream();
if( tcp )
tcp->forceDisconnect();
return erTimeOut; // return erHardwareError;
}
......
......@@ -427,7 +427,7 @@ void ReadCoilMessage::init( const ModbusMessage& m )
assert( m.pduhead.func == fnReadCoilStatus );
// memset(this, 0, sizeof(*this));
memcpy(this, &m.pduhead, sizeof(m.pduhead));
memcpy(&start, m.data, szData());
memcpy(&start, &(m.data[0]), szData());
// переворачиваем слова
start = SWAPSHORT(start);
......@@ -2273,7 +2273,7 @@ void DiagnosticMessage::init( const ModbusMessage& m )
func = m.pduhead.func;
memcpy( &subf, &(m.data[0]), sizeof(subf) );
int last = sizeof(subf);
size_t last = sizeof(subf);
subf = SWAPSHORT(subf);
count = szRequestDiagnosticData((DiagnosticsSubFunction)subf );
......@@ -2281,15 +2281,15 @@ void DiagnosticMessage::init( const ModbusMessage& m )
if( count > MAXDATALEN )
throw mbException(erPacketTooLong);
if( count < 0 )
throw mbException(erBadDataValue);
if( count > 0 )
{
memcpy(&data, &(m.data[last]), sizeof(ModbusData)*count);
last += sizeof(ModbusData) * count;
// переворачиваем данные
for( size_t i = 0; i < count; i++ )
data[i] = SWAPSHORT(data[i]);
}
memcpy(&crc, &(m.data[last]), szCRC);
}
......@@ -3111,7 +3111,7 @@ ModbusMessage SetDateTimeMessage::transport_msg()
mm.data[6] = century;
*/
size_t bcnt = 7;
memcpy( mm.data, &hour, bcnt );
memcpy( mm.data, &hour, bcnt ); // копируем начиная с адреса 'hour' 7 байт.
// пересчитываем CRC
ModbusData crc = checkCRC( (ModbusByte*)(&mm.pduhead), szModbusHeader + bcnt );
......@@ -3175,7 +3175,7 @@ ModbusMessage SetDateTimeRetMessage::transport_msg()
// копируем заголовок и данные
memcpy(&mm.pduhead, this, szModbusHeader);
/*
size_t bcnt = 7;
mm.data[0] = hour;
mm.data[1] = min;
mm.data[2] = sec;
......@@ -3183,9 +3183,6 @@ ModbusMessage SetDateTimeRetMessage::transport_msg()
mm.data[4] = mon;
mm.data[5] = year;
mm.data[6] = century;
*/
size_t bcnt = 7;
memcpy( mm.data, &hour, bcnt );
// пересчитываем CRC
ModbusData crc = checkCRC( (ModbusByte*)(&mm.pduhead), szModbusHeader + bcnt );
......@@ -3508,8 +3505,7 @@ FileTransferRetMessage::FileTransferRetMessage( ModbusAddr _from ):
bool FileTransferRetMessage::set( ModbusData nfile, ModbusData fpacks,
ModbusData pack, ModbusByte* buf, ModbusByte len )
{
if( len > sizeof(data) )
return false;
assert( std::numeric_limits<ModbusByte>::max() <= sizeof(data) );
clear();
memcpy(data, buf, len);
......
......@@ -89,7 +89,7 @@ class TGuard
public:
TGuard( T* m, typename ThreadCreator<T>::Action a ):
t(m,a)
t(m, a)
{
t.start();
}
......
......@@ -9,7 +9,7 @@ USocket::~USocket()
{
close();
}
catch(...){}
catch(...) {}
}
// -------------------------------------------------------------------------
USocket::USocket( int sock )
......
......@@ -53,7 +53,7 @@ UTCPCore::Buffer::~Buffer()
delete [] data;
}
// -------------------------------------------------------------------------
unsigned char*UTCPCore::Buffer::dpos() noexcept
unsigned char* UTCPCore::Buffer::dpos() noexcept
{
return data + pos;
}
......
......@@ -16,7 +16,7 @@ UTCPSocket::~UTCPSocket()
{
Poco::Net::ServerSocket::close();
}
catch(...){}
catch(...) {}
}
// -------------------------------------------------------------------------
UTCPSocket::UTCPSocket()
......
......@@ -65,7 +65,7 @@ void UTCPStream::forceDisconnect()
setLinger(false, 0);
}
// catch( Poco::Net::NetException& ex ){}
catch( std::exception& ex ){}
catch( std::exception& ex ) {}
try
{
......@@ -73,7 +73,7 @@ void UTCPStream::forceDisconnect()
//shutdown();
}
// catch( Poco::Net::NetException& ex ){}
catch( std::exception& ex ){}
catch( std::exception& ex ) {}
}
// -------------------------------------------------------------------------
void UTCPStream::disconnect()
......@@ -82,15 +82,15 @@ void UTCPStream::disconnect()
{
shutdown();
}
// catch( Poco::Net::NetException& ex ){}
catch( std::exception& ex ){}
// catch( Poco::Net::NetException& ex ){}
catch( std::exception& ex ) {}
try
{
close();
}
// catch( Poco::Net::NetException& ex ){}
catch( std::exception& ex ){}
// catch( Poco::Net::NetException& ex ){}
catch( std::exception& ex ) {}
}
// -------------------------------------------------------------------------
int UTCPStream::getSocket() const
......@@ -116,7 +116,7 @@ void UTCPStream::create( const std::string& hname, int port, timeout_t tout_msec
bool UTCPStream::isConnected() noexcept
{
return ( Poco::Net::StreamSocket::sockfd() != POCO_INVALID_SOCKET );
/*
/*
try
{
// Вариант 1
......@@ -126,14 +126,14 @@ bool UTCPStream::isConnected() noexcept
return ( Poco::Net::StreamSocket::peerAddress().port() != 0 );
// Вариант 3
// if( poll({0, 5}, Poco::Net::Socket::SELECT_READ) )
// return (tcp->available() > 0);
// if( poll({0, 5}, Poco::Net::Socket::SELECT_READ) )
// return (tcp->available() > 0);
}
catch( Poco::Net::NetException& ex )
{
}
return false;
*/
*/
}
// -------------------------------------------------------------------------
......@@ -33,7 +33,7 @@
// -----------------------------------------------------------------------------
using namespace omni;
using namespace UniversalIO;
using namespace UniSetTypes;
// using namespace UniSetTypes;
using namespace std;
// -----------------------------------------------------------------------------
UInterface::UInterface( const std::shared_ptr<UniSetTypes::Configuration>& _uconf ):
......@@ -47,7 +47,7 @@ UInterface::UInterface( const std::shared_ptr<UniSetTypes::Configuration>& _ucon
init();
}
// -----------------------------------------------------------------------------
UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, const shared_ptr<ObjectIndex> _oind ):
UInterface::UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb, const shared_ptr<UniSetTypes::ObjectIndex> _oind ):
rep(UniSetTypes::uniset_conf()),
myid(backid),
orb(orb),
......@@ -85,7 +85,7 @@ void UInterface::init()
else
localctx = ORepHelpers::getRootNamingContext( orb, s.str() );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
// if( !uconf->isLocalIOR() )
// throw ex;
......@@ -112,17 +112,17 @@ void UInterface::initBackId( const UniSetTypes::ObjectId backid )
* \exception IOBadParam - генерируется если указано неправильное имя датчика или секции
* \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ
*/
long UInterface::getValue( const ObjectId id, const ObjectId node ) const
long UInterface::getValue( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
throw(UI_THROW_EXCEPTIONS)
{
if ( id == DefaultObjectId )
throw ORepFailed("UI(getValue): error id=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getValue): error id=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getValue): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -133,7 +133,7 @@ throw(UI_THROW_EXCEPTIONS)
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -164,11 +164,11 @@ throw(UI_THROW_EXCEPTIONS)
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getValue): " + string(ex.err));
}
catch( const ORepFailed& )
catch( const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(getValue): ORepFailed", id, node));
throw UniSetTypes::IOBadParam(set_err("UI(getValue): UniSetTypes::ORepFailed", id, node));
}
catch( const CORBA::NO_IMPLEMENT& )
{
......@@ -194,7 +194,7 @@ throw(UI_THROW_EXCEPTIONS)
throw UniSetTypes::TimeOut(set_err("UI(getValue): TimeOut", id, node));
}
long UInterface::getValue( const ObjectId name ) const
long UInterface::getValue( const UniSetTypes::ObjectId name ) const
{
return getValue(name, uconf->getLocalNode());
}
......@@ -203,13 +203,13 @@ long UInterface::getValue( const ObjectId name ) const
// ------------------------------------------------------------------------------------------------------------
void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId sup_id )
{
if( si.id == DefaultObjectId )
if( si.id == UniSetTypes::DefaultObjectId )
{
uwarn << "UI(setUndefinedState): ID=UniSetTypes::DefaultObjectId" << endl;
return;
}
if( sup_id == DefaultObjectId )
if( sup_id == UniSetTypes::DefaultObjectId )
sup_id = myid;
try
......@@ -220,7 +220,7 @@ void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool u
{
oref = rcache.resolve(si.id, si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -252,7 +252,7 @@ void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool u
rcache.erase(si.id, si.node);
throw UniSetTypes::IOBadParam("UI(setUndefinedState): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(si.id, si.node);
// не смогли получить ссылку на объект
......@@ -282,26 +282,27 @@ void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool u
* \return текущее значение датчика
* \exception IOBadParam - генерируется если указано неправильное имя вывода или секции
*/
void UInterface::setValue( const ObjectId id, long value, const ObjectId node, const UniSetTypes::ObjectId sup_id ) const
void UInterface::setValue( const UniSetTypes::ObjectId id, long value, const UniSetTypes::ObjectId node, const UniSetTypes::ObjectId sup_id ) const
throw(UI_THROW_EXCEPTIONS)
{
if ( id == DefaultObjectId )
throw ORepFailed("UI(setValue): error: id=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(setValue): error: id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
if ( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(setValue): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
/*
if ( sup_id == DefaultObjectId )
/*
if ( sup_id == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(setValue): id='" << id << "' error: supplier=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
*/
*/
try
{
CORBA::Object_var oref;
......@@ -310,7 +311,7 @@ throw(UI_THROW_EXCEPTIONS)
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -335,14 +336,14 @@ throw(UI_THROW_EXCEPTIONS)
catch(const IOController_i::NameNotFound& ex)
{
rcache.erase(id, node);
throw UniSetTypes::NameNotFound(set_err("UI(setValue): const NameNotFound& для объекта", id, node));
throw UniSetTypes::NameNotFound(set_err("UI(setValue): const UniSetTypes::NameNotFound& для объекта", id, node));
}
catch(const IOController_i::IOBadParam& ex)
{
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(setValue): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
......@@ -370,7 +371,7 @@ throw(UI_THROW_EXCEPTIONS)
throw UniSetTypes::TimeOut(set_err("UI(setValue): Timeout", id, node));
}
void UInterface::setValue( const ObjectId name, long value ) const
void UInterface::setValue( const UniSetTypes::ObjectId name, long value ) const
{
setValue(name, value, uconf->getLocalNode(), myid);
}
......@@ -378,20 +379,20 @@ void UInterface::setValue( const ObjectId name, long value ) const
void UInterface::setValue( const IOController_i::SensorInfo& si, long value, const UniSetTypes::ObjectId sup_id ) const
{
setValue(si.id, value, si.node,sup_id);
setValue(si.id, value, si.node, sup_id);
}
// ------------------------------------------------------------------------------------------------------------
// функция не вырабатывает исключий!
void UInterface::fastSetValue( const IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId sup_id ) const
{
if ( si.id == DefaultObjectId )
if ( si.id == UniSetTypes::DefaultObjectId )
{
uwarn << "UI(fastSetValue): ID=UniSetTypes::DefaultObjectId" << endl;
return;
}
if( sup_id == DefaultObjectId )
if( sup_id == UniSetTypes::DefaultObjectId )
sup_id = myid;
try
......@@ -402,7 +403,7 @@ void UInterface::fastSetValue( const IOController_i::SensorInfo& si, long value,
{
oref = rcache.resolve(si.id, si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -427,14 +428,14 @@ void UInterface::fastSetValue( const IOController_i::SensorInfo& si, long value,
catch(const IOController_i::NameNotFound& ex)
{
rcache.erase(si.id, si.node);
uwarn << set_err("UI(fastSetValue): const NameNotFound& для объекта", si.id, si.node) << endl;
uwarn << set_err("UI(fastSetValue): const UniSetTypes::NameNotFound& для объекта", si.id, si.node) << endl;
}
catch(const IOController_i::IOBadParam& ex)
{
rcache.erase(si.id, si.node);
throw UniSetTypes::IOBadParam("UI(fastSetValue): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(si.id, si.node);
// не смогли получить ссылку на объект
......@@ -473,7 +474,8 @@ void UInterface::fastSetValue( const IOController_i::SensorInfo& si, long value,
* \param cmd - команда см. \ref UniversalIO::UIOCommand
* \param backid - обратный адрес (идентификатор заказчика)
*/
void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd, const ObjectId node,
void UInterface::askRemoteSensor( const UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd,
const UniSetTypes::ObjectId node,
UniSetTypes::ObjectId backid ) const throw(UI_THROW_EXCEPTIONS)
{
if( backid == UniSetTypes::DefaultObjectId )
......@@ -482,14 +484,14 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd
if( backid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::IOBadParam("UI(askRemoteSensor): unknown back ID");
if ( id == DefaultObjectId )
throw ORepFailed("UI(askRemoteSensor): error: id=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(askRemoteSensor): error: id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
if ( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(askRemoteSensor): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -500,7 +502,7 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -510,7 +512,7 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd
oref = resolve( id, node );
IONotifyController_i_var inc = IONotifyController_i::_narrow(oref);
ConsumerInfo_var ci;
UniSetTypes::ConsumerInfo_var ci;
ci->id = backid;
ci->node = uconf->getLocalNode();
inc->askSensor(id, ci, cmd );
......@@ -535,7 +537,7 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(askSensor): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
......@@ -566,7 +568,7 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd
throw UniSetTypes::TimeOut(set_err("UI(askSensor): Timeout", id, node));
}
void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId backid ) const
void UInterface::askSensor( const UniSetTypes::ObjectId name, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId backid ) const
{
askRemoteSensor(name, cmd, uconf->getLocalNode(), backid);
}
......@@ -576,17 +578,17 @@ void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, co
* \param id - идентификатор объекта
* \param node - идентификатор узла
*/
IOType UInterface::getIOType( const ObjectId id, const ObjectId node ) const
IOType UInterface::getIOType( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
throw(UI_THROW_EXCEPTIONS)
{
if ( id == DefaultObjectId )
throw ORepFailed("UI(getIOType): error: id=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getIOType): error: id=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getIOType): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -597,7 +599,7 @@ throw(UI_THROW_EXCEPTIONS)
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -627,7 +629,7 @@ throw(UI_THROW_EXCEPTIONS)
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getIOType): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
......@@ -658,7 +660,7 @@ throw(UI_THROW_EXCEPTIONS)
throw UniSetTypes::TimeOut(set_err("UI(getIOType): Timeout", id, node));
}
IOType UInterface::getIOType( const ObjectId id ) const
IOType UInterface::getIOType( const UniSetTypes::ObjectId id ) const
{
return getIOType(id, uconf->getLocalNode() );
}
......@@ -667,17 +669,17 @@ IOType UInterface::getIOType( const ObjectId id ) const
* \param id - идентификатор объекта
* \param node - идентификатор узла
*/
ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const
UniSetTypes::ObjectType UInterface::getType( const UniSetTypes::ObjectId name, const UniSetTypes::ObjectId node) const
throw(UI_THROW_EXCEPTIONS)
{
if ( name == DefaultObjectId )
throw ORepFailed("UI(getType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( name == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getType): id='" << name << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -688,7 +690,7 @@ throw(UI_THROW_EXCEPTIONS)
{
oref = rcache.resolve(name, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -718,7 +720,7 @@ throw(UI_THROW_EXCEPTIONS)
rcache.erase(name, node);
throw UniSetTypes::IOBadParam("UI(getType): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(name, node);
// не смогли получить ссылку на объект
......@@ -750,13 +752,13 @@ throw(UI_THROW_EXCEPTIONS)
throw UniSetTypes::TimeOut(set_err("UI(getType): Timeout", name, node));
}
ObjectType UInterface::getType( const ObjectId name ) const
UniSetTypes::ObjectType UInterface::getType( const UniSetTypes::ObjectId name ) const
{
return getType(name, uconf->getLocalNode());
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force ) const throw(UniSetTypes::ORepFailed)
void UInterface::registered( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force ) const throw(UniSetTypes::ORepFailed)
{
// если влючён режим использования локальных файлов
// то пишем IOR в файл
......@@ -773,14 +775,14 @@ void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force
{
rep.registration( oind->getNameById(id), oRef, force );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
throw;
}
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::unregister( const ObjectId id )throw(ORepFailed)
void UInterface::unregister( const UniSetTypes::ObjectId id )throw(UniSetTypes::ORepFailed)
{
if( uconf->isLocalIOR() )
{
......@@ -792,24 +794,24 @@ void UInterface::unregister( const ObjectId id )throw(ORepFailed)
{
rep.unregistration( oind->getNameById(id) );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
throw;
}
}
// ------------------------------------------------------------------------------------------------------------
ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node ) const
throw(ResolveNameError, UniSetTypes::TimeOut )
UniSetTypes::ObjectPtr UInterface::resolve( const UniSetTypes::ObjectId rid , const UniSetTypes::ObjectId node ) const
throw(UniSetTypes::ResolveNameError, UniSetTypes::TimeOut )
{
if ( rid == DefaultObjectId )
throw ResolveNameError("UI(resolve): ID=UniSetTypes::DefaultObjectId");
if ( rid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ResolveNameError("UI(resolve): ID=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(resolve): id='" << rid << "' error: node=UniSetTypes::DefaultObjectId";
throw ResolveNameError(err.str());
throw UniSetTypes::ResolveNameError(err.str());
}
CosNaming::NamingContext_var ctx;
......@@ -858,7 +860,7 @@ throw(ResolveNameError, UniSetTypes::TimeOut )
break;
}
// catch( const CORBA::COMM_FAILURE& ex )
catch( const ORepFailed& ex )
catch( const UniSetTypes::ORepFailed& ex )
{
// нет связи с этим узлом
// пробуем связатся по другой сети
......@@ -872,7 +874,7 @@ throw(ResolveNameError, UniSetTypes::TimeOut )
if( CORBA::is_nil(ctx) )
{
// uwarn << "NameService недоступен на узле "<< node << endl;
throw NSResolveError();
throw UniSetTypes::NSResolveError();
}
}
else
......@@ -940,17 +942,17 @@ throw(ResolveNameError, UniSetTypes::TimeOut )
}
// -------------------------------------------------------------------------------------------
void UInterface::send( const ObjectId name, const TransportMessage& msg, const ObjectId node )
void UInterface::send( const UniSetTypes::ObjectId name, const UniSetTypes::TransportMessage& msg, const UniSetTypes::ObjectId node )
throw(UI_THROW_EXCEPTIONS)
{
if ( name == DefaultObjectId )
throw ORepFailed("UI(send): ERROR: id=UniSetTypes::DefaultObjectId");
if ( name == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(send): ERROR: id=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(send): id='" << name << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -961,7 +963,7 @@ throw(UI_THROW_EXCEPTIONS)
{
oref = rcache.resolve(name, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -982,7 +984,7 @@ throw(UI_THROW_EXCEPTIONS)
oref = CORBA::Object::_nil();
}
}
catch( const ORepFailed )
catch( const UniSetTypes::ORepFailed )
{
rcache.erase(name, node);
throw UniSetTypes::IOBadParam(set_err("UI(send): resolve failed ", name, node));
......@@ -1012,22 +1014,22 @@ throw(UI_THROW_EXCEPTIONS)
throw UniSetTypes::TimeOut(set_err("UI(send): Timeout", name, node));
}
void UInterface::send( const ObjectId name, const TransportMessage& msg )
void UInterface::send( const UniSetTypes::ObjectId name, const UniSetTypes::TransportMessage& msg )
{
send(name, msg, uconf->getLocalNode());
}
// ------------------------------------------------------------------------------------------------------------
IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ObjectId node ) const
IOController_i::ShortIOInfo UInterface::getChangedTime( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{
if( id == DefaultObjectId )
throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
if( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getChangedTime): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1038,7 +1040,7 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1069,7 +1071,7 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getChangedTime): " + string(ex.err));
}
catch( const ORepFailed& )
catch( const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): resolve failed ", id, node) << endl;
......@@ -1100,12 +1102,12 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
}
// ------------------------------------------------------------------------------------------------------------
ObjectPtr UInterface::CacheOfResolve::resolve( const ObjectId id, const ObjectId node ) const
throw(NameNotFound)
UniSetTypes::ObjectPtr UInterface::CacheOfResolve::resolve( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
throw(UniSetTypes::NameNotFound)
{
UniSetTypes::uniset_rwmutex_rlock l(cmutex);
auto it = mcache.find( key(id, node) );
auto it = mcache.find( UniSetTypes::key(id, node) );
if( it == mcache.end() )
throw UniSetTypes::NameNotFound();
......@@ -1122,11 +1124,11 @@ throw(NameNotFound)
throw UniSetTypes::NameNotFound();
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::CacheOfResolve::cache( const ObjectId id, const ObjectId node, ObjectVar& ptr ) const
void UInterface::CacheOfResolve::cache( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node, UniSetTypes::ObjectVar& ptr ) const
{
UniSetTypes::uniset_rwmutex_wrlock l(cmutex);
UniSetTypes::KeyType k( key(id, node) );
UniSetTypes::KeyType k( UniSetTypes::key(id, node) );
auto it = mcache.find(k);
......@@ -1153,7 +1155,7 @@ bool UInterface::CacheOfResolve::clean() noexcept
{
mcache.erase(it++);
}
catch(...){}
catch(...) {}
}
else
++it;
......@@ -1169,14 +1171,15 @@ bool UInterface::CacheOfResolve::clean() noexcept
void UInterface::CacheOfResolve::erase( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const noexcept
{
UniSetTypes::uniset_rwmutex_wrlock l(cmutex);
try
{
auto it = mcache.find( key(id, node) );
auto it = mcache.find( UniSetTypes::key(id, node) );
if( it != mcache.end() )
mcache.erase(it);
}
catch(...){}
catch(...) {}
}
// ------------------------------------------------------------------------------------------------------------
......@@ -1224,7 +1227,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id, const UniSetTypes::Obj
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
if( CORBA::is_nil(oref) )
oref = resolve(id, node);
......@@ -1236,10 +1239,10 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id, const UniSetTypes::Obj
return false;
}
// --------------------------------------------------------------------------------------------
string UInterface::set_err( const std::string& pre, const ObjectId id, const ObjectId node ) const
string UInterface::set_err( const std::string& pre, const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{
if( id == UniSetTypes::DefaultObjectId )
return string(pre + " DefaultObjectId");
return string(pre + " UniSetTypes::DefaultObjectId");
string nm( oind->getNameById(node) );
......@@ -1251,18 +1254,18 @@ string UInterface::set_err( const std::string& pre, const ObjectId id, const Obj
return s.str();
}
// --------------------------------------------------------------------------------------------
void UInterface::askThreshold( const ObjectId sid, const ThresholdId tid,
void UInterface::askThreshold( const UniSetTypes::ObjectId sid, const UniSetTypes::ThresholdId tid,
UniversalIO::UIOCommand cmd,
long low, long hi, bool invert,
const ObjectId backid ) const
const UniSetTypes::ObjectId backid ) const
{
askRemoteThreshold(sid, uconf->getLocalNode(), tid, cmd, low, hi, invert, backid);
}
// --------------------------------------------------------------------------------------------
void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
ThresholdId tid, UniversalIO::UIOCommand cmd,
void UInterface::askRemoteThreshold( const UniSetTypes::ObjectId sid, const UniSetTypes::ObjectId node,
UniSetTypes::ThresholdId tid, UniversalIO::UIOCommand cmd,
long lowLimit, long hiLimit, bool invert,
ObjectId backid ) const
UniSetTypes::ObjectId backid ) const
{
if( backid == UniSetTypes::DefaultObjectId )
backid = myid;
......@@ -1270,14 +1273,14 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
if( backid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::IOBadParam("UI(askRemoteThreshold): unknown back ID");
if ( sid == DefaultObjectId )
throw ORepFailed("UI(askRemoteThreshold): error: id=UniSetTypes::DefaultObjectId");
if ( sid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(askRemoteThreshold): error: id=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(askRemoteThreshold): id='" << sid << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1288,7 +1291,7 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
{
oref = rcache.resolve(sid, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for (unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1298,7 +1301,7 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
oref = resolve( sid, node );
IONotifyController_i_var inc = IONotifyController_i::_narrow(oref);
ConsumerInfo_var ci;
UniSetTypes::ConsumerInfo_var ci;
ci->id = backid;
ci->node = uconf->getLocalNode();
......@@ -1324,7 +1327,7 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
rcache.erase(sid, node);
throw UniSetTypes::IOBadParam("UI(askThreshold): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(sid, node);
throw UniSetTypes::IOBadParam(set_err("UI(askThreshold): resolve failed ", sid, node));
......@@ -1356,7 +1359,7 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
}
// --------------------------------------------------------------------------------------------
IONotifyController_i::ThresholdInfo
UInterface::getThresholdInfo( const ObjectId sid, const ThresholdId tid ) const
UInterface::getThresholdInfo( const UniSetTypes::ObjectId sid, const UniSetTypes::ThresholdId tid ) const
{
IOController_i::SensorInfo si;
si.id = sid;
......@@ -1367,14 +1370,14 @@ UInterface::getThresholdInfo( const ObjectId sid, const ThresholdId tid ) const
IONotifyController_i::ThresholdInfo
UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, const UniSetTypes::ThresholdId tid ) const
{
if ( si.id == DefaultObjectId )
throw ORepFailed("UI(getThresholdInfo): error: id=UniSetTypes::DefaultObjectId");
if ( si.id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getThresholdInfo): error: id=UniSetTypes::DefaultObjectId");
if( si.node == DefaultObjectId )
if( si.node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getThresholdInfo): id='" << si.id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1385,7 +1388,7 @@ UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, const UniSet
{
oref = rcache.resolve(si.id, si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1416,7 +1419,7 @@ UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, const UniSet
rcache.erase(si.id, si.node);
throw UniSetTypes::IOBadParam("UI(getThresholdInfo): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(si.id, si.node);
// не смогли получить ссылку на объект
......@@ -1448,14 +1451,14 @@ UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, const UniSet
// --------------------------------------------------------------------------------------------
long UInterface::getRawValue( const IOController_i::SensorInfo& si )
{
if ( si.id == DefaultObjectId )
throw ORepFailed("UI(getRawValue): error: id=UniSetTypes::DefaultObjectId");
if ( si.id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getRawValue): error: id=UniSetTypes::DefaultObjectId");
if( si.node == DefaultObjectId )
if( si.node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getRawValue): id='" << si.id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1466,7 +1469,7 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si )
{
oref = rcache.resolve(si.id, si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1497,7 +1500,7 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si )
rcache.erase(si.id, si.node);
throw UniSetTypes::IOBadParam("UI(getRawValue): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(si.id, si.node);
// не смогли получить ссылку на объект
......@@ -1537,14 +1540,14 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
// if( admId==UniSetTypes::DefaultObjectId )
// throw UniSetTypes::IOBadParam("UI(askTreshold): неизвестен ID администратора");
if( si.id == DefaultObjectId )
throw ORepFailed("UI(calibrate): error: id=UniSetTypes::DefaultObjectId");
if( si.id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(calibrate): error: id=UniSetTypes::DefaultObjectId");
if( si.node == DefaultObjectId )
if( si.node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(calibrate): id='" << si.id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1555,7 +1558,7 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
{
oref = rcache.resolve(si.id, si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1587,7 +1590,7 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
rcache.erase(si.id, si.node);
throw UniSetTypes::IOBadParam("UI(calibrate): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(si.id, si.node);
// не смогли получить ссылку на объект
......@@ -1619,14 +1622,14 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
// --------------------------------------------------------------------------------------------
IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i::SensorInfo& si )
{
if ( si.id == DefaultObjectId )
throw ORepFailed("UI(getCalibrateInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( si.id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getCalibrateInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if( si.node == DefaultObjectId )
if( si.node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getCalibrateInfo): id='" << si.id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1637,7 +1640,7 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i
{
oref = rcache.resolve(si.id, si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1668,7 +1671,7 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i
rcache.erase(si.id, si.node);
throw UniSetTypes::IOBadParam("UI(getCalibrateInfo): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(si.id, si.node);
// не смогли получить ссылку на объект
......@@ -1703,10 +1706,10 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
if( lst.empty() )
return IOController_i::SensorInfoSeq_var();
ObjectId sid = lst.getFirst();
UniSetTypes::ObjectId sid = lst.getFirst();
if ( sid == DefaultObjectId )
throw ORepFailed("UI(getSensorSeq): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( sid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getSensorSeq): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
try
{
......@@ -1716,7 +1719,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
{
oref = rcache.resolve(sid, uconf->getLocalNode());
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1749,7 +1752,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
rcache.erase(sid, uconf->getLocalNode());
throw UniSetTypes::IOBadParam("UI(getSensorSeq): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(sid, uconf->getLocalNode());
// не смогли получить ссылку на объект
......@@ -1780,14 +1783,14 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
}
// --------------------------------------------------------------------------------------------
IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTypes::ObjectId sup_id )
UniSetTypes::IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTypes::ObjectId sup_id )
{
if( lst.length() == 0 )
return UniSetTypes::IDSeq_var();
if ( lst[0].si.id == DefaultObjectId )
throw ORepFailed("UI(setOutputSeq): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( lst[0].si.id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(setOutputSeq): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
try
{
......@@ -1797,7 +1800,7 @@ IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTyp
{
oref = rcache.resolve(lst[0].si.id, lst[0].si.node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1828,7 +1831,7 @@ IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTyp
rcache.erase(lst[0].si.id, lst[0].si.node);
throw UniSetTypes::IOBadParam("UI(setOutputSeq): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(lst[0].si.id, lst[0].si.node);
// не смогли получить ссылку на объект
......@@ -1870,10 +1873,10 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
if( backid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::IOBadParam("UI(askSensorSeq): unknown back ID");
ObjectId sid = lst.getFirst();
UniSetTypes::ObjectId sid = lst.getFirst();
if ( sid == DefaultObjectId )
throw ORepFailed("UI(askSensorSeq): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( sid == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(askSensorSeq): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
try
{
......@@ -1883,7 +1886,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
{
oref = rcache.resolve(sid, uconf->getLocalNode());
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -1894,7 +1897,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
IONotifyController_i_var iom = IONotifyController_i::_narrow(oref);
ConsumerInfo_var ci;
UniSetTypes::ConsumerInfo_var ci;
ci->id = backid;
ci->node = uconf->getLocalNode();
UniSetTypes::IDSeq_var seq = lst.getIDSeq();
......@@ -1920,7 +1923,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
rcache.erase(sid, uconf->getLocalNode());
throw UniSetTypes::IOBadParam("UI(getSensorSeq): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(sid, uconf->getLocalNode());
// не смогли получить ссылку на объект
......@@ -1952,14 +1955,14 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
// -----------------------------------------------------------------------------
IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
{
if ( id == DefaultObjectId )
throw ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getSensors): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -1970,7 +1973,7 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -2001,7 +2004,7 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getSensors): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
......@@ -2033,14 +2036,14 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId
// -----------------------------------------------------------------------------
IOController_i::SensorInfoSeq* UInterface::getSensorsMap( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node )
{
if ( id == DefaultObjectId )
throw ORepFailed("UI(getSensorsMap): error node=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getSensorsMap): error node=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getSensorsMap): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -2051,7 +2054,7 @@ IOController_i::SensorInfoSeq* UInterface::getSensorsMap( const UniSetTypes::Obj
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -2082,7 +2085,7 @@ IOController_i::SensorInfoSeq* UInterface::getSensorsMap( const UniSetTypes::Obj
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getSensorsMap): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
......@@ -2113,14 +2116,14 @@ IOController_i::SensorInfoSeq* UInterface::getSensorsMap( const UniSetTypes::Obj
// -----------------------------------------------------------------------------
IONotifyController_i::ThresholdsListSeq* UInterface::getThresholdsList( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node )
{
if ( id == DefaultObjectId )
throw ORepFailed("UI(getThresholdsList): error node=UniSetTypes::DefaultObjectId");
if ( id == UniSetTypes::DefaultObjectId )
throw UniSetTypes::ORepFailed("UI(getThresholdsList): error node=UniSetTypes::DefaultObjectId");
if( node == DefaultObjectId )
if( node == UniSetTypes::DefaultObjectId )
{
ostringstream err;
err << "UI(getThresholdsList): id='" << id << "' error: node=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
throw UniSetTypes::ORepFailed(err.str());
}
try
......@@ -2131,7 +2134,7 @@ IONotifyController_i::ThresholdsListSeq* UInterface::getThresholdsList( const Un
{
oref = rcache.resolve(id, node);
}
catch( const NameNotFound& ) {}
catch( const UniSetTypes::NameNotFound& ) {}
for( unsigned int i = 0; i < uconf->getRepeatCount(); i++)
{
......@@ -2162,7 +2165,7 @@ IONotifyController_i::ThresholdsListSeq* UInterface::getThresholdsList( const Un
rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getThresholdsList): " + string(ex.err));
}
catch(const ORepFailed& )
catch(const UniSetTypes::ORepFailed& )
{
rcache.erase(id, node);
// не смогли получить ссылку на объект
......@@ -2191,7 +2194,7 @@ IONotifyController_i::ThresholdsListSeq* UInterface::getThresholdsList( const Un
throw UniSetTypes::TimeOut(set_err("UI(getThresholdsList): Timeout", id, node));
}
// -----------------------------------------------------------------------------
bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const ObjectId node ) noexcept
bool UInterface::waitReady( const UniSetTypes::ObjectId id, int msec, int pmsec, const UniSetTypes::ObjectId node ) noexcept
{
if( msec < 0 )
msec = 0;
......@@ -2228,7 +2231,7 @@ bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const Object
return ready;
}
// -----------------------------------------------------------------------------
bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const ObjectId node ) noexcept
bool UInterface::waitWorking( const UniSetTypes::ObjectId id, int msec, int pmsec, const UniSetTypes::ObjectId node ) noexcept
{
if( msec < 0 )
msec = 0;
......
......@@ -80,10 +80,11 @@ Debug::type Debug::value(string const& val)
break;
bool del = false;
if( tmp[0] == '-' )
{
del = true;
tmp = tmp.substr(1,tmp.size());
tmp = tmp.substr(1, tmp.size());
}
for (int i = 0 ; i < numErrorTags ; ++i)
......@@ -128,7 +129,7 @@ void Debug::showTags(ostream& os) noexcept
{
os.flush();
}
catch(...){}
catch(...) {}
}
std::ostream& operator<<(std::ostream& os, Debug::type level ) noexcept
......@@ -174,7 +175,7 @@ std::string Debug::str( Debug::type level ) noexcept
{
return s.str();
}
catch(...){}
catch(...) {}
return "";
}
......
......@@ -79,7 +79,7 @@ void DebugStream::sbuf_overflow( const std::string& s ) noexcept
{
s_stream.emit(s);
}
catch(...){}
catch(...) {}
}
//--------------------------------------------------------------------------
DebugStream::~DebugStream()
......
......@@ -36,13 +36,14 @@ LogServer::~LogServer() noexcept
if( isrunning )
loop.evstop(this);
}
catch(...){}
catch(...) {}
}
// -------------------------------------------------------------------------
LogServer::LogServer( std::shared_ptr<LogAgregator> log ):
LogServer()
{
elog = dynamic_pointer_cast<DebugStream>(log);
if( !elog )
{
ostringstream err;
......@@ -137,7 +138,7 @@ bool LogServer::check( bool restart_if_fail )
s.close();
return true;
}
catch(...){}
catch(...) {}
if( !restart_if_fail )
return false;
......@@ -247,6 +248,7 @@ void LogServer::ioAccept( ev::io& watcher, int revents )
{
uniset_rwmutex_wrlock l(mutSList);
slist.push_back(s);
// на первой сессии запоминаем состояние логов
if( slist.size() == 1 )
saveDefaultLogLevels("ALL");
......
......@@ -137,12 +137,14 @@ void LogSession::logOnEvent( const std::string& s ) noexcept
if( logbuf.size() >= maxRecordsNum )
{
numLostMsg++;
if( numLostMsg > maxRecordsNum )
{
// видимо клиент отвалился или совсем не успевает читать
// разрываем сессию..
if( mylog.is_info() )
mylog.info() << peername << "(LogSession::onEvent): too many lost messages. Close session.." << endl;
cancelled = true;
}
......@@ -160,7 +162,7 @@ void LogSession::logOnEvent( const std::string& s ) noexcept
lostMsg = false;
logbuf.emplace(new UTCPCore::Buffer(s));
}
catch(...){}
catch(...) {}
if( asyncEvent.is_active() )
asyncEvent.send();
......@@ -238,7 +240,7 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
{
readEvent(watcher);
}
catch(...){}
catch(...) {}
}
if (revents & EV_WRITE)
......@@ -247,7 +249,7 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
{
writeEvent(watcher);
}
catch(...){}
catch(...) {}
}
if( cancelled.load() )
......@@ -257,13 +259,14 @@ void LogSession::callback( ev::io& watcher, int revents ) noexcept
io.stop();
cmdTimer.stop();
try
{
std::unique_lock<std::mutex> lk(logbuf_mutex);
asyncEvent.stop();
conn.disconnect();
}
catch(...){}
catch(...) {}
final();
}
......@@ -410,7 +413,7 @@ void LogSession::readEvent( ev::io& watcher ) noexcept
if( mylog.is_warn() )
mylog.warn() << peername << "(LogSession::readEvent): " << ex.what() << endl;
}
catch(...){}
catch(...) {}
#if 0
// Выводим итоговый получившийся список (с учётом выполненных команд)
......@@ -604,7 +607,7 @@ void LogSession::onCheckConnectionTimer( ev::timer& watcher, int revents ) noexc
//
logbuf.emplace(new UTCPCore::Buffer(" \b"));
}
catch(...){}
catch(...) {}
io.set(ev::WRITE);
checkConnectionTimer.start( checkConnectionTime ); // restart timer
......@@ -616,7 +619,7 @@ void LogSession::final() noexcept
{
slFin(this);
}
catch(...){}
catch(...) {}
}
// -------------------------------------------------------------------------
void LogSession::connectFinalSession( FinalSlot sl ) noexcept
......
......@@ -43,7 +43,7 @@ std::string ObjectIndex::getBaseName( const std::string& fname ) noexcept
if( pos != string::npos )
return fname.substr(pos + 1);
}
catch(...){}
catch(...) {}
return fname;
}
......
......@@ -56,7 +56,8 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name ) const noexcept
if( it != mok.end() )
return it->second;
}
catch(...){}
catch(...) {}
return DefaultObjectId;
}
// -----------------------------------------------------------------------------------------
......@@ -293,7 +294,7 @@ const ObjectInfo* ObjectIndex_XML::getObjectInfo( const std::string& name ) cons
if( it != mok.end() )
return &(omap[it->second]);
}
catch(...){}
catch(...) {}
return nullptr;
}
......
......@@ -52,7 +52,7 @@ ObjectId ObjectIndex_idXML::getIdByName( const string& name ) const noexcept
if( it != mok.end() )
return it->second;
}
catch(...){}
catch(...) {}
return DefaultObjectId;
}
......@@ -66,7 +66,8 @@ string ObjectIndex_idXML::getMapName( const ObjectId id ) const noexcept
if( it != omap.end() )
return it->second.repName;
}
catch(...){}
catch(...) {}
return "";
}
// -----------------------------------------------------------------------------------------
......@@ -79,7 +80,7 @@ string ObjectIndex_idXML::getTextName( const ObjectId id ) const noexcept
if( it != omap.end() )
return it->second.textName;
}
catch(...){}
catch(...) {}
return "";
}
......@@ -255,7 +256,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) const no
if( it != omap.end() )
return &(it->second);
}
catch(...){}
catch(...) {}
return nullptr;
}
......@@ -269,7 +270,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name ) co
if( it != mok.end() )
return getObjectInfo(it->second);
}
catch(...){}
catch(...) {}
return nullptr;
}
......
......@@ -101,7 +101,7 @@ void PassiveObject::processingMessage( const UniSetTypes::VoidMessage* msg )
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(processingMessage): " << ex << endl;
}
......
......@@ -97,14 +97,14 @@ bool ProxyManager::activateObject()
{
ui->unregister(it.first);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(unregistered): " << ex << endl;
}
}
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(activate): " << ex << endl;
}
......@@ -121,7 +121,7 @@ bool ProxyManager::deactivateObject()
{
ui->unregister(it->first);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(activate): " << ex << endl;
}
......@@ -153,7 +153,7 @@ void ProxyManager::processingMessage( const UniSetTypes::VoidMessage* msg )
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(processingMessage): " << ex << endl;
}
......@@ -167,7 +167,7 @@ void ProxyManager::allMessage( const UniSetTypes::VoidMessage* msg )
{
o.second->processingMessage(msg);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(allMessage): " << ex << endl;
}
......
......@@ -962,7 +962,7 @@ void UniSetActivator::term( int signo )
s_term.emit(signo);
ulogsys << myname << "(term): sigterm() ok." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(term): " << ex << endl;
}
......
......@@ -206,7 +206,7 @@ bool UniSetManager::removeObject( const std::shared_ptr<UniSetObject>& obj )
if(obj)
obj->deactivate();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(removeObject): " << ex << endl;
}
......@@ -275,7 +275,7 @@ void UniSetManager::managers( OManagerCommand cmd )
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(managers): " << ex << endl
<< " Не смог зарегистрировать (разрегистрировать) объект -->" << li->getName() << endl;
......@@ -339,10 +339,11 @@ void UniSetManager::objects(OManagerCommand cmd)
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(objects): " << ex << endl;
ucrit << myname << "(objects): не смог зарегистрировать (разрегистрировать) объект -->" << li->getName() << endl;
if( cmd == activ )
std::terminate();
}
......
......@@ -277,7 +277,7 @@ void UniSetObject::registered()
string err(myname + ": don`t registration in object reposotory");
throw ORepFailed(err);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(registered): " << ex << endl;
string err(myname + ": don`t registration in object reposotory");
......@@ -501,7 +501,7 @@ bool UniSetObject::deactivate()
{
uwarn << myname << "(deactivate): " << "поймали CORBA::Exception." << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(deactivate): " << ex << endl;
}
......@@ -636,7 +636,7 @@ void UniSetObject::callback()
sleepTime = checkTimers(this);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(callback): " << ex << endl;
}
......@@ -664,7 +664,7 @@ void UniSetObject::processingMessage( const UniSetTypes::VoidMessage* msg )
break;
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(processingMessage): " << ex << endl;
}
......
......@@ -83,7 +83,7 @@ void IOController::sensorsUnregistration()
{
ioUnRegistration( li.second->si.id );
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(sensorsUnregistration): " << ex << endl;
}
......@@ -115,7 +115,7 @@ void IOController::activateInit()
sigInit.emit(s, this);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(activateInit): " << ex << endl;
}
......@@ -420,7 +420,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
}
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << myname << "(ioRegistration): " << ex << endl;
}
......
......@@ -246,7 +246,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
{
ui->send(ci.id, std::move(smsg.transport_msg()), ci.node);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(askSensor): " << uniset_conf()->oind->getNameById(sid) << " error: " << ex << endl;
}
......@@ -283,7 +283,7 @@ void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
{
dumpOrdersList(sid, lst);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << " не смогли сделать dump: " << ex << endl;
}
......@@ -533,7 +533,7 @@ void IONotifyController::dumpOrdersList( const UniSetTypes::ObjectId sid,
auto sinf = make_shared<NCRestorer::SInfo>( std::move(tmp) );
restorer->dump(this, sinf, lst);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(IONotifyController::dumpOrderList): " << ex << endl;
}
......@@ -551,7 +551,7 @@ void IONotifyController::dumpThresholdList( const UniSetTypes::ObjectId sid, con
auto sinf = make_shared<NCRestorer::SInfo>( std::move(ainf) );
restorer->dumpThreshold(this, sinf, lst);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(IONotifyController::dumpThresholdList): " << ex << endl;
}
......@@ -609,7 +609,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
{
dumpThresholdList(sid, tli.list);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << " не смогли сделать dump: " << ex << endl;
}
......@@ -625,7 +625,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
{
dumpThresholdList(sid, it->second.list);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(askThreshold): dump: " << ex << endl;
}
......@@ -670,7 +670,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
ref->push( std::move(sm.transport_msg()) );
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(askThreshod): " << ex << endl;
}
......@@ -692,7 +692,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
{
dumpThresholdList(sid, it->second.list);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(askThreshold): dump: " << ex << endl;
}
......@@ -943,7 +943,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
res->value = IOController::localGetValue(it->second.usi);
res->type = it->second.type;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << myname << "(getThresholds): для датчика "
<< uniset_conf()->oind->getNameById(it->second.si.id)
......
......@@ -151,7 +151,7 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
{
ioRegistration(ic, uinf, true);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
uwarn << "(read_list): " << ex << endl;
}
......
......@@ -44,7 +44,7 @@ void PassiveCondTimer::terminate() noexcept
std::unique_lock<std::mutex> lk(m_working);
terminated = true;
}
catch(...){}
catch(...) {}
cv_working.notify_all();
}
......@@ -72,7 +72,7 @@ bool PassiveCondTimer::wait( timeout_t time_msec ) noexcept
terminated = true;
return true;
}
catch(...){}
catch(...) {}
return false;
}
......
......@@ -114,17 +114,17 @@ void UniSetTimer::stop() noexcept
const Poco::Timespan UniSetTimer::millisecToPoco( const timeout_t msec ) noexcept
{
if( msec == WaitUpTime )
return Poco::Timespan(-1,0);
return Poco::Timespan(-1, 0);
// msec --> usec
return Poco::Timespan( long(msec/1000), long((msec*1000)%1000000) );
return Poco::Timespan( long(msec / 1000), long((msec * 1000) % 1000000) );
}
//------------------------------------------------------------------------------
const Poco::Timespan UniSetTimer::microsecToPoco( const timeout_t usec ) noexcept
{
if( usec == WaitUpTime )
return Poco::Timespan(-1,0);
return Poco::Timespan(-1, 0);
return Poco::Timespan( long(usec/1000000), long(usec%1000000) );
return Poco::Timespan( long(usec / 1000000), long(usec % 1000000) );
}
//------------------------------------------------------------------------------
......@@ -254,7 +254,7 @@ namespace UniSetTypes
oind = static_pointer_cast<ObjectIndex>(oi);
}
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << "(Configuration:init): INIT FAILED! from " << fileConfName << endl;
throw;
......@@ -447,7 +447,7 @@ namespace UniSetTypes
// ---------------------------------------
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << "Configuration:" << ex << endl;
throw;
......@@ -1005,6 +1005,8 @@ namespace UniSetTypes
secServices = makeSecName(secRoot, getRepSectionName("services", xmlServicesSec));
}
// -------------------------------------------------------------------------
// второй параметр намеренно передаётся и переопредеяется
// это просто такой способ вернуть и строку и указатель на узел (одним махом)
string Configuration::getRepSectionName( const string& sec, xmlNode* secnode )
{
secnode = unixml->findNode(unixml->getFirstNode(), sec);
......
......@@ -115,7 +115,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
tmLast.reset();
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
ucrit << "(checkTimers): " << ex << endl;
}
......
......@@ -141,11 +141,12 @@ void MQAtomic::setMaxSizeOfMessageQueue( size_t s )
if( s != SizeOfMessageQueue )
{
SizeOfMessageQueue = s;
try
{
mqFill(nullptr);
}
catch(...){}
catch(...) {}
}
}
//---------------------------------------------------------------------------
......
......@@ -68,7 +68,7 @@ VoidMessagePtr MQMutex::top() noexcept
mqueue.pop_front();
return m;
}
catch(...){}
catch(...) {}
return nullptr;
}
......
......@@ -71,7 +71,7 @@ void SMonitor::sysCommand( const SystemMessage* sm )
if( it.si.id != DefaultObjectId )
ui->askRemoteSensor(it.si.id, UniversalIO::UIONotify, it.si.node);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << myname << ":(askSensor): " << ex << endl;
raise(SIGTERM);
......
......@@ -61,7 +61,7 @@ void SViewer::view()
{
readSection(csec, "");
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << ex << endl;
}
......@@ -139,7 +139,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
else
getInfo(id);
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cout << "(readSection): " << ex << endl;
}
......@@ -187,7 +187,7 @@ void SViewer::getInfo( ObjectId id )
return;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cout << "(getInfo):" << ex << endl;
}
......@@ -218,6 +218,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
name = ORepHelpers::getShortName(name);
string supplier = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(amap[i].supplier));
if( amap[i].supplier == UniSetTypes::AdminID )
supplier = "uniset-admin";
......@@ -242,6 +243,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
name = ORepHelpers::getShortName(name);
string supplier = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(amap[i].supplier));
if( amap[i].supplier == UniSetTypes::AdminID )
supplier = "uniset-admin";
......
......@@ -83,6 +83,7 @@ void UniXML::newDoc(const string& root_node, const string& xml_ver)
xmlKeepBlanksDefault(0);
xmlDoc* d = xmlNewDoc((const xmlChar*)xml_ver.c_str());
if( d == NULL )
throw NameNotFound("UniXML(open): не смогли создать doc=" + root_node);
......@@ -130,7 +131,7 @@ void UniXML::open( const string& _filename )
if( d == NULL )
throw NameNotFound("UniXML(open): NotFound file=" + _filename);
doc = std::shared_ptr<xmlDoc>(d,UniXMLDocDeleter());
doc = std::shared_ptr<xmlDoc>(d, UniXMLDocDeleter());
// Support for XInclude (see eterbug #6304)
// main tag must to have follow property: xmlns:xi="http://www.w3.org/2001/XInclude"
......@@ -142,7 +143,7 @@ void UniXML::open( const string& _filename )
// -----------------------------------------------------------------------------
void UniXML::close()
{
doc= nullptr;
doc = nullptr;
filename = "";
}
// -----------------------------------------------------------------------------
......@@ -157,10 +158,11 @@ string UniXML::getProp2(const xmlNode* node, const string& name, const string& d
try
{
string s(getProp(node, name));
if( !s.empty() )
return std::move(s);
}
catch(...){}
catch(...) {}
return defval;
}
......@@ -182,7 +184,7 @@ string UniXML::getProp(const xmlNode* node, const string& name) noexcept
xmlFree( (xmlChar*) text );
return std::move(t);
}
catch(...){}
catch(...) {}
xmlFree( (xmlChar*) text );
return "";
......@@ -470,7 +472,7 @@ bool UniXML_iterator::goChildren() noexcept
return true;
}
// -------------------------------------------------------------------------
xmlNode*UniXML_iterator::getCurrent() noexcept
xmlNode* UniXML_iterator::getCurrent() noexcept
{
return curNode;
}
......@@ -524,7 +526,7 @@ void UniXML_iterator::goEnd() noexcept
}
}
// -------------------------------------------------------------------------
UniXML_iterator::operator xmlNode*() const noexcept
UniXML_iterator::operator xmlNode* () const noexcept
{
//ulog.< "current\n";
return curNode;
......
......@@ -95,11 +95,11 @@ int main(int argc, const char** argv)
return 0;
}
catch( const SystemError& err )
catch( const UniSetTypes::SystemError& err )
{
cerr << "(mq-test): " << err << endl;
}
catch( const Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
cerr << "(mq-test): " << ex << endl;
}
......
......@@ -28,11 +28,20 @@ class PtrMapHashFn
return std::hash<long>()((long)key);
}
};
struct struct_t
{
unsigned char hour = { 0 }; /*!< часы [0..23] */
unsigned char min = { 0 }; /*!< минуты [0..59] */
unsigned char sec = { 0 }; /*!< секунды [0..59] */
unsigned char day = { 1 }; /*!< день [1..31] */
unsigned char mon = { 1 }; /*!< месяц [1..12] */
unsigned char year = { 0 }; /*!< год [0..99] */
unsigned char century = { 20 }; /*!<*/
} __attribute__((packed));
int main( int argc, const char** argv )
{
cerr << "2000%1000000=" << int(2000%1000000) << endl;
cerr << "2000%1000000=" << int(2000 % 1000000) << endl;
return 0;
unordered_map<const long*, const long*, PtrMapHashFn> vmap;
......
......@@ -82,6 +82,7 @@ bool readlog_thread2()
while( !g_read_cancel )
lr.readlogs(ip, port); // ,LogServerTypes::cmdNOP,0,"",true);
return true;
}
catch( std::exception& ex )
......
......@@ -30,7 +30,7 @@ bool run_test_server()
return true;
}
catch(...){}
catch(...) {}
return false;
}
......
......@@ -24,3 +24,4 @@ Utilities/codegen/tests
Utilities/MBTester
Utilities/NullController
/usr/include/sigc++-2.0
/usr/include/omniORB4
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