Commit 7c03e4dd authored by Pavel Vainerman's avatar Pavel Vainerman

make style

parent 9242dc0d
......@@ -539,6 +539,7 @@ int omap()
{
if( !quiet )
cerr << "std::exception: " << ex.what() << endl;
return 1;
}
......@@ -600,6 +601,7 @@ int setValue( const string& args, UInterface& ui )
{
if( !quiet )
cerr << "std::exception: " << ex.what() << endl;
err = 1;
}
}
......@@ -666,6 +668,7 @@ int getValue( const string& args, UInterface& ui )
{
if( !quiet )
cerr << "std::exception: " << ex.what() << endl;
err = 1;
}
}
......@@ -714,6 +717,7 @@ int getCalibrate( const std::string& args, UInterface& ui )
{
if( !quiet )
cerr << "std::exception: " << ex.what() << endl;
err = 1;
}
}
......@@ -758,6 +762,7 @@ int getRawValue( const std::string& args, UInterface& ui )
{
if( !quiet )
cerr << "std::exception: " << ex.what() << endl;
err = 1;
}
}
......@@ -802,12 +807,14 @@ int getChangedTime( const std::string& args, UInterface& ui )
{
if( !quiet )
cerr << "CORBA::SystemException: " << ex.NP_minorString() << endl;
err = 1;
}
catch( const CORBA::Exception& )
{
if( !quiet )
cerr << "CORBA::Exception." << endl;
err = 1;
}
catch( const omniORB::fatalException& fe )
......@@ -819,18 +826,21 @@ int getChangedTime( const std::string& args, UInterface& ui )
cerr << " line: " << fe.line() << endl;
cerr << " mesg: " << fe.errmsg() << endl;
}
err = 1;
}
catch( const std::exception& ex )
{
if( !quiet )
cerr << "std::exception: " << ex.what() << endl;
err = 1;
}
catch(...)
{
if( !quiet )
cerr << "Unknown exception.." << endl;
err = 1;
}
}
......
......@@ -609,7 +609,7 @@ int main( int argc, char** argv )
case cmdCheck:
{
bool res = ModbusTCPMaster::checkConnection(iaddr,port,tout);
bool res = ModbusTCPMaster::checkConnection(iaddr, port, tout);
cout << iaddr << ":" << port << " connection " << (res ? "OK" : "FAIL") << endl;
}
break;
......@@ -676,6 +676,6 @@ char* checkArg( int i, int argc, char* argv[] )
// --------------------------------------------------------------------------
void ping( const std::string& iaddr, int port )
{
cerr << "ping2: check connection " << ModbusTCPMaster::checkConnection(iaddr,port,1000) << endl;
cerr << "ping2: check connection " << ModbusTCPMaster::checkConnection(iaddr, port, 1000) << endl;
}
// --------------------------------------------------------------------------
......@@ -945,7 +945,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
return false;
}
if( p->pollfactor>1 && ncycle%p->pollfactor!=0 )
if( p->pollfactor > 1 && ncycle % p->pollfactor != 0 )
return false;
if( mblog->is_level3() )
......@@ -2090,7 +2090,7 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, ModbusRTU::RegID id, Modbus
// ------------------------------------------------------------------------------------------
MBExchange::RSProperty* MBExchange::addProp( PList& plist, RSProperty&& p )
{
for( auto&& it : plist )
for( auto && it : plist )
{
if( it.si.id == p.si.id && it.si.node == p.si.node )
return &it;
......@@ -2184,7 +2184,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML::iterator& it, MBExchange::RTU
{
r->dev = dev;
r->mbval = IOBase::initIntProp(it, "default", prop_prefix, false);
r->pollfactor = IOBase::initIntProp(it, "pollfactor", prop_prefix, false,0);
r->pollfactor = IOBase::initIntProp(it, "pollfactor", prop_prefix, false, 0);
if( dev->dtype == MBExchange::dtRTU )
......@@ -2969,7 +2969,7 @@ void MBExchange::sensorInfo( const UniSetTypes::SensorMessage* sm )
if( !isWriteFunction(it.second->mbfunc) )
continue;
for( auto&& i : it.second->slst )
for( auto && i : it.second->slst )
{
if( sm->id == i.si.id && sm->node == i.si.node )
{
......@@ -3237,7 +3237,8 @@ UniSetTypes::SimpleInfo* MBExchange::getInfo()
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
inf << "Devices:" << endl;
for( const auto& it: rmap )
for( const auto& it : rmap )
inf << " " << it.second->getShortInfo() << endl;
i->info = inf.str().c_str();
......
......@@ -415,7 +415,7 @@ void MBTCPMultiMaster::initIterators()
{
MBExchange::initIterators();
for( auto&& it : mblist )
for( auto && it : mblist )
shm->initIterator(it.respond_it);
}
// -----------------------------------------------------------------------------
......@@ -514,7 +514,7 @@ UniSetTypes::SimpleInfo* MBTCPMultiMaster::getInfo()
ostringstream inf;
inf << i->info << endl;
inf << "Gates: " << (checktime<=0 ? "/ check connections DISABLED /" : "") << endl;
inf << "Gates: " << (checktime <= 0 ? "/ check connections DISABLED /" : "") << endl;
for( const auto& m : mblist )
inf << " " << m.getShortInfo() << endl;
......
......@@ -559,7 +559,7 @@ void MBSlave::execute_rtu()
}
}
for( auto&& it : iomap )
for( auto && it : iomap )
IOBase::processingThreshold(&it.second, shm, force);
}
catch(...) {}
......@@ -645,7 +645,7 @@ void MBSlave::execute_tcp()
}
}
for( auto&& it : iomap )
for( auto && it : iomap )
IOBase::processingThreshold(&it.second, shm, force);
}
catch( const std::exception& ex )
......
......@@ -289,7 +289,7 @@ bool SharedMemory::activateObject()
itPulsar = myioEnd();
for( auto&& it : hist )
for( auto && it : hist )
{
for( auto && hit : it.hlst )
hit.ioit = myioEnd();
......@@ -331,7 +331,7 @@ void SharedMemory::checkHeartBeat()
bool wdtpingOK = true;
for( auto&& it : hlist )
for( auto && it : hlist )
{
try
{
......@@ -378,7 +378,7 @@ void SharedMemory::checkHeartBeat()
// ------------------------------------------------------------------------------------------
bool SharedMemory::readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec )
{
for( auto&& r : lstRSlot )
for( auto && r : lstRSlot )
{
try
{
......@@ -666,7 +666,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
// -----------------------------------------------------------------------------
void SharedMemory::checkHistoryFilter( UniXML::iterator& xit )
{
for( auto&& it : hist )
for( auto && it : hist )
{
if( xit.getProp(it.filter).empty() )
continue;
......@@ -701,9 +701,9 @@ void SharedMemory::saveHistory()
if( hist.empty() )
return;
for( auto&& it : hist )
for( auto && it : hist )
{
for( auto&& hit : it.hlst )
for( auto && hit : it.hlst )
{
try
{
......@@ -743,7 +743,7 @@ void SharedMemory::updateHistory( std::shared_ptr<USensorInfo>& s_it, IOControll
<< " value=" << value
<< endl;
for( auto&& it1 : i->second )
for( auto && it1 : i->second )
{
History::iterator it = it1;
......
......@@ -745,7 +745,7 @@ void UNetExchange::initIterators()
if( sender2 )
sender2->initIterators();
for( auto&& it : recvlist )
for( auto && it : recvlist )
it.initIterators(shm);
}
// -----------------------------------------------------------------------------
......@@ -814,7 +814,7 @@ std::shared_ptr<UNetExchange> UNetExchange::init_unetexchange( int argc, const c
// -----------------------------------------------------------------------------
void UNetExchange::receiverEvent( const shared_ptr<UNetReceiver>& r, UNetReceiver::Event ev )
{
for( auto&& it : recvlist )
for( auto && it : recvlist )
{
if( it.r1 == r )
{
......
......@@ -285,7 +285,7 @@ void UNetReceiver::real_update()
if( sub >= maxDifferens )
{
// считаем сколько пакетов потеряли.. (pnum=0 - означает что мы только что запустились...)
if( pnum!=0 && p.num > pnum )
if( pnum != 0 && p.num > pnum )
lostPackets += sub;
}
}
......
......@@ -16,7 +16,7 @@ class UTCPStream:
void create( const std::string& hname, int port, bool throwflag = false, timeout_t timer = 0 );
// set keepalive params
void setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl=2 );
void setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl = 2 );
protected:
......
......@@ -43,7 +43,7 @@ void ModbusTCPMaster::setChannelTimeout( timeout_t msec )
if( tcp )
{
tcp->setTimeout(msec);
tcp->setKeepAliveParams((msec > 1000 ? msec/1000 : 1));
tcp->setKeepAliveParams((msec > 1000 ? msec / 1000 : 1));
}
}
// -------------------------------------------------------------------------
......@@ -309,7 +309,7 @@ bool ModbusTCPMaster::checkConnection( const std::string& ip, int port, int time
// Проверяем просто попыткой создать соединение..
UTCPStream t;
t.create(ip, port, true, timeout_msec);
t.setKeepAliveParams( (timeout_msec > 1000 ? timeout_msec/1000 : 1),1,1);
t.setKeepAliveParams( (timeout_msec > 1000 ? timeout_msec / 1000 : 1), 1, 1);
t.disconnect();
return true;
}
......@@ -336,7 +336,7 @@ void ModbusTCPMaster::reconnect()
tcp = make_shared<UTCPStream>();
tcp->create(iaddr, port, true, 500);
tcp->setTimeout(replyTimeOut_ms);
tcp->setKeepAliveParams((replyTimeOut_ms > 1000 ? replyTimeOut_ms/1000 : 1));
tcp->setKeepAliveParams((replyTimeOut_ms > 1000 ? replyTimeOut_ms / 1000 : 1));
}
catch( const std::exception& e )
{
......@@ -390,7 +390,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int _port )
tcp = make_shared<UTCPStream>();
tcp->create(iaddr, port, true, 500);
tcp->setTimeout(replyTimeOut_ms);
tcp->setKeepAliveParams((replyTimeOut_ms > 1000 ? replyTimeOut_ms/1000 : 1));
tcp->setKeepAliveParams((replyTimeOut_ms > 1000 ? replyTimeOut_ms / 1000 : 1));
}
catch( const std::exception& e )
{
......
......@@ -60,7 +60,7 @@ void TCPCheck::check_thread()
ost::Thread::setException(ost::Thread::throwException);
UTCPStream t;
t.create(ip, port, true, tout_msec);
t.setKeepAliveParams( (tout_msec > 1000 ? tout_msec/1000 : 1) );
t.setKeepAliveParams( (tout_msec > 1000 ? tout_msec / 1000 : 1) );
setResult(true);
t.disconnect();
}
......
......@@ -27,8 +27,8 @@ void UTCPStream::setKeepAliveParams(timeout_t timeout_sec, int keepcnt, int keep
{
SOCKET fd = TCPStream::so;
int enable = 1;
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,(void*)&enable,sizeof(enable));
setsockopt(fd, SOL_TCP, TCP_KEEPCNT, (void *) &keepcnt, sizeof(keepcnt));
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&enable, sizeof(enable));
setsockopt(fd, SOL_TCP, TCP_KEEPCNT, (void*) &keepcnt, sizeof(keepcnt));
setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, (void*) &keepintvl, sizeof (keepintvl));
setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, (void*) &timeout_sec, sizeof (timeout_sec));
}
......
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