Commit 8755ae5c authored by Pavel Vainerman's avatar Pavel Vainerman

make style

parent c966df0d
......@@ -286,7 +286,7 @@ class MBExchange:
RTUDeviceMap devices;
InitList initRegList; /*!< список регистров для инициализации */
// UniSetTypes::uniset_rwmutex pollMutex;
// UniSetTypes::uniset_rwmutex pollMutex;
virtual std::shared_ptr<ModbusClient> initMB( bool reopen = false ) = 0;
......
......@@ -180,8 +180,10 @@ MBSlave::MBSlave(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const
ostringstream n;
n << prefix << "-exchangelog";
auto l = loga->create(n.str());
if( mblog->is_crit() )
l->addLevel(Debug::CRIT);
if( mblog->is_warn() )
l->addLevel(Debug::WARN);
......@@ -215,6 +217,7 @@ MBSlave::MBSlave(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const
if( mblog->is_crit() )
l->addLevel(Debug::CRIT);
if( mblog->is_warn() )
l->addLevel(Debug::WARN);
......@@ -630,6 +633,7 @@ void MBSlave::execute_tcp()
tcpCancelled = false;
ost::Thread::setException(ost::Thread::throwException);
try
{
tcpserver->run( vaddr, true );
......
......@@ -312,10 +312,11 @@ bool SharedMemory::activateObject()
hit.ioit = myioEnd();
}
for( auto&& it: histmap )
for( auto && it : histmap )
{
auto i = myiofind(it.first);
if( i!= myioEnd() )
if( i != myioEnd() )
i->second->userdata[udataHistory] = (void*)(&(it.second));
}
......@@ -755,9 +756,9 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
HistoryItList& lst = *(static_cast<HistoryItList*>(usi->userdata[udataHistory]));
// auto i = histmap.find(s_it->si.id);
// if( i == histmap.end() )
// return;
// auto i = histmap.find(s_it->si.id);
// if( i == histmap.end() )
// return;
long value = 0;
long sm_tv_sec = 0;
......
......@@ -218,6 +218,7 @@ void UNetReceiver::start()
{
activated = true;
loop.evrun(this, true);
if( !upThread->isRunning() )
upThread->start();
}
......@@ -280,9 +281,9 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents)
}
unetlog9 << myname << "(statisctics):"
<< " recvCount=" << recvCount << "[per sec]"
<< " upCount=" << upCount << "[per sec]"
<< endl;
<< " recvCount=" << recvCount << "[per sec]"
<< " upCount=" << upCount << "[per sec]"
<< endl;
recvCount = 0;
upCount = 0;
......
......@@ -29,7 +29,7 @@ shared_ptr<SMInterface> smiInstance()
return smi;
}
// --------------------------------------------------------------------------
static void run_senders( size_t max, const std::string& s_host, size_t count=50, timeout_t usecpause=50 )
static void run_senders( size_t max, const std::string& s_host, size_t count = 50, timeout_t usecpause = 50 )
{
ost::IPV4Host host(s_host.c_str());
......@@ -39,11 +39,11 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
cout << "Run " << max << " senders (" << s_host << ")" << endl;
// make sendesrs..
for( size_t i=0; i<max; i++ )
for( size_t i = 0; i < max; i++ )
{
try
{
auto s = make_shared<ost::UDPSocket>(host,begPort+i);
auto s = make_shared<ost::UDPSocket>(host, begPort + i);
vsend.emplace_back(s);
}
catch( ost::SockException& e )
......@@ -71,12 +71,12 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
for( size_t i = 0; i < count; i++ )
mypack.addDData(i, i);
for( size_t i=0; i<max; i++ )
for( size_t i = 0; i < max; i++ )
{
try
{
if( vsend[i] )
vsend[i]->setPeer(host, begPort+i);
vsend[i]->setPeer(host, begPort + i);
}
catch( ost::SockException& e )
{
......@@ -104,7 +104,7 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
if( packetnum == 0 )
packetnum = 1;
for( auto&& udp: vsend )
for( auto && udp : vsend )
{
try
{
......@@ -127,6 +127,7 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
}
}
usleep(usecpause);
}
}
......@@ -137,16 +138,17 @@ static void run_test( size_t max, const std::string& host )
vrecv.reserve(max);
// make receivers..
for( size_t i=0; i<max; i++ )
for( size_t i = 0; i < max; i++ )
{
auto r = make_shared<UNetReceiver>(host,begPort+i,smiInstance());
auto r = make_shared<UNetReceiver>(host, begPort + i, smiInstance());
r->setLockUpdate(true);
vrecv.emplace_back(r);
}
size_t count = 0;
// Run receivers..
for( auto&& r: vrecv )
for( auto && r : vrecv )
{
if( r )
{
......@@ -160,7 +162,7 @@ static void run_test( size_t max, const std::string& host )
// wait..
pause();
for( auto&& r: vrecv )
for( auto && r : vrecv )
{
if(r)
r->stop();
......@@ -170,14 +172,15 @@ static void run_test( size_t max, const std::string& host )
int main(int argc, char* argv[] )
{
std::string host = "127.255.255.255";
try
{
auto conf = uniset_init(argc, argv);
if( argc > 1 && !strcmp(argv[1],"s") )
run_senders(10,host);
if( argc > 1 && !strcmp(argv[1], "s") )
run_senders(10, host);
else
run_test(10,host);
run_test(10, host);
return 0;
}
......
......@@ -1695,7 +1695,7 @@ ModbusRTU::mbErrCode ModbusServer::replySetDateTime( ModbusRTU::SetDateTimeMessa
struct timezone tz;
struct timeval set;
if( gettimeofday(&set,&tz) == 0 )
if( gettimeofday(&set, &tz) == 0 )
{
struct tm t;
localtime_r(&set.tv_sec, &t);
......
......@@ -91,6 +91,7 @@ bool ModbusTCPServer::isActive() const
void ModbusTCPServer::evprepare()
{
ost::Thread::setException(ost::Thread::throwException);
try
{
sock = make_shared<UTCPSocket>(iaddr, port);
......
......@@ -379,7 +379,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
struct timeval tm;
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm,NULL);
gettimeofday(&tm, NULL);
ai->tv_sec = tm.tv_sec;
ai->tv_usec = tm.tv_usec;
ai->value = ai->default_val;
......@@ -776,7 +776,7 @@ IOController::ChangeUndefinedStateSignal IOController::signal_change_undefined_s
throw IOController_i::NameNotFound(err.str().c_str());
}
// uniset_rwmutex_rlock lock(it->second->val_lock);
// uniset_rwmutex_rlock lock(it->second->val_lock);
return it->second->sigUndefChange;
}
// -----------------------------------------------------------------------------
......
......@@ -269,8 +269,9 @@ void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
{
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
auto s = myiofind(sid);
if( s != myioEnd() )
s->second->userdata[udataConsumerList] =(void*)(&(askIterator->second));
s->second->userdata[udataConsumerList] = (void*)(&(askIterator->second));
else
s->second->userdata[udataConsumerList] = nullptr;
}
......@@ -329,6 +330,7 @@ void IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf
{
uniset_rwmutex_rlock lock(askIOMutex);
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if( usi->userdata[udataConsumerList] != nullptr )
{
......@@ -617,6 +619,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
}
it = askTMap.find(sid);
if( li != myioEnd() )
{
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
......@@ -698,12 +701,14 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
{
uniset_rwmutex_rlock lock(trshMutex);
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if( usi->userdata[udataThresholdList] == nullptr )
return;
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
ti = static_cast<ThresholdsListInfo*>(usi->userdata[udataThresholdList]);
if( ti->list.empty() )
return;
}
......@@ -817,7 +822,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
throw IOController_i::NameNotFound(err.str().c_str());
}
for( const auto& it2: it->second.list )
for( const auto& it2 : it->second.list )
{
/*! \warning На самом деле список разрешает иметь много порогов с одинаковым ID, для разных "заказчиков".
Но здесь мы возвращаем первый встретившийся..
......@@ -877,7 +882,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
size_t k = 0;
for( const auto& it2: it->second.list )
for( const auto& it2 : it->second.list )
{
res->tlist[k].id = it2.id;
res->tlist[k].hilimit = it2.hilimit;
......@@ -903,7 +908,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
{
size_t i = 0;
for( auto&& it: askTMap )
for( auto && it : askTMap )
{
try
{
......@@ -931,7 +936,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
size_t k = 0;
for( const auto& it2: it.second.list )
for( const auto& it2 : it.second.list )
{
(*res)[i].tlist[k].id = it2.id;
(*res)[i].tlist[k].hilimit = it2.hilimit;
......@@ -963,6 +968,7 @@ void IONotifyController::onChangeUndefinedState( std::shared_ptr<USensorInfo>& u
{
// lock
uniset_rwmutex_rlock lock(askIOMutex);
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if( usi->userdata[udataConsumerList] != nullptr )
{
......
......@@ -121,6 +121,7 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, std::shared_ptr<IOCon
{
auto i = ic->myiofind(inf->si.id);
ic->askTMap[inf->si.id].usi = i->second;
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if( i->second )
i->second->userdata[IONotifyController::udataThresholdList] = &(ic->askTMap[inf->si.id]);
......@@ -149,7 +150,7 @@ NCRestorer::SInfo& NCRestorer::SInfo::operator=( const IOController_i::SensorIOI
this->blocked = inf.blocked;
this->dbignore = inf.dbignore;
for( size_t i=0; i<IOController::USensorInfo::MaxUserData; i++ )
for( size_t i = 0; i < IOController::USensorInfo::MaxUserData; i++ )
this->userdata[i] = nullptr;
return *this;
......
......@@ -295,7 +295,7 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
{
ostringstream err;
err << "(NCRestorer_XML:getSensorInfo): unknown iotype=" << xml->getProp(it, "iotype")
<< " for " << xml->getProp(it, "name");
<< " for " << xml->getProp(it, "name");
ucrit << err.str() << endl;
throw SystemError(err.str());
}
......@@ -334,8 +334,8 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
{
ostringstream err;
err << "(NCRestorer_XML:getSensorInfo): sensor='"
<< xml->getProp(it, "name") << "' err: "
<< " Unknown SensorID for depend='" << d_txt;
<< xml->getProp(it, "name") << "' err: "
<< " Unknown SensorID for depend='" << d_txt;
ucrit << err.str() << endl;
throw SystemError(err.str());
......@@ -491,7 +491,7 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo
{
ostringstream err;
err << "(NCRestorer_XML:getThresholdInfo): "
<< " Not found ID for " << sid_name;
<< " Not found ID for " << sid_name;
ucrit << err.str() << endl;
throw SystemError(err.str());
......@@ -505,8 +505,8 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo
{
ostringstream err;
err << "(NCRestorer_XML:getThresholdInfo): "
<< " Bad iotype(" << iotype << ") for " << sid_name
<< ". iotype must be 'DI' or 'DO'.";
<< " Bad iotype(" << iotype << ") for " << sid_name
<< ". iotype must be 'DI' or 'DO'.";
ucrit << err.str() << endl;
throw SystemError(err.str());
......
......@@ -702,7 +702,7 @@ namespace UniSetTypes
return _argc;
}
// -------------------------------------------------------------------------
const char* const*Configuration::getArgv() const
const char* const* Configuration::getArgv() const
{
return _argv;
}
......
......@@ -58,7 +58,7 @@ namespace UniSetTypes
{
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm,NULL);
gettimeofday(&tm, NULL);
}
/*
......
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