Commit 316d7772 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

(modbus): make style

parent 08cccaf0
......@@ -139,7 +139,7 @@ namespace uniset
return i;
}
// -------------------------------------------------------------------------
size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size_t max , size_t attempts )
size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size_t max, size_t attempts )
{
bool commfail = false;
......
......@@ -115,6 +115,7 @@ namespace uniset
try
{
auto tmpSock = make_shared<UTCPSocket>(iaddr, port);
if( sock )
sock.reset();
......@@ -148,10 +149,12 @@ namespace uniset
asyncResetSockTimeout.start();
ioTimer.set(loop);
if( tmTime_msec != UniSetTimer::WaitUpTime )
ioTimer.start(0, tmTime);
sockTimeout.set(loop);
if( socketTimeout_msec > 0 && socketTimeout_msec != UniSetTimer::WaitUpTime )
sockTimeout.start(0, tmSockTimeout);
}
......@@ -263,15 +266,18 @@ namespace uniset
void ModbusTCPServer::setSocketTimeout( timeout_t msec )
{
socketTimeout_msec = msec;
if( msec == UniSetTimer::WaitUpTime || msec == 0 )
{
socketTimeout_msec = 0;
if( sockTimeout.is_active() )
sockTimeout.stop();
}
else
{
tmSockTimeout = (double)msec / 1000.;
if( sockTimeout.is_active() )
sockTimeout.start( 0, tmSockTimeout );
}
......@@ -417,11 +423,13 @@ namespace uniset
{
if( dlog->is_crit() )
dlog->crit() << myname << "(ModbusTCPServer::onSocketTimeout): invalid event" << endl;
return;
}
{
std::lock_guard<std::mutex> l(sMutex);
if( !slist.empty())
{
if( dlog->is_info() )
......@@ -438,6 +446,7 @@ namespace uniset
try
{
createSocket();
if( io.is_active() )
io.stop();
......
......@@ -315,7 +315,7 @@ namespace uniset
return 0;
}
}
catch( const uniset::CommFailed& ex ){}
catch( const uniset::CommFailed& ex ) {}
if( !cancelled && dlog->is_info() )
dlog->info() << peername << "(getNextData): client disconnected" << endl;
......@@ -384,7 +384,7 @@ namespace uniset
}
while( len == 0 && !pt.checkTime() );
}
catch( const uniset::CommFailed& ex ){}
catch( const uniset::CommFailed& ex ) {}
if( len < mhead.len )
{
......
......@@ -1617,7 +1617,7 @@ namespace uniset
{
addr = a;
func = fnWriteOutputRegisters;
memset(data,0,sizeof(data));
memset(data, 0, sizeof(data));
}
// -------------------------------------------------------------------------
bool WriteOutputMessage::addData( ModbusData d )
......@@ -1869,7 +1869,7 @@ namespace uniset
return os << (*m);
}
// -------------------------------------------------------------------------
ForceSingleCoilMessage::ForceSingleCoilMessage( ModbusAddr a, ModbusData r , bool cmd ):
ForceSingleCoilMessage::ForceSingleCoilMessage( ModbusAddr a, ModbusData r, bool cmd ):
start(r)
{
addr = a;
......@@ -2040,7 +2040,7 @@ namespace uniset
}
// -------------------------------------------------------------------------
WriteSingleOutputMessage::WriteSingleOutputMessage( ModbusAddr a, ModbusData r , ModbusData d ):
WriteSingleOutputMessage::WriteSingleOutputMessage( ModbusAddr a, ModbusData r, ModbusData d ):
start(r),
data(d)
{
......
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