Commit 07eba77f authored by Pavel Vainerman's avatar Pavel Vainerman

make style..

parent 6db2f221
...@@ -56,13 +56,15 @@ int main( int argc, const char** argv ) ...@@ -56,13 +56,15 @@ int main( int argc, const char** argv )
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
int count = conf->getArgPInt("--count",50); int count = conf->getArgPInt("--count", 50);
for( int i=1; i<=count; i++ )
for( int i = 1; i <= count; i++ )
{ {
ostringstream prefix; ostringstream prefix;
prefix << "mbtcp" << i; prefix << "mbtcp" << i;
auto mb = MBTCPMultiMaster::init_mbmaster(argc, argv,shmID,nullptr, prefix.str()); auto mb = MBTCPMultiMaster::init_mbmaster(argc, argv, shmID, nullptr, prefix.str());
if( !mb ) if( !mb )
{ {
cerr << "(main): " << prefix.str() << " init failed..." << endl; cerr << "(main): " << prefix.str() << " init failed..." << endl;
......
...@@ -229,7 +229,7 @@ namespace UniSetTypes ...@@ -229,7 +229,7 @@ namespace UniSetTypes
ConfirmMessage( const VoidMessage* msg ); ConfirmMessage( const VoidMessage* msg );
ConfirmMessage(ObjectId in_sensor_id, ConfirmMessage(ObjectId in_sensor_id,
double in_sensor_value, const double& in_sensor_value,
const timespec& in_sensor_time, const timespec& in_sensor_time,
const timespec& in_confirm_time, const timespec& in_confirm_time,
Priority in_priority = Message::Medium); Priority in_priority = Message::Medium);
......
...@@ -185,7 +185,7 @@ namespace UniSetTypes ...@@ -185,7 +185,7 @@ namespace UniSetTypes
inline bool operator!=( const struct timespec& r1, const struct timespec& r2 ) inline bool operator!=( const struct timespec& r1, const struct timespec& r2 )
{ {
return !(operator==(r1,r2)); return !(operator==(r1, r2));
} }
/*! Разбивка строки по указанному символу */ /*! Разбивка строки по указанному символу */
......
...@@ -34,7 +34,7 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp, ...@@ -34,7 +34,7 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp,
#ifdef USE_BUFFER_FOR_READ #ifdef USE_BUFFER_FOR_READ
max = std::max(max,(size_t)DEFAULT_BUFFER_SIZE_FOR_READ); max = std::max(max, (size_t)DEFAULT_BUFFER_SIZE_FOR_READ);
char* buf = new char[max]; char* buf = new char[max];
...@@ -60,7 +60,7 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp, ...@@ -60,7 +60,7 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp,
catch( ost::SockException& e ) catch( ost::SockException& e )
{ {
if( e.getSocketError() == ost::Socket::errConnectFailed || if( e.getSocketError() == ost::Socket::errConnectFailed ||
e.getSocketError() == ost::Socket::errConnectInvalid ) e.getSocketError() == ost::Socket::errConnectInvalid )
{ {
commfail = true; commfail = true;
} }
...@@ -136,7 +136,7 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size ...@@ -136,7 +136,7 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size
#ifdef USE_BUFFER_FOR_READ #ifdef USE_BUFFER_FOR_READ
max = std::max(max,(size_t)DEFAULT_BUFFER_SIZE_FOR_READ); max = std::max(max, (size_t)DEFAULT_BUFFER_SIZE_FOR_READ);
char* buf = new char[max]; char* buf = new char[max];
...@@ -197,7 +197,7 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size ...@@ -197,7 +197,7 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size
if( commfail ) if( commfail )
throw UniSetTypes::CommFailed(); throw UniSetTypes::CommFailed();
return std::min(qrecv.size(),max); return std::min(qrecv.size(), max);
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
size_t ModbusTCPCore::getDataFD( int fd, std::queue<unsigned char>& qrecv, size_t ModbusTCPCore::getDataFD( int fd, std::queue<unsigned char>& qrecv,
......
...@@ -329,7 +329,7 @@ void ModbusTCPMaster::cleanInputStream() ...@@ -329,7 +329,7 @@ void ModbusTCPMaster::cleanInputStream()
} }
while( ret > 0); while( ret > 0);
} }
catch( ... ){} catch( ... ) {}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPMaster::setReadTimeout( timeout_t msec ) void ModbusTCPMaster::setReadTimeout( timeout_t msec )
......
...@@ -590,34 +590,34 @@ std::string UniSetTypes::replace_all( const std::string& src, const std::string& ...@@ -590,34 +590,34 @@ std::string UniSetTypes::replace_all( const std::string& src, const std::string&
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
timeval UniSetTypes::to_timeval( const chrono::system_clock::duration& d ) timeval UniSetTypes::to_timeval( const chrono::system_clock::duration& d )
{ {
struct timeval tv; struct timeval tv;
if( d.count() == 0 ) if( d.count() == 0 )
tv.tv_sec = tv.tv_usec = 0; tv.tv_sec = tv.tv_usec = 0;
else else
{ {
std::chrono::seconds const sec = std::chrono::duration_cast<std::chrono::seconds>(d); std::chrono::seconds const sec = std::chrono::duration_cast<std::chrono::seconds>(d);
tv.tv_sec = sec.count(); tv.tv_sec = sec.count();
tv.tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(d - sec).count(); tv.tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(d - sec).count();
} }
return std::move(tv); return std::move(tv);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
timespec UniSetTypes::to_timespec( const chrono::system_clock::duration& d ) timespec UniSetTypes::to_timespec( const chrono::system_clock::duration& d )
{ {
struct timespec ts; struct timespec ts;
if( d.count() == 0 ) if( d.count() == 0 )
ts.tv_sec = ts.tv_nsec = 0; ts.tv_sec = ts.tv_nsec = 0;
else else
{ {
std::chrono::seconds const sec = std::chrono::duration_cast<std::chrono::seconds>(d); std::chrono::seconds const sec = std::chrono::duration_cast<std::chrono::seconds>(d);
ts.tv_sec = sec.count(); ts.tv_sec = sec.count();
ts.tv_nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(d - sec).count(); ts.tv_nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(d - sec).count();
} }
return std::move(ts); return std::move(ts);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
timespec UniSetTypes::now_to_timespec() timespec UniSetTypes::now_to_timespec()
......
...@@ -88,7 +88,8 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam ) ...@@ -88,7 +88,8 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam )
auto oind = uniset_conf()->oind; auto oind = uniset_conf()->oind;
uniset_rwmutex_rlock lock(askIOMutex); uniset_rwmutex_rlock lock(askIOMutex);
for( auto&& a: askIOList )
for( auto && a : askIOList )
{ {
auto& i = a.second; auto& i = a.second;
...@@ -100,7 +101,7 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam ) ...@@ -100,7 +101,7 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam )
inf << "(" << setw(6) << a.first << ")[" << oind->getMapName(a.first) << "]" << endl; inf << "(" << setw(6) << a.first << ")[" << oind->getMapName(a.first) << "]" << endl;
for( const auto& c: i.clst ) for( const auto& c : i.clst )
{ {
inf << " " << "(" << setw(6) << c.id << ")" inf << " " << "(" << setw(6) << c.id << ")"
<< setw(35) << ORepHelpers::getShortName(oind->getMapName(c.id)) << setw(35) << ORepHelpers::getShortName(oind->getMapName(c.id))
......
...@@ -442,6 +442,7 @@ void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode ...@@ -442,6 +442,7 @@ void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode
if( cit.goChildren() ) if( cit.goChildren() )
{ {
IONotifyController::ConsumerListInfo lst; IONotifyController::ConsumerListInfo lst;
if( getConsumerList(xml, cit, lst) ) if( getConsumerList(xml, cit, lst) )
{ {
std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf); std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf);
......
...@@ -196,10 +196,10 @@ namespace UniSetTypes ...@@ -196,10 +196,10 @@ namespace UniSetTypes
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
ConfirmMessage::ConfirmMessage(UniSetTypes::ObjectId in_sensor_id, ConfirmMessage::ConfirmMessage(UniSetTypes::ObjectId in_sensor_id,
double in_sensor_value, const double& in_sensor_value,
const timespec& in_sensor_time, const timespec& in_sensor_time,
const timespec& in_confirm_time, const timespec& in_confirm_time,
Priority in_priority ): Priority in_priority ):
sensor_id(in_sensor_id), sensor_id(in_sensor_id),
sensor_value(in_sensor_value), sensor_value(in_sensor_value),
sensor_time(in_sensor_time), sensor_time(in_sensor_time),
......
...@@ -30,24 +30,24 @@ int main( int argc, const char** argv ) ...@@ -30,24 +30,24 @@ int main( int argc, const char** argv )
return 0; return 0;
std::chrono::time_point<std::chrono::system_clock> p1, p2, p3; std::chrono::time_point<std::chrono::system_clock> p1, p2, p3;
p2 = std::chrono::system_clock::now(); p2 = std::chrono::system_clock::now();
p3 = p2 - std::chrono::hours(24); p3 = p2 - std::chrono::hours(24);
std::time_t epoch_time = std::chrono::system_clock::to_time_t(p1); std::time_t epoch_time = std::chrono::system_clock::to_time_t(p1);
std::cout << "epoch: " << std::ctime(&epoch_time); std::cout << "epoch: " << std::ctime(&epoch_time);
std::time_t today_time = std::chrono::system_clock::to_time_t(p2); std::time_t today_time = std::chrono::system_clock::to_time_t(p2);
std::cout << "today: " << std::ctime(&today_time); std::cout << "today: " << std::ctime(&today_time);
std::cout << "hours since epoch: " std::cout << "hours since epoch: "
<< std::chrono::duration_cast<std::chrono::hours>( << std::chrono::duration_cast<std::chrono::hours>(
p2.time_since_epoch()).count() p2.time_since_epoch()).count()
<< '\n'; << '\n';
std::cout << "yesterday, hours since epoch: " std::cout << "yesterday, hours since epoch: "
<< std::chrono::duration_cast<std::chrono::hours>( << std::chrono::duration_cast<std::chrono::hours>(
p3.time_since_epoch()).count() p3.time_since_epoch()).count()
<< '\n'; << '\n';
return 0; return 0;
unsigned char dat[] = { '1', '2', '3' , '4' }; unsigned char dat[] = { '1', '2', '3' , '4' };
......
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