Commit 9b14a94b authored by Pavel Vainerman's avatar Pavel Vainerman

global make style

parent 7a75750e
...@@ -751,10 +751,10 @@ int getChangedTime( const std::string& args, UInterface& ui ) ...@@ -751,10 +751,10 @@ int getChangedTime( const std::string& args, UInterface& ui )
{ {
cout << " name: (" << it.si.id << ") " << it.fname << endl; cout << " name: (" << it.si.id << ") " << it.fname << endl;
cout << " text: " << conf->oind->getTextName(it.si.id) << "\n\n"; cout << " text: " << conf->oind->getTextName(it.si.id) << "\n\n";
cout << ui.getChangedTime(it.si.id,it.si.node) << endl; cout << ui.getChangedTime(it.si.id, it.si.node) << endl;
} }
else else
cout << ui.getChangedTime(it.si.id,it.si.node); cout << ui.getChangedTime(it.si.id, it.si.node);
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
...@@ -845,14 +845,14 @@ int oinfo( const string& args, UInterface& ui ) ...@@ -845,14 +845,14 @@ int oinfo( const string& args, UInterface& ui )
auto conf = uniset_conf(); auto conf = uniset_conf();
auto sl = UniSetTypes::getSInfoList( args, conf ); auto sl = UniSetTypes::getSInfoList( args, conf );
for( auto&& it : sl ) for( auto && it : sl )
{ {
if( it.si.node == DefaultObjectId ) if( it.si.node == DefaultObjectId )
it.si.node = conf->getLocalNode(); it.si.node = conf->getLocalNode();
try try
{ {
UniSetTypes::ObjectVar o = ui.resolve(it.si.id,it.si.node); UniSetTypes::ObjectVar o = ui.resolve(it.si.id, it.si.node);
UniSetObject_i_var obj = UniSetObject_i::_narrow(o); UniSetObject_i_var obj = UniSetObject_i::_narrow(o);
if(CORBA::is_nil(obj)) if(CORBA::is_nil(obj))
......
...@@ -139,7 +139,7 @@ int main( int argc, char** argv ) ...@@ -139,7 +139,7 @@ int main( int argc, char** argv )
if( arg2 ) if( arg2 )
filter = string(arg2); filter = string(arg2);
vcmd.push_back( LogReader::Command(LogServerTypes::cmdList,0, filter) ); vcmd.push_back( LogReader::Command(LogServerTypes::cmdList, 0, filter) );
cmdlist = true; cmdlist = true;
} }
break; break;
...@@ -239,15 +239,15 @@ int main( int argc, char** argv ) ...@@ -239,15 +239,15 @@ int main( int argc, char** argv )
lr.setinTimeout(tout); lr.setinTimeout(tout);
lr.setReconnectDelay(rdelay); lr.setReconnectDelay(rdelay);
/* /*
if( cmdlist && vcmd.size() == 1 ) if( cmdlist && vcmd.size() == 1 )
{ {
cmdonly = 1; cmdonly = 1;
lr.setReadCount(1); lr.setReadCount(1);
lr.sendCommand(addr, port, vcmd, cmdonly, verb); lr.sendCommand(addr, port, vcmd, cmdonly, verb);
return 0; return 0;
} }
*/ */
if( !vcmd.empty() ) if( !vcmd.empty() )
lr.sendCommand(addr, port, vcmd, cmdonly, verb); lr.sendCommand(addr, port, vcmd, cmdonly, verb);
......
...@@ -123,7 +123,7 @@ int main( int argc, char** argv ) ...@@ -123,7 +123,7 @@ int main( int argc, char** argv )
la2->add(dlog); la2->add(dlog);
la2->add(dlog2); la2->add(dlog2);
la->add(la2); la->add(la2);
if( la->getLog("la2/dlog3") == nullptr ) if( la->getLog("la2/dlog3") == nullptr )
...@@ -139,6 +139,7 @@ int main( int argc, char** argv ) ...@@ -139,6 +139,7 @@ int main( int argc, char** argv )
auto dlog6 = la3->create("dlog6"); auto dlog6 = la3->create("dlog6");
la->add(la3); la->add(la3);
#if 0 #if 0
for( int i = 0; i < 15; i++ ) for( int i = 0; i < 15; i++ )
{ {
ostringstream s; ostringstream s;
...@@ -151,6 +152,7 @@ int main( int argc, char** argv ) ...@@ -151,6 +152,7 @@ int main( int argc, char** argv )
la->add(l); la->add(l);
} }
#endif #endif
#if 0 #if 0
......
...@@ -30,12 +30,12 @@ void TestGen::step() ...@@ -30,12 +30,12 @@ void TestGen::step()
myinfo << str(input2_s) << endl; myinfo << str(input2_s) << endl;
ulog()->info() << "ulog: " << str(input2_s) << endl; ulog()->info() << "ulog: " << str(input2_s) << endl;
int_var++; int_var++;
bool_var^=true; bool_var ^= true;
cout << vmon << endl; cout << vmon << endl;
// cout << vmon.pretty_str() << endl; // cout << vmon.pretty_str() << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void TestGen::sensorInfo( const SensorMessage* sm ) void TestGen::sensorInfo( const SensorMessage* sm )
......
...@@ -21,8 +21,8 @@ class TestGen: ...@@ -21,8 +21,8 @@ class TestGen:
virtual void sigterm( int signo ) override; virtual void sigterm( int signo ) override;
private: private:
bool bool_var = { false }; bool bool_var = { false };
int int_var = {0}; int int_var = {0};
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#endif // TestGen_H_ #endif // TestGen_H_
......
...@@ -176,6 +176,7 @@ ...@@ -176,6 +176,7 @@
<item id="3101" ip="127.0.0.1" name="LocalhostNode" textname="Локальный узел" unet_ignore="0" unet_port="2048"/> <item id="3101" ip="127.0.0.1" name="LocalhostNode" textname="Локальный узел" unet_ignore="0" unet_port="2048"/>
</specnet> </specnet>
<GroupAnalogSensors name="TestGroup" ok_c="D106_S"/>
</settings> </settings>
<ObjectsMap idfromfile="1"> <ObjectsMap idfromfile="1">
<!-- <!--
...@@ -261,6 +262,13 @@ ...@@ -261,6 +262,13 @@
<item id="100" iotype="AI" name="AI100_AS" textname="AI100" mbaddr="0x01" mbfunc="0x03" mbreg="100" mbtype="rtu" tcp="6" vtype="F2" precision="1" mbtcp="3"/> <item id="100" iotype="AI" name="AI100_AS" textname="AI100" mbaddr="0x01" mbfunc="0x03" mbreg="100" mbtype="rtu" tcp="6" vtype="F2" precision="1" mbtcp="3"/>
<item id="102" iotype="AI" name="AI102_AS" textname="AI101" mbaddr="0x01" mbfunc="0x03" mbreg="102" mbtype="rtu" tcp="6"/> <item id="102" iotype="AI" name="AI102_AS" textname="AI101" mbaddr="0x01" mbfunc="0x03" mbreg="102" mbtype="rtu" tcp="6"/>
<item id="103" iotype="AI" name="AI103_AS" textname="AI102" mbaddr="0x01" mbfunc="0x03" mbreg="99" mbtype="rtu" tcp="6"/> <item id="103" iotype="AI" name="AI103_AS" textname="AI102" mbaddr="0x01" mbfunc="0x03" mbreg="99" mbtype="rtu" tcp="6"/>
<item id="104" iotype="AI" name="AI104_AS" textname="AI104" ag="2" ag_min="100" ag_max="120"/>
<item id="105" iotype="AI" name="AI105_AS" textname="AI105" ag="1" ag_min="0" ag_max="40" ag_status="AI107_AS"/>
<item id="106" iotype="DI" name="D106_S" textname="D106"/>
<item id="107" iotype="AI" name="AI107_AS" textname="AI107" default="1"/>
<item id="108" iotype="AI" name="AI108_AS" textname="AI108" ag="1" ag_min="30" ag_max="40" ag_invert="1"/>
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI_AS"> <sensor iotype="AI" name="AI_AS">
...@@ -368,6 +376,7 @@ ...@@ -368,6 +376,7 @@
<item id="6085" name="MBSlave8"/> <item id="6085" name="MBSlave8"/>
<item id="6086" name="MBSlave9"/> <item id="6086" name="MBSlave9"/>
<item id="6087" name="MBSlave10"/> <item id="6087" name="MBSlave10"/>
<item id="6088" name="TestGroup"/>
</objects> </objects>
</ObjectsMap> </ObjectsMap>
<messages idfromfile="1" name="messages"> <messages idfromfile="1" name="messages">
......
...@@ -497,8 +497,10 @@ UniSetTypes::SimpleInfo* MBTCPMultiMaster::getInfo() ...@@ -497,8 +497,10 @@ UniSetTypes::SimpleInfo* MBTCPMultiMaster::getInfo()
inf << i->info << endl; inf << i->info << endl;
inf << "Gates: " << endl; inf << "Gates: " << endl;
for( const auto& m: mblist )
for( const auto& m : mblist )
inf << " " << m.getShortInfo() << endl; inf << " " << m.getShortInfo() << endl;
inf << endl; inf << endl;
i->info = inf.str().c_str(); i->info = inf.str().c_str();
......
...@@ -356,7 +356,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::writeOutputRegisters( ModbusRTU::WriteOutp ...@@ -356,7 +356,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::writeOutputRegisters( ModbusRTU::WriteOutp
if( query.start == 41 ) if( query.start == 41 )
{ {
VTypes::F2 f2(query.data,VTypes::F2::wsize()); VTypes::F2 f2(query.data, VTypes::F2::wsize());
f2_test_value = (float)f2; f2_test_value = (float)f2;
} }
......
...@@ -64,7 +64,10 @@ class MBTCPTestServer ...@@ -64,7 +64,10 @@ class MBTCPTestServer
friend std::ostream& operator<<(std::ostream& os, const MBTCPTestServer* m ); friend std::ostream& operator<<(std::ostream& os, const MBTCPTestServer* m );
inline float getF2TestValue(){ return f2_test_value; } inline float getF2TestValue()
{
return f2_test_value;
}
protected: protected:
// действия при завершении работы // действия при завершении работы
......
...@@ -371,8 +371,10 @@ UniSetTypes::SimpleInfo* MBTCPMultiSlave::getInfo() ...@@ -371,8 +371,10 @@ UniSetTypes::SimpleInfo* MBTCPMultiSlave::getInfo()
inf << i->info << endl; inf << i->info << endl;
inf << "Clients: " << endl; inf << "Clients: " << endl;
for( const auto& m: cmap )
for( const auto& m : cmap )
inf << " " << m.second.getShortInfo() << endl; inf << " " << m.second.getShortInfo() << endl;
inf << endl; inf << endl;
i->info = inf.str().c_str(); i->info = inf.str().c_str();
......
...@@ -1170,11 +1170,11 @@ TEST_CASE("(0x10): write register outputs or memories [F2](precision)", "[modbus ...@@ -1170,11 +1170,11 @@ TEST_CASE("(0x10): write register outputs or memories [F2](precision)", "[modbus
REQUIRE( ui->getValue(tID) == 2004 ); REQUIRE( ui->getValue(tID) == 2004 );
// read.. // read..
ui->setValue(tID,203); ui->setValue(tID, 203);
ModbusRTU::ReadOutputRetMessage ret2 = mb->read03(slaveaddr, tREG, 2); ModbusRTU::ReadOutputRetMessage ret2 = mb->read03(slaveaddr, tREG, 2);
F2 r_f2(ret2.data,F2::wsize()); F2 r_f2(ret2.data, F2::wsize());
REQUIRE( (float)r_f2 == 20.3f ); REQUIRE( (float)r_f2 == 20.3f );
} }
......
...@@ -904,13 +904,15 @@ UniSetTypes::SimpleInfo* UNetExchange::getInfo() ...@@ -904,13 +904,15 @@ UniSetTypes::SimpleInfo* UNetExchange::getInfo()
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl; inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
inf << endl; inf << endl;
inf << "Receivers: " << endl; inf << "Receivers: " << endl;
for( const auto& r: recvlist )
for( const auto& r : recvlist )
{ {
inf << "[ " << endl; inf << "[ " << endl;
inf << " chan1: " << ( r.r1 ? r.r1->getShortInfo() : "disable" ) << endl; inf << " chan1: " << ( r.r1 ? r.r1->getShortInfo() : "disable" ) << endl;
inf << " chan2: " << ( r.r2 ? r.r2->getShortInfo() : "disable" ) << endl; inf << " chan2: " << ( r.r2 ? r.r2->getShortInfo() : "disable" ) << endl;
inf << "]" << endl; inf << "]" << endl;
} }
inf << endl; inf << endl;
inf << "Senders: " << endl; inf << "Senders: " << endl;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
/* /*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE. DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST. ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ. НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2015-06-08+03:00 // generate timestamp: 2015-06-08+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -31,11 +31,11 @@ class UObject_SK: ...@@ -31,11 +31,11 @@ class UObject_SK:
public LT_Object public LT_Object
{ {
public: 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(); UObject_SK();
virtual ~UObject_SK(); virtual ~UObject_SK();
long getValue( UniSetTypes::ObjectId sid ); long getValue( UniSetTypes::ObjectId sid );
void setValue( UniSetTypes::ObjectId sid, long value ); void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() ); void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
...@@ -45,115 +45,127 @@ class UObject_SK: ...@@ -45,115 +45,127 @@ class UObject_SK:
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true ); virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
inline std::shared_ptr<DebugStream> log(){ return mylog; } inline std::shared_ptr<DebugStream> log()
inline std::shared_ptr<LogAgregator> logAgregator(){ return loga; } {
return mylog;
}
inline std::shared_ptr<LogAgregator> logAgregator()
{
return loga;
}
void init_dlog( std::shared_ptr<DebugStream> d ); void init_dlog( std::shared_ptr<DebugStream> d );
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef myinfo #ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info() #define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif #endif
#ifndef mywarn #ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn() #define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif #endif
#ifndef mycrit #ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit() #define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif #endif
#ifndef mylog1 #ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1() #define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif #endif
#ifndef mylog2 #ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2() #define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif #endif
#ifndef mylog3 #ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3() #define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif #endif
#ifndef mylog4 #ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4() #define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif #endif
#ifndef mylog5 #ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5() #define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif #endif
#ifndef mylog6 #ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6() #define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif #endif
#ifndef mylog7 #ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7() #define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif #endif
#ifndef mylog8 #ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8() #define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif #endif
#ifndef mylog9 #ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9() #define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif #endif
#ifndef mylogany #ifndef mylogany
#define mylogany log()->any() #define mylogany log()->any()
#endif #endif
#ifndef vmonit #ifndef vmonit
#define vmonit( var ) vmon.add( #var, var ) #define vmonit( var ) vmon.add( #var, var )
#endif #endif
// Вспомогательные функции для удобства логирования // Вспомогательные функции для удобства логирования
// ------------------------------------------------------------ // ------------------------------------------------------------
/*! вывод в строку значение всех входов и выходов в формате /*! вывод в строку значение всех входов и выходов в формате
ObjectName: ObjectName:
in_xxx = val in_xxx = val
in_xxx2 = val in_xxx2 = val
out_zzz = val out_zzz = val
... ...
*/ */
std::string dumpIO(); std::string dumpIO();
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName) /*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/ */
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true ); std::string str( UniSetTypes::ObjectId id, bool showLinkName = true );
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val /*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/ */
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true ); std::string strval( UniSetTypes::ObjectId id, bool showLinkName = true );
/*! Вывод состояния внутренних переменных */ /*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); } inline std::string dumpVars()
// ------------------------------------------------------------ {
return std::move(vmon.pretty_str());
}
// ------------------------------------------------------------
// Используемые идентификаторы // Используемые идентификаторы
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
// Текущее значение // Текущее значение
// --- public variables --- // --- public variables ---
// --- end of public variables --- // --- end of public variables ---
protected: protected:
// --- protected variables --- // --- protected variables ---
// ---- end of protected variables ---- // ---- end of protected variables ----
virtual void callback() override; virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override; virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){}; virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{} virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override {}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{} virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override {}
virtual void sigterm( int signo ) override; virtual void sigterm( int signo ) override;
virtual bool activateObject() override; virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */ virtual std::string getMonitInfo()
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual void testMode( bool state ); virtual void testMode( bool state );
void updatePreviousValues(); void updatePreviousValues();
void checkSensors(); void checkSensors();
...@@ -171,7 +183,7 @@ class UObject_SK: ...@@ -171,7 +183,7 @@ class UObject_SK:
int resetMsgTime; int resetMsgTime;
// Выполнение очередного шага программы // Выполнение очередного шага программы
virtual void step(){} virtual void step() {}
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
...@@ -183,22 +195,28 @@ class UObject_SK: ...@@ -183,22 +195,28 @@ class UObject_SK:
PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */ PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */
UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */ UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */
int maxHeartBeat; /*! < сохраняемое значение */ int maxHeartBeat; /*! < сохраняемое значение */
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */ /*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); } int getIntProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getIntProp(confnode, name);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */ /*! получить текстовое свойство из конф. файла по привязанной 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);
}
int smReadyTimeout; /*!< время ожидания готовности SM */ int smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated; std::atomic_bool activated;
int activateTimeout; /*!< время ожидания готовности UniSetObject к работе */ int activateTimeout; /*!< время ожидания готовности UniSetObject к работе */
PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */ PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int askPause; /*!< пауза между неудачными попытками заказать датчики */ int askPause; /*!< пауза между неудачными попытками заказать датчики */
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
bool forceOut; /*!< флаг принудительного обноления "выходов" */ bool forceOut; /*!< флаг принудительного обноления "выходов" */
std::shared_ptr<LogAgregator> loga; std::shared_ptr<LogAgregator> loga;
std::shared_ptr<DebugStream> mylog; std::shared_ptr<DebugStream> mylog;
std::shared_ptr<LogServer> logserv; std::shared_ptr<LogServer> logserv;
...@@ -207,20 +225,20 @@ class UObject_SK: ...@@ -207,20 +225,20 @@ class UObject_SK:
// snap // snap
bool no_snap = {false}; bool no_snap = {false};
VMonitor vmon; VMonitor vmon;
private: private:
// --- private variables --- // --- private variables ---
// --- end of private variables --- // --- end of private variables ---
// предыдущее значение (для работы UpdateValue()) // предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода) bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
}; };
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
/* /*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE. DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST. ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ. НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2015-06-08+03:00 // generate timestamp: 2015-06-08+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -32,26 +32,26 @@ using namespace UniSetTypes; ...@@ -32,26 +32,26 @@ using namespace UniSetTypes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UObject_SK::UObject_SK(): UObject_SK::UObject_SK():
// Инициализация идентификаторов (имена берутся из конф. файла) // Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла) // Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables // variables
active(false), active(false),
idHeartBeat(DefaultObjectId), idHeartBeat(DefaultObjectId),
maxHeartBeat(10), maxHeartBeat(10),
confnode(0), confnode(0),
smReadyTimeout(0), smReadyTimeout(0),
activated(false), activated(false),
askPause(2000), askPause(2000),
forceOut(false), forceOut(false),
end_private(false) end_private(false)
{ {
ucrit << "UObject: init failed!!!!!!!!!!!!!!!" << endl; ucrit << "UObject: init failed!!!!!!!!!!!!!!!" << endl;
throw Exception( string(myname+": init failed!!!") ); throw Exception( string(myname + ": init failed!!!") );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ( val, confval, default val ) // ( val, confval, default val )
...@@ -59,41 +59,42 @@ static const std::string init3_str( const std::string& s1, const std::string& s2 ...@@ -59,41 +59,42 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{ {
if( !s1.empty() ) if( !s1.empty() )
return s1; return s1;
if( !s2.empty() ) if( !s2.empty() )
return s2; return s2;
return s3; return s3;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argprefix ): UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argprefix ):
UniSetObject(id), UniSetObject(id),
argprefix( (_argprefix.empty() ? myname+"-" : _argprefix) ), argprefix( (_argprefix.empty() ? myname + "-" : _argprefix) ),
// Инициализация идентификаторов (имена берутся из конф. файла) // Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла) // Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables // variables
sleep_msec(150), sleep_msec(150),
active(true), active(true),
idHeartBeat(DefaultObjectId), idHeartBeat(DefaultObjectId),
maxHeartBeat(10), maxHeartBeat(10),
confnode(cnode), confnode(cnode),
smReadyTimeout(0), smReadyTimeout(0),
activated(false), activated(false),
askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)), askPause(uniset_conf()->getPIntProp(cnode, "askPause", 2000)),
forceOut(false), forceOut(false),
end_private(false) end_private(false)
{ {
auto conf = uniset_conf(); 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();
} }
...@@ -104,15 +105,15 @@ end_private(false) ...@@ -104,15 +105,15 @@ end_private(false)
throw SystemError( err.str() ); throw SystemError( err.str() );
} }
mylog = make_shared<DebugStream>(); mylog = make_shared<DebugStream>();
mylog->setLogName(myname); mylog->setLogName(myname);
{ {
ostringstream s; ostringstream s;
s << argprefix << "log"; 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(mylog);
loga->add(ulog()); loga->add(ulog());
...@@ -129,13 +130,15 @@ end_private(false) ...@@ -129,13 +130,15 @@ end_private(false)
logserv_host = conf->getArg2Param("--" + argprefix + "logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + argprefix + "logserver-host", it.getProp("logserverHost"), "localhost");
logserv_port = conf->getArgPInt("--" + argprefix + "logserver-port", it.getProp("logserverPort"), getId()); logserv_port = conf->getArgPInt("--" + argprefix + "logserver-port", it.getProp("logserverPort"), getId());
} }
forceOut = conf->getArgPInt("--" + argprefix + "force-out",it.getProp("forceOut"),false);
string heart = conf->getArgParam("--" + argprefix + "heartbeat-id",it.getProp("heartbeat_id")); forceOut = conf->getArgPInt("--" + argprefix + "force-out", it.getProp("forceOut"), false);
string heart = conf->getArgParam("--" + argprefix + "heartbeat-id", it.getProp("heartbeat_id"));
if( !heart.empty() ) if( !heart.empty() )
{ {
idHeartBeat = conf->getSensorID(heart); idHeartBeat = conf->getSensorID(heart);
if( idHeartBeat == DefaultObjectId ) if( idHeartBeat == DefaultObjectId )
{ {
ostringstream err; ostringstream err;
...@@ -143,35 +146,38 @@ end_private(false) ...@@ -143,35 +146,38 @@ end_private(false)
throw SystemError(err.str()); throw SystemError(err.str());
} }
int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time",it.getProp("heartbeatTime"),conf->getHeartBeatTime()); int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time", it.getProp("heartbeatTime"), conf->getHeartBeatTime());
if( heartbeatTime>0 )
if( heartbeatTime > 0 )
ptHeartBeat.setTiming(heartbeatTime); ptHeartBeat.setTiming(heartbeatTime);
else else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime); 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);
} }
// Инициализация значений // Инициализация значений
sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec","150", 150); sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec", "150", 150);
string s_resetTime(""); string s_resetTime("");
if( s_resetTime.empty() ) if( s_resetTime.empty() )
s_resetTime = "500"; 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); ptResetMsg.setTiming(resetMsgTime);
smReadyTimeout = conf->getArgInt("--" + argprefix + "sm-ready-timeout",""); smReadyTimeout = conf->getArgInt("--" + argprefix + "sm-ready-timeout", "");
if( smReadyTimeout == 0 ) if( smReadyTimeout == 0 )
smReadyTimeout = 60000; smReadyTimeout = 60000;
else if( smReadyTimeout < 0 ) else if( smReadyTimeout < 0 )
smReadyTimeout = UniSetTimer::WaitUpTime; smReadyTimeout = UniSetTimer::WaitUpTime;
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"), ""));
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 20000); activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 20000);
...@@ -179,7 +185,7 @@ end_private(false) ...@@ -179,7 +185,7 @@ end_private(false)
ptStartUpTimeout.setTiming(msec); ptStartUpTimeout.setTiming(msec);
// ===================== <variables> ===================== // ===================== <variables> =====================
// ===================== end of <variables> ===================== // ===================== end of <variables> =====================
vmonit(sleep_msec); vmonit(sleep_msec);
...@@ -201,17 +207,17 @@ UObject_SK::~UObject_SK() ...@@ -201,17 +207,17 @@ UObject_SK::~UObject_SK()
void UObject_SK::updateValues() void UObject_SK::updateValues()
{ {
// Опрашиваем все входы... // Опрашиваем все входы...
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::updatePreviousValues() void UObject_SK::updatePreviousValues()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::checkSensors() void UObject_SK::checkSensors()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state ) bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state )
...@@ -219,24 +225,24 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state ) ...@@ -219,24 +225,24 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state )
if( _code == UniSetTypes::DefaultObjectId ) if( _code == UniSetTypes::DefaultObjectId )
{ {
mycrit << myname << "(setMsg): попытка послать сообщение с DefaultObjectId" << endl; mycrit << myname << "(setMsg): попытка послать сообщение с DefaultObjectId" << endl;
return false; return false;
} }
mylog8 << myname << "(setMsg): " << ( _state ? "SEND " : "RESET " ) << endl; mylog8 << myname << "(setMsg): " << ( _state ? "SEND " : "RESET " ) << endl;
// взводим автоматический сброс
if( _state )
ptResetMsg.reset();
// взводим автоматический сброс
if( _state )
ptResetMsg.reset();
mylog8 << myname << "(setMsg): not found MessgeOID?!!" << endl;
mylog8 << myname << "(setMsg): not found MessgeOID?!!" << endl;
return false; return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::resetMsg() void UObject_SK::resetMsg()
{ {
// reset messages // reset messages
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -246,14 +252,14 @@ void UObject_SK::testMode( bool _state ) ...@@ -246,14 +252,14 @@ void UObject_SK::testMode( bool _state )
return; return;
// отключаем все выходы // отключаем все выходы
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string UObject_SK::dumpIO() std::string UObject_SK::dumpIO()
{ {
ostringstream s; ostringstream s;
s << myname << ": " << endl; s << myname << ": " << endl;
return s.str(); return s.str();
} }
...@@ -261,14 +267,14 @@ std::string UObject_SK::dumpIO() ...@@ -261,14 +267,14 @@ std::string UObject_SK::dumpIO()
std::string UObject_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) std::string UObject_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
{ {
ostringstream s; ostringstream s;
return ""; return "";
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string UObject_SK::strval( UniSetTypes::ObjectId id, bool showLinkName ) std::string UObject_SK::strval( UniSetTypes::ObjectId id, bool showLinkName )
{ {
ostringstream s; ostringstream s;
return ""; return "";
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -289,19 +295,19 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg ) ...@@ -289,19 +295,19 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
{ {
case Message::SensorInfo: case Message::SensorInfo:
preSensorInfo( reinterpret_cast<SensorMessage*>(_msg) ); preSensorInfo( reinterpret_cast<SensorMessage*>(_msg) );
break; break;
case Message::Timer: case Message::Timer:
preTimerInfo( reinterpret_cast<TimerMessage*>(_msg) ); preTimerInfo( reinterpret_cast<TimerMessage*>(_msg) );
break; break;
case Message::SysCommand: case Message::SysCommand:
preSysCommand( reinterpret_cast<SystemMessage*>(_msg) ); preSysCommand( reinterpret_cast<SystemMessage*>(_msg) );
break; break;
default: default:
break; break;
} }
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
...@@ -315,11 +321,13 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -315,11 +321,13 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
{ {
case SystemMessage::WatchDog: case SystemMessage::WatchDog:
uinfo << myname << "(preSysCommand): WatchDog" << endl; uinfo << myname << "(preSysCommand): WatchDog" << endl;
if( !active || !ptStartUpTimeout.checkTime() ) if( !active || !ptStartUpTimeout.checkTime() )
{ {
uwarn << myname << "(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl; uwarn << myname << "(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl;
break; break;
} }
case SystemMessage::StartUp: case SystemMessage::StartUp:
{ {
if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() ) if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() )
...@@ -339,21 +347,22 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -339,21 +347,22 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
active = true; active = true;
break; break;
} }
case SystemMessage::FoldUp: case SystemMessage::FoldUp:
case SystemMessage::Finish: case SystemMessage::Finish:
preAskSensors(UniversalIO::UIODontNotify); preAskSensors(UniversalIO::UIODontNotify);
askSensors(UniversalIO::UIODontNotify); askSensors(UniversalIO::UIODontNotify);
break; break;
case SystemMessage::LogRotate: case SystemMessage::LogRotate:
{ {
// переоткрываем логи // переоткрываем логи
mylogany << myname << "(preSysCommand): logRotate" << endl; mylogany << myname << "(preSysCommand): logRotate" << endl;
string fname( log()->getLogFile() ); string fname( log()->getLogFile() );
if( !fname.empty() ) if( !fname.empty() )
{ {
mylog->logFile(fname.c_str(),true); mylog->logFile(fname.c_str(), true);
mylogany << myname << "(preSysCommand): ***************** mylog LOG ROTATE *****************" << endl; mylogany << myname << "(preSysCommand): ***************** mylog LOG ROTATE *****************" << endl;
} }
} }
...@@ -362,24 +371,24 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -362,24 +371,24 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
default: default:
break; break;
} }
sysCommand(_sm); sysCommand(_sm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* UObject_SK::getInfo() UniSetTypes::SimpleInfo* UObject_SK::getInfo()
{ {
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(); UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo();
ostringstream inf; ostringstream inf;
inf << i->info << endl; inf << i->info << endl;
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl; inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
inf << dumpIO() << endl; inf << dumpIO() << endl;
inf << vmon.pretty_str() << endl; inf << vmon.pretty_str() << endl;
inf << getMonitInfo() << endl; inf << getMonitInfo() << endl;
i->info = inf.str().c_str(); i->info = inf.str().c_str();
return i._retn(); return i._retn();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -392,7 +401,7 @@ void UObject_SK::sigterm( int signo ) ...@@ -392,7 +401,7 @@ void UObject_SK::sigterm( int signo )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UObject_SK::activateObject() bool UObject_SK::activateObject()
{ {
// блокирование обработки Startup // блокирование обработки Startup
// пока не пройдёт инициализация датчиков // пока не пройдёт инициализация датчиков
// см. preSysCommand() // см. preSysCommand()
{ {
...@@ -418,24 +427,24 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID ) ...@@ -418,24 +427,24 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
if( _testID == DefaultObjectId ) if( _testID == DefaultObjectId )
return; return;
uinfo << myname << "(waitSM): waiting SM ready " uinfo << myname << "(waitSM): waiting SM ready "
<< wait_msec << " msec" << wait_msec << " msec"
<< " testID=" << _testID << endl; << " testID=" << _testID << endl;
if( !ui->waitReady(_testID,wait_msec) ) if( !ui->waitReady(_testID, wait_msec) )
{ {
ostringstream err; ostringstream err;
err << myname err << myname
<< "(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение " << "(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<< wait_msec << " мсек"; << wait_msec << " мсек";
ucrit << err.str() << endl; ucrit << err.str() << endl;
// terminate(); // terminate();
// abort(); // abort();
raise(SIGTERM); raise(SIGTERM);
terminate(); terminate();
// throw SystemError(err.str()); // throw SystemError(err.str());
} }
...@@ -447,37 +456,39 @@ void UObject_SK::callback() ...@@ -447,37 +456,39 @@ void UObject_SK::callback()
{ {
if( !active ) if( !active )
return; return;
try try
{ {
// проверка таймеров // проверка таймеров
checkTimers(this); 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(); resetMsg();
} }
// обработка сообщений (таймеров и т.п.) // обработка сообщений (таймеров и т.п.)
for( unsigned int i=0; i<20; i++ ) for( unsigned int i = 0; i < 20; i++ )
{ {
if( !receiveMessage(msg) ) if( !receiveMessage(msg) )
break; break;
processingMessage(&msg); processingMessage(&msg);
updateOutputs(forceOut); updateOutputs(forceOut);
// updatePreviousValues(); // updatePreviousValues();
} }
// Выполнение шага программы // Выполнение шага программы
step(); step();
// "сердцебиение" // "сердцебиение"
if( idHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() ) if( idHeartBeat != DefaultObjectId && ptHeartBeat.checkTime() )
{ {
try try
{ {
ui->setValue(idHeartBeat,maxHeartBeat); ui->setValue(idHeartBeat, maxHeartBeat);
ptHeartBeat.reset(); ptHeartBeat.reset();
} }
catch( const Exception& ex ) catch( const Exception& ex )
...@@ -492,46 +503,46 @@ void UObject_SK::callback() ...@@ -492,46 +503,46 @@ void UObject_SK::callback()
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
ucrit << myname << "(execute): " << ex << endl; ucrit << myname << "(execute): " << ex << endl;
} }
catch( const CORBA::SystemException& ex ) catch( const CORBA::SystemException& ex )
{ {
ucrit << myname << "(execute): СORBA::SystemException: " ucrit << myname << "(execute): СORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
}
catch( const std::exception& ex )
{
ucrit << myname << "(execute): catch " << ex.what() << endl;
} }
catch( const std::exception&ex )
{
ucrit << myname << "(execute): catch " << ex.what() << endl;
}
if( !active ) if( !active )
return; return;
msleep( sleep_msec ); msleep( sleep_msec );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val ) void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{ {
ui->setValue(_sid,_val);
ui->setValue(_sid, _val);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::updateOutputs( bool _force ) void UObject_SK::updateOutputs( bool _force )
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm ) void UObject_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm )
{ {
sensorInfo(_sm); sensorInfo(_sm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::askSensor( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node ) 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 ) long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
...@@ -544,7 +555,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid ) ...@@ -544,7 +555,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
ucrit << myname << "(getValue): " << ex << endl; ucrit << myname << "(getValue): " << ex << endl;
throw; throw;
} }
} }
...@@ -553,33 +564,35 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid ) ...@@ -553,33 +564,35 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd ) void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
{ {
PassiveTimer ptAct(activateTimeout); PassiveTimer ptAct(activateTimeout);
while( !activated && !ptAct.checkTime() ) while( !activated && !ptAct.checkTime() )
{ {
cout << myname << "(preAskSensors): wait activate..." << endl; cout << myname << "(preAskSensors): wait activate..." << endl;
msleep(300); msleep(300);
if( activated ) if( activated )
break; break;
} }
if( !activated ) if( !activated )
ucrit << myname ucrit << myname
<< "(preAskSensors): ************* don`t activated?! ************" << endl; << "(preAskSensors): ************* don`t activated?! ************" << endl;
for( ;; ) for( ;; )
{ {
try try
{ {
return; return;
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
ucrit << myname << "(preAskSensors): " << ex << endl; ucrit << myname << "(preAskSensors): " << ex << endl;
}
catch( const std::exception& ex )
{
ucrit << myname << "(execute): catch " << ex.what() << endl;
} }
catch( const std::exception&ex )
{
ucrit << myname << "(execute): catch " << ex.what() << endl;
}
msleep(askPause); msleep(askPause);
} }
......
...@@ -40,7 +40,7 @@ int main(int argc, const char** argv) ...@@ -40,7 +40,7 @@ int main(int argc, const char** argv)
cout << "..create " << s.str() << endl; cout << "..create " << s.str() << endl;
auto tp = make_shared<TestProc>( conf->getObjectID(s.str())); auto tp = make_shared<TestProc>( conf->getObjectID(s.str()));
// tp->init_dlog(dlog()); // tp->init_dlog(dlog());
act->add(tp); act->add(tp);
} }
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
class VMonitor class VMonitor
{ {
public: public:
VMonitor(){} VMonitor() {}
friend std::ostream& operator<<(std::ostream& os, VMonitor& m ); friend std::ostream& operator<<(std::ostream& os, VMonitor& m );
...@@ -125,13 +125,19 @@ class VMonitor ...@@ -125,13 +125,19 @@ class VMonitor
VMON_DEF_FUNC(bool); VMON_DEF_FUNC(bool);
VMON_DEF_FUNC(float); VMON_DEF_FUNC(float);
VMON_DEF_FUNC(double); VMON_DEF_FUNC(double);
// VMON_DEF_FUNC(UniSetTypes::ObjectId); // <--- long // VMON_DEF_FUNC(UniSetTypes::ObjectId); // <--- long
void add( const std::string& name, const std::string& v ); void add( const std::string& name, const std::string& v );
const std::string pretty_str( const std::string& name, const std::string* v ); const std::string pretty_str( const std::string& name, const std::string* v );
inline int getNameWidth(){ return nameWidth; } inline int getNameWidth()
inline void setNameWidth( int w ){ nameWidth = w; } {
return nameWidth;
}
inline void setNameWidth( int w )
{
nameWidth = w;
}
protected: protected:
...@@ -145,7 +151,7 @@ class VMonitor ...@@ -145,7 +151,7 @@ class VMonitor
VMON_DEF_MAP(float); VMON_DEF_MAP(float);
VMON_DEF_MAP(double); VMON_DEF_MAP(double);
// VMON_DEF_MAP3(UniSetTypes::ObjectId,ObjectId); // <-- long // VMON_DEF_MAP3(UniSetTypes::ObjectId,ObjectId); // <-- long
VMON_DEF_MAP3(std::string,string); VMON_DEF_MAP3(std::string, string);
int nameWidth = { 30 }; int nameWidth = { 30 };
}; };
......
...@@ -38,8 +38,14 @@ class ModbusTCPMaster: ...@@ -38,8 +38,14 @@ class ModbusTCPMaster:
cleanInputStream(); cleanInputStream();
} }
inline std::string getAddress(){ return iaddr; } inline std::string getAddress()
inline int getPort(){ return port; } {
return iaddr;
}
inline int getPort()
{
return port;
}
protected: protected:
......
...@@ -55,7 +55,7 @@ std::shared_ptr<DebugStream> LogAgregator::create( const std::string& logname ) ...@@ -55,7 +55,7 @@ std::shared_ptr<DebugStream> LogAgregator::create( const std::string& logname )
auto l = std::make_shared<DebugStream>(); auto l = std::make_shared<DebugStream>();
l->setLogName(logname); l->setLogName(logname);
auto conn = l->signal_stream_event().connect( sigc::mem_fun(this, &LogAgregator::logOnEvent) ); auto conn = l->signal_stream_event().connect( sigc::mem_fun(this, &LogAgregator::logOnEvent) );
conmap.emplace(l,conn); conmap.emplace(l, conn);
lmap[logname] = l; lmap[logname] = l;
return l; return l;
} }
...@@ -83,13 +83,15 @@ void LogAgregator::addLogAgregator( std::shared_ptr<LogAgregator> la, const std: ...@@ -83,13 +83,15 @@ void LogAgregator::addLogAgregator( std::shared_ptr<LogAgregator> la, const std:
return; return;
auto lst = la->getLogList(); auto lst = la->getLogList();
for( auto&& l: lst )
for( auto && l : lst )
{ {
auto c = conmap.find(l.log); auto c = conmap.find(l.log);
if( c == conmap.end() ) if( c == conmap.end() )
{ {
auto conn = l.log->signal_stream_event().connect( sigc::mem_fun(this, &LogAgregator::logOnEvent) ); auto conn = l.log->signal_stream_event().connect( sigc::mem_fun(this, &LogAgregator::logOnEvent) );
conmap.emplace(l.log,conn); conmap.emplace(l.log, conn);
} }
} }
...@@ -106,10 +108,11 @@ void LogAgregator::addLog( std::shared_ptr<DebugStream> l, const std::string& ln ...@@ -106,10 +108,11 @@ void LogAgregator::addLog( std::shared_ptr<DebugStream> l, const std::string& ln
if( connect ) if( connect )
{ {
auto c = conmap.find(l); auto c = conmap.find(l);
if( c == conmap.end() ) if( c == conmap.end() )
{ {
auto conn = l->signal_stream_event().connect( sigc::mem_fun(this, &LogAgregator::logOnEvent) ); auto conn = l->signal_stream_event().connect( sigc::mem_fun(this, &LogAgregator::logOnEvent) );
conmap.emplace(l,conn); conmap.emplace(l, conn);
} }
} }
...@@ -157,7 +160,7 @@ std::ostream& LogAgregator::printLogList( std::ostream& os, const std::string& r ...@@ -157,7 +160,7 @@ std::ostream& LogAgregator::printLogList( std::ostream& os, const std::string& r
else else
lst = getLogList(regexp_str); lst = getLogList(regexp_str);
return printLogList(os,lst); return printLogList(os, lst);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::ostream& LogAgregator::printLogList( std::ostream& os, std::list<iLog>& lst ) std::ostream& LogAgregator::printLogList( std::ostream& os, std::list<iLog>& lst )
...@@ -233,13 +236,14 @@ std::vector<std::string> LogAgregator::splitFirst( const std::string& lname, con ...@@ -233,13 +236,14 @@ std::vector<std::string> LogAgregator::splitFirst( const std::string& lname, con
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool LogAgregator::logExist( std::shared_ptr<DebugStream>& log ) bool LogAgregator::logExist( std::shared_ptr<DebugStream>& log )
{ {
for( const auto& l: lmap ) for( const auto& l : lmap )
{ {
if( l.second == log ) if( l.second == log )
return true; return true;
bool res = false; bool res = false;
auto ag = dynamic_pointer_cast<LogAgregator>(l.second); auto ag = dynamic_pointer_cast<LogAgregator>(l.second);
if( ag ) if( ag )
res = ag->logExist(log); res = ag->logExist(log);
......
...@@ -180,7 +180,7 @@ void LogReader::sendCommand( const std::string& _addr, ost::tpport_t _port, std: ...@@ -180,7 +180,7 @@ void LogReader::sendCommand( const std::string& _addr, ost::tpport_t _port, std:
if( c.cmd == LogServerTypes::cmdList ) if( c.cmd == LogServerTypes::cmdList )
{ {
listfilter = c.logfilter; listfilter = c.logfilter;
n=0; n = 0;
continue; continue;
} }
...@@ -218,6 +218,7 @@ void LogReader::sendCommand( const std::string& _addr, ost::tpport_t _port, std: ...@@ -218,6 +218,7 @@ void LogReader::sendCommand( const std::string& _addr, ost::tpport_t _port, std:
while( a > 0 && tcp->isPending(ost::Socket::pendingInput, reply_timeout) ) while( a > 0 && tcp->isPending(ost::Socket::pendingInput, reply_timeout) )
{ {
int n = tcp->peek( buf, sizeof(buf) - 1 ); int n = tcp->peek( buf, sizeof(buf) - 1 );
if( n > 0 ) if( n > 0 )
{ {
tcp->read(buf, n); tcp->read(buf, n);
...@@ -280,7 +281,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ ...@@ -280,7 +281,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
{ {
rlog.warn() << "(LogReader): **** connection timeout.." << endl; rlog.warn() << "(LogReader): **** connection timeout.." << endl;
if( rcount>0 && readcount > 0 ) if( rcount > 0 && readcount > 0 )
rcount--; rcount--;
if( rcount == 0 ) if( rcount == 0 )
...@@ -299,6 +300,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ ...@@ -299,6 +300,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
while( tcp->isPending(ost::Socket::pendingInput, inTimeout) ) while( tcp->isPending(ost::Socket::pendingInput, inTimeout) )
{ {
int n = tcp->peek( buf, sizeof(buf) - 1 ); int n = tcp->peek( buf, sizeof(buf) - 1 );
if( n > 0 ) if( n > 0 )
{ {
tcp->read(buf, n); tcp->read(buf, n);
...@@ -307,18 +309,19 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ ...@@ -307,18 +309,19 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
log << buf; log << buf;
} }
if( rcount>0 && readcount > 0 ) if( rcount > 0 && readcount > 0 )
rcount--; rcount--;
if( readcount>0 && rcount==0 ) if( readcount > 0 && rcount == 0 )
break; break;
} }
if( rcount>0 && readcount > 0 ) if( rcount > 0 && readcount > 0 )
rcount--; rcount--;
if( rcount != 0 ) if( rcount != 0 )
rlog.warn() << "(LogReader): ...connection timeout..." << endl; rlog.warn() << "(LogReader): ...connection timeout..." << endl;
disconnect(); disconnect();
} }
catch( const ost::SockException& e ) catch( const ost::SockException& e )
...@@ -330,7 +333,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ ...@@ -330,7 +333,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
cerr << "(LogReader): " << ex.what() << endl; cerr << "(LogReader): " << ex.what() << endl;
} }
if( rcount==0 && readcount > 0 ) if( rcount == 0 && readcount > 0 )
break; break;
} }
......
...@@ -119,14 +119,14 @@ long UniSetTypes::setoutregion(long ret, long calMin, long calMax) ...@@ -119,14 +119,14 @@ long UniSetTypes::setoutregion(long ret, long calMin, long calMax)
UniSetTypes::IDList::IDList( std::vector<std::string>&& svec ): UniSetTypes::IDList::IDList( std::vector<std::string>&& svec ):
UniSetTypes::IDList::IDList() UniSetTypes::IDList::IDList()
{ {
for( const auto& s: svec ) for( const auto& s : svec )
add( uni_atoi(s) ); add( uni_atoi(s) );
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
UniSetTypes::IDList::IDList( std::vector<std::string>& svec ): UniSetTypes::IDList::IDList( std::vector<std::string>& svec ):
UniSetTypes::IDList::IDList() UniSetTypes::IDList::IDList()
{ {
for( const auto& s: svec ) for( const auto& s : svec )
add( uni_atoi(s) ); add( uni_atoi(s) );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -209,7 +209,7 @@ bool UniSetTypes::file_exist( const std::string& filename ) ...@@ -209,7 +209,7 @@ bool UniSetTypes::file_exist( const std::string& filename )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniSetTypes::IDList UniSetTypes::explode( const string& str, char sep ) UniSetTypes::IDList UniSetTypes::explode( const string& str, char sep )
{ {
UniSetTypes::IDList l( explode_str(str,sep) ); UniSetTypes::IDList l( explode_str(str, sep) );
return std::move(l); return std::move(l);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -230,9 +230,11 @@ std::vector<std::string> UniSetTypes::explode_str( const string& str, char sep ) ...@@ -230,9 +230,11 @@ std::vector<std::string> UniSetTypes::explode_str( const string& str, char sep )
if( pos == string::npos ) if( pos == string::npos )
{ {
string s(str.substr(prev, sz-prev)); string s(str.substr(prev, sz - prev));
if( !s.empty() ) if( !s.empty() )
v.emplace_back(s); v.emplace_back(s);
break; break;
} }
......
...@@ -160,6 +160,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid, ...@@ -160,6 +160,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
if( cmd == UniversalIO::UIONotify || (cmd == UIONotifyFirstNotNull && li->second->value) ) if( cmd == UniversalIO::UIONotify || (cmd == UIONotifyFirstNotNull && li->second->value) )
{ {
SensorMessage smsg(li->second->makeSensorMessage()); SensorMessage smsg(li->second->makeSensorMessage());
try try
{ {
ui->send(ci.id, std::move(smsg.transport_msg()), ci.node); ui->send(ci.id, std::move(smsg.transport_msg()), ci.node);
......
...@@ -5,97 +5,97 @@ ...@@ -5,97 +5,97 @@
#include "VMonitor.h" #include "VMonitor.h"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_ADD(T) void VMonitor::add( const std::string& name, const T& v ) \ #define VMON_IMPL_ADD(T) void VMonitor::add( const std::string& name, const T& v ) \
{\ {\
m_##T.emplace(&v,name); \ m_##T.emplace(&v,name); \
} \ } \
\ \
const std::string VMonitor::pretty_str( const std::string& name, const T* v ) \ const std::string VMonitor::pretty_str( const std::string& name, const T* v ) \
{ \ { \
std::ostringstream s; \ std::ostringstream s; \
s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \ s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \
return std::move(s.str()); \ return std::move(s.str()); \
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_ADD2(T) \ #define VMON_IMPL_ADD2(T) \
void VMonitor::add( const std::string& name, const T& v ) \ void VMonitor::add( const std::string& name, const T& v ) \
{\ {\
m_##T.emplace(&v,name); \ m_##T.emplace(&v,name); \
} \ } \
void VMonitor::add( const std::string& name, const unsigned T& v ) \ void VMonitor::add( const std::string& name, const unsigned T& v ) \
{\ {\
m_unsigned_##T.emplace(&v,name); \ m_unsigned_##T.emplace(&v,name); \
} \ } \
const std::string VMonitor::pretty_str( const std::string& name, const T* v ) \ const std::string VMonitor::pretty_str( const std::string& name, const T* v ) \
{ \ { \
std::ostringstream s; \ std::ostringstream s; \
s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \ s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \
return std::move(s.str()); \ return std::move(s.str()); \
} \ } \
const std::string VMonitor::pretty_str( const std::string& name, const unsigned T* v ) \ const std::string VMonitor::pretty_str( const std::string& name, const unsigned T* v ) \
{ \ { \
std::ostringstream s; \ std::ostringstream s; \
s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \ s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \
return std::move(s.str()); \ return std::move(s.str()); \
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_ADD3(T,M) void VMonitor::add( const std::string& name, const T& v ) \ #define VMON_IMPL_ADD3(T,M) void VMonitor::add( const std::string& name, const T& v ) \
{\ {\
m_##M.emplace(&v,name); \ m_##M.emplace(&v,name); \
} \ } \
const std::string VMonitor::pretty_str( const std::string& name, const T* v ) \ const std::string VMonitor::pretty_str( const std::string& name, const T* v ) \
{ \ { \
std::ostringstream s; \ std::ostringstream s; \
s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \ s << std::right << std::setw(nameWidth) << name << std::left << " = " << std::right << std::setw(6) << *(v); \
return std::move(s.str()); \ return std::move(s.str()); \
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRN(M,T) \ #define VMON_IMPL_PRN(M,T) \
{\ {\
for( const auto& e: M.m_##T ) \ for( const auto& e: M.m_##T ) \
os << e.second << "=" << *(e.first) << std::endl;\ os << e.second << "=" << *(e.first) << std::endl;\
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRN2(M,T) \ #define VMON_IMPL_PRN2(M,T) \
{\ {\
for( const auto& e: M.m_##T ) \ for( const auto& e: M.m_##T ) \
os << e.second << "=" << *(e.first) << std::endl;\ os << e.second << "=" << *(e.first) << std::endl;\
\ \
for( const auto& e: M.m_unsigned_##T ) \ for( const auto& e: M.m_unsigned_##T ) \
os << e.second << "=" << *(e.first) << std::endl;\ os << e.second << "=" << *(e.first) << std::endl;\
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRN_CHAR(M) \ #define VMON_IMPL_PRN_CHAR(M) \
{\ {\
for( const auto& e: M.m_char ) \ for( const auto& e: M.m_char ) \
os << e.second << "=" << (int)(*(e.first)) << std::endl;\ os << e.second << "=" << (int)(*(e.first)) << std::endl;\
\ \
for( const auto& e: M.m_unsigned_char) \ for( const auto& e: M.m_unsigned_char) \
os << e.second << "=" << (int)(*(e.first)) << std::endl;\ os << e.second << "=" << (int)(*(e.first)) << std::endl;\
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRET(T) \ #define VMON_IMPL_PRET(T) \
{\ {\
for( const auto& e: m_##T ) \ for( const auto& e: m_##T ) \
os << pretty_str(e.second,e.first) << std::endl;\ os << pretty_str(e.second,e.first) << std::endl;\
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRET2(T) \ #define VMON_IMPL_PRET2(T) \
{\ {\
for( const auto& e: m_##T ) \ for( const auto& e: m_##T ) \
os << pretty_str(e.second,e.first) << std::endl;\ os << pretty_str(e.second,e.first) << std::endl;\
\ \
for( const auto& e: m_unsigned_##T ) \ for( const auto& e: m_unsigned_##T ) \
os << pretty_str(e.second,e.first) << std::endl;\ os << pretty_str(e.second,e.first) << std::endl;\
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRET_CHAR \ #define VMON_IMPL_PRET_CHAR \
{\ {\
for( const auto& e: m_char ) \ for( const auto& e: m_char ) \
os << std::right << std::setw(nameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\ os << std::right << std::setw(nameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\
\ \
for( const auto& e: m_unsigned_char ) \ for( const auto& e: m_unsigned_char ) \
os << std::right << std::setw(nameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\ os << std::right << std::setw(nameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
VMON_IMPL_ADD2(int) VMON_IMPL_ADD2(int)
VMON_IMPL_ADD2(long) VMON_IMPL_ADD2(long)
...@@ -104,20 +104,20 @@ VMON_IMPL_ADD2(char) ...@@ -104,20 +104,20 @@ VMON_IMPL_ADD2(char)
VMON_IMPL_ADD(bool) VMON_IMPL_ADD(bool)
VMON_IMPL_ADD(float) VMON_IMPL_ADD(float)
VMON_IMPL_ADD(double) VMON_IMPL_ADD(double)
VMON_IMPL_ADD3(std::string,string) VMON_IMPL_ADD3(std::string, string)
//VMON_IMPL_ADD3(UniSetTypes::ObjectId,ObjectId) //VMON_IMPL_ADD3(UniSetTypes::ObjectId,ObjectId)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, VMonitor& m ) std::ostream& operator<<(std::ostream& os, VMonitor& m )
{ {
VMON_IMPL_PRN2(m,int); VMON_IMPL_PRN2(m, int);
VMON_IMPL_PRN2(m,long); VMON_IMPL_PRN2(m, long);
VMON_IMPL_PRN2(m,short); VMON_IMPL_PRN2(m, short);
VMON_IMPL_PRN_CHAR(m); VMON_IMPL_PRN_CHAR(m);
VMON_IMPL_PRN(m,bool); VMON_IMPL_PRN(m, bool);
VMON_IMPL_PRN(m,float); VMON_IMPL_PRN(m, float);
VMON_IMPL_PRN(m,double); VMON_IMPL_PRN(m, double);
VMON_IMPL_PRN(m,string); VMON_IMPL_PRN(m, string);
// VMON_IMPL_PRN(m,ObjectId); // VMON_IMPL_PRN(m,ObjectId);
return os; return os;
} }
...@@ -141,7 +141,7 @@ std::string VMonitor::pretty_str() ...@@ -141,7 +141,7 @@ std::string VMonitor::pretty_str()
VMON_IMPL_PRET(float); VMON_IMPL_PRET(float);
VMON_IMPL_PRET(double); VMON_IMPL_PRET(double);
VMON_IMPL_PRET(string); VMON_IMPL_PRET(string);
// VMON_IMPL_PRET(ObjectId); // VMON_IMPL_PRET(ObjectId);
return std::move(os.str()); return std::move(os.str());
} }
......
...@@ -11,7 +11,7 @@ class VMon ...@@ -11,7 +11,7 @@ class VMon
{ {
public: public:
std::tuple<std::unordered_map<const Args*,const std::string>...> m_tuple; std::tuple<std::unordered_map<const Args*, const std::string>...> m_tuple;
}; };
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
...@@ -19,9 +19,9 @@ using namespace std; ...@@ -19,9 +19,9 @@ using namespace std;
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
// VMon<int,double,char> vmon; // VMon<int,double,char> vmon;
// cout << std::get<0>(vmon.m_tuple).size() << endl; // cout << std::get<0>(vmon.m_tuple).size() << endl;
return 0; return 0;
} }
...@@ -169,6 +169,7 @@ TEST_CASE("LogServer", "[LogServer]" ) ...@@ -169,6 +169,7 @@ TEST_CASE("LogServer", "[LogServer]" )
g_read_cancel = true; g_read_cancel = true;
msleep(readTimeout); msleep(readTimeout);
if( r_thr->joinable() ) if( r_thr->joinable() )
r_thr->join(); r_thr->join();
} }
......
...@@ -78,29 +78,29 @@ TEST_CASE("UniSetTypes: explode", "[utypes][explode]" ) ...@@ -78,29 +78,29 @@ TEST_CASE("UniSetTypes: explode", "[utypes][explode]" )
{ {
const std::string str1("id1/wed/wedwed/"); const std::string str1("id1/wed/wedwed/");
auto t1 = UniSetTypes::explode_str(str1,'/'); auto t1 = UniSetTypes::explode_str(str1, '/');
CHECK( t1.size() == 3 ); CHECK( t1.size() == 3 );
auto t2 = UniSetTypes::explode_str(str1,'.'); auto t2 = UniSetTypes::explode_str(str1, '.');
CHECK( t2.size() == 1 ); CHECK( t2.size() == 1 );
const std::string str2("id1/wed/wedwed/f"); const std::string str2("id1/wed/wedwed/f");
auto t3 = UniSetTypes::explode_str(str2,'/'); auto t3 = UniSetTypes::explode_str(str2, '/');
CHECK( t3.size() == 4 ); CHECK( t3.size() == 4 );
const std::string str3("/id1/wed/wedwed/"); const std::string str3("/id1/wed/wedwed/");
auto t4 = UniSetTypes::explode_str(str3,'/'); auto t4 = UniSetTypes::explode_str(str3, '/');
CHECK( t4.size() == 3 ); CHECK( t4.size() == 3 );
const std::string str4(""); const std::string str4("");
auto t5 = UniSetTypes::explode_str(str4,'/'); auto t5 = UniSetTypes::explode_str(str4, '/');
CHECK( t5.size() == 0 ); CHECK( t5.size() == 0 );
const std::string str5("/"); const std::string str5("/");
auto t6 = UniSetTypes::explode_str(str5,'/'); auto t6 = UniSetTypes::explode_str(str5, '/');
CHECK( t6.size() == 0 ); CHECK( t6.size() == 0 );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment