Commit bfaa9178 authored by Pavel Vainerman's avatar Pavel Vainerman

make style

parent 6e177d62
...@@ -38,7 +38,7 @@ using namespace UniSetTypes; ...@@ -38,7 +38,7 @@ using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ): DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ):
DBServer(id,prefix), DBServer(id, prefix),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
...@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ): ...@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ):
} }
DBServer_MySQL::DBServer_MySQL( const std::string& prefix ): DBServer_MySQL::DBServer_MySQL( const std::string& prefix ):
DBServer_MySQL(uniset_conf()->getDBServer(),prefix) DBServer_MySQL(uniset_conf()->getDBServer(), prefix)
{ {
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -150,7 +150,7 @@ bool DBServer_MySQL::writeToBase( const string& query ) ...@@ -150,7 +150,7 @@ bool DBServer_MySQL::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
dbcrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize dbcrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -191,7 +191,7 @@ void DBServer_MySQL::flushBuffer() ...@@ -191,7 +191,7 @@ void DBServer_MySQL::flushBuffer()
if( !err.empty() ) if( !err.empty() )
dbcrit << myname << "(writeToBase): error: " << err << dbcrit << myname << "(writeToBase): error: " << err <<
" lost query: " << qbuf.front() << endl; " lost query: " << qbuf.front() << endl;
qbuf.pop(); qbuf.pop();
} }
...@@ -293,16 +293,16 @@ void DBServer_MySQL::initDBServer() ...@@ -293,16 +293,16 @@ void DBServer_MySQL::initDBServer()
dbnode = "localhost"; dbnode = "localhost";
dbinfo << myname << "(init): connect dbnode=" << dbnode dbinfo << myname << "(init): connect dbnode=" << dbnode
<< "\tdbname=" << dbname << "\tdbname=" << dbname
<< " pingTime=" << PingTime << " pingTime=" << PingTime
<< " ReconnectTime=" << ReconnectTime << endl; << " ReconnectTime=" << ReconnectTime << endl;
if( !db->connect(dbnode, user, password, dbname) ) if( !db->connect(dbnode, user, password, dbname) )
{ {
// ostringstream err; // ostringstream err;
dbcrit << myname dbcrit << myname
<< "(init): DB connection error: " << "(init): DB connection error: "
<< db->error() << endl; << db->error() << endl;
// throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) ); // throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) );
askTimer(DBServer_MySQL::ReconnectTimer, ReconnectTime); askTimer(DBServer_MySQL::ReconnectTimer, ReconnectTime);
} }
......
...@@ -15,13 +15,13 @@ int main(int argc, char** argv) ...@@ -15,13 +15,13 @@ int main(int argc, char** argv)
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) ) if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
{ {
cout << "--confile filename - configuration file. Default: configure.xml" << endl; cout << "--confile filename - configuration file. Default: configure.xml" << endl;
DBServer_MySQL::help_print(argc,argv); DBServer_MySQL::help_print(argc, argv);
return 0; return 0;
} }
auto conf = uniset_init(argc, argv, "configure.xml"); auto conf = uniset_init(argc, argv, "configure.xml");
auto db = DBServer_MySQL::init_dbserver(argc,argv); auto db = DBServer_MySQL::init_dbserver(argc, argv);
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act->add(db); act->add(db);
......
...@@ -14,7 +14,7 @@ using namespace UniSetTypes; ...@@ -14,7 +14,7 @@ using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_PostgreSQL::DBServer_PostgreSQL(ObjectId id, const std::string& prefix ): DBServer_PostgreSQL::DBServer_PostgreSQL(ObjectId id, const std::string& prefix ):
DBServer(id,prefix), DBServer(id, prefix),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
...@@ -90,6 +90,7 @@ void DBServer_PostgreSQL::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -90,6 +90,7 @@ void DBServer_PostgreSQL::sysCommand( const UniSetTypes::SystemMessage* sm )
void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem ) void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
{ {
DBServer::confirmInfo(cem); DBServer::confirmInfo(cem);
try try
{ {
ostringstream data; ostringstream data;
...@@ -138,7 +139,7 @@ bool DBServer_PostgreSQL::writeToBase( const string& query ) ...@@ -138,7 +139,7 @@ bool DBServer_PostgreSQL::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
dbcrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize dbcrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -268,9 +269,9 @@ void DBServer_PostgreSQL::initDBServer() ...@@ -268,9 +269,9 @@ void DBServer_PostgreSQL::initDBServer()
dbnode = "localhost"; dbnode = "localhost";
dbinfo << myname << "(init): connect dbnode=" << dbnode dbinfo << myname << "(init): connect dbnode=" << dbnode
<< "\tdbname=" << dbname << "\tdbname=" << dbname
<< " pingTime=" << PingTime << " pingTime=" << PingTime
<< " ReconnectTime=" << ReconnectTime << endl; << " ReconnectTime=" << ReconnectTime << endl;
if( !db->connect(dbnode, user, password, dbname) ) if( !db->connect(dbnode, user, password, dbname) )
{ {
......
...@@ -9,6 +9,7 @@ using namespace std; ...@@ -9,6 +9,7 @@ using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
std::ios::sync_with_stdio(false); std::ios::sync_with_stdio(false);
try try
{ {
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) ) if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
......
...@@ -38,7 +38,7 @@ using namespace UniSetTypes; ...@@ -38,7 +38,7 @@ using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ): DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ):
DBServer(id,prefix), DBServer(id, prefix),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
...@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ): ...@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ):
} }
DBServer_SQLite::DBServer_SQLite( const std::string& prefix ): DBServer_SQLite::DBServer_SQLite( const std::string& prefix ):
DBServer_SQLite(uniset_conf()->getDBServer(),prefix) DBServer_SQLite(uniset_conf()->getDBServer(), prefix)
{ {
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -147,7 +147,7 @@ bool DBServer_SQLite::writeToBase( const string& query ) ...@@ -147,7 +147,7 @@ bool DBServer_SQLite::writeToBase( const string& query )
qbuf.pop(); qbuf.pop();
dbcrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize dbcrit << myname << "(writeToBase): DB not connected! buffer(" << qbufSize
<< ") overflow! lost query: " << qlost << endl; << ") overflow! lost query: " << qlost << endl;
} }
return false; return false;
...@@ -173,7 +173,7 @@ void DBServer_SQLite::flushBuffer() ...@@ -173,7 +173,7 @@ void DBServer_SQLite::flushBuffer()
if( !db->insert(qbuf.front()) ) if( !db->insert(qbuf.front()) )
{ {
dbcrit << myname << "(writeToBase): error: " << db->error() << dbcrit << myname << "(writeToBase): error: " << db->error() <<
" lost query: " << qbuf.front() << endl; " lost query: " << qbuf.front() << endl;
} }
qbuf.pop(); qbuf.pop();
...@@ -270,15 +270,15 @@ void DBServer_SQLite::initDBServer() ...@@ -270,15 +270,15 @@ void DBServer_SQLite::initDBServer()
lastRemove = false; lastRemove = false;
dbinfo << myname << "(init): connect dbfile=" << dbfile dbinfo << myname << "(init): connect dbfile=" << dbfile
<< " pingTime=" << PingTime << " pingTime=" << PingTime
<< " ReconnectTime=" << ReconnectTime << endl; << " ReconnectTime=" << ReconnectTime << endl;
if( !db->connect(dbfile, false) ) if( !db->connect(dbfile, false) )
{ {
// ostringstream err; // ostringstream err;
dbcrit << myname dbcrit << myname
<< "(init): DB connection error: " << "(init): DB connection error: "
<< db->error() << endl; << db->error() << endl;
// throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) ); // throw Exception( string(myname+"(init): не смогли создать соединение с БД "+db->error()) );
askTimer(DBServer_SQLite::ReconnectTimer, ReconnectTime); askTimer(DBServer_SQLite::ReconnectTimer, ReconnectTime);
} }
...@@ -323,6 +323,7 @@ void DBServer_SQLite::createTables( SQLiteInterface* db ) ...@@ -323,6 +323,7 @@ void DBServer_SQLite::createTables( SQLiteInterface* db )
void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm ) void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
DBServer::timerInfo(tm); DBServer::timerInfo(tm);
switch( tm->id ) switch( tm->id )
{ {
case DBServer_SQLite::PingTimer: case DBServer_SQLite::PingTimer:
......
...@@ -20,13 +20,13 @@ int main(int argc, char** argv) ...@@ -20,13 +20,13 @@ int main(int argc, char** argv)
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) ) if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
{ {
cout << "--confile filename - configuration file. Default: configure.xml" << endl; cout << "--confile filename - configuration file. Default: configure.xml" << endl;
DBServer_SQLite::help_print(argc,argv); DBServer_SQLite::help_print(argc, argv);
return 0; return 0;
} }
auto conf = uniset_init(argc, argv, "configure.xml"); auto conf = uniset_init(argc, argv, "configure.xml");
auto db = DBServer_SQLite::init_dbserver(argc,argv); auto db = DBServer_SQLite::init_dbserver(argc, argv);
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act->add(db); act->add(db);
......
...@@ -60,7 +60,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -60,7 +60,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
iolog = make_shared<DebugStream>(); iolog = make_shared<DebugStream>();
iolog->setLogName(myname); iolog->setLogName(myname);
conf->initLogStream(iolog,prefix+"-log"); conf->initLogStream(iolog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(iolog); loga->add(iolog);
...@@ -76,7 +76,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -76,7 +76,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -107,8 +108,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -107,8 +108,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
if( cards[i] == NULL ) if( cards[i] == NULL )
{ {
iolog3 << myname << "(init): Card N" << i iolog3 << myname << "(init): Card N" << i
<< " DISABLED! dev='" << " DISABLED! dev='"
<< iodev << "'" << endl; << iodev << "'" << endl;
} }
} }
else else
...@@ -141,8 +142,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -141,8 +142,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
if( !stype.empty() ) if( !stype.empty() )
{ {
ioinfo << myname ioinfo << myname
<< "(init): card" << i << "(init): card" << i
<< " subdev" << s << " set type " << stype << endl; << " subdev" << s << " set type " << stype << endl;
cards[i]->configureSubdev(s - 1, st); cards[i]->configureSubdev(s - 1, st);
} }
...@@ -206,7 +207,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -206,7 +207,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
s_fvalue = conf->getArgParam("--" + prefix + "-s-filter-value"); s_fvalue = conf->getArgParam("--" + prefix + "-s-filter-value");
ioinfo << myname << "(init): read s_field='" << s_field ioinfo << myname << "(init): read s_field='" << s_field
<< "' s_fvalue='" << s_fvalue << "'" << endl; << "' s_fvalue='" << s_fvalue << "'" << endl;
int blink_msec = conf->getArgPInt("--" + prefix + "-blink-time", it.getProp("blink-time"), 300); int blink_msec = conf->getArgPInt("--" + prefix + "-blink-time", it.getProp("blink-time"), 300);
ptBlink.setTiming(blink_msec); ptBlink.setTiming(blink_msec);
...@@ -232,8 +233,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -232,8 +233,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
{ {
sidTestSMReady = conf->getSensorID("TestMode_S"); sidTestSMReady = conf->getSensorID("TestMode_S");
iowarn << myname iowarn << myname
<< "(init): Unknown ID for sm-ready-test-sid (--" << prefix << "-sm-ready-test-sid)." << "(init): Unknown ID for sm-ready-test-sid (--" << prefix << "-sm-ready-test-sid)."
<< " Use 'TestMode_S'" << endl; << " Use 'TestMode_S'" << endl;
} }
else else
ioinfo << myname << "(init): test-sid: " << sm_ready_sid << endl; ioinfo << myname << "(init): test-sid: " << sm_ready_sid << endl;
...@@ -421,7 +422,7 @@ void IOControl::execute() ...@@ -421,7 +422,7 @@ void IOControl::execute()
catch( const CORBA::SystemException& ex ) catch( const CORBA::SystemException& ex )
{ {
iolog3 << myname << "(execute): CORBA::SystemException: " iolog3 << myname << "(execute): CORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
catch(...) catch(...)
{ {
...@@ -538,11 +539,11 @@ void IOControl::ioread( IOInfo* it ) ...@@ -538,11 +539,11 @@ void IOControl::ioread( IOInfo* it )
int val = card->getAnalogChannel(it->subdev, it->channel, it->range, it->aref); int val = card->getAnalogChannel(it->subdev, it->channel, it->range, it->aref);
iolog3 << myname << "(iopoll): read AI " iolog3 << myname << "(iopoll): read AI "
<< " sid=" << it->si.id << " sid=" << it->si.id
<< " subdev=" << it->subdev << " subdev=" << it->subdev
<< " chan=" << it->channel << " chan=" << it->channel
<< " val=" << val << " val=" << val
<< endl; << endl;
IOBase::processingAsAI( ib, val, shm, force ); IOBase::processingAsAI( ib, val, shm, force );
} }
...@@ -676,7 +677,7 @@ void IOControl::ioread( IOInfo* it ) ...@@ -676,7 +677,7 @@ void IOControl::ioread( IOInfo* it )
catch( const CORBA::SystemException& ex ) catch( const CORBA::SystemException& ex )
{ {
iolog3 << myname << "(iopoll): СORBA::SystemException: " iolog3 << myname << "(iopoll): СORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
...@@ -729,9 +730,9 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -729,9 +730,9 @@ bool IOControl::initIOItem( UniXML::iterator& it )
if( c.empty() || inf.ncard < 0 || inf.ncard >= (int)cards.size() ) if( c.empty() || inf.ncard < 0 || inf.ncard >= (int)cards.size() )
{ {
iolog3 << myname iolog3 << myname
<< "(initIOItem): Unknown or bad card number (" << "(initIOItem): Unknown or bad card number ("
<< inf.ncard << ") for " << it.getProp("name") << inf.ncard << ") for " << it.getProp("name")
<< " set default=" << defCardNum << endl; << " set default=" << defCardNum << endl;
inf.ncard = defCardNum; inf.ncard = defCardNum;
} }
...@@ -777,8 +778,8 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -777,8 +778,8 @@ bool IOControl::initIOItem( UniXML::iterator& it )
IOPriority p(prior, maxItem); IOPriority p(prior, maxItem);
pmap.push_back(p); pmap.push_back(p);
iolog3 << myname << "(readItem): add to priority list: " << iolog3 << myname << "(readItem): add to priority list: " <<
it.getProp("name") it.getProp("name")
<< " priority=" << prior << endl; << " priority=" << prior << endl;
} }
// значит это пороговый датчик.. // значит это пороговый датчик..
...@@ -786,7 +787,7 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -786,7 +787,7 @@ bool IOControl::initIOItem( UniXML::iterator& it )
{ {
iomap[maxItem++] = std::move(inf); iomap[maxItem++] = std::move(inf);
iolog3 << myname << "(readItem): add threshold '" << it.getProp("name") iolog3 << myname << "(readItem): add threshold '" << it.getProp("name")
<< " for '" << uniset_conf()->oind->getNameById(inf.t_ai) << endl; << " for '" << uniset_conf()->oind->getNameById(inf.t_ai) << endl;
return true; return true;
} }
...@@ -795,7 +796,7 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -795,7 +796,7 @@ bool IOControl::initIOItem( UniXML::iterator& it )
if( inf.channel < 0 || inf.channel > 32 ) if( inf.channel < 0 || inf.channel > 32 )
{ {
iowarn << myname << "(readItem): Unknown channel: " << inf.channel iowarn << myname << "(readItem): Unknown channel: " << inf.channel
<< " for " << it.getProp("name") << endl; << " for " << it.getProp("name") << endl;
return false; return false;
} }
...@@ -814,8 +815,8 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -814,8 +815,8 @@ bool IOControl::initIOItem( UniXML::iterator& it )
if( inf.range < 0 || inf.range > 3 ) if( inf.range < 0 || inf.range > 3 )
{ {
iocrit << myname << "(readItem): Unknown 'range': " << inf.range iocrit << myname << "(readItem): Unknown 'range': " << inf.range
<< " for " << it.getProp("name") << " for " << it.getProp("name")
<< " Must be range=[0..3]" << endl; << " Must be range=[0..3]" << endl;
return false; return false;
} }
...@@ -824,8 +825,8 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -824,8 +825,8 @@ bool IOControl::initIOItem( UniXML::iterator& it )
if( inf.aref < 0 || inf.aref > 3 ) if( inf.aref < 0 || inf.aref > 3 )
{ {
iocrit << myname << "(readItem): Unknown 'aref': " << inf.aref iocrit << myname << "(readItem): Unknown 'aref': " << inf.aref
<< " for " << it.getProp("name") << " for " << it.getProp("name")
<< ". Must be aref=[0..3]" << endl; << ". Must be aref=[0..3]" << endl;
return false; return false;
} }
} }
...@@ -1389,7 +1390,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -1389,7 +1390,7 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm ) void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
iolog1 << myname << "(sensorInfo): sm->id=" << sm->id iolog1 << myname << "(sensorInfo): sm->id=" << sm->id
<< " val=" << sm->value << endl; << " val=" << sm->value << endl;
if( force_out ) if( force_out )
return; return;
...@@ -1410,8 +1411,8 @@ void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm ) ...@@ -1410,8 +1411,8 @@ void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm )
if( it.si.id == sm->id ) if( it.si.id == sm->id )
{ {
ioinfo << myname << "(sensorInfo): sid=" << sm->id ioinfo << myname << "(sensorInfo): sid=" << sm->id
<< " value=" << sm->value << " value=" << sm->value
<< endl; << endl;
if( it.stype == UniversalIO::AO ) if( it.stype == UniversalIO::AO )
{ {
...@@ -1512,7 +1513,7 @@ void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm ) ...@@ -1512,7 +1513,7 @@ void IOControl::sensorInfo( const UniSetTypes::SensorMessage* sm )
else if( it.stype == UniversalIO::DO ) else if( it.stype == UniversalIO::DO )
{ {
iolog1 << myname << "(sensorInfo): DO: sm->id=" << sm->id iolog1 << myname << "(sensorInfo): DO: sm->id=" << sm->id
<< " val=" << sm->value << endl; << " val=" << sm->value << endl;
uniset_rwmutex_wrlock lock(it.val_lock); uniset_rwmutex_wrlock lock(it.val_lock);
it.value = sm->value ? 1 : 0; it.value = sm->value ? 1 : 0;
...@@ -1627,7 +1628,7 @@ void IOControl::buildCardsList() ...@@ -1627,7 +1628,7 @@ void IOControl::buildCardsList()
{ {
cards[cardnum] = NULL; cards[cardnum] = NULL;
iolog3 << myname << "(init): card=" << it.getProp("card") << "(" << cname << ")" iolog3 << myname << "(init): card=" << it.getProp("card") << "(" << cname << ")"
<< " DISABLED! ignore=1" << endl; << " DISABLED! ignore=1" << endl;
continue; continue;
} }
...@@ -1638,7 +1639,7 @@ void IOControl::buildCardsList() ...@@ -1638,7 +1639,7 @@ void IOControl::buildCardsList()
{ {
cards[cardnum] = NULL; cards[cardnum] = NULL;
iolog3 << myname << "(init): card=" << it.getProp("card") << "(" << cname << ")" iolog3 << myname << "(init): card=" << it.getProp("card") << "(" << cname << ")"
<< " DISABLED! (" << s.str() << ")" << endl; << " DISABLED! (" << s.str() << ")" << endl;
continue; continue;
} }
...@@ -1648,8 +1649,8 @@ void IOControl::buildCardsList() ...@@ -1648,8 +1649,8 @@ void IOControl::buildCardsList()
{ {
cards[cardnum] = NULL; cards[cardnum] = NULL;
iolog3 << myname << "(init): card=" << it.getProp("card") << "(" << cname << ")" iolog3 << myname << "(init): card=" << it.getProp("card") << "(" << cname << ")"
<< " DISABLED! iodev='" << " DISABLED! iodev='"
<< iodev << "'" << endl; << iodev << "'" << endl;
continue; continue;
} }
...@@ -1710,14 +1711,14 @@ void IOControl::buildCardsList() ...@@ -1710,14 +1711,14 @@ void IOControl::buildCardsList()
{ {
// для Grayhill конфигурирование не требуется // для Grayhill конфигурирование не требуется
ioinfo << myname << "(buildCardsList): card=" << it.getProp("card") ioinfo << myname << "(buildCardsList): card=" << it.getProp("card")
<< "(" << cname << ")" << "(" << cname << ")"
<< " init subdev" << i << " 'GRAYHILL'" << endl; << " init subdev" << i << " 'GRAYHILL'" << endl;
continue; continue;
} }
ioinfo << myname << "(buildCardsList): card=" << it.getProp("card") ioinfo << myname << "(buildCardsList): card=" << it.getProp("card")
<< "(" << cname << ")" << "(" << cname << ")"
<< " init subdev" << i << " " << it.getProp(s.str()) << endl; << " init subdev" << i << " " << it.getProp(s.str()) << endl;
cards[cardnum]->configureSubdev(i - 1, st); cards[cardnum]->configureSubdev(i - 1, st);
} }
} }
......
#ifndef IOLogSugar_H_ #ifndef IOLogSugar_H_
#define IOLogSugar_H_ #define IOLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef ioinfo #ifndef ioinfo
#define ioinfo if( iolog->debugging(Debug::INFO) ) iolog->info() #define ioinfo if( iolog->debugging(Debug::INFO) ) iolog->info()
#endif #endif
#ifndef iowarn #ifndef iowarn
#define iowarn if( iolog->debugging(Debug::WARN) ) iolog->warn() #define iowarn if( iolog->debugging(Debug::WARN) ) iolog->warn()
#endif #endif
#ifndef iocrit #ifndef iocrit
#define iocrit if( iolog->debugging(Debug::CRIT) ) iolog->crit() #define iocrit if( iolog->debugging(Debug::CRIT) ) iolog->crit()
#endif #endif
#ifndef iolog1 #ifndef iolog1
#define iolog1 if( iolog->debugging(Debug::LEVEL1) ) iolog->level1() #define iolog1 if( iolog->debugging(Debug::LEVEL1) ) iolog->level1()
#endif #endif
#ifndef iolog2 #ifndef iolog2
#define iolog2 if( iolog->debugging(Debug::LEVEL2) ) iolog->level2() #define iolog2 if( iolog->debugging(Debug::LEVEL2) ) iolog->level2()
#endif #endif
#ifndef iolog3 #ifndef iolog3
#define iolog3 if( iolog->debugging(Debug::LEVEL3) ) iolog->level3() #define iolog3 if( iolog->debugging(Debug::LEVEL3) ) iolog->level3()
#endif #endif
#ifndef iolog4 #ifndef iolog4
#define iolog4 if( iolog->debugging(Debug::LEVEL4) ) iolog->level4() #define iolog4 if( iolog->debugging(Debug::LEVEL4) ) iolog->level4()
#endif #endif
#ifndef iolog5 #ifndef iolog5
#define iolog5 if( iolog->debugging(Debug::LEVEL5) ) iolog->level5() #define iolog5 if( iolog->debugging(Debug::LEVEL5) ) iolog->level5()
#endif #endif
#ifndef iolog6 #ifndef iolog6
#define iolog6 if( iolog->debugging(Debug::LEVEL6) ) iolog->level6() #define iolog6 if( iolog->debugging(Debug::LEVEL6) ) iolog->level6()
#endif #endif
#ifndef iolog7 #ifndef iolog7
#define iolog7 if( iolog->debugging(Debug::LEVEL7) ) iolog->level7() #define iolog7 if( iolog->debugging(Debug::LEVEL7) ) iolog->level7()
#endif #endif
#ifndef iolog8 #ifndef iolog8
#define iolog8 if( iolog->debugging(Debug::LEVEL8) ) iolog->level8() #define iolog8 if( iolog->debugging(Debug::LEVEL8) ) iolog->level8()
#endif #endif
#ifndef iolog9 #ifndef iolog9
#define iolog9 if( iolog->debugging(Debug::LEVEL9) ) iolog->level9() #define iolog9 if( iolog->debugging(Debug::LEVEL9) ) iolog->level9()
#endif #endif
#ifndef iologany #ifndef iologany
#define iologany iolog->any() #define iologany iolog->any()
#endif #endif
#endif #endif
...@@ -58,7 +58,8 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId ...@@ -58,7 +58,8 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
......
...@@ -285,7 +285,7 @@ bool RTUExchange::poll() ...@@ -285,7 +285,7 @@ bool RTUExchange::poll()
updateSM(); updateSM();
// check thresholds // check thresholds
for( auto&& t : thrlist ) for( auto && t : thrlist )
{ {
if( !checkProcActive() ) if( !checkProcActive() )
return false; return false;
...@@ -358,7 +358,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -358,7 +358,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
{ {
d->second->speed = defSpeed; d->second->speed = defSpeed;
mbcrit << myname << "(initDeviceInfo): Unknown speed=" << s << mbcrit << myname << "(initDeviceInfo): Unknown speed=" << s <<
" for addr=" << ModbusRTU::addr2str(a) << endl; " for addr=" << ModbusRTU::addr2str(a) << endl;
return false; return false;
} }
} }
......
...@@ -57,7 +57,8 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons ...@@ -57,7 +57,8 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
......
...@@ -198,8 +198,8 @@ void MBTCPMultiSlave::execute_tcp() ...@@ -198,8 +198,8 @@ void MBTCPMultiSlave::execute_tcp()
auto c = it.second; auto c = it.second;
mblog4 << myname << "(work): " << c.iaddr << " resp=" << (c.invert ? c.ptTimeout.checkTime() : !c.ptTimeout.checkTime()) mblog4 << myname << "(work): " << c.iaddr << " resp=" << (c.invert ? c.ptTimeout.checkTime() : !c.ptTimeout.checkTime())
<< " askcount=" << c.askCount << " askcount=" << c.askCount
<< endl; << endl;
if( c.respond_s != DefaultObjectId ) if( c.respond_s != DefaultObjectId )
......
...@@ -28,7 +28,8 @@ RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes:: ...@@ -28,7 +28,8 @@ RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -330,7 +331,7 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -330,7 +331,7 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm )
logserv->run(logserv_host, logserv_port, true); logserv->run(logserv_host, logserv_port, true);
} }
for( auto&& it : rrdlist ) for( auto && it : rrdlist )
{ {
try try
{ {
......
...@@ -68,11 +68,11 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -68,11 +68,11 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
if( confnode == NULL ) if( confnode == NULL )
throw SystemError("Not found conf-node for " + cname ); throw SystemError("Not found conf-node for " + cname );
string prefix="sm"; string prefix = "sm";
smlog = make_shared<DebugStream>(); smlog = make_shared<DebugStream>();
smlog->setLogName(myname); smlog->setLogName(myname);
conf->initLogStream(smlog,prefix+"-log"); conf->initLogStream(smlog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(smlog); loga->add(smlog);
...@@ -82,7 +82,8 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -82,7 +82,8 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
UniXML::iterator it(confnode); UniXML::iterator it(confnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", confnode ); logserv->init( prefix + "-logserver", confnode );
// ---------------------- // ----------------------
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
...@@ -521,7 +522,7 @@ void SharedMemory::readEventList( const std::string& oname ) ...@@ -521,7 +522,7 @@ void SharedMemory::readEventList( const std::string& oname )
} }
else else
smcrit << myname << "(readEventList): Не найден ID для " smcrit << myname << "(readEventList): Не найден ID для "
<< it.getProp("name") << endl; << it.getProp("name") << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -621,9 +622,9 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -621,9 +622,9 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
if( hi.fuse_id == DefaultObjectId ) if( hi.fuse_id == DefaultObjectId )
{ {
smwarn << myname << "(buildHistory): not found sensor ID for " smwarn << myname << "(buildHistory): not found sensor ID for "
<< it.getProp("fuse_id") << it.getProp("fuse_id")
<< " history item id=" << it.getProp("id") << " history item id=" << it.getProp("id")
<< " ..ignore.." << endl; << " ..ignore.." << endl;
continue; continue;
} }
...@@ -638,10 +639,10 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -638,10 +639,10 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
} }
sminfo << myname << "(buildHistory): add fuse_id=" << hi.fuse_id sminfo << myname << "(buildHistory): add fuse_id=" << hi.fuse_id
<< " fuse_val=" << hi.fuse_val << " fuse_val=" << hi.fuse_val
<< " fuse_use_val=" << hi.fuse_use_val << " fuse_use_val=" << hi.fuse_use_val
<< " fuse_invert=" << hi.fuse_invert << " fuse_invert=" << hi.fuse_invert
<< endl; << endl;
// WARNING: no check duplicates... // WARNING: no check duplicates...
hist.push_back(hi); hist.push_back(hi);
...@@ -725,9 +726,9 @@ void SharedMemory::updateHistory( std::shared_ptr<USensorInfo>& s_it, IOControll ...@@ -725,9 +726,9 @@ void SharedMemory::updateHistory( std::shared_ptr<USensorInfo>& s_it, IOControll
} }
sminfo << myname << "(updateHistory): " sminfo << myname << "(updateHistory): "
<< " sid=" << s_it->si.id << " sid=" << s_it->si.id
<< " value=" << value << " value=" << value
<< endl; << endl;
for( auto& it1 : i->second ) for( auto& it1 : i->second )
{ {
......
...@@ -380,7 +380,7 @@ class SharedMemory: ...@@ -380,7 +380,7 @@ class SharedMemory:
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override; virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override; virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ){}; virtual void askSensors( UniversalIO::UIOCommand cmd ) {};
void sendEvent( UniSetTypes::SystemMessage& sm ); void sendEvent( UniSetTypes::SystemMessage& sm );
void initFromReserv(); void initFromReserv();
bool initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectId sm_node ); bool initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectId sm_node );
......
...@@ -26,7 +26,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -26,7 +26,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
unetlog = make_shared<DebugStream>(); unetlog = make_shared<DebugStream>();
unetlog->setLogName(myname); unetlog->setLogName(myname);
conf->initLogStream(unetlog,prefix+"-log"); conf->initLogStream(unetlog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(unetlog); loga->add(unetlog);
...@@ -38,7 +38,8 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -38,7 +38,8 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -49,12 +50,12 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -49,12 +50,12 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
s_field = conf->getArgParam("--" + prefix + "-filter-field"); s_field = conf->getArgParam("--" + prefix + "-filter-field");
s_fvalue = conf->getArgParam("--" + prefix + "-filter-value"); s_fvalue = conf->getArgParam("--" + prefix + "-filter-value");
unetinfo << myname << "(init): read filter-field='" << s_field unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
const string n_field(conf->getArgParam("--" + prefix + "-nodes-filter-field")); const string n_field(conf->getArgParam("--" + prefix + "-nodes-filter-field"));
const string n_fvalue(conf->getArgParam("--" + prefix + "-nodes-filter-value")); const string n_fvalue(conf->getArgParam("--" + prefix + "-nodes-filter-value"));
unetinfo << myname << "(init): read nodes-filter-field='" << n_field unetinfo << myname << "(init): read nodes-filter-field='" << n_field
<< "' nodes-filter-value='" << n_fvalue << "'" << endl; << "' nodes-filter-value='" << n_fvalue << "'" << endl;
int recvTimeout = conf->getArgPInt("--" + prefix + "-recv-timeout", it.getProp("recvTimeout"), 5000); int recvTimeout = conf->getArgPInt("--" + prefix + "-recv-timeout", it.getProp("recvTimeout"), 5000);
int prepareTime = conf->getArgPInt("--" + prefix + "-preapre-time", it.getProp("prepareTime"), 2000); int prepareTime = conf->getArgPInt("--" + prefix + "-preapre-time", it.getProp("prepareTime"), 2000);
...@@ -68,7 +69,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -68,7 +69,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
no_sender = conf->getArgInt("--" + prefix + "-nosender", it.getProp("nosender")); no_sender = conf->getArgInt("--" + prefix + "-nosender", it.getProp("nosender"));
std::string nconfname = conf->getArg2Param("--" + prefix + "-nodes-confnode", it.getProp("nodesConfNode"),"nodes"); std::string nconfname = conf->getArg2Param("--" + prefix + "-nodes-confnode", it.getProp("nodesConfNode"), "nodes");
xmlNode* nodes = 0; xmlNode* nodes = 0;
...@@ -83,7 +84,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -83,7 +84,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
unetinfo << myname << "(init): init from <" << nconfname << ">" << endl; unetinfo << myname << "(init): init from <" << nconfname << ">" << endl;
if( !nodes ) if( !nodes )
throw UniSetTypes::SystemError("(UNetExchange): Not found confnode <" + nconfname +">"); throw UniSetTypes::SystemError("(UNetExchange): Not found confnode <" + nconfname + ">");
UniXML::iterator n_it(nodes); UniXML::iterator n_it(nodes);
...@@ -152,7 +153,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -152,7 +153,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
if( no_sender ) if( no_sender )
{ {
unetinfo << myname << "(init): sender OFF for this node...(" unetinfo << myname << "(init): sender OFF for this node...("
<< n_it.getProp("name") << ")" << endl; << n_it.getProp("name") << ")" << endl;
continue; continue;
} }
...@@ -306,7 +307,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -306,7 +307,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
} }
unetinfo << myname << "(init): (node='" << n << "') add receiver " unetinfo << myname << "(init): (node='" << n << "') add receiver "
<< h2 << ":" << p2 << endl; << h2 << ":" << p2 << endl;
auto r = make_shared<UNetReceiver>(h, p, shm); auto r = make_shared<UNetReceiver>(h, p, shm);
loga->add(r->getLog()); loga->add(r->getLog());
...@@ -333,7 +334,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -333,7 +334,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
if( !h2.empty() ) // создаём читателя впо второму каналу if( !h2.empty() ) // создаём читателя впо второму каналу
{ {
unetinfo << myname << "(init): (node='" << n << "') add reserv receiver " unetinfo << myname << "(init): (node='" << n << "') add reserv receiver "
<< h2 << ":" << p2 << endl; << h2 << ":" << p2 << endl;
r2 = make_shared<UNetReceiver>(h2, p2, shm); r2 = make_shared<UNetReceiver>(h2, p2, shm);
...@@ -487,7 +488,7 @@ void UNetExchange::step() ...@@ -487,7 +488,7 @@ void UNetExchange::step()
} }
} }
for( auto&& it : recvlist ) for( auto && it : recvlist )
it.step(shm, myname, unetlog); it.step(shm, myname, unetlog);
} }
......
#ifndef UNETLogSugar_H_ #ifndef UNETLogSugar_H_
#define UNETLogSugar_H_ #define UNETLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef unetinfo #ifndef unetinfo
#define unetinfo if( unetlog->debugging(Debug::INFO) ) unetlog->info() #define unetinfo if( unetlog->debugging(Debug::INFO) ) unetlog->info()
#endif #endif
#ifndef unetwarn #ifndef unetwarn
#define unetwarn if( unetlog->debugging(Debug::WARN) ) unetlog->warn() #define unetwarn if( unetlog->debugging(Debug::WARN) ) unetlog->warn()
#endif #endif
#ifndef unetcrit #ifndef unetcrit
#define unetcrit if( unetlog->debugging(Debug::CRIT) ) unetlog->crit() #define unetcrit if( unetlog->debugging(Debug::CRIT) ) unetlog->crit()
#endif #endif
#ifndef unetlog1 #ifndef unetlog1
#define unetlog1 if( unetlog->debugging(Debug::LEVEL1) ) unetlog->level1() #define unetlog1 if( unetlog->debugging(Debug::LEVEL1) ) unetlog->level1()
#endif #endif
#ifndef unetlog2 #ifndef unetlog2
#define unetlog2 if( unetlog->debugging(Debug::LEVEL2) ) unetlog->level2() #define unetlog2 if( unetlog->debugging(Debug::LEVEL2) ) unetlog->level2()
#endif #endif
#ifndef unetlog3 #ifndef unetlog3
#define unetlog3 if( unetlog->debugging(Debug::LEVEL3) ) unetlog->level3() #define unetlog3 if( unetlog->debugging(Debug::LEVEL3) ) unetlog->level3()
#endif #endif
#ifndef unetlog4 #ifndef unetlog4
#define unetlog4 if( unetlog->debugging(Debug::LEVEL4) ) unetlog->level4() #define unetlog4 if( unetlog->debugging(Debug::LEVEL4) ) unetlog->level4()
#endif #endif
#ifndef unetlog5 #ifndef unetlog5
#define unetlog5 if( unetlog->debugging(Debug::LEVEL5) ) unetlog->level5() #define unetlog5 if( unetlog->debugging(Debug::LEVEL5) ) unetlog->level5()
#endif #endif
#ifndef unetlog6 #ifndef unetlog6
#define unetlog6 if( unetlog->debugging(Debug::LEVEL6) ) unetlog->level6() #define unetlog6 if( unetlog->debugging(Debug::LEVEL6) ) unetlog->level6()
#endif #endif
#ifndef unetlog7 #ifndef unetlog7
#define unetlog7 if( unetlog->debugging(Debug::LEVEL7) ) unetlog->level7() #define unetlog7 if( unetlog->debugging(Debug::LEVEL7) ) unetlog->level7()
#endif #endif
#ifndef unetlog8 #ifndef unetlog8
#define unetlog8 if( unetlog->debugging(Debug::LEVEL8) ) unetlog->level8() #define unetlog8 if( unetlog->debugging(Debug::LEVEL8) ) unetlog->level8()
#endif #endif
#ifndef unetlog9 #ifndef unetlog9
#define unetlog9 if( unetlog->debugging(Debug::LEVEL9) ) unetlog->level9() #define unetlog9 if( unetlog->debugging(Debug::LEVEL9) ) unetlog->level9()
#endif #endif
#ifndef unetlogany #ifndef unetlogany
#define unetlogany unetlog->any() #define unetlogany unetlog->any()
#endif #endif
#endif // end of UNETLogSugar #endif // end of UNETLogSugar
...@@ -119,7 +119,10 @@ class UNetReceiver: ...@@ -119,7 +119,10 @@ class UNetReceiver:
typedef sigc::slot<void, const std::shared_ptr<UNetReceiver>&, Event> EventSlot; typedef sigc::slot<void, const std::shared_ptr<UNetReceiver>&, Event> EventSlot;
void connectEvent( EventSlot sl ); void connectEvent( EventSlot sl );
inline std::shared_ptr<DebugStream> getLog(){ return unetlog; } inline std::shared_ptr<DebugStream> getLog()
{
return unetlog;
}
protected: protected:
......
...@@ -37,7 +37,7 @@ UNetSender::UNetSender( const std::string& s_host, const ost::tpport_t port, con ...@@ -37,7 +37,7 @@ UNetSender::UNetSender( const std::string& s_host, const ost::tpport_t port, con
// s_field = conf->getArgParam("--udp-filter-field"); // s_field = conf->getArgParam("--udp-filter-field");
// s_fvalue = conf->getArgParam("--udp-filter-value"); // s_fvalue = conf->getArgParam("--udp-filter-value");
unetinfo << myname << "(init): read filter-field='" << s_field unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
unetinfo << "(UNetSender): UDP set to " << s_host << ":" << port << endl; unetinfo << "(UNetSender): UDP set to " << s_host << ":" << port << endl;
...@@ -295,7 +295,7 @@ bool UNetSender::initItem( UniXML::iterator& it ) ...@@ -295,7 +295,7 @@ bool UNetSender::initItem( UniXML::iterator& it )
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
unetcrit << myname << "(readItem): ID not found for " unetcrit << myname << "(readItem): ID not found for "
<< sname << endl; << sname << endl;
return false; return false;
} }
...@@ -317,8 +317,8 @@ bool UNetSender::initItem( UniXML::iterator& it ) ...@@ -317,8 +317,8 @@ bool UNetSender::initItem( UniXML::iterator& it )
if ( p.pack_ind >= UniSetUDP::MaxDCount ) if ( p.pack_ind >= UniSetUDP::MaxDCount )
{ {
unetcrit << myname unetcrit << myname
<< "(readItem): OVERFLOW! MAX UDP DIGITAL DATA LIMIT! max=" << "(readItem): OVERFLOW! MAX UDP DIGITAL DATA LIMIT! max="
<< UniSetUDP::MaxDCount << endl; << UniSetUDP::MaxDCount << endl;
raise(SIGTERM); raise(SIGTERM);
return false; return false;
...@@ -331,8 +331,8 @@ bool UNetSender::initItem( UniXML::iterator& it ) ...@@ -331,8 +331,8 @@ bool UNetSender::initItem( UniXML::iterator& it )
if ( p.pack_ind >= UniSetUDP::MaxACount ) if ( p.pack_ind >= UniSetUDP::MaxACount )
{ {
unetcrit << myname unetcrit << myname
<< "(readItem): OVERFLOW! MAX UDP ANALOG DATA LIMIT! max=" << "(readItem): OVERFLOW! MAX UDP ANALOG DATA LIMIT! max="
<< UniSetUDP::MaxACount << endl; << UniSetUDP::MaxACount << endl;
raise(SIGTERM); raise(SIGTERM);
return false; return false;
} }
......
...@@ -70,7 +70,10 @@ class UNetSender ...@@ -70,7 +70,10 @@ class UNetSender
/*! инициализация итераторов */ /*! инициализация итераторов */
void initIterators(); void initIterators();
inline std::shared_ptr<DebugStream> getLog(){ return unetlog; } inline std::shared_ptr<DebugStream> getLog()
{
return unetlog;
}
protected: protected:
......
...@@ -47,7 +47,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm ...@@ -47,7 +47,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
auto&& r_worker = [&shm, bound] auto&& r_worker = [&shm, bound]
{ {
int num = bound; int num = bound;
ObjectId sid = begSensorID + rand()%10000; ObjectId sid = begSensorID + rand() % 10000;
while (num--) while (num--)
{ {
...@@ -58,7 +58,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm ...@@ -58,7 +58,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
auto&& w_worker = [&shm, bound] auto&& w_worker = [&shm, bound]
{ {
int num = bound; int num = bound;
ObjectId sid = begSensorID + rand()%10000; ObjectId sid = begSensorID + rand() % 10000;
while (num--) while (num--)
{ {
...@@ -68,10 +68,10 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm ...@@ -68,10 +68,10 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
std::vector<std::thread> threads; std::vector<std::thread> threads;
for (std::size_t i = 0; i < concurrency/2 - 1; ++i) for (std::size_t i = 0; i < concurrency / 2 - 1; ++i)
threads.emplace_back(r_worker); threads.emplace_back(r_worker);
for (std::size_t i = 0; i < concurrency/2 - 1; ++i) for (std::size_t i = 0; i < concurrency / 2 - 1; ++i)
threads.emplace_back(w_worker); threads.emplace_back(w_worker);
for (auto && thread : threads) for (auto && thread : threads)
...@@ -112,8 +112,8 @@ int main(int argc, char* argv[] ) ...@@ -112,8 +112,8 @@ int main(int argc, char* argv[] )
start = std::chrono::system_clock::now(); start = std::chrono::system_clock::now();
run_test(50, 1000000, shm); run_test(50, 1000000, shm);
end = std::chrono::system_clock::now(); end = std::chrono::system_clock::now();
int elapsed_seconds = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count(); int elapsed_seconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
std::cout << "elapsed time: " << elapsed_seconds << " ms\n"; std::cout << "elapsed time: " << elapsed_seconds << " ms\n";
return 0; return 0;
} }
......
#ifndef DBLogSugar_H_ #ifndef DBLogSugar_H_
#define DBLogSugar_H_ #define DBLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef dbinfo #ifndef dbinfo
#define dbinfo if( dblog->debugging(Debug::INFO) ) dblog->info() #define dbinfo if( dblog->debugging(Debug::INFO) ) dblog->info()
#endif #endif
#ifndef dbwarn #ifndef dbwarn
#define dbwarn if( dblog->debugging(Debug::WARN) ) dblog->warn() #define dbwarn if( dblog->debugging(Debug::WARN) ) dblog->warn()
#endif #endif
#ifndef dbcrit #ifndef dbcrit
#define dbcrit if( dblog->debugging(Debug::CRIT) ) dblog->crit() #define dbcrit if( dblog->debugging(Debug::CRIT) ) dblog->crit()
#endif #endif
#ifndef dblog1 #ifndef dblog1
#define dblog1 if( dblog->debugging(Debug::LEVEL1) ) dblog->level1() #define dblog1 if( dblog->debugging(Debug::LEVEL1) ) dblog->level1()
#endif #endif
#ifndef dblog2 #ifndef dblog2
#define dblog2 if( dblog->debugging(Debug::LEVEL2) ) dblog->level2() #define dblog2 if( dblog->debugging(Debug::LEVEL2) ) dblog->level2()
#endif #endif
#ifndef dblog3 #ifndef dblog3
#define dblog3 if( dblog->debugging(Debug::LEVEL3) ) dblog->level3() #define dblog3 if( dblog->debugging(Debug::LEVEL3) ) dblog->level3()
#endif #endif
#ifndef dblog4 #ifndef dblog4
#define dblog4 if( dblog->debugging(Debug::LEVEL4) ) dblog->level4() #define dblog4 if( dblog->debugging(Debug::LEVEL4) ) dblog->level4()
#endif #endif
#ifndef dblog5 #ifndef dblog5
#define dblog5 if( dblog->debugging(Debug::LEVEL5) ) dblog->level5() #define dblog5 if( dblog->debugging(Debug::LEVEL5) ) dblog->level5()
#endif #endif
#ifndef dblog6 #ifndef dblog6
#define dblog6 if( dblog->debugging(Debug::LEVEL6) ) dblog->level6() #define dblog6 if( dblog->debugging(Debug::LEVEL6) ) dblog->level6()
#endif #endif
#ifndef dblog7 #ifndef dblog7
#define dblog7 if( dblog->debugging(Debug::LEVEL7) ) dblog->level7() #define dblog7 if( dblog->debugging(Debug::LEVEL7) ) dblog->level7()
#endif #endif
#ifndef dblog8 #ifndef dblog8
#define dblog8 if( dblog->debugging(Debug::LEVEL8) ) dblog->level8() #define dblog8 if( dblog->debugging(Debug::LEVEL8) ) dblog->level8()
#endif #endif
#ifndef dblog9 #ifndef dblog9
#define dblog9 if( dblog->debugging(Debug::LEVEL9) ) dblog->level9() #define dblog9 if( dblog->debugging(Debug::LEVEL9) ) dblog->level9()
#endif #endif
#ifndef dblogany #ifndef dblogany
#define dblogany dblog->any() #define dblogany dblog->any()
#endif #endif
#endif // end of DBLogSugar #endif // end of DBLogSugar
...@@ -53,8 +53,8 @@ class DBServer: ...@@ -53,8 +53,8 @@ class DBServer:
public UniSetObject_LT public UniSetObject_LT
{ {
public: public:
DBServer( UniSetTypes::ObjectId id, const std::string& prefix="db" ); DBServer( UniSetTypes::ObjectId id, const std::string& prefix = "db" );
DBServer( const std::string& prefix="db" ); DBServer( const std::string& prefix = "db" );
~DBServer(); ~DBServer();
static std::string help_print(); static std::string help_print();
...@@ -66,7 +66,7 @@ class DBServer: ...@@ -66,7 +66,7 @@ class DBServer:
virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ) {} virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ) {}
virtual bool activateObject() override; virtual bool activateObject() override;
virtual void initDBServer(){}; virtual void initDBServer() {};
std::shared_ptr<LogAgregator> loga; std::shared_ptr<LogAgregator> loga;
......
...@@ -87,7 +87,7 @@ class LogServer ...@@ -87,7 +87,7 @@ class LogServer
return (thr && thr->isRunning()); return (thr && thr->isRunning());
} }
void init( const std::string& prefix, xmlNode* cnode=0 ); void init( const std::string& prefix, xmlNode* cnode = 0 );
static std::string help_print( const std::string& prefix ); static std::string help_print( const std::string& prefix );
......
#ifndef MBLogSugar_H_ #ifndef MBLogSugar_H_
#define MBLogSugar_H_ #define MBLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef mbinfo #ifndef mbinfo
#define mbinfo if( mblog->debugging(Debug::INFO) ) mblog->info() #define mbinfo if( mblog->debugging(Debug::INFO) ) mblog->info()
#endif #endif
#ifndef mbwarn #ifndef mbwarn
#define mbwarn if( mblog->debugging(Debug::WARN) ) mblog->warn() #define mbwarn if( mblog->debugging(Debug::WARN) ) mblog->warn()
#endif #endif
#ifndef mbcrit #ifndef mbcrit
#define mbcrit if( mblog->debugging(Debug::CRIT) ) mblog->crit() #define mbcrit if( mblog->debugging(Debug::CRIT) ) mblog->crit()
#endif #endif
#ifndef mblog1 #ifndef mblog1
#define mblog1 if( mblog->debugging(Debug::LEVEL1) ) mblog->level1() #define mblog1 if( mblog->debugging(Debug::LEVEL1) ) mblog->level1()
#endif #endif
#ifndef mblog2 #ifndef mblog2
#define mblog2 if( mblog->debugging(Debug::LEVEL2) ) mblog->level2() #define mblog2 if( mblog->debugging(Debug::LEVEL2) ) mblog->level2()
#endif #endif
#ifndef mblog3 #ifndef mblog3
#define mblog3 if( mblog->debugging(Debug::LEVEL3) ) mblog->level3() #define mblog3 if( mblog->debugging(Debug::LEVEL3) ) mblog->level3()
#endif #endif
#ifndef mblog4 #ifndef mblog4
#define mblog4 if( mblog->debugging(Debug::LEVEL4) ) mblog->level4() #define mblog4 if( mblog->debugging(Debug::LEVEL4) ) mblog->level4()
#endif #endif
#ifndef mblog5 #ifndef mblog5
#define mblog5 if( mblog->debugging(Debug::LEVEL5) ) mblog->level5() #define mblog5 if( mblog->debugging(Debug::LEVEL5) ) mblog->level5()
#endif #endif
#ifndef mblog6 #ifndef mblog6
#define mblog6 if( mblog->debugging(Debug::LEVEL6) ) mblog->level6() #define mblog6 if( mblog->debugging(Debug::LEVEL6) ) mblog->level6()
#endif #endif
#ifndef mblog7 #ifndef mblog7
#define mblog7 if( mblog->debugging(Debug::LEVEL7) ) mblog->level7() #define mblog7 if( mblog->debugging(Debug::LEVEL7) ) mblog->level7()
#endif #endif
#ifndef mblog8 #ifndef mblog8
#define mblog8 if( mblog->debugging(Debug::LEVEL8) ) mblog->level8() #define mblog8 if( mblog->debugging(Debug::LEVEL8) ) mblog->level8()
#endif #endif
#ifndef mblog9 #ifndef mblog9
#define mblog9 if( mblog->debugging(Debug::LEVEL9) ) mblog->level9() #define mblog9 if( mblog->debugging(Debug::LEVEL9) ) mblog->level9()
#endif #endif
#ifndef mblogany #ifndef mblogany
#define mblogany mblog->any() #define mblogany mblog->any()
#endif #endif
#endif #endif
...@@ -16,7 +16,7 @@ LogAgregator::LogAgregator( Debug::type t ): ...@@ -16,7 +16,7 @@ LogAgregator::LogAgregator( Debug::type t ):
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LogAgregator::logFile( const std::string& f, bool truncate ) void LogAgregator::logFile( const std::string& f, bool truncate )
{ {
DebugStream::logFile(f,truncate); DebugStream::logFile(f, truncate);
if( !f.empty() ) if( !f.empty() )
delete rdbuf(new teebuf(&internal->fbuf, &internal->sbuf)); delete rdbuf(new teebuf(&internal->fbuf, &internal->sbuf));
......
...@@ -13,6 +13,7 @@ LogServer::~LogServer() ...@@ -13,6 +13,7 @@ LogServer::~LogServer()
{ {
if( nullsess ) if( nullsess )
nullsess->cancel(); nullsess->cancel();
{ {
// uniset_rwmutex_wrlock l(mutSList); // uniset_rwmutex_wrlock l(mutSList);
for( const auto& i : slist ) for( const auto& i : slist )
...@@ -123,6 +124,7 @@ void LogServer::work() ...@@ -123,6 +124,7 @@ void LogServer::work()
while( !cancelled && tcp->isPendingConnection(timeout) ) while( !cancelled && tcp->isPendingConnection(timeout) )
{ {
if( cancelled ) break; if( cancelled ) break;
{ {
uniset_rwmutex_wrlock l(mutSList); uniset_rwmutex_wrlock l(mutSList);
int sz = slist.size(); int sz = slist.size();
......
...@@ -58,7 +58,7 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ): ...@@ -58,7 +58,7 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ):
dblog = make_shared<DebugStream>(); dblog = make_shared<DebugStream>();
dblog->setLogName(myname); dblog->setLogName(myname);
conf->initLogStream(dblog,prefix+"-log"); conf->initLogStream(dblog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(dblog); loga->add(dblog);
...@@ -69,7 +69,8 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ): ...@@ -69,7 +69,8 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ):
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -111,9 +112,10 @@ bool DBServer::activateObject() ...@@ -111,9 +112,10 @@ bool DBServer::activateObject()
void DBServer::sysCommand( const UniSetTypes::SystemMessage* sm ) void DBServer::sysCommand( const UniSetTypes::SystemMessage* sm )
{ {
UniSetObject_LT::sysCommand(sm); UniSetObject_LT::sysCommand(sm);
if( sm->command == SystemMessage::StartUp ) if( sm->command == SystemMessage::StartUp )
{ {
if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() ) if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() )
{ {
dbinfo << myname << "(init): run log server " << logserv_host << ":" << logserv_port << endl; dbinfo << myname << "(init): run log server " << logserv_host << ":" << logserv_port << endl;
logserv->run(logserv_host, logserv_port, true); logserv->run(logserv_host, logserv_port, true);
......
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