Commit b0c264a1 authored by Pavel Vainerman's avatar Pavel Vainerman

make style..

parent d52d7d65
...@@ -16,10 +16,10 @@ int main( int argc, const char** argv ) ...@@ -16,10 +16,10 @@ int main( int argc, const 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 << "Usage: uniset-smonit [ args ] --sid id1@node1,Sensor2@node2,id2,sensorname3,... " << endl cout << "Usage: uniset-smonit [ args ] --sid id1@node1,Sensor2@node2,id2,sensorname3,... " << endl
<< "Args: " << endl << "Args: " << endl
<< " --confile confilename - Default: configure.xml" << endl << " --confile confilename - Default: configure.xml" << endl
<< " --name XXX - name for smonit. Default: TestProc" << endl; << " --name XXX - name for smonit. Default: TestProc" << endl;
// << " --script scriptname \n" // << " --script scriptname \n"
return 0; return 0;
} }
......
...@@ -257,7 +257,7 @@ int main( int argc, char** argv ) ...@@ -257,7 +257,7 @@ int main( int argc, char** argv )
lr.setReconnectDelay(rdelay); lr.setReconnectDelay(rdelay);
if( !logfile.empty() ) if( !logfile.empty() )
lr.log()->logFile(logfile,logtruncate); lr.log()->logFile(logfile, logtruncate);
if( !vcmd.empty() ) if( !vcmd.empty() )
lr.sendCommand(addr, port, vcmd, cmdonly, verb); lr.sendCommand(addr, port, vcmd, cmdonly, verb);
......
...@@ -41,6 +41,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet ...@@ -41,6 +41,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
{ {
ostringstream s; ostringstream s;
if( t.empty() ) if( t.empty() )
s << conf->getRootSection() << "/sensors"; s << conf->getRootSection() << "/sensors";
else else
......
...@@ -194,7 +194,7 @@ void MBTCPPersistentSlave::execute_tcp() ...@@ -194,7 +194,7 @@ void MBTCPPersistentSlave::execute_tcp()
#warning MBTCPPersistentSlave: Из этой функции нет возврата.. #warning MBTCPPersistentSlave: Из этой функции нет возврата..
sslot->mainLoop( vaddr ); sslot->mainLoop( vaddr );
// ========== В текущей реализации КОД НИЖЕ не будет вызван... по крайней мере пока не завершится процесс ==== // ========== В текущей реализации КОД НИЖЕ не будет вызван... по крайней мере пока не завершится процесс ====
// если слишком быстро обработали запрос // если слишком быстро обработали запрос
// то ничего не делаем.. // то ничего не делаем..
......
...@@ -47,18 +47,18 @@ int main(int argc, const char* argv[] ) ...@@ -47,18 +47,18 @@ int main(int argc, const char* argv[] )
act->add(shm); act->add(shm);
/* /*
ObjectId ns_id = conf->getControllerID("ReservSharedMemory"); ObjectId ns_id = conf->getControllerID("ReservSharedMemory");
if( ns_id == DefaultObjectId ) if( ns_id == DefaultObjectId )
{ {
cerr << "Not found ID for 'ReservSharedMemory'" << endl; cerr << "Not found ID for 'ReservSharedMemory'" << endl;
return 1; return 1;
} }
auto nullsm = make_shared<NullSM>(ns_id, "reserv-sm-configure.xml"); auto nullsm = make_shared<NullSM>(ns_id, "reserv-sm-configure.xml");
act->add(nullsm); act->add(nullsm);
*/ */
ObjectId o_id = conf->getObjectID("TestObject"); ObjectId o_id = conf->getObjectID("TestObject");
if( o_id == DefaultObjectId ) if( o_id == DefaultObjectId )
......
...@@ -100,7 +100,7 @@ void UNetReceiver::setCheckConnectionPause( timeout_t msec ) ...@@ -100,7 +100,7 @@ void UNetReceiver::setCheckConnectionPause( timeout_t msec )
checkConnectionTime = (double)msec / 1000.0; checkConnectionTime = (double)msec / 1000.0;
if( evCheckConnection.is_active() ) if( evCheckConnection.is_active() )
evCheckConnection.start(0,checkConnectionTime); evCheckConnection.start(0, checkConnectionTime);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::setLostTimeout( timeout_t msec ) void UNetReceiver::setLostTimeout( timeout_t msec )
...@@ -120,7 +120,7 @@ void UNetReceiver::setUpdatePause( timeout_t msec ) ...@@ -120,7 +120,7 @@ void UNetReceiver::setUpdatePause( timeout_t msec )
updateTime = (double)updatepause / 1000.0; updateTime = (double)updatepause / 1000.0;
if( evUpdate.is_active() ) if( evUpdate.is_active() )
evUpdate.start(0,updateTime); evUpdate.start(0, updateTime);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::setMaxProcessingCount( int set ) void UNetReceiver::setMaxProcessingCount( int set )
...@@ -181,6 +181,7 @@ bool UNetReceiver::createConnection( bool throwEx ) ...@@ -181,6 +181,7 @@ bool UNetReceiver::createConnection( bool throwEx )
ptRecvTimeout.setTiming(recvTimeout); ptRecvTimeout.setTiming(recvTimeout);
ptPrepare.setTiming(prepareTime); ptPrepare.setTiming(prepareTime);
if( activated ) if( activated )
evprepare(loop.evloop()); evprepare(loop.evloop());
} }
...@@ -189,6 +190,7 @@ bool UNetReceiver::createConnection( bool throwEx ) ...@@ -189,6 +190,7 @@ bool UNetReceiver::createConnection( bool throwEx )
ostringstream s; ostringstream s;
s << myname << "(createConnection): " << e.what(); s << myname << "(createConnection): " << e.what();
unetcrit << s.str() << std::endl; unetcrit << s.str() << std::endl;
if( throwEx ) if( throwEx )
throw SystemError(s.str()); throw SystemError(s.str());
...@@ -199,12 +201,14 @@ bool UNetReceiver::createConnection( bool throwEx ) ...@@ -199,12 +201,14 @@ bool UNetReceiver::createConnection( bool throwEx )
ostringstream s; ostringstream s;
s << myname << "(createConnection): catch..."; s << myname << "(createConnection): catch...";
unetcrit << s.str() << std::endl; unetcrit << s.str() << std::endl;
if( throwEx ) if( throwEx )
throw SystemError(s.str()); throw SystemError(s.str());
udp = nullptr; udp = nullptr;
} }
return ( udp!=nullptr ); return ( udp != nullptr );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::start() void UNetReceiver::start()
...@@ -225,7 +229,7 @@ void UNetReceiver::evprepare( const ev::loop_ref& eloop ) ...@@ -225,7 +229,7 @@ void UNetReceiver::evprepare( const ev::loop_ref& eloop )
if( !udp ) if( !udp )
{ {
evCheckConnection.set(eloop); evCheckConnection.set(eloop);
evCheckConnection.start(0,checkConnectionTime); evCheckConnection.start(0, checkConnectionTime);
} }
else else
{ {
...@@ -243,6 +247,7 @@ void UNetReceiver::evfinish( const ev::loop_ref& eloop ) ...@@ -243,6 +247,7 @@ void UNetReceiver::evfinish( const ev::loop_ref& eloop )
{ {
uniset_mutex_lock l(checkConnMutex); uniset_mutex_lock l(checkConnMutex);
if( evCheckConnection.is_active() ) if( evCheckConnection.is_active() )
evCheckConnection.stop(); evCheckConnection.stop();
} }
...@@ -550,6 +555,7 @@ void UNetReceiver::checkConnectionEvent( ev::periodic& tm, int revents ) ...@@ -550,6 +555,7 @@ void UNetReceiver::checkConnectionEvent( ev::periodic& tm, int revents )
unetinfo << myname << "(checkConnectionEvent): check connection event.." << endl; unetinfo << myname << "(checkConnectionEvent): check connection event.." << endl;
uniset_mutex_lock l(checkConnMutex); uniset_mutex_lock l(checkConnMutex);
if( !createConnection(false) ) if( !createConnection(false) )
tm.again(); tm.again();
} }
......
...@@ -92,7 +92,7 @@ class UNetReceiver: ...@@ -92,7 +92,7 @@ class UNetReceiver:
public std::enable_shared_from_this<UNetReceiver> public std::enable_shared_from_this<UNetReceiver>
{ {
public: public:
UNetReceiver( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection=false ); UNetReceiver( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection = false );
virtual ~UNetReceiver(); virtual ~UNetReceiver();
void start(); void start();
......
...@@ -119,6 +119,7 @@ bool UNetSender::createConnection( bool throwEx ) ...@@ -119,6 +119,7 @@ bool UNetSender::createConnection( bool throwEx )
ostringstream s; ostringstream s;
s << myname << "(createConnection): " << e.what(); s << myname << "(createConnection): " << e.what();
unetcrit << s.str() << std::endl; unetcrit << s.str() << std::endl;
if( throwEx ) if( throwEx )
throw SystemError(s.str()); throw SystemError(s.str());
...@@ -129,6 +130,7 @@ bool UNetSender::createConnection( bool throwEx ) ...@@ -129,6 +130,7 @@ bool UNetSender::createConnection( bool throwEx )
ostringstream s; ostringstream s;
s << myname << "(createConnection): catch..."; s << myname << "(createConnection): catch...";
unetcrit << s.str() << std::endl; unetcrit << s.str() << std::endl;
if( throwEx ) if( throwEx )
throw SystemError(s.str()); throw SystemError(s.str());
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
class UNetSender class UNetSender
{ {
public: public:
UNetSender( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection=false, UNetSender( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection = false,
const std::string& s_field = "", const std::string& s_fvalue = "", const std::string& prefix = "unet", const std::string& s_field = "", const std::string& s_fvalue = "", const std::string& prefix = "unet",
size_t maxDCount = UniSetUDP::MaxDCount, size_t maxACount = UniSetUDP::MaxACount ); size_t maxDCount = UniSetUDP::MaxDCount, size_t maxACount = UniSetUDP::MaxACount );
......
...@@ -77,7 +77,10 @@ class LogReader ...@@ -77,7 +77,10 @@ class LogReader
void setLogLevel( Debug::type t ); void setLogLevel( Debug::type t );
inline std::shared_ptr<DebugStream> log(){ return outlog; } inline std::shared_ptr<DebugStream> log()
{
return outlog;
}
protected: protected:
......
...@@ -572,18 +572,19 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle ...@@ -572,18 +572,19 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
std::string UniSetTypes::replace_all( const std::string& src, const std::string& from, const std::string& to ) std::string UniSetTypes::replace_all( const std::string& src, const std::string& from, const std::string& to )
{ {
string res(src); string res(src);
if( from.empty() ) if( from.empty() )
return std::move(res); return std::move(res);
size_t pos = res.find(from,pos); size_t pos = res.find(from, pos);
while( pos != std::string::npos ) while( pos != std::string::npos )
{ {
res.replace(pos, from.length(), to); res.replace(pos, from.length(), to);
pos += to.length(); pos += to.length();
pos = res.find(from,pos); pos = res.find(from, pos);
} }
return std::move(res); return std::move(res);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -160,17 +160,17 @@ TEST_CASE("UniSetTypes: replace_all", "[utypes][replace_all]" ) ...@@ -160,17 +160,17 @@ TEST_CASE("UniSetTypes: replace_all", "[utypes][replace_all]" )
{ {
const std::string str1("Text %p test text %p"); const std::string str1("Text %p test text %p");
std::string res = UniSetTypes::replace_all(str1,"%p","my"); std::string res = UniSetTypes::replace_all(str1, "%p", "my");
REQUIRE( res == "Text my test text my" ); REQUIRE( res == "Text my test text my" );
const std::string str2("Text %rlong test text %rlong"); const std::string str2("Text %rlong test text %rlong");
res = UniSetTypes::replace_all(str2,"%rlong","2"); res = UniSetTypes::replace_all(str2, "%rlong", "2");
REQUIRE( res == "Text 2 test text 2" ); REQUIRE( res == "Text 2 test text 2" );
res = UniSetTypes::replace_all(str2,"","my"); res = UniSetTypes::replace_all(str2, "", "my");
REQUIRE( res == str2 ); REQUIRE( res == str2 );
res = UniSetTypes::replace_all(str2,"not found","my"); res = UniSetTypes::replace_all(str2, "not found", "my");
REQUIRE( res == str2 ); REQUIRE( res == str2 );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
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