Commit f4be5a48 authored by Pavel Vainerman's avatar Pavel Vainerman

Перешёл на использование -std=c++0x, использование auto,

циклов for( auto ...) и т.п.
parent f15984b2
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.0 Version: 2.0
Release: alt0.8 Release: alt0.9
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -333,6 +333,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -333,6 +333,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc %exclude %_pkgconfigdir/libUniSet2.pc
%changelog %changelog
* Tue Feb 04 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.9
- use -std=c++0x (auto, for( auto..), etc)
* Mon Feb 03 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.8 * Mon Feb 03 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.8
- fixed bug in LT_Object - fixed bug in LT_Object
......
...@@ -58,7 +58,7 @@ AM_CONDITIONAL(DISABLE_SQLITE, test ${buildsqlite} = false) ...@@ -58,7 +58,7 @@ AM_CONDITIONAL(DISABLE_SQLITE, test ${buildsqlite} = false)
# export # export
LDFLAGS="${OMNI_LIBS} ${XML_LIBS}" LDFLAGS="${OMNI_LIBS} ${XML_LIBS}"
CXXFLAGS="-pedantic -Wall -funsigned-char -g -D_GNU_SOURCE ${OMNI_CFLAGS} ${XML_CFLAGS} -I\$(top_builddir)/include" CXXFLAGS="-pedantic -Wall -funsigned-char -std=c++0x -g -D_GNU_SOURCE ${OMNI_CFLAGS} ${XML_CFLAGS} -I\$(top_builddir)/include"
AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGS)
AC_SUBST(CXXFLAGS) AC_SUBST(CXXFLAGS)
......
...@@ -17,9 +17,9 @@ void Element::addChildOut( Element* el, int num ) ...@@ -17,9 +17,9 @@ void Element::addChildOut( Element* el, int num )
} }
for( OutputList::iterator it=outs.begin(); it!=outs.end(); ++it ) for( auto &it: outs )
{ {
if( it->el == el ) if( it.el == el )
{ {
ostringstream msg; ostringstream msg;
msg << "(" << myid << "):" << el->getId() << " уже есть в списке дочерних(такое соединение уже есть)..."; msg << "(" << myid << "):" << el->getId() << " уже есть в списке дочерних(такое соединение уже есть)...";
...@@ -42,7 +42,7 @@ void Element::addChildOut( Element* el, int num ) ...@@ -42,7 +42,7 @@ void Element::addChildOut( Element* el, int num )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Element::delChildOut( Element* el ) void Element::delChildOut( Element* el )
{ {
for( OutputList::iterator it=outs.begin(); it!=outs.end(); ++it ) for( auto it=outs.begin(); it!=outs.end(); ++it )
{ {
if( it->el == el ) if( it->el == el )
{ {
...@@ -56,11 +56,11 @@ void Element::delChildOut( Element* el ) ...@@ -56,11 +56,11 @@ void Element::delChildOut( Element* el )
void Element::setChildOut() void Element::setChildOut()
{ {
bool _myout(getOut()); bool _myout(getOut());
for( OutputList::iterator it=outs.begin(); it!=outs.end(); ++it ) for( auto &it: outs )
{ {
// try // try
// { // {
it->el->setIn(it->num,_myout); it.el->setIn(it.num,_myout);
// } // }
// catch(...){} // catch(...){}
} }
...@@ -68,12 +68,12 @@ void Element::setChildOut() ...@@ -68,12 +68,12 @@ void Element::setChildOut()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Element* Element::find( ElementID id ) Element* Element::find( ElementID id )
{ {
for( OutputList::iterator it=outs.begin(); it!=outs.end(); ++it ) for( auto &it: outs )
{ {
if( it->el->getId() == id ) if( it.el->getId() == id )
return it->el; return it.el;
Element* el( it->el->find(id) ); Element* el( it.el->find(id) );
if( el != NULL ) if( el != NULL )
return el; return el;
} }
...@@ -83,9 +83,9 @@ Element* Element::find( ElementID id ) ...@@ -83,9 +83,9 @@ Element* Element::find( ElementID id )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Element::addInput(int num, bool state) void Element::addInput(int num, bool state)
{ {
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( auto &it: ins )
{ {
if( it->num == num ) if( it.num == num )
{ {
ostringstream msg; ostringstream msg;
msg << "(" << myid << "): попытка второй раз добавить input N" << num; msg << "(" << myid << "): попытка второй раз добавить input N" << num;
...@@ -98,7 +98,7 @@ void Element::addInput(int num, bool state) ...@@ -98,7 +98,7 @@ void Element::addInput(int num, bool state)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Element::delInput( int num ) void Element::delInput( int num )
{ {
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( auto it=ins.begin(); it!=ins.end(); ++it )
{ {
if( it->num == num ) if( it->num == num )
{ {
...@@ -108,4 +108,3 @@ void Element::delInput( int num ) ...@@ -108,4 +108,3 @@ void Element::delInput( int num )
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...@@ -116,11 +116,11 @@ void LProcessor::build( const string& lfile ) ...@@ -116,11 +116,11 @@ void LProcessor::build( const string& lfile )
*/ */
void LProcessor::getInputs() void LProcessor::getInputs()
{ {
for( EXTList::iterator it=extInputs.begin(); it!=extInputs.end(); ++it ) for( auto &it: extInputs )
{ {
// try // try
// { // {
it->state = (bool)ui.getValue(it->sid); it.state = (bool)ui.getValue(it.sid);
// } // }
} }
} }
...@@ -128,22 +128,22 @@ void LProcessor::getInputs() ...@@ -128,22 +128,22 @@ void LProcessor::getInputs()
void LProcessor::processing() void LProcessor::processing()
{ {
// выcтавляем все внешние входы // выcтавляем все внешние входы
for( EXTList::iterator it=extInputs.begin(); it!=extInputs.end();++it ) for( auto &it: extInputs )
it->lnk->to->setIn(it->lnk->numInput,it->state); it.lnk->to->setIn(it.lnk->numInput,it.state);
// проходим по всем элементам // проходим по всем элементам
for( Schema::iterator it=sch.begin(); it!=sch.end(); ++it ) for( auto &it: sch )
it->second->tick(); it.second->tick();
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LProcessor::setOuts() void LProcessor::setOuts()
{ {
// выcтавляем выходы // выcтавляем выходы
for( OUTList::iterator it=extOuts.begin(); it!=extOuts.end(); ++it ) for( auto &it: extOuts )
{ {
try try
{ {
ui.setValue(it->sid,it->lnk->from->getOut(),DefaultObjectId); ui.setValue(it.sid,it.lnk->from->getOut(),DefaultObjectId);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
......
...@@ -78,8 +78,8 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -78,8 +78,8 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
{ {
try try
{ {
for( EXTList::iterator it=extInputs.begin(); it!=extInputs.end(); ++it ) for( auto &it: extInputs )
shm->askSensor(it->sid,cmd); shm->askSensor(it.sid,cmd);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
...@@ -90,10 +90,10 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -90,10 +90,10 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::sensorInfo( const UniSetTypes::SensorMessage*sm ) void PassiveLProcessor::sensorInfo( const UniSetTypes::SensorMessage*sm )
{ {
for( EXTList::iterator it=extInputs.begin(); it!=extInputs.end(); ++it ) for( auto& it: extInputs )
{ {
if( it->sid == sm->id ) if( it.sid == sm->id )
it->state = (bool)sm->value; it.state = sm->value ? true : false;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -189,11 +189,11 @@ void PassiveLProcessor::initIterators() ...@@ -189,11 +189,11 @@ void PassiveLProcessor::initIterators()
void PassiveLProcessor::setOuts() void PassiveLProcessor::setOuts()
{ {
// выcтавляем выходы // выcтавляем выходы
for( OUTList::iterator it=extOuts.begin(); it!=extOuts.end(); ++it ) for( auto &it: extOuts )
{ {
try try
{ {
shm->setValue( it->sid,it->lnk->from->getOut() ); shm->setValue( it.sid,it.lnk->from->getOut() );
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
...@@ -208,11 +208,11 @@ void PassiveLProcessor::setOuts() ...@@ -208,11 +208,11 @@ void PassiveLProcessor::setOuts()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::sigterm( int signo ) void PassiveLProcessor::sigterm( int signo )
{ {
for( OUTList::iterator it=extOuts.begin(); it!=extOuts.end(); ++it ) for( auto &it: extOuts )
{ {
try try
{ {
shm->setValue(it->sid,0); shm->setValue(it.sid,0);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
......
...@@ -13,12 +13,12 @@ Schema::Schema() ...@@ -13,12 +13,12 @@ Schema::Schema()
Schema::~Schema() Schema::~Schema()
{ {
for( ElementMap::iterator it=emap.begin(); it!=emap.end(); ++it ) for( auto &it: emap )
{ {
if( it->second != 0 ) if( it.second != 0 )
{ {
delete it->second; delete it.second;
it->second = 0; it.second = 0;
} }
} }
} }
...@@ -28,7 +28,7 @@ void Schema::link( Element::ElementID rootID, Element::ElementID childID, int nu ...@@ -28,7 +28,7 @@ void Schema::link( Element::ElementID rootID, Element::ElementID childID, int nu
Element* e1 = 0; Element* e1 = 0;
Element* e2 = 0; Element* e2 = 0;
ElementMap::iterator it = emap.find(rootID); auto it = emap.find(rootID);
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
...@@ -57,7 +57,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID ) ...@@ -57,7 +57,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID )
Element* e1(0); Element* e1(0);
Element* e2(0); Element* e2(0);
ElementMap::iterator it = emap.find(rootID); auto it = emap.find(rootID);
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
...@@ -78,7 +78,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID ) ...@@ -78,7 +78,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID )
e1->delChildOut(e2); e1->delChildOut(e2);
// удаляем из списка соединений // удаляем из списка соединений
for( InternalList::iterator lit=inLinks.begin(); lit!=inLinks.end(); ++lit ) for( auto lit=inLinks.begin(); lit!=inLinks.end(); ++lit )
{ {
if( lit->from == e1 && lit->to == e2 ) if( lit->from == e1 && lit->to == e2 )
{ {
...@@ -90,7 +90,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID ) ...@@ -90,7 +90,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Schema::extlink( const string& name, Element::ElementID childID, int numIn ) void Schema::extlink( const string& name, Element::ElementID childID, int numIn )
{ {
ElementMap::iterator it = emap.find(childID); auto it = emap.find(childID);
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
...@@ -120,7 +120,7 @@ Element* Schema::manage( Element* el ) ...@@ -120,7 +120,7 @@ Element* Schema::manage( Element* el )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Schema::remove( Element* el ) void Schema::remove( Element* el )
{ {
for( ElementMap::iterator it=emap.begin(); it!=emap.end(); ++it ) for( auto it=emap.begin(); it!=emap.end(); ++it )
{ {
if( it->second != el ) if( it->second != el )
{ {
...@@ -130,34 +130,34 @@ void Schema::remove( Element* el ) ...@@ -130,34 +130,34 @@ void Schema::remove( Element* el )
} }
// помечаем внутренние связи // помечаем внутренние связи
for( InternalList::iterator lit=inLinks.begin(); lit!=inLinks.end(); ++lit ) for( auto &lit: inLinks )
{ {
if( lit->from == el ) if( lit.from == el )
lit->from = 0; lit.from = 0;
if( lit->to == el ) if( lit.to == el )
lit->to = 0; lit.to = 0;
} }
// помечаем внешние связи // помечаем внешние связи
for( ExternalList::iterator lit=extLinks.begin(); lit!=extLinks.end(); ++lit ) for( auto &lit: extLinks )
{ {
if( lit->to == el ) if( lit.to == el )
lit->to = 0; lit.to = 0;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Schema::setIn( Element::ElementID ID, int inNum, bool state ) void Schema::setIn( Element::ElementID ID, int inNum, bool state )
{ {
ElementMap::iterator it = emap.find(ID); auto it = emap.find(ID);
if( it != emap.end() ) if( it != emap.end() )
it->second->setIn(inNum,state); it->second->setIn(inNum,state);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool Schema::getOut( Element::ElementID ID ) bool Schema::getOut( Element::ElementID ID )
{ {
ElementMap::iterator it = emap.find(ID); auto it = emap.find(ID);
if( it != emap.end() ) if( it != emap.end() )
return it->second->getOut(); return it->second->getOut();
...@@ -168,7 +168,7 @@ bool Schema::getOut( Element::ElementID ID ) ...@@ -168,7 +168,7 @@ bool Schema::getOut( Element::ElementID ID )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Element* Schema::find( Element::ElementID id ) Element* Schema::find( Element::ElementID id )
{ {
ElementMap::iterator it = emap.find(id); auto it = emap.find(id);
if( it != emap.end() ) if( it != emap.end() )
return it->second; return it->second;
return 0; return 0;
...@@ -177,10 +177,10 @@ Element* Schema::find( Element::ElementID id ) ...@@ -177,10 +177,10 @@ Element* Schema::find( Element::ElementID id )
Element* Schema::findExtLink( const string& name ) Element* Schema::findExtLink( const string& name )
{ {
// помечаем внешние связи // помечаем внешние связи
for( ExternalList::iterator it=extLinks.begin(); it!=extLinks.end(); ++it ) for( auto &it: extLinks )
{ {
if( it->name == name ) if( it.name == name )
return it->to; return it.to;
} }
return 0; return 0;
......
...@@ -17,14 +17,14 @@ TAND::~TAND() ...@@ -17,14 +17,14 @@ TAND::~TAND()
void TAND::setIn( int num, bool state ) void TAND::setIn( int num, bool state )
{ {
// cout << this << ": input " << num << " set " << state << endl; // cout << this << ": input " << num << " set " << state << endl;
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( auto &it: ins )
{ {
if( it->num == num ) if( it.num == num )
{ {
if( it->state == state ) if( it.state == state )
return; // вход не менялся можно вообще прервать проверку return; // вход не менялся можно вообще прервать проверку
it->state = state; it.state = state;
break; break;
} }
} }
...@@ -34,9 +34,9 @@ void TAND::setIn( int num, bool state ) ...@@ -34,9 +34,9 @@ void TAND::setIn( int num, bool state )
// проверяем изменился ли выход // проверяем изменился ли выход
// для тригера 'AND' проверка до первого 0 // для тригера 'AND' проверка до первого 0
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( auto &it: ins )
{ {
if( !it->state ) if( !it.state )
{ {
myout = false; myout = false;
brk = true; brk = true;
......
...@@ -30,14 +30,14 @@ void TOR::setIn( int num, bool state ) ...@@ -30,14 +30,14 @@ void TOR::setIn( int num, bool state )
{ {
// cout << getType() << "(" << myid << "): input " << num << " set " << state << endl; // cout << getType() << "(" << myid << "): input " << num << " set " << state << endl;
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( auto &it: ins )
{ {
if( it->num == num ) if( it.num == num )
{ {
if( it->state == state ) if( it.state == state )
return; // вход не менялся можно вообще прервать проверку return; // вход не менялся можно вообще прервать проверку
it->state = state; it.state = state;
break; break;
} }
} }
...@@ -47,9 +47,9 @@ void TOR::setIn( int num, bool state ) ...@@ -47,9 +47,9 @@ void TOR::setIn( int num, bool state )
// проверяем изменился ли выход // проверяем изменился ли выход
// для тригера 'OR' проверка до первой единицы // для тригера 'OR' проверка до первой единицы
for( InputList::iterator it=ins.begin(); it!=ins.end(); ++it ) for( auto &it: ins )
{ {
if( it->state ) if( it.state )
{ {
myout = true; myout = true;
brk = true; brk = true;
......
...@@ -83,7 +83,7 @@ class MBExchange: ...@@ -83,7 +83,7 @@ class MBExchange:
friend std::ostream& operator<<( std::ostream& os, const RSProperty& p ); friend std::ostream& operator<<( std::ostream& os, const RSProperty& p );
typedef std::list<RSProperty> PList; typedef std::list<RSProperty> PList;
static std::ostream& print_plist( std::ostream& os, PList& p ); static std::ostream& print_plist( std::ostream& os, const PList& p );
typedef unsigned long RegID; typedef unsigned long RegID;
......
...@@ -155,10 +155,10 @@ MBTCPMultiMaster::~MBTCPMultiMaster() ...@@ -155,10 +155,10 @@ MBTCPMultiMaster::~MBTCPMultiMaster()
{ {
delete pollThread; delete pollThread;
delete checkThread; delete checkThread;
for( MBGateList::iterator it=mblist.begin(); it!=mblist.end(); ++it ) for( auto &it: mblist )
{ {
delete it->mbtcp; delete it.mbtcp;
it->mbtcp = 0; it.mbtcp = 0;
mbi = mblist.rend(); mbi = mblist.rend();
} }
} }
...@@ -195,7 +195,7 @@ ModbusClient* MBTCPMultiMaster::initMB( bool reopen ) ...@@ -195,7 +195,7 @@ ModbusClient* MBTCPMultiMaster::initMB( bool reopen )
} }
// проходим по списку (в обратном порядке, т.к. самый приоритетный в конце) // проходим по списку (в обратном порядке, т.к. самый приоритетный в конце)
for( MBGateList::reverse_iterator it=mblist.rbegin(); it!=mblist.rend(); ++it ) for( auto it=mblist.rbegin(); it!=mblist.rend(); ++it )
{ {
uniset_rwmutex_wrlock l(tcpMutex); uniset_rwmutex_wrlock l(tcpMutex);
if( it->respond && it->init() ) if( it->respond && it->init() )
...@@ -302,7 +302,7 @@ void MBTCPMultiMaster::check_thread() ...@@ -302,7 +302,7 @@ void MBTCPMultiMaster::check_thread()
{ {
while( checkProcActive() ) while( checkProcActive() )
{ {
for( MBGateList::iterator it=mblist.begin(); it!=mblist.end(); ++it ) for( auto it=mblist.begin(); it!=mblist.end(); ++it )
{ {
try try
{ {
...@@ -345,8 +345,8 @@ void MBTCPMultiMaster::check_thread() ...@@ -345,8 +345,8 @@ void MBTCPMultiMaster::check_thread()
void MBTCPMultiMaster::initIterators() void MBTCPMultiMaster::initIterators()
{ {
MBExchange::initIterators(); MBExchange::initIterators();
for( MBGateList::iterator it=mblist.begin(); it!=mblist.end(); ++it ) for( auto &it: mblist )
shm->initIterator(it->respond_it); shm->initIterator(it.respond_it);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void MBTCPMultiMaster::help_print( int argc, const char* const* argv ) void MBTCPMultiMaster::help_print( int argc, const char* const* argv )
......
...@@ -177,8 +177,8 @@ void RTUExchange::poll() ...@@ -177,8 +177,8 @@ void RTUExchange::poll()
mb = initMB(false); mb = initMB(false);
if( !mb ) if( !mb )
{ {
for( MBExchange::RTUDeviceMap::iterator it=rmap.begin(); it!=rmap.end(); ++it ) for( auto &it: rmap )
it->second->resp_real = false; it.second->resp_real = false;
} }
} }
...@@ -205,9 +205,9 @@ void RTUExchange::poll() ...@@ -205,9 +205,9 @@ void RTUExchange::poll()
bool allNotRespond = true; bool allNotRespond = true;
ComPort::Speed s = mbrtu->getSpeed(); ComPort::Speed s = mbrtu->getSpeed();
for( MBExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 ) for( auto it1: rmap )
{ {
RTUDevice* d(it1->second); RTUDevice* d(it1.second);
if( d->mode_id != DefaultObjectId && d->mode == emSkipExchange ) if( d->mode_id != DefaultObjectId && d->mode == emSkipExchange )
continue; continue;
...@@ -251,7 +251,7 @@ void RTUExchange::poll() ...@@ -251,7 +251,7 @@ void RTUExchange::poll()
<< " regs=" << d->regmap.size() << endl; << " regs=" << d->regmap.size() << endl;
d->resp_real = false; d->resp_real = false;
for( RTUExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it ) for( auto it=d->regmap.begin(); it!=d->regmap.end(); ++it )
{ {
try try
{ {
...@@ -292,12 +292,12 @@ void RTUExchange::poll() ...@@ -292,12 +292,12 @@ void RTUExchange::poll()
updateSM(); updateSM();
// check thresholds // check thresholds
for( MBExchange::ThresholdList::iterator t=thrlist.begin(); t!=thrlist.end(); ++t ) for( auto &t: thrlist )
{ {
if( !checkProcActive() ) if( !checkProcActive() )
return; return;
IOBase::processingThreshold(&(*t),shm,force); IOBase::processingThreshold(&t,shm,force);
} }
if( trReopen.hi(allNotRespond) ) if( trReopen.hi(allNotRespond) )
...@@ -343,7 +343,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -343,7 +343,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
if( !MBExchange::initDeviceInfo(m,a,it) ) if( !MBExchange::initDeviceInfo(m,a,it) )
return false; return false;
RTUDeviceMap::iterator d = m.find(a); auto d = m.find(a);
if( d == m.end() ) if( d == m.end() )
{ {
dwarn << myname << "(initDeviceInfo): not found device for addr=" << ModbusRTU::addr2str(a) << endl; dwarn << myname << "(initDeviceInfo): not found device for addr=" << ModbusRTU::addr2str(a) << endl;
......
...@@ -455,8 +455,8 @@ void MBSlave::execute_rtu() ...@@ -455,8 +455,8 @@ void MBSlave::execute_rtu()
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it ) for( auto &it: iomap )
IOBase::processingThreshold(&it->second,shm,force); IOBase::processingThreshold(&it.second,shm,force);
} }
catch(...){} catch(...){}
} }
...@@ -536,8 +536,8 @@ void MBSlave::execute_tcp() ...@@ -536,8 +536,8 @@ void MBSlave::execute_tcp()
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it ) for( auto &it: iomap )
IOBase::processingThreshold(&it->second,shm,force); IOBase::processingThreshold(&it.second,shm,force);
} }
catch(...){} catch(...){}
} }
...@@ -644,10 +644,10 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -644,10 +644,10 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
if( force ) if( force )
return; return;
IOMap::iterator it=iomap.begin();
for( ; it!=iomap.end(); ++it ) for( auto &it: iomap )
{ {
IOProperty* p(&it->second); IOProperty* p(&it.second);
try try
{ {
shm->askSensor(p->si.id,cmd); shm->askSensor(p->si.id,cmd);
...@@ -662,8 +662,7 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -662,8 +662,7 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void MBSlave::sensorInfo( const UniSetTypes::SensorMessage* sm ) void MBSlave::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
IOMap::iterator it=iomap.begin(); for( auto it=iomap.begin(); it!=iomap.end(); ++it )
for( ; it!=iomap.end(); ++it )
{ {
if( it->second.si.id == sm->id ) if( it->second.si.id == sm->id )
{ {
...@@ -832,7 +831,7 @@ bool MBSlave::initItem( UniXML_iterator& it ) ...@@ -832,7 +831,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
} }
p.vtype = v; p.vtype = v;
p.wnum = 0; p.wnum = 0;
for( unsigned int i=0; i<VTypes::wsize(p.vtype); i++ ) for( auto i=0; i<VTypes::wsize(p.vtype); i++ )
{ {
p.mbreg += i; p.mbreg += i;
p.wnum+= i; p.wnum+= i;
...@@ -846,7 +845,7 @@ bool MBSlave::initItem( UniXML_iterator& it ) ...@@ -846,7 +845,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void MBSlave::initIterators() void MBSlave::initIterators()
{ {
IOMap::iterator it=iomap.begin(); auto it=iomap.begin();
for( ; it!=iomap.end(); ++it ) for( ; it!=iomap.end(); ++it )
shm->initIterator(it->second.ioit); shm->initIterator(it->second.ioit);
...@@ -989,7 +988,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( ModbusRTU::ModbusData reg, Modbus ...@@ -989,7 +988,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( ModbusRTU::ModbusData reg, Modbus
int i=0; int i=0;
IOMap::iterator it = iomap.end(); auto it = iomap.end();
for( ; i<count; i++ ) for( ; i<count; i++ )
{ {
it = iomap.find(reg+i); it = iomap.find(reg+i);
...@@ -1022,7 +1021,7 @@ ModbusRTU::mbErrCode MBSlave::real_write( ModbusRTU::ModbusData reg, ModbusRTU:: ...@@ -1022,7 +1021,7 @@ ModbusRTU::mbErrCode MBSlave::real_write( ModbusRTU::ModbusData reg, ModbusRTU::
<< " data=" << ModbusRTU::dat2str(mbval) << " data=" << ModbusRTU::dat2str(mbval)
<< "(" << (int)mbval << ")" << endl; << "(" << (int)mbval << ")" << endl;
IOMap::iterator it = iomap.find(reg); auto it = iomap.find(reg);
return real_write_it(it,mbval); return real_write_it(it,mbval);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -1149,7 +1148,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR ...@@ -1149,7 +1148,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
dinfo << myname << "(much_real_read): read mbID=" dinfo << myname << "(much_real_read): read mbID="
<< ModbusRTU::dat2str(reg) << " count=" << count << endl; << ModbusRTU::dat2str(reg) << " count=" << count << endl;
IOMap::iterator it = iomap.end(); auto it = iomap.end();
int i=0; int i=0;
for( ; i<count; i++ ) for( ; i<count; i++ )
{ {
...@@ -1195,7 +1194,7 @@ ModbusRTU::mbErrCode MBSlave::real_read( ModbusRTU::ModbusData reg, ModbusRTU::M ...@@ -1195,7 +1194,7 @@ ModbusRTU::mbErrCode MBSlave::real_read( ModbusRTU::ModbusData reg, ModbusRTU::M
dinfo << myname << "(real_read): read mbID=" dinfo << myname << "(real_read): read mbID="
<< ModbusRTU::dat2str(reg) << endl; << ModbusRTU::dat2str(reg) << endl;
IOMap::iterator it = iomap.find(reg); auto it = iomap.find(reg);
return real_read_it(it,val); return real_read_it(it,val);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -1353,7 +1352,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -1353,7 +1352,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
{ {
dinfo << myname << "(fileTransfer): " << query << endl; dinfo << myname << "(fileTransfer): " << query << endl;
FileList::iterator it = flist.find(query.numfile); auto it = flist.find(query.numfile);
if( it == flist.end() ) if( it == flist.end() )
return ModbusRTU::erBadDataValue; return ModbusRTU::erBadDataValue;
...@@ -1361,7 +1360,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -1361,7 +1360,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
return ModbusServer::replyFileTransfer( fname,query,reply,&dlog ); return ModbusServer::replyFileTransfer( fname,query,reply,&dlog );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusRTU::mbErrCode MBSlave::readCoilStatus( ReadCoilMessage& query, ModbusRTU::mbErrCode MBSlave::readCoilStatus( ReadCoilMessage& query,
ReadCoilRetMessage& reply ) ReadCoilRetMessage& reply )
{ {
// cout << "(readInputStatus): " << query << endl; // cout << "(readInputStatus): " << query << endl;
...@@ -1396,7 +1395,7 @@ ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query, ...@@ -1396,7 +1395,7 @@ ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query,
while( i<query.count ) while( i<query.count )
{ {
reply.addData(0); reply.addData(0);
for( unsigned int nbit=0; nbit<BitsPerByte && i<query.count; nbit++,i++ ) for( auto nbit=0; nbit<BitsPerByte && i<query.count; nbit++,i++ )
reply.setBit(bnum,nbit,buf[i]); reply.setBit(bnum,nbit,buf[i]);
bnum++; bnum++;
} }
...@@ -1440,7 +1439,7 @@ ModbusRTU::mbErrCode MBSlave::forceMultipleCoils( ModbusRTU::ForceCoilsMessage& ...@@ -1440,7 +1439,7 @@ ModbusRTU::mbErrCode MBSlave::forceMultipleCoils( ModbusRTU::ForceCoilsMessage&
for( unsigned int i = 0; i<query.bcnt; i++ ) for( unsigned int i = 0; i<query.bcnt; i++ )
{ {
ModbusRTU::DataBits b(query.data[i]); ModbusRTU::DataBits b(query.data[i]);
for( unsigned int k=0; k<ModbusRTU::BitsPerByte && nbit<query.quant; k++, nbit++ ) for( auto k=0; k<ModbusRTU::BitsPerByte && nbit<query.quant; k++, nbit++ )
{ {
// ModbusRTU::mbErrCode ret = // ModbusRTU::mbErrCode ret =
real_write(query.start+nbit, (b[k] ? 1 : 0) ); real_write(query.start+nbit, (b[k] ? 1 : 0) );
...@@ -1518,18 +1517,18 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query, ...@@ -1518,18 +1517,18 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query,
// if( query.devID <= rdevMinNum || query.devID >= rdevMaxNum ) // if( query.devID <= rdevMinNum || query.devID >= rdevMaxNum )
// return erOperationFailed; // return erOperationFailed;
MEIDevIDMap::iterator dit = meidev.find(query.devID); auto dit = meidev.find(query.devID);
if( dit == meidev.end() ) if( dit == meidev.end() )
return ModbusRTU::erBadDataAddress; return ModbusRTU::erBadDataAddress;
MEIObjIDMap::iterator oit = dit->second.find(query.objID); auto oit = dit->second.find(query.objID);
if( oit == dit->second.end() ) if( oit == dit->second.end() )
return ModbusRTU::erBadDataAddress; return ModbusRTU::erBadDataAddress;
reply.mf = 0xFF; reply.mf = 0xFF;
reply.conformity = query.devID; reply.conformity = query.devID;
for( MEIValMap::iterator i=oit->second.begin(); i!=oit->second.end(); ++i ) for( const auto &i: oit->second )
reply.addData( i->first, i->second ); reply.addData( i.first, i.second );
return erNoError; return erNoError;
} }
......
...@@ -166,11 +166,11 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -166,11 +166,11 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
char** argv = new char*[ argc ]; char** argv = new char*[ argc ];
int k=0; int k=0;
for( std::list<std::string>::iterator i=dslist.begin(); i!=dslist.end(); ++i,k++ ) for( auto &i: dslist )
argv[k] = strdup(i->c_str()); argv[k++] = strdup(i.c_str());
for( std::list<std::string>::iterator i=rralist.begin(); i!=rralist.end(); ++i,k++ ) for( auto &i: rralist )
argv[k] = strdup(i->c_str()); argv[k++] = strdup(i.c_str());
// for( k=0; k<argc; k++ ) // for( k=0; k<argc; k++ )
// cout << "*** argv[" << k << "]='" << argv[k] << "'" << endl; // cout << "*** argv[" << k << "]='" << argv[k] << "'" << endl;
...@@ -257,13 +257,13 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -257,13 +257,13 @@ void RRDServer::askSensors( UniversalIO::UIOCommand cmd )
{ {
UObject_SK::askSensors(cmd); UObject_SK::askSensors(cmd);
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it ) for( auto &it: rrdlist )
{ {
for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s ) for( auto &s: it.dsmap )
{ {
try try
{ {
shm->askSensor(s->first,cmd); shm->askSensor(s.first,cmd);
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
...@@ -278,11 +278,11 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -278,11 +278,11 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm )
UObject_SK::sysCommand(sm); UObject_SK::sysCommand(sm);
if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog ) if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog )
{ {
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it ) for( auto &it: rrdlist )
{ {
try try
{ {
askTimer(it->tid,it->sec*1000); askTimer(it.tid,it.sec*1000);
} }
catch( std::exception& ex ) catch( std::exception& ex )
{ {
...@@ -294,10 +294,10 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -294,10 +294,10 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RRDServer::sensorInfo( const UniSetTypes::SensorMessage* sm ) void RRDServer::sensorInfo( const UniSetTypes::SensorMessage* sm )
{ {
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it ) for( auto &it: rrdlist )
{ {
DSMap::iterator s = it->dsmap.find(sm->id); auto s = it.dsmap.find(sm->id);
if( s!=it->dsmap.end() ) if( s!=it.dsmap.end() )
s->second.value = sm->value; s->second.value = sm->value;
// продолжаем искать по другим rrd, т.к. датчик может входить в несколько.. // продолжаем искать по другим rrd, т.к. датчик может входить в несколько..
...@@ -306,25 +306,25 @@ void RRDServer::sensorInfo( const UniSetTypes::SensorMessage* sm ) ...@@ -306,25 +306,25 @@ void RRDServer::sensorInfo( const UniSetTypes::SensorMessage* sm )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm ) void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it ) for( auto &it: rrdlist )
{ {
if( it->tid == tm->id ) if( it.tid == tm->id )
{ {
ostringstream v; ostringstream v;
v << time(0); v << time(0);
for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s ) for( auto &s: it.dsmap )
v << ":" << s->second.value; v << ":" << s.second.value;
myinfo << myname << "(update): '" << it->filename << "' " << v.str() << endl; myinfo << myname << "(update): '" << it.filename << "' " << v.str() << endl;
rrd_clear_error(); rrd_clear_error();
const char* argv = v.str().c_str(); const char* argv = v.str().c_str();
if( rrd_update_r(it->filename.c_str(),NULL,1,&argv) < 0 ) if( rrd_update_r(it.filename.c_str(),NULL,1,&argv) < 0 )
{ {
ostringstream err; ostringstream err;
err << myname << "(update): Can`t update RRD ('" << it->filename << "'): err: " << string(rrd_get_error()); err << myname << "(update): Can`t update RRD ('" << it.filename << "'): err: " << string(rrd_get_error());
mycrit << err.str() << endl; mycrit << err.str() << endl;
} }
......
...@@ -56,7 +56,7 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -56,7 +56,7 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
// ---------------------- // ----------------------
buildHistoryList(cnode); buildHistoryList(cnode);
signal_change_value().connect(sigc::mem_fun(*this, &SharedMemory::updateHistory)); signal_change_value().connect(sigc::mem_fun(*this, &SharedMemory::updateHistory));
for( History::iterator i=hist.begin(); i!=hist.end(); ++i ) for( auto i=hist.begin(); i!=hist.end(); ++i )
histmap[i->fuse_id].push_back(i); histmap[i->fuse_id].push_back(i);
// ---------------------- // ----------------------
restorer = NULL; restorer = NULL;
...@@ -239,17 +239,17 @@ bool SharedMemory::activateObject() ...@@ -239,17 +239,17 @@ bool SharedMemory::activateObject()
res = IONotifyController_LT::activateObject(); res = IONotifyController_LT::activateObject();
// инициализируем указатели // инициализируем указатели
for( HeartBeatList::iterator it=hlist.begin(); it!=hlist.end(); ++it ) for( auto &it: hlist )
{ {
it->ioit = myioEnd(); it.ioit = myioEnd();
} }
itPulsar = myioEnd(); itPulsar = myioEnd();
for( History::iterator it=hist.begin(); it!=hist.end(); ++it ) for( auto &it: hist )
{ {
for( HistoryList::iterator hit=it->hlst.begin(); hit!=it->hlst.end(); ++hit ) for( auto& hit: it.hlst )
hit->ioit = myioEnd(); hit.ioit = myioEnd();
} }
activated = 1; activated = 1;
...@@ -283,36 +283,36 @@ void SharedMemory::checkHeartBeat() ...@@ -283,36 +283,36 @@ void SharedMemory::checkHeartBeat()
bool wdtpingOK = true; bool wdtpingOK = true;
for( HeartBeatList::iterator it=hlist.begin(); it!=hlist.end(); ++it ) for( auto &it: hlist )
{ {
try try
{ {
long val = localGetValue(it->ioit,it->a_sid); long val = localGetValue(it.ioit,it.a_sid);
val --; val --;
if( val < -1 ) if( val < -1 )
val = -1; val = -1;
localSetValue(it->ioit,it->a_sid,val,getId()); localSetValue(it.ioit,it.a_sid,val,getId());
localSetValue(it->ioit,it->d_sid,( val >= 0 ? true:false),getId()); localSetValue(it.ioit,it.d_sid,( val >= 0 ? true:false),getId());
// проверяем нужна ли "перезагрузка" по данному датчику // проверяем нужна ли "перезагрузка" по данному датчику
if( wdt && it->ptReboot.getInterval() ) if( wdt && it.ptReboot.getInterval() )
{ {
if( val > 0 ) if( val > 0 )
it->timer_running = false; it.timer_running = false;
else else
{ {
if( !it->timer_running ) if( !it.timer_running )
{ {
it->timer_running = true; it.timer_running = true;
it->ptReboot.setTiming(it->reboot_msec); it.ptReboot.setTiming(it.reboot_msec);
} }
else if( it->ptReboot.checkTime() ) else if( it.ptReboot.checkTime() )
wdtpingOK = false; wdtpingOK = false;
} }
} }
} }
catch(Exception& ex) catch( Exception& ex )
{ {
dcrit << myname << "(checkHeartBeat): " << ex << endl; dcrit << myname << "(checkHeartBeat): " << ex << endl;
} }
...@@ -328,11 +328,11 @@ void SharedMemory::checkHeartBeat() ...@@ -328,11 +328,11 @@ void SharedMemory::checkHeartBeat()
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool SharedMemory::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool SharedMemory::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
for( ReadSlotList::iterator r=lstRSlot.begin(); r!=lstRSlot.end(); ++r ) for( auto &r: lstRSlot )
{ {
try try
{ {
(*r)(xml,it,sec); (r)(xml,it,sec);
} }
catch(...){} catch(...){}
} }
...@@ -476,14 +476,14 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm ) ...@@ -476,14 +476,14 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm )
{ {
TransportMessage tm(sm.transport_msg()); TransportMessage tm(sm.transport_msg());
for( EventList::iterator it=elst.begin(); it!=elst.end(); ++it ) for( auto &it: elst )
{ {
bool ok = false; bool ok = false;
for( unsigned int i=0; i<2; i++ ) for( unsigned int i=0; i<2; i++ )
{ {
try try
{ {
ui.send((*it),tm); ui.send(it,tm);
ok = true; ok = true;
break; break;
} }
...@@ -491,7 +491,7 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm ) ...@@ -491,7 +491,7 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm )
} }
if(!ok) if(!ok)
dcrit << myname << "(sendEvent): Объект " << (*it) << " НЕДОСТУПЕН" << endl; dcrit << myname << "(sendEvent): Объект " << it << " НЕДОСТУПЕН" << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -591,9 +591,9 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -591,9 +591,9 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SharedMemory::checkHistoryFilter( UniXML_iterator& xit ) void SharedMemory::checkHistoryFilter( UniXML_iterator& xit )
{ {
for( History::iterator it=hist.begin(); it!=hist.end(); ++it ) for( auto &it: hist )
{ {
if( xit.getProp(it->filter).empty() ) if( xit.getProp(it.filter).empty() )
continue; continue;
HistoryItem ai; HistoryItem ai;
...@@ -601,8 +601,8 @@ void SharedMemory::checkHistoryFilter( UniXML_iterator& xit ) ...@@ -601,8 +601,8 @@ void SharedMemory::checkHistoryFilter( UniXML_iterator& xit )
if( !xit.getProp("id").empty() ) if( !xit.getProp("id").empty() )
{ {
ai.id = xit.getIntProp("id"); ai.id = xit.getIntProp("id");
ai.init( it->size, xit.getIntProp("default") ); ai.init( it.size, xit.getIntProp("default") );
it->hlst.push_back(ai); it.hlst.push_back(ai);
continue; continue;
} }
...@@ -613,8 +613,8 @@ void SharedMemory::checkHistoryFilter( UniXML_iterator& xit ) ...@@ -613,8 +613,8 @@ void SharedMemory::checkHistoryFilter( UniXML_iterator& xit )
continue; continue;
} }
ai.init( it->size, xit.getIntProp("default") ); ai.init( it.size, xit.getIntProp("default") );
it->hlst.push_back(ai); it.hlst.push_back(ai);
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -630,18 +630,18 @@ void SharedMemory::saveHistory() ...@@ -630,18 +630,18 @@ void SharedMemory::saveHistory()
// if( dlog.is_info() ) // if( dlog.is_info() )
// dlog.info() << myname << "(saveHistory): ..." << endl; // dlog.info() << myname << "(saveHistory): ..." << endl;
for( History::iterator it=hist.begin(); it!=hist.end(); ++it ) for( auto &it: hist )
{ {
for( HistoryList::iterator hit=it->hlst.begin(); hit!=it->hlst.end(); ++hit ) for( auto &hit: it.hlst )
{ {
if( hit->ioit != myioEnd() ) if( hit.ioit != myioEnd() )
hit->add( localGetValue( hit->ioit, hit->ioit->second.si.id ), it->size ); hit.add( localGetValue( hit.ioit, hit.ioit->second.si.id ), it.size );
else else
{ {
try try
{ {
hit->add( localGetValue( hit->ioit, hit->id ), it->size ); hit.add( localGetValue( hit.ioit, hit.id ), it.size );
continue; continue;
} }
catch(...){} catch(...){}
...@@ -655,7 +655,7 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* ) ...@@ -655,7 +655,7 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* )
if( hist.empty() ) if( hist.empty() )
return; return;
HistoryFuseMap::iterator i = histmap.find(s_it->second.si.id); auto i = histmap.find(s_it->second.si.id);
if( i == histmap.end() ) if( i == histmap.end() )
return; return;
...@@ -674,9 +674,9 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* ) ...@@ -674,9 +674,9 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* )
<< " value=" << value << " value=" << value
<< endl; << endl;
for( HistoryItList::iterator it1=i->second.begin(); it1!=i->second.end(); ++it1 ) for( auto &it1: i->second )
{ {
History::iterator it( (*it1) ); History::iterator it = it1;
if( s_it->second.type == UniversalIO::DI || if( s_it->second.type == UniversalIO::DI ||
s_it->second.type == UniversalIO::DO ) s_it->second.type == UniversalIO::DO )
......
...@@ -337,12 +337,12 @@ sender2(0) ...@@ -337,12 +337,12 @@ sender2(0)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UNetExchange::~UNetExchange() UNetExchange::~UNetExchange()
{ {
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
{ {
if( it->r1 ) if( it.r1 )
delete it->r1; delete it.r1;
if( it->r2 ) if( it.r2 )
delete it->r2; delete it.r2;
} }
delete sender; delete sender;
...@@ -353,9 +353,9 @@ UNetExchange::~UNetExchange() ...@@ -353,9 +353,9 @@ UNetExchange::~UNetExchange()
bool UNetExchange::checkExistUNetHost( const std::string& addr, ost::tpport_t port ) bool UNetExchange::checkExistUNetHost( const std::string& addr, ost::tpport_t port )
{ {
ost::IPV4Address a1(addr.c_str()); ost::IPV4Address a1(addr.c_str());
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
{ {
if( it->r1->getAddress() == a1.getAddress() && it->r1->getPort() == port ) if( it.r1->getAddress() == a1.getAddress() && it.r1->getPort() == port )
return true; return true;
} }
...@@ -364,12 +364,12 @@ bool UNetExchange::checkExistUNetHost( const std::string& addr, ost::tpport_t po ...@@ -364,12 +364,12 @@ bool UNetExchange::checkExistUNetHost( const std::string& addr, ost::tpport_t po
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetExchange::startReceivers() void UNetExchange::startReceivers()
{ {
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
{ {
if( it->r1 ) if( it.r1 )
it->r1->start(); it.r1->start();
if( it->r2 ) if( it.r2 )
it->r2->start(); it.r2->start();
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -418,8 +418,8 @@ void UNetExchange::step() ...@@ -418,8 +418,8 @@ void UNetExchange::step()
} }
} }
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
it->step(shm, myname); it.step(shm, myname);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -590,18 +590,18 @@ void UNetExchange::sigterm( int signo ) ...@@ -590,18 +590,18 @@ void UNetExchange::sigterm( int signo )
{ {
dinfo << myname << ": ********* SIGTERM(" << signo <<") ********" << endl; dinfo << myname << ": ********* SIGTERM(" << signo <<") ********" << endl;
activated = 0; activated = 0;
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
{ {
try try
{ {
if( it->r1 ) if( it.r1 )
it->r1->stop(); it.r1->stop();
} }
catch(...){} catch(...){}
try try
{ {
if( it->r2 ) if( it.r2 )
it->r2->stop(); it.r2->stop();
} }
catch(...){} catch(...){}
} }
...@@ -630,8 +630,8 @@ void UNetExchange::initIterators() ...@@ -630,8 +630,8 @@ void UNetExchange::initIterators()
if( sender2 ) if( sender2 )
sender2->initIterators(); sender2->initIterators();
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
it->initIterators(shm); it.initIterators(shm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetExchange::help_print( int argc, const char* argv[] ) void UNetExchange::help_print( int argc, const char* argv[] )
...@@ -682,31 +682,31 @@ void UNetExchange::receiverEvent( UNetReceiver* r, UNetReceiver::Event ev ) ...@@ -682,31 +682,31 @@ void UNetExchange::receiverEvent( UNetReceiver* r, UNetReceiver::Event ev )
if( ev != UNetReceiver::evTimeout ) if( ev != UNetReceiver::evTimeout )
return; return;
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( auto &it: recvlist )
{ {
if( it->r1 == r ) if( it.r1 == r )
{ {
// если нет второго канала // если нет второго канала
// то и переключать некуда // то и переключать некуда
if( !it->r2 ) if( !it.r2 )
return; return;
// пропала связь по первому каналу... // пропала связь по первому каналу...
// переключаемся на второй // переключаемся на второй
it->r1->setLockUpdate(true); it.r1->setLockUpdate(true);
it->r2->setLockUpdate(false); it.r2->setLockUpdate(false);
dinfo << myname << "(event): " << r->getName() dinfo << myname << "(event): " << r->getName()
<< ": timeout for channel1.. select channel 2" << endl; << ": timeout for channel1.. select channel 2" << endl;
return; return;
} }
if( it->r2 == r ) if( it.r2 == r )
{ {
// пропала связь по второму каналу... // пропала связь по второму каналу...
// переключаемся на первый // переключаемся на первый
it->r1->setLockUpdate(false); it.r1->setLockUpdate(false);
it->r2->setLockUpdate(true); it.r2->setLockUpdate(true);
dinfo << myname << "(event): " << r->getName() dinfo << myname << "(event): " << r->getName()
<< ": timeout for channel2.. select channel 1" << endl; << ": timeout for channel2.. select channel 1" << endl;
......
...@@ -490,11 +490,11 @@ bool UNetReceiver::recv() ...@@ -490,11 +490,11 @@ bool UNetReceiver::recv()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::initIterators() void UNetReceiver::initIterators()
{ {
for( ItemVec::iterator it=d_icache.begin(); it!=d_icache.end(); ++it ) for( auto &it: d_icache )
shm->initIterator(it->ioit); shm->initIterator(it.ioit);
for( ItemVec::iterator it=a_icache.begin(); it!=a_icache.end(); ++it ) for( auto &it: a_icache )
shm->initIterator(it->ioit); shm->initIterator(it.ioit);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
......
...@@ -84,7 +84,7 @@ UNetSender::~UNetSender() ...@@ -84,7 +84,7 @@ UNetSender::~UNetSender()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::updateFromSM() void UNetSender::updateFromSM()
{ {
DMap::iterator it=dlist.begin(); auto it=dlist.begin();
for( ; it!=dlist.end(); ++it ) for( ; it!=dlist.end(); ++it )
{ {
long value = shm->localGetValue(it->ioit,it->id); long value = shm->localGetValue(it->ioit,it->id);
...@@ -98,7 +98,7 @@ void UNetSender::updateSensor( UniSetTypes::ObjectId id, long value ) ...@@ -98,7 +98,7 @@ void UNetSender::updateSensor( UniSetTypes::ObjectId id, long value )
return; return;
// cerr << myname << ": UPDATE SENSOR id=" << id << " value=" << value << endl; // cerr << myname << ": UPDATE SENSOR id=" << id << " value=" << value << endl;
DMap::iterator it=dlist.begin(); auto it=dlist.begin();
for( ; it!=dlist.end(); ++it ) for( ; it!=dlist.end(); ++it )
{ {
if( it->id == id ) if( it->id == id )
...@@ -318,14 +318,14 @@ std::ostream& operator<<( std::ostream& os, UNetSender::UItem& p ) ...@@ -318,14 +318,14 @@ std::ostream& operator<<( std::ostream& os, UNetSender::UItem& p )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::initIterators() void UNetSender::initIterators()
{ {
DMap::iterator it=dlist.begin(); auto it=dlist.begin();
for( ; it!=dlist.end(); ++it ) for( ; it!=dlist.end(); ++it )
shm->initIterator(it->ioit); shm->initIterator(it->ioit);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::askSensors( UniversalIO::UIOCommand cmd ) void UNetSender::askSensors( UniversalIO::UIOCommand cmd )
{ {
DMap::iterator it=dlist.begin(); auto it=dlist.begin();
for( ; it!=dlist.end(); ++it ) for( ; it!=dlist.end(); ++it )
shm->askSensor(it->id,cmd); shm->askSensor(it->id,cmd);
} }
......
...@@ -145,18 +145,18 @@ void UniExchange::execute() ...@@ -145,18 +145,18 @@ void UniExchange::execute()
while(1) while(1)
{ {
for( NetNodeList::iterator it=nlst.begin(); it!=nlst.end(); ++it ) for( auto &it: nlst )
{ {
bool ok = false; bool ok = false;
try try
{ {
dinfo << myname << ": connect to id=" << it->id << " node=" << it->node << endl; dinfo << myname << ": connect to id=" << it.id << " node=" << it.node << endl;
IOController_i::ShortMapSeq_var sseq = ui.getSensors( it->id, it->node ); IOController_i::ShortMapSeq_var sseq = ui.getSensors( it.id, it.node );
ok = true; ok = true;
dinfo << myname << " update sensors from id=" << it->id << " node=" << it->node << endl; dinfo << myname << " update sensors from id=" << it.id << " node=" << it.node << endl;
it->update(sseq,shm); it.update(sseq,shm);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
...@@ -167,22 +167,22 @@ void UniExchange::execute() ...@@ -167,22 +167,22 @@ void UniExchange::execute()
dwarn << myname << "(execute): catch ..." << endl; dwarn << myname << "(execute): catch ..." << endl;
} }
if( it->sidConnection != DefaultObjectId ) if( it.sidConnection != DefaultObjectId )
{ {
try try
{ {
shm->localSetValue(it->conn_it,it->sidConnection,ok,getId()); shm->localSetValue(it.conn_it,it.sidConnection,ok,getId());
} }
catch(...) catch(...)
{ {
dcrit << myname << "(execute): sensor not avalible " dcrit << myname << "(execute): sensor not avalible "
<< conf->oind->getNameById( it->sidConnection) << conf->oind->getNameById(it.sidConnection)
<< endl; << endl;
} }
} }
if( !ok ) if( !ok )
dinfo << myname << ": ****** cannot connect with node=" << it->node << endl; dinfo << myname << ": ****** cannot connect with node=" << it.node << endl;
} }
if( ptUpdate.checkTime() ) if( ptUpdate.checkTime() )
...@@ -249,14 +249,14 @@ IOController_i::ShortMapSeq* UniExchange::getSensors() ...@@ -249,14 +249,14 @@ IOController_i::ShortMapSeq* UniExchange::getSensors()
res->length( mymap.size() ); res->length( mymap.size() );
int i=0; int i=0;
for( SList::iterator it=mymap.begin(); it!=mymap.end(); ++it ) for( auto &it: mymap )
{ {
IOController_i::ShortMap m; IOController_i::ShortMap m;
{ {
uniset_rwmutex_rlock lock(it->val_lock); uniset_rwmutex_rlock lock(it.val_lock);
m.id = it->id; m.id = it.id;
m.value = it->val; m.value = it.val;
m.type = it->type; m.type = it.type;
} }
(*res)[i++] = m; (*res)[i++] = m;
} }
...@@ -266,12 +266,12 @@ IOController_i::ShortMapSeq* UniExchange::getSensors() ...@@ -266,12 +266,12 @@ IOController_i::ShortMapSeq* UniExchange::getSensors()
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void UniExchange::updateLocalData() void UniExchange::updateLocalData()
{ {
for( SList::iterator it=mymap.begin(); it!=mymap.end(); ++it ) for( auto &it: mymap )
{ {
try try
{ {
uniset_rwmutex_wrlock lock(it->val_lock); uniset_rwmutex_wrlock lock(it.val_lock);
it->val = shm->localGetValue( it->ioit, it->id ); it.val = shm->localGetValue( it.ioit, it.id );
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
...@@ -288,8 +288,8 @@ void UniExchange::updateLocalData() ...@@ -288,8 +288,8 @@ void UniExchange::updateLocalData()
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void UniExchange::initIterators() void UniExchange::initIterators()
{ {
for( SList::iterator it=mymap.begin(); it!=mymap.end(); ++it ) for( auto &it: mymap )
shm->initIterator(it->ioit); shm->initIterator(it.ioit);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void UniExchange::askSensors( UniversalIO::UIOCommand cmd ) void UniExchange::askSensors( UniversalIO::UIOCommand cmd )
......
...@@ -219,8 +219,8 @@ void Calibration::build( const string& name, const string& confile, xmlNode* roo ...@@ -219,8 +219,8 @@ void Calibration::build( const string& name, const string& confile, xmlNode* roo
std::sort(pvec.begin(),pvec.end()); std::sort(pvec.begin(),pvec.end());
PartsVec::iterator beg = pvec.begin(); auto beg = pvec.begin();
PartsVec::iterator end = pvec.end(); auto end = pvec.end();
if( pvec.size() > 0 ) if( pvec.size() > 0 )
{ {
...@@ -248,7 +248,7 @@ static Calibration::PartsVec::iterator find_range( long raw, Calibration::PartsV ...@@ -248,7 +248,7 @@ static Calibration::PartsVec::iterator find_range( long raw, Calibration::PartsV
if( end->checkX(raw) ) if( end->checkX(raw) )
return end; return end;
Calibration::PartsVec::iterator it = beg + std::distance(beg,end)/2; auto it = beg + std::distance(beg,end)/2;
if( raw < it->left_x() ) if( raw < it->left_x() )
return find_range(raw,beg,it); return find_range(raw,beg,it);
...@@ -271,16 +271,16 @@ long Calibration::getValue( long raw, bool crop_raw ) ...@@ -271,16 +271,16 @@ long Calibration::getValue( long raw, bool crop_raw )
if( szCache ) // > 0 if( szCache ) // > 0
{ {
for( ValueCache::iterator c=cache.begin(); c!=cache.end(); ++c ) for( auto &c: cache )
{ {
if( c->raw == raw ) if( c.raw == raw )
{ {
--numCallToCache; --numCallToCache;
c->cnt++; c.cnt++;
if( numCallToCache ) if( numCallToCache )
return c->val; return c.val;
long val = c->val; // после сортировки итератор станет недействительным, поэтому запоминаем.. long val = c.val; // после сортировки итератор станет недействительным, поэтому запоминаем..
sort(cache.begin(),cache.end()); sort(cache.begin(),cache.end());
numCallToCache = numCacheResort; numCallToCache = numCacheResort;
return val; return val;
...@@ -288,7 +288,7 @@ long Calibration::getValue( long raw, bool crop_raw ) ...@@ -288,7 +288,7 @@ long Calibration::getValue( long raw, bool crop_raw )
} }
} }
PartsVec::iterator fit = find_range(raw, pvec.begin(), pvec.end()); auto fit = find_range(raw, pvec.begin(), pvec.end());
if( fit == pvec.end() ) if( fit == pvec.end() )
{ {
...@@ -333,9 +333,9 @@ void Calibration::insertToCache( const long raw, const long val ) ...@@ -333,9 +333,9 @@ void Calibration::insertToCache( const long raw, const long val )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
long Calibration::getRawValue( long cal, bool range ) long Calibration::getRawValue( long cal, bool range )
{ {
for( PartsVec::iterator it=pvec.begin(); it!=pvec.end(); ++it ) for( auto &it: pvec )
{ {
TypeOfValue q = it->getX(cal); TypeOfValue q = it.getX(cal);
if( q != outOfRange ) if( q != outOfRange )
return tRound(q); return tRound(q);
} }
...@@ -355,10 +355,10 @@ long Calibration::getRawValue( long cal, bool range ) ...@@ -355,10 +355,10 @@ long Calibration::getRawValue( long cal, bool range )
std::ostream& operator<<( std::ostream& os, Calibration& c ) std::ostream& operator<<( std::ostream& os, Calibration& c )
{ {
os << "*******************" << endl; os << "*******************" << endl;
for( Calibration::PartsVec::iterator it=c.pvec.begin(); it!=c.pvec.end(); ++it ) for( auto &it: c.pvec )
{ {
os << "[" << it->leftPoint().x << " : " << it->rightPoint().x << " ] --> [" os << "[" << it.leftPoint().x << " : " << it.rightPoint().x << " ] --> ["
<< it->leftPoint().y << " : " << it->rightPoint().y << " ]" << it.leftPoint().y << " : " << it.rightPoint().y << " ]"
<< endl; << endl;
} }
os << "*******************" << endl; os << "*******************" << endl;
...@@ -368,10 +368,10 @@ std::ostream& operator<<( std::ostream& os, Calibration& c ) ...@@ -368,10 +368,10 @@ std::ostream& operator<<( std::ostream& os, Calibration& c )
std::ostream& operator<<( std::ostream& os, Calibration* c ) std::ostream& operator<<( std::ostream& os, Calibration* c )
{ {
os << "*******************" << endl; os << "*******************" << endl;
for( Calibration::PartsVec::iterator it=c->pvec.begin(); it!=c->pvec.end(); ++it ) for( auto &it: c->pvec )
{ {
os << "[" << it->leftPoint().x << " : " << it->rightPoint().x << " ] --> [" os << "[" << it.leftPoint().x << " : " << it.rightPoint().x << " ] --> ["
<< it->leftPoint().y << " : " << it->rightPoint().y << " ]" << it.leftPoint().y << " : " << it.rightPoint().y << " ]"
<< endl; << endl;
} }
os << "*******************" << endl; os << "*******************" << endl;
......
...@@ -54,7 +54,7 @@ void DigitalFilter::setSettings( unsigned int bufsize, double T, double lsq, ...@@ -54,7 +54,7 @@ void DigitalFilter::setSettings( unsigned int bufsize, double T, double lsq,
{ {
// удаляем лишние (первые) элементы // удаляем лишние (первые) элементы
int sub = buf.size() - maxsize; int sub = buf.size() - maxsize;
for( unsigned int i=0; i<sub; i++ ) for( int i=0; i<sub; i++ )
buf.pop_front(); buf.pop_front();
} }
buf.resize(maxsize); buf.resize(maxsize);
...@@ -82,17 +82,17 @@ double DigitalFilter::firstLevel() ...@@ -82,17 +82,17 @@ double DigitalFilter::firstLevel()
{ {
// считаем среднее арифметическое // считаем среднее арифметическое
M=0; M=0;
for( FIFOBuffer::iterator i=buf.begin(); i!=buf.end(); ++i ) for( auto &i: buf )
M = M + (*i); M = M + i;
M = M/buf.size(); M = M/buf.size();
// считаем среднеквадратичное отклонение // считаем среднеквадратичное отклонение
S=0; S=0;
double r=0; double r=0;
for( FIFOBuffer::iterator i=buf.begin(); i!=buf.end(); ++i ) for( auto &i: buf )
{ {
r = M-(*i); r = M - i;
S = S + r*r; S = S + r*r;
} }
...@@ -105,12 +105,12 @@ double DigitalFilter::firstLevel() ...@@ -105,12 +105,12 @@ double DigitalFilter::firstLevel()
// Находим среднее арифметическое без учета элементов, отклонение которых вдвое превышает среднеквадратичное // Находим среднее арифметическое без учета элементов, отклонение которых вдвое превышает среднеквадратичное
int n = 0; int n = 0;
double val = 0; // Конечное среднее значение double val = 0; // Конечное среднее значение
for( FIFOBuffer::iterator i=buf.begin(); i!=buf.end(); ++i ) for( auto &i: buf )
{ {
if( fabs(M-(*i)) > S*2 ) if( fabs(M-i) > S*2 )
{ {
val = val + (*i); val += i;
n = n + 1; n++;
} }
} }
...@@ -182,10 +182,10 @@ int DigitalFilter::currentRC() ...@@ -182,10 +182,10 @@ int DigitalFilter::currentRC()
std::ostream& operator<<(std::ostream& os, const DigitalFilter& d ) std::ostream& operator<<(std::ostream& os, const DigitalFilter& d )
{ {
os << "(" << d.buf.size() << ")["; os << "(" << d.buf.size() << ")[";
for( DigitalFilter::FIFOBuffer::const_iterator i=d.buf.begin(); i!=d.buf.end(); ++i )
{ for( auto &i: d.buf )
os << " " << setw(5) << (*i); os << " " << setw(5) << i;
}
os << " ]"; os << " ]";
return os; return os;
} }
...@@ -202,14 +202,7 @@ int DigitalFilter::median( int newval ) ...@@ -202,14 +202,7 @@ int DigitalFilter::median( int newval )
add(newval); add(newval);
// FIFOBuffer::iterator it = buf.begin();
// for( unsigned int i=0; i<maxsize && it!=buf.end(); i++,it++ )
// mvec[i] = (*it);
// copy(buf.begin(),buf.end(),mvec.begin());
mvec.assign(buf.begin(),buf.end()); mvec.assign(buf.begin(),buf.end());
sort(mvec.begin(),mvec.end()); sort(mvec.begin(),mvec.end());
return mvec[maxsize/2]; return mvec[maxsize/2];
...@@ -227,7 +220,7 @@ int DigitalFilter::leastsqr( int newval ) ...@@ -227,7 +220,7 @@ int DigitalFilter::leastsqr( int newval )
add(newval); add(newval);
// Цифровая фильтрация // Цифровая фильтрация
FIFOBuffer::const_iterator it = buf.begin(); auto it = buf.begin();
for( unsigned int i=0; i<maxsize; i++,it++ ) for( unsigned int i=0; i<maxsize; i++,it++ )
ls += *it * w[i]; ls += *it * w[i];
...@@ -258,11 +251,12 @@ int DigitalFilter::filterIIR( int newval ) ...@@ -258,11 +251,12 @@ int DigitalFilter::filterIIR( int newval )
} }
else else
{ {
double aver=0; double aver = 0;
add(newval); add(newval);
for( FIFOBuffer::iterator i = buf.begin(); i != buf.end(); ++i ) for( auto &i: buf )
aver += *i; aver += i;
aver /= maxsize; aver /= maxsize;
prev = lroundf((coeff_prev * prev + coeff_new * aver)/(coeff_prev + coeff_new)); prev = lroundf((coeff_prev * prev + coeff_new * aver)/(coeff_prev + coeff_new));
} }
......
...@@ -379,7 +379,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, ...@@ -379,7 +379,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
return false; return false;
} }
for( DataMap::iterator it=dmap.begin(); it!=dmap.end(); ++it ) for( auto it=dmap.begin(); it!=dmap.end(); ++it )
{ {
// ModbusRTU::WriteOutputMessage msg(addr,it->first); // ModbusRTU::WriteOutputMessage msg(addr,it->first);
// cout << "send reg=" << ModbusRTU::dat2str(it->first) // cout << "send reg=" << ModbusRTU::dat2str(it->first)
...@@ -387,7 +387,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, ...@@ -387,7 +387,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
int reg = it->first; int reg = it->first;
// bool ok = false; // bool ok = false;
for( DataList::iterator it1=it->second.begin(); it1!=it->second.end(); ++it1, reg++ ) for( auto it1=it->second.begin(); it1!=it->second.end(); ++it1, reg++ )
{ {
const ModbusRTU::ModbusData *last = skip + sizeof(skip)/sizeof(skip[0]); const ModbusRTU::ModbusData *last = skip + sizeof(skip)/sizeof(skip[0]);
if( std::find(skip, last, reg) != last) if( std::find(skip, last, reg) != last)
......
SUBDIR=SMemoryTest SUBDIR=SMemoryTest
noinst_PROGRAMS = calibration noinst_PROGRAMS = calibration digitalfilter
calibration_SOURCES = calibration.cc calibration_SOURCES = calibration.cc
calibration_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la calibration_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
calibration_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include calibration_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include
digitalfilter_SOURCES = digitalfilter.cc
digitalfilter_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
digitalfilter_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include
...@@ -103,8 +103,8 @@ void TestProc::timerInfo( const TimerMessage *tm ) ...@@ -103,8 +103,8 @@ void TestProc::timerInfo( const TimerMessage *tm )
cerr << endl; cerr << endl;
cerr << "======= TEST LOG PRINT ======" << endl; cerr << "======= TEST LOG PRINT ======" << endl;
cerr << "LOGLEVEL: [" << (int)(*lit) << "] " << (*lit) << endl; cerr << "LOGLEVEL: [" << (int)(*lit) << "] " << (*lit) << endl;
for( std::vector<Debug::type>::iterator it=loglevels.begin(); it!=loglevels.end(); ++it ) for( auto &it: loglevels )
mylog[*it] << myname << ": test log print..." << endl; mylog[it] << myname << ": test log print..." << endl;
cerr << "======= END LOG PRINT ======" << endl; cerr << "======= END LOG PRINT ======" << endl;
} }
......
...@@ -68,11 +68,11 @@ int main( int argc, const char** argv ) ...@@ -68,11 +68,11 @@ int main( int argc, const char** argv )
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
cerr << "(unetexchange): " << ex << std::endl; cerr << "(main): " << ex << std::endl;
} }
catch(...) catch(...)
{ {
cerr << "(unetexchange): catch ..." << std::endl; cerr << "(main): catch ..." << std::endl;
} }
return 1; return 1;
......
#include <iostream>
#include <vector>
#include <iomanip>
#include "Exceptions.h"
#include "Extensions.h"
#include "DigitalFilter.h"
using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
int main( int argc, const char** argv )
{
try
{
DigitalFilter df;
DigitalFilter df_m;
vector<long> dat={0,234,356,344,234,320,250,250,250,250,250,250,250,251,252,251,252,252,250};
for( auto v: dat )
{
df.add(v);
cout << "[" << setw(4) << v << "]: "
<< " filter1: " << setw(4) << df.current1()
<< " filterRC: " << setw(4) << df.currentRC()
<< " median: " << setw(4) << df_m.median(v)
<< endl;
}
return 0;
}
catch( Exception& ex )
{
cerr << "(main): " << ex << std::endl;
}
catch(...)
{
cerr << "(main): catch ..." << std::endl;
}
return 1;
}
...@@ -2575,7 +2575,7 @@ ModbusMessage MEIMessageRetRDI::transport_msg() ...@@ -2575,7 +2575,7 @@ ModbusMessage MEIMessageRetRDI::transport_msg()
mm.data[5] = objNum; mm.data[5] = objNum;
int ind = 6; int ind = 6;
for( RDIObjectList::iterator it = dlist.begin(); it!=dlist.end() && ind <= MAXLENPACKET; ++it ) for( auto it = dlist.begin(); it!=dlist.end() && ind <= MAXLENPACKET; ++it )
{ {
mm.data[ind++] = it->id; mm.data[ind++] = it->id;
int dlen = it->val.size(); // !! не копируем завершающий символ int dlen = it->val.size(); // !! не копируем завершающий символ
...@@ -2617,8 +2617,8 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, MEIMessageRetRDI& m ) ...@@ -2617,8 +2617,8 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, MEIMessageRetRDI& m )
if( !m.dlist.empty() ) if( !m.dlist.empty() )
{ {
os << endl; os << endl;
for( RDIObjectList::iterator it=m.dlist.begin(); it!=m.dlist.end(); ++it ) for( auto &it: m.dlist )
os << " " << rdi2str(it->id) << " : " << it->val << endl; os << " " << rdi2str(it.id) << " : " << it.val << endl;
} }
return os; return os;
...@@ -2633,8 +2633,8 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os,RDIObjectList& dlist ) ...@@ -2633,8 +2633,8 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os,RDIObjectList& dlist )
{ {
if( !dlist.empty() ) if( !dlist.empty() )
{ {
for( RDIObjectList::iterator it=dlist.begin(); it!=dlist.end(); ++it ) for( auto &it: dlist )
os << " " << rdi2str(it->id) << " : " << it->val << endl; os << " " << rdi2str(it.id) << " : " << it.val << endl;
} }
return os; return os;
......
...@@ -1032,7 +1032,7 @@ ObjectPtr UInterface::CacheOfResolve::resolve( const ObjectId id, const ObjectId ...@@ -1032,7 +1032,7 @@ ObjectPtr UInterface::CacheOfResolve::resolve( const ObjectId id, const ObjectId
{ {
UniSetTypes::uniset_rwmutex_rlock l(cmutex); UniSetTypes::uniset_rwmutex_rlock l(cmutex);
CacheMap::iterator it = mcache.find( key(id,node) ); auto it = mcache.find( key(id,node) );
if( it == mcache.end() ) if( it == mcache.end() )
throw UniSetTypes::NameNotFound(); throw UniSetTypes::NameNotFound();
...@@ -1054,7 +1054,7 @@ void UInterface::CacheOfResolve::cache( const ObjectId id, const ObjectId node, ...@@ -1054,7 +1054,7 @@ void UInterface::CacheOfResolve::cache( const ObjectId id, const ObjectId node,
UniSetTypes::KeyType k( key(id,node) ); UniSetTypes::KeyType k( key(id,node) );
CacheMap::iterator it = mcache.find(k); auto it = mcache.find(k);
if( it == mcache.end() ) if( it == mcache.end() )
mcache.insert(CacheMap::value_type(k,Info(ptr))); mcache.insert(CacheMap::value_type(k,Info(ptr)));
else else
...@@ -1070,7 +1070,7 @@ bool UInterface::CacheOfResolve::clean() ...@@ -1070,7 +1070,7 @@ bool UInterface::CacheOfResolve::clean()
uinfo << "UI: clean cache...."<< endl; uinfo << "UI: clean cache...."<< endl;
for( CacheMap::iterator it=mcache.begin(); it!=mcache.end();) for( auto it=mcache.begin(); it!=mcache.end();)
{ {
if( it->second.ncall <= minCallCount ) if( it->second.ncall <= minCallCount )
mcache.erase(it++); mcache.erase(it++);
...@@ -1088,7 +1088,7 @@ bool UInterface::CacheOfResolve::clean() ...@@ -1088,7 +1088,7 @@ bool UInterface::CacheOfResolve::clean()
void UInterface::CacheOfResolve::erase( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const void UInterface::CacheOfResolve::erase( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{ {
UniSetTypes::uniset_rwmutex_wrlock l(cmutex); UniSetTypes::uniset_rwmutex_wrlock l(cmutex);
CacheMap::iterator it = mcache.find( key(id,node) ); auto it = mcache.find( key(id,node) );
if( it != mcache.end() ) if( it != mcache.end() )
mcache.erase(it); mcache.erase(it);
} }
......
...@@ -53,7 +53,7 @@ ObjectIndex_Array::ObjectIndex_Array( const ObjectInfo *objectInfo ): ...@@ -53,7 +53,7 @@ ObjectIndex_Array::ObjectIndex_Array( const ObjectInfo *objectInfo ):
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_Array::getIdByName( const string& name ) ObjectId ObjectIndex_Array::getIdByName( const string& name )
{ {
MapObjectKey::iterator it = mok.find(name); auto it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return it->second; return it->second;
...@@ -119,7 +119,7 @@ const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id ) ...@@ -119,7 +119,7 @@ const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_Array::getObjectInfo( const std::string& name ) const ObjectInfo* ObjectIndex_Array::getObjectInfo( const std::string& name )
{ {
MapObjectKey::iterator it = mok.find(name); auto it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return &(objectInfo[it->second]); return &(objectInfo[it->second]);
......
...@@ -52,7 +52,7 @@ ObjectIndex_XML::~ObjectIndex_XML() ...@@ -52,7 +52,7 @@ ObjectIndex_XML::~ObjectIndex_XML()
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_XML::getIdByName( const string& name ) ObjectId ObjectIndex_XML::getIdByName( const string& name )
{ {
MapObjectKey::iterator it = mok.find(name); auto it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return it->second; return it->second;
...@@ -83,7 +83,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi ) ...@@ -83,7 +83,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi )
std::ostream& ObjectIndex_XML::printMap( std::ostream& os ) std::ostream& ObjectIndex_XML::printMap( std::ostream& os )
{ {
cout << "size: " << omap.size() << endl; cout << "size: " << omap.size() << endl;
for( vector<ObjectInfo>::iterator it=omap.begin(); it!=omap.end(); ++it ) for( auto it=omap.begin(); it!=omap.end(); ++it )
{ {
if( it->repName == NULL ) if( it->repName == NULL )
continue; continue;
...@@ -282,7 +282,7 @@ const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id ) ...@@ -282,7 +282,7 @@ const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const std::string& name ) const ObjectInfo* ObjectIndex_XML::getObjectInfo( const std::string& name )
{ {
MapObjectKey::iterator it = mok.find(name); auto it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return &(omap[it->second]); return &(omap[it->second]);
......
...@@ -30,7 +30,7 @@ ObjectIndex_idXML::~ObjectIndex_idXML() ...@@ -30,7 +30,7 @@ ObjectIndex_idXML::~ObjectIndex_idXML()
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_idXML::getIdByName( const string& name ) ObjectId ObjectIndex_idXML::getIdByName( const string& name )
{ {
MapObjectKey::iterator it = mok.find(name); auto it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return it->second; return it->second;
...@@ -39,7 +39,7 @@ ObjectId ObjectIndex_idXML::getIdByName( const string& name ) ...@@ -39,7 +39,7 @@ ObjectId ObjectIndex_idXML::getIdByName( const string& name )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex_idXML::getMapName( const ObjectId id ) string ObjectIndex_idXML::getMapName( const ObjectId id )
{ {
MapObjects::iterator it = omap.find(id); auto it = omap.find(id);
if( it!=omap.end() ) if( it!=omap.end() )
return it->second.repName; return it->second.repName;
...@@ -48,7 +48,7 @@ string ObjectIndex_idXML::getMapName( const ObjectId id ) ...@@ -48,7 +48,7 @@ string ObjectIndex_idXML::getMapName( const ObjectId id )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex_idXML::getTextName( const ObjectId id ) string ObjectIndex_idXML::getTextName( const ObjectId id )
{ {
MapObjects::iterator it = omap.find(id); auto it = omap.find(id);
if( it!=omap.end() ) if( it!=omap.end() )
return it->second.textName; return it->second.textName;
...@@ -63,7 +63,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_idXML& oi ) ...@@ -63,7 +63,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_idXML& oi )
std::ostream& ObjectIndex_idXML::printMap( std::ostream& os ) std::ostream& ObjectIndex_idXML::printMap( std::ostream& os )
{ {
os << "size: " << omap.size() << endl; os << "size: " << omap.size() << endl;
for( MapObjects::iterator it=omap.begin(); it!=omap.end(); ++it ) for( auto it=omap.begin(); it!=omap.end(); ++it )
{ {
if( it->second.repName == NULL ) if( it->second.repName == NULL )
continue; continue;
...@@ -216,7 +216,7 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec ) ...@@ -216,7 +216,7 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
{ {
MapObjects::iterator it = omap.find(id); auto it = omap.find(id);
if( it!=omap.end() ) if( it!=omap.end() )
return &(it->second); return &(it->second);
...@@ -225,7 +225,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) ...@@ -225,7 +225,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name ) const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name )
{ {
MapObjectKey::iterator it = mok.find(name); auto it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return getObjectInfo(it->second); return getObjectInfo(it->second);
......
...@@ -176,11 +176,9 @@ bool ObjectRepositoryFactory::createContext(const char *cname, CosNaming::Naming ...@@ -176,11 +176,9 @@ bool ObjectRepositoryFactory::createContext(const char *cname, CosNaming::Naming
/*! /*!
\note Функция не вывести список, если не сможет получить доступ к секции \note Функция не вывести список, если не сможет получить доступ к секции
*/ */
void ObjectRepositoryFactory::printSection(const string& fullName) void ObjectRepositoryFactory::printSection( const string& fullName )
{ {
ListObjectName ls; ListObjectName ls;
ListObjectName::const_iterator li;
try try
{ {
list(fullName.c_str(),&ls); list(fullName.c_str(),&ls);
...@@ -196,12 +194,8 @@ void ObjectRepositoryFactory::printSection(const string& fullName) ...@@ -196,12 +194,8 @@ void ObjectRepositoryFactory::printSection(const string& fullName)
cout << fullName << "(" << ls.size() <<"):" << endl; cout << fullName << "(" << ls.size() <<"):" << endl;
for( li=ls.begin();li!=ls.end();++li ) for( auto v: ls )
{ cout << v << endl;
string ob(*li);
cout << ob << endl;
}
} }
// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------
......
...@@ -54,14 +54,14 @@ void ProxyManager::attachObject( PassiveObject* po, UniSetTypes::ObjectId id ) ...@@ -54,14 +54,14 @@ void ProxyManager::attachObject( PassiveObject* po, UniSetTypes::ObjectId id )
return; return;
} }
PObjectMap::iterator it = omap.find(id); auto it = omap.find(id);
if( it==omap.end() ) if( it==omap.end() )
omap.insert(PObjectMap::value_type(id,po)); omap.insert(PObjectMap::value_type(id,po));
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ProxyManager::detachObject( UniSetTypes::ObjectId id ) void ProxyManager::detachObject( UniSetTypes::ObjectId id )
{ {
PObjectMap::iterator it = omap.find(id); auto it = omap.find(id);
if( it!=omap.end() ) if( it!=omap.end() )
omap.erase(it); omap.erase(it);
} }
...@@ -73,7 +73,7 @@ bool ProxyManager::activateObject() ...@@ -73,7 +73,7 @@ bool ProxyManager::activateObject()
return false; return false;
// Регистрируемся от имени объектов // Регистрируемся от имени объектов
for( PObjectMap::const_iterator it=omap.begin();it!=omap.end();++it ) for( auto &it: omap )
{ {
try try
{ {
...@@ -82,11 +82,11 @@ bool ProxyManager::activateObject() ...@@ -82,11 +82,11 @@ bool ProxyManager::activateObject()
try try
{ {
uinfo << myname << "(registered): попытка " uinfo << myname << "(registered): попытка "
<< i+1 << " регистриую (id=" << it->first << ") " << i+1 << " регистриую (id=" << it.first << ") "
<< " (pname=" << it->second->getName() << ") " << " (pname=" << it.second->getName() << ") "
<< conf->oind->getNameById(it->first) << endl; << conf->oind->getNameById(it.first) << endl;
ui.registered(it->first, getRef(),true); ui.registered(it.first, getRef(),true);
break; break;
} }
catch( UniSetTypes::ObjectNameAlready& ex ) catch( UniSetTypes::ObjectNameAlready& ex )
...@@ -94,7 +94,7 @@ bool ProxyManager::activateObject() ...@@ -94,7 +94,7 @@ bool ProxyManager::activateObject()
ucrit << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl; ucrit << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl;
try try
{ {
ui.unregister(it->first); ui.unregister(it.first);
} }
catch(Exception & ex) catch(Exception & ex)
{ {
...@@ -141,7 +141,7 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg ) ...@@ -141,7 +141,7 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg )
default: default:
{ {
PObjectMap::iterator it = omap.find(msg->consumer); auto it = omap.find(msg->consumer);
if( it!=omap.end() ) if( it!=omap.end() )
it->second->processingMessage(msg); it->second->processingMessage(msg);
else else
...@@ -159,11 +159,11 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg ) ...@@ -159,11 +159,11 @@ void ProxyManager::processingMessage( UniSetTypes::VoidMessage *msg )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ProxyManager::allMessage( UniSetTypes::VoidMessage* msg ) void ProxyManager::allMessage( UniSetTypes::VoidMessage* msg )
{ {
for( PObjectMap::const_iterator it=omap.begin();it!=omap.end();++it ) for( auto &o: omap )
{ {
try try
{ {
it->second->processingMessage(msg); o.second->processingMessage(msg);
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
......
...@@ -325,8 +325,7 @@ void UniSetActivator::work() ...@@ -325,8 +325,7 @@ void UniSetActivator::work()
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetActivator::getinfo() void UniSetActivator::getinfo()
{ {
for( UniSetManagerList::const_iterator it= beginMList(); for( auto it=beginMList(); it!=endMList(); ++it )
it!= endMList(); ++it )
{ {
MInfo mi; MInfo mi;
mi.mnr = (*it); mi.mnr = (*it);
...@@ -334,8 +333,7 @@ void UniSetActivator::getinfo() ...@@ -334,8 +333,7 @@ void UniSetActivator::getinfo()
lstMInfo.push_back(mi); lstMInfo.push_back(mi);
} }
for( ObjectsList::const_iterator it= beginOList(); for( auto it=beginOList(); it!= endOList(); ++it )
it!= endOList(); ++it )
{ {
OInfo oi; OInfo oi;
oi.obj = (*it); oi.obj = (*it);
......
...@@ -149,7 +149,7 @@ bool UniSetManager::addObject( UniSetObject *obj ) ...@@ -149,7 +149,7 @@ bool UniSetManager::addObject( UniSetObject *obj )
{ {
{ //lock { //lock
uniset_rwmutex_wrlock lock(olistMutex); uniset_rwmutex_wrlock lock(olistMutex);
ObjectsList::iterator li=find(olist.begin(),olist.end(), obj); auto li=find(olist.begin(),olist.end(), obj);
if( li==olist.end() ) if( li==olist.end() )
{ {
uinfo << myname << "(activator): добавляем объект "<< obj->getName()<< endl; uinfo << myname << "(activator): добавляем объект "<< obj->getName()<< endl;
...@@ -164,7 +164,7 @@ bool UniSetManager::removeObject(UniSetObject* obj) ...@@ -164,7 +164,7 @@ bool UniSetManager::removeObject(UniSetObject* obj)
{ {
{ //lock { //lock
uniset_rwmutex_wrlock lock(olistMutex); uniset_rwmutex_wrlock lock(olistMutex);
ObjectsList::iterator li=find(olist.begin(),olist.end(), obj); auto li=find(olist.begin(),olist.end(), obj);
if( li!=olist.end() ) if( li!=olist.end() )
{ {
uinfo << myname << "(activator): удаляем объект "<< obj->getName()<< endl; uinfo << myname << "(activator): удаляем объект "<< obj->getName()<< endl;
...@@ -210,26 +210,26 @@ void UniSetManager::managers(OManagerCommand cmd) ...@@ -210,26 +210,26 @@ void UniSetManager::managers(OManagerCommand cmd)
<< mlist.size() << " cmd=" << cmd << endl; << mlist.size() << " cmd=" << cmd << endl;
{ //lock { //lock
uniset_rwmutex_rlock lock(mlistMutex); uniset_rwmutex_rlock lock(mlistMutex);
for( UniSetManagerList::iterator li=mlist.begin();li!=mlist.end();++li ) for( auto &li: mlist )
{ {
try try
{ {
switch(cmd) switch(cmd)
{ {
case initial: case initial:
(*li)->initPOA(this); li->initPOA(this);
break; break;
case activ: case activ:
(*li)->activate(); li->activate();
break; break;
case deactiv: case deactiv:
(*li)->disactivate(); li->disactivate();
break; break;
case term: case term:
(*li)->sigterm(sig); li->sigterm(sig);
break; break;
default: default:
...@@ -239,7 +239,7 @@ void UniSetManager::managers(OManagerCommand cmd) ...@@ -239,7 +239,7 @@ void UniSetManager::managers(OManagerCommand cmd)
catch( Exception& ex ) catch( Exception& ex )
{ {
ucrit << myname << "(managers): " << ex << endl ucrit << myname << "(managers): " << ex << endl
<< " Не смог зарегистрировать (разрегистрировать) объект -->"<< (*li)->getName() << endl; << " Не смог зарегистрировать (разрегистрировать) объект -->"<< li->getName() << endl;
} }
catch( CORBA::SystemException& ex ) catch( CORBA::SystemException& ex )
{ {
...@@ -270,26 +270,26 @@ void UniSetManager::objects(OManagerCommand cmd) ...@@ -270,26 +270,26 @@ void UniSetManager::objects(OManagerCommand cmd)
{ //lock { //lock
uniset_rwmutex_rlock lock(olistMutex); uniset_rwmutex_rlock lock(olistMutex);
for (ObjectsList::iterator li=olist.begin();li!=olist.end();++li) for( auto &li: olist )
{ {
try try
{ {
switch(cmd) switch(cmd)
{ {
case initial: case initial:
(*li)->init(this); li->init(this);
break; break;
case activ: case activ:
(*li)->activate(); li->activate();
break; break;
case deactiv: case deactiv:
(*li)->disactivate(); li->disactivate();
break; break;
case term: case term:
(*li)->sigterm(sig); li->sigterm(sig);
break; break;
default: default:
...@@ -299,7 +299,7 @@ void UniSetManager::objects(OManagerCommand cmd) ...@@ -299,7 +299,7 @@ void UniSetManager::objects(OManagerCommand cmd)
catch( Exception& ex ) catch( Exception& ex )
{ {
ucrit << myname << "(objects): " << ex << endl; ucrit << myname << "(objects): " << ex << endl;
ucrit << myname << "(objects): не смог зарегистрировать (разрегистрировать) объект -->"<< (*li)->getName() << endl; ucrit << myname << "(objects): не смог зарегистрировать (разрегистрировать) объект -->"<< li->getName() << endl;
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
...@@ -309,9 +309,9 @@ void UniSetManager::objects(OManagerCommand cmd) ...@@ -309,9 +309,9 @@ void UniSetManager::objects(OManagerCommand cmd)
{ {
ucrit << myname << "(objects): Caught CORBA::Exception. " ucrit << myname << "(objects): Caught CORBA::Exception. "
<< ex._name() << ex._name()
<< " (" << (*li)->getName() << ")" << endl; << " (" << li->getName() << ")" << endl;
} }
catch( omniORB::fatalException& fe ) catch( omniORB::fatalException& fe )
{ {
ucrit << myname << "(objects): Caught omniORB::fatalException:" << endl; ucrit << myname << "(objects): Caught omniORB::fatalException:" << endl;
ucrit << myname << "(objects): file: " << fe.file() ucrit << myname << "(objects): file: " << fe.file()
...@@ -382,7 +382,7 @@ bool UniSetManager::addManager( UniSetManager *child ) ...@@ -382,7 +382,7 @@ bool UniSetManager::addManager( UniSetManager *child )
uniset_rwmutex_wrlock lock(mlistMutex); uniset_rwmutex_wrlock lock(mlistMutex);
// Проверка на совпадение // Проверка на совпадение
UniSetManagerList::iterator it= find(mlist.begin(),mlist.end(),child); auto it= find(mlist.begin(),mlist.end(),child);
if(it == mlist.end() ) if(it == mlist.end() )
{ {
mlist.push_back( child ); mlist.push_back( child );
...@@ -410,15 +410,15 @@ bool UniSetManager::removeManager( UniSetManager* child ) ...@@ -410,15 +410,15 @@ bool UniSetManager::removeManager( UniSetManager* child )
const UniSetManager* UniSetManager::itemM(const ObjectId id) const UniSetManager* UniSetManager::itemM(const ObjectId id)
{ {
{ //lock { //lock
uniset_rwmutex_rlock lock(mlistMutex); uniset_rwmutex_rlock lock(mlistMutex);
for( UniSetManagerList::iterator li=mlist.begin(); li!=mlist.end();++li ) for( auto &li: mlist )
{ {
if ( (*li)->getId()==id ) if ( li->getId()==id )
return (*li); return li;
} }
} // unlock } // unlock
return 0; return 0;
} }
...@@ -429,12 +429,12 @@ const UniSetObject* UniSetManager::itemO(const ObjectId id) ...@@ -429,12 +429,12 @@ const UniSetObject* UniSetManager::itemO(const ObjectId id)
{ {
{ //lock { //lock
uniset_rwmutex_rlock lock(olistMutex); uniset_rwmutex_rlock lock(olistMutex);
for (ObjectsList::iterator li=olist.begin(); li!=olist.end();++li) for( auto &li: olist )
{ {
if ( (*li)->getId()==id ) if ( li->getId()==id )
return (*li); return li;
} }
} // unlock } // unlock
return 0; return 0;
} }
...@@ -468,8 +468,7 @@ int UniSetManager::getObjectsInfo( UniSetManager* mngr, SimpleInfoSeq* seq, ...@@ -468,8 +468,7 @@ int UniSetManager::getObjectsInfo( UniSetManager* mngr, SimpleInfoSeq* seq,
if( ind > uplimit ) if( ind > uplimit )
return ind; return ind;
for( ObjectsList::const_iterator it= mngr->beginOList(); for( auto it=mngr->beginOList(); it!=mngr->endOList(); ++it )
it!=mngr->endOList(); ++it )
{ {
try try
{ {
...@@ -494,8 +493,7 @@ int UniSetManager::getObjectsInfo( UniSetManager* mngr, SimpleInfoSeq* seq, ...@@ -494,8 +493,7 @@ int UniSetManager::getObjectsInfo( UniSetManager* mngr, SimpleInfoSeq* seq,
return ind; return ind;
// а далее у его менеджеров (рекурсивно) // а далее у его менеджеров (рекурсивно)
for( UniSetManagerList::const_iterator it=mngr->beginMList(); for( auto it=mngr->beginMList(); it!=mngr->endMList(); ++it )
it!=mngr->endMList(); ++it )
{ {
ind = getObjectsInfo((*it),seq,ind,uplimit); ind = getObjectsInfo((*it),seq,ind,uplimit);
if( ind > uplimit ) if( ind > uplimit )
......
...@@ -544,44 +544,30 @@ void UniSetObject::cleanMsgQueue( MessagesQueue& q ) ...@@ -544,44 +544,30 @@ void UniSetObject::cleanMsgQueue( MessagesQueue& q )
ucrit << myname << "(cleanMsgQueue): ******** cleanup RESULT ********" << endl; ucrit << myname << "(cleanMsgQueue): ******** cleanup RESULT ********" << endl;
for( map<UniSetTypes::ObjectId,tmpConsumerInfo>::iterator it0 = consumermap.begin(); for( auto &c: consumermap )
it0!=consumermap.end(); ++it0 )
{ {
ucrit << myname << "(cleanMsgQueue): CONSUMER=" << it0->first << endl; ucrit << myname << "(cleanMsgQueue): CONSUMER=" << c.first << endl;
ucrit << myname << "(cleanMsgQueue): after clean SensorMessage: " << it0->second.smap.size() << endl; ucrit << myname << "(cleanMsgQueue): after clean SensorMessage: " << c.second.smap.size() << endl;
ucrit << myname << "(cleanMsgQueue): after clean TimerMessage: " << it0->second.tmap.size() << endl; ucrit << myname << "(cleanMsgQueue): after clean TimerMessage: " << c.second.tmap.size() << endl;
ucrit << myname << "(cleanMsgQueue): after clean SystemMessage: " << it0->second.sysmap.size() << endl; ucrit << myname << "(cleanMsgQueue): after clean SystemMessage: " << c.second.sysmap.size() << endl;
ucrit << myname << "(cleanMsgQueue): after clean ConfirmMessage: " << it0->second.cmap.size() << endl; ucrit << myname << "(cleanMsgQueue): after clean ConfirmMessage: " << c.second.cmap.size() << endl;
ucrit << myname << "(cleanMsgQueue): after clean other: " << it0->second.lstOther.size() << endl; ucrit << myname << "(cleanMsgQueue): after clean other: " << c.second.lstOther.size() << endl;
// теперь ОСТАВШИЕСЯ запихиваем обратно в очередь... // теперь ОСТАВШИЕСЯ запихиваем обратно в очередь...
map<UniSetTypes::KeyType,VoidMessage>::iterator it=it0->second.smap.begin(); for( auto &v: c.second.smap )
for( ; it!=it0->second.smap.end(); ++it ) q.push(v.second);
{
q.push(it->second);
}
map<int,VoidMessage>::iterator it1=it0->second.tmap.begin(); for( auto &v: c.second.tmap )
for( ; it1!=it0->second.tmap.end(); ++it1 ) q.push(v.second);
{
q.push(it1->second);
}
map<int,VoidMessage>::iterator it2=it0->second.sysmap.begin(); for( auto &v: c.second.sysmap )
for( ; it2!=it0->second.sysmap.end(); ++it2 ) q.push(v.second);
{
q.push(it2->second);
}
map<CInfo,VoidMessage>::iterator it5=it0->second.cmap.begin(); for( auto &v: c.second.cmap )
for( ; it5!=it0->second.cmap.end(); ++it5 ) q.push(v.second);
{
q.push(it5->second);
}
list<VoidMessage>::iterator it6=it0->second.lstOther.begin(); for( auto &v: c.second.lstOther )
for( ; it6!=it0->second.lstOther.end(); ++it6 ) q.push(v);
q.push(*it6);
} }
ucrit << myname ucrit << myname
......
...@@ -115,7 +115,7 @@ using namespace UniSetTypes; ...@@ -115,7 +115,7 @@ using namespace UniSetTypes;
void UniSetTypes::IDList::add( ObjectId id ) void UniSetTypes::IDList::add( ObjectId id )
{ {
for( list<ObjectId>::iterator it=lst.begin(); it!=lst.end(); ++it ) for( auto it=lst.begin(); it!=lst.end(); ++it )
{ {
if( (*it) == id ) if( (*it) == id )
return; return;
...@@ -126,7 +126,7 @@ using namespace UniSetTypes; ...@@ -126,7 +126,7 @@ using namespace UniSetTypes;
void UniSetTypes::IDList::del( ObjectId id ) void UniSetTypes::IDList::del( ObjectId id )
{ {
for( list<ObjectId>::iterator it=lst.begin(); it!=lst.end(); ++it ) for( auto it=lst.begin(); it!=lst.end(); ++it )
{ {
if( (*it) == id ) if( (*it) == id )
{ {
...@@ -156,7 +156,7 @@ using namespace UniSetTypes; ...@@ -156,7 +156,7 @@ using namespace UniSetTypes;
IDSeq* seq = new IDSeq(); IDSeq* seq = new IDSeq();
seq->length(lst.size()); seq->length(lst.size());
int i=0; int i=0;
for( list<ObjectId>::iterator it=lst.begin(); it!=lst.end(); ++it,i++ ) for( auto it=lst.begin(); it!=lst.end(); ++it,i++ )
(*seq)[i] = (*it); (*seq)[i] = (*it);
return seq; return seq;
...@@ -222,9 +222,9 @@ using namespace UniSetTypes; ...@@ -222,9 +222,9 @@ using namespace UniSetTypes;
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetTypes::is_digit( const std::string& s ) bool UniSetTypes::is_digit( const std::string& s )
{ {
for( std::string::const_iterator it=s.begin(); it!=s.end(); ++it ) for( auto c: s )
{ {
if( !isdigit(*it) ) if( !isdigit(c) )
return false; return false;
} }
...@@ -236,12 +236,12 @@ using namespace UniSetTypes; ...@@ -236,12 +236,12 @@ using namespace UniSetTypes;
{ {
std::list<UniSetTypes::ParamSInfo> res; std::list<UniSetTypes::ParamSInfo> res;
std::list<std::string> l = UniSetTypes::explode_str(str,','); auto lst = UniSetTypes::explode_str(str,',');
for( std::list<std::string>::iterator it=l.begin(); it!=l.end(); ++it ) for( auto it: lst )
{ {
UniSetTypes::ParamSInfo item; UniSetTypes::ParamSInfo item;
std::list<std::string> p = UniSetTypes::explode_str((*it),'='); auto p = UniSetTypes::explode_str(it,'=');
std::string s = ""; std::string s = "";
if( p.size() == 1 ) if( p.size() == 1 )
{ {
...@@ -250,17 +250,17 @@ using namespace UniSetTypes; ...@@ -250,17 +250,17 @@ using namespace UniSetTypes;
} }
else if( p.size() == 2 ) else if( p.size() == 2 )
{ {
s = *(p.begin()); s = *(p.begin());
item.val = uni_atoi(*(++p.begin())); item.val = uni_atoi(*(++p.begin()));
} }
else else
{ {
cerr << "WARNING: parse error for '" << (*it) << "'. IGNORE..." << endl; cerr << "WARNING: parse error for '" << it << "'. IGNORE..." << endl;
continue; continue;
} }
item.fname = s; item.fname = s;
std::list<std::string> t = UniSetTypes::explode_str(s,'@'); auto t = UniSetTypes::explode_str(s,'@');
if( t.size() == 1 ) if( t.size() == 1 )
{ {
std::string s_id = *(t.begin()); std::string s_id = *(t.begin());
......
...@@ -102,7 +102,7 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo& ...@@ -102,7 +102,7 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo&
{ {
uniset_rwmutex_wrlock l(lst.mut); uniset_rwmutex_wrlock l(lst.mut);
for( ConsumerList::const_iterator it=lst.clst.begin(); it!=lst.clst.end(); ++it ) for( auto it=lst.clst.begin(); it!=lst.clst.end(); ++it )
{ {
if( it->id==ci.id && it->node==ci.node ) if( it->id==ci.id && it->node==ci.node )
return false; return false;
...@@ -128,7 +128,7 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo& ...@@ -128,7 +128,7 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo&
bool IONotifyController::removeConsumer( ConsumerListInfo& lst, const ConsumerInfo& cons ) bool IONotifyController::removeConsumer( ConsumerListInfo& lst, const ConsumerInfo& cons )
{ {
uniset_rwmutex_wrlock l(lst.mut); uniset_rwmutex_wrlock l(lst.mut);
for( ConsumerList::iterator li=lst.clst.begin();li!=lst.clst.end(); ++li ) for( auto li=lst.clst.begin();li!=lst.clst.end(); ++li )
{ {
if( li->id==cons.id && li->node==cons.node ) if( li->id==cons.id && li->node==cons.node )
{ {
...@@ -154,7 +154,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid, ...@@ -154,7 +154,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
<< conf->oind->getNameById(sid) << endl; << conf->oind->getNameById(sid) << endl;
// если такого аналогового датчика нет, здесь сработает исключение... // если такого аналогового датчика нет, здесь сработает исключение...
IOStateList::iterator li = myioEnd(); auto li = myioEnd();
localGetValue(li,sid); localGetValue(li,sid);
{ // lock { // lock
...@@ -212,7 +212,7 @@ void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid, ...@@ -212,7 +212,7 @@ void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd) const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd)
{ {
// поиск датчика в списке // поиск датчика в списке
AskMap::iterator askIterator = askLst.find(sid); auto askIterator = askLst.find(sid);
switch (cmd) switch (cmd)
{ {
...@@ -357,7 +357,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -357,7 +357,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
{ {
uniset_rwmutex_rlock lock(askIOMutex); uniset_rwmutex_rlock lock(askIOMutex);
AskMap::iterator it = askIOList.find(sid); auto it = askIOList.find(sid);
if( it!=askIOList.end() ) if( it!=askIOList.end() )
send(it->second, sm); send(it->second, sm);
} }
...@@ -380,7 +380,7 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage ...@@ -380,7 +380,7 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage
TransportMessage tmsg; TransportMessage tmsg;
uniset_rwmutex_wrlock l(lst.mut); uniset_rwmutex_wrlock l(lst.mut);
for( ConsumerList::iterator li=lst.clst.begin(); li!=lst.clst.end(); ++li ) for( auto li=lst.clst.begin(); li!=lst.clst.end(); ++li )
{ {
for( int i=0; i<2; i++ ) // на каждый объект по две поптыки for( int i=0; i<2; i++ ) // на каждый объект по две поптыки
{ {
...@@ -519,14 +519,14 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp ...@@ -519,14 +519,14 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
throw IONotifyController_i::BadRange(); throw IONotifyController_i::BadRange();
// если такого дискретного датчика нет сдесь сработает исключение... // если такого дискретного датчика нет сдесь сработает исключение...
IOStateList::iterator li = myioEnd(); auto li = myioEnd();
CORBA::Long val = localGetValue(li,sid); CORBA::Long val = localGetValue(li,sid);
{ // lock { // lock
uniset_rwmutex_wrlock lock(trshMutex); uniset_rwmutex_wrlock lock(trshMutex);
// поиск датчика в списке // поиск датчика в списке
AskThresholdMap::iterator it = askTMap.find(sid); auto it = askTMap.find(sid);
ThresholdInfoExt ti(tid,lowLimit,hiLimit,invert); ThresholdInfoExt ti(tid,lowLimit,hiLimit,invert);
ti.sit = myioEnd(); ti.sit = myioEnd();
...@@ -664,7 +664,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp ...@@ -664,7 +664,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt& ti, const UniSetTypes::ConsumerInfo& ci ) bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt& ti, const UniSetTypes::ConsumerInfo& ci )
{ {
for( ThresholdExtList::iterator it=lst.begin(); it!=lst.end(); ++it) for( auto it=lst.begin(); it!=lst.end(); ++it)
{ {
if( ti==(*it) ) if( ti==(*it) )
{ {
...@@ -694,7 +694,7 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt& ...@@ -694,7 +694,7 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
bool IONotifyController::removeThreshold( ThresholdExtList& lst, ThresholdInfoExt& ti, const UniSetTypes::ConsumerInfo& ci ) bool IONotifyController::removeThreshold( ThresholdExtList& lst, ThresholdInfoExt& ti, const UniSetTypes::ConsumerInfo& ci )
{ {
for( ThresholdExtList::iterator it=lst.begin(); it!=lst.end(); ++it) for( auto it=lst.begin(); it!=lst.end(); ++it)
{ {
if( ti == (*it) ) if( ti == (*it) )
{ {
...@@ -720,7 +720,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li, ...@@ -720,7 +720,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
bool send_msg ) bool send_msg )
{ {
// поиск списка порогов // поиск списка порогов
AskThresholdMap::iterator lst = askTMap.end(); auto lst = askTMap.end();
{ {
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
...@@ -760,7 +760,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li, ...@@ -760,7 +760,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
{ {
uniset_rwmutex_rlock l(lst->second.mut); uniset_rwmutex_rlock l(lst->second.mut);
for( ThresholdExtList::iterator it=lst->second.list.begin(); it!=lst->second.list.end(); ++it ) for( auto it=lst->second.list.begin(); it!=lst->second.list.end(); ++it )
{ {
// Используем здесь sm.value чтобы не делать ещё раз lock на li->second.value // Используем здесь sm.value чтобы не делать ещё раз lock на li->second.value
...@@ -826,11 +826,11 @@ IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold ...@@ -826,11 +826,11 @@ IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold
{ // lock { // lock
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
// поиск списка порогов // поиск списка порогов
AskThresholdMap::iterator lst = askTMap.find(sid); auto lst = askTMap.find(sid);
if( lst!=askTMap.end() ) if( lst!=askTMap.end() )
{ {
for( ThresholdExtList::iterator it=lst->second.list.begin(); it!=lst->second.list.end(); ++it) for( auto it=lst->second.list.begin(); it!=lst->second.list.end(); ++it)
{ {
if( it->id == tid ) if( it->id == tid )
return it; return it;
...@@ -845,7 +845,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet ...@@ -845,7 +845,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
{ {
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
AskThresholdMap::iterator it = askTMap.find(sid); auto it = askTMap.find(sid);
if( it == askTMap.end() ) if( it == askTMap.end() )
{ {
ostringstream err; ostringstream err;
...@@ -856,7 +856,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet ...@@ -856,7 +856,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
for( ThresholdExtList::const_iterator it2= it->second.list.begin(); it2!=it->second.list.end(); ++it2 ) for( auto it2= it->second.list.begin(); it2!=it->second.list.end(); ++it2 )
{ {
if( it2->id == tid ) if( it2->id == tid )
return IONotifyController_i::ThresholdInfo( *it2 ); return IONotifyController_i::ThresholdInfo( *it2 );
...@@ -874,7 +874,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy ...@@ -874,7 +874,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
{ {
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
AskThresholdMap::iterator it = askTMap.find(sid); auto it = askTMap.find(sid);
if( it == askTMap.end() ) if( it == askTMap.end() )
{ {
ostringstream err; ostringstream err;
...@@ -903,7 +903,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy ...@@ -903,7 +903,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
res->tlist.length( it->second.list.size() ); res->tlist.length( it->second.list.size() );
unsigned int k=0; unsigned int k=0;
for( ThresholdExtList::const_iterator it2= it->second.list.begin(); it2!=it->second.list.end(); ++it2 ) for( auto it2= it->second.list.begin(); it2!=it->second.list.end(); ++it2 )
{ {
res->tlist[k].id = it2->id; res->tlist[k].id = it2->id;
res->tlist[k].hilimit = it2->hilimit; res->tlist[k].hilimit = it2->hilimit;
...@@ -927,7 +927,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList() ...@@ -927,7 +927,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
if( !askTMap.empty() ) if( !askTMap.empty() )
{ {
unsigned int i=0; unsigned int i=0;
for( AskThresholdMap::iterator it=askTMap.begin(); it!=askTMap.end(); ++it ) for( auto it=askTMap.begin(); it!=askTMap.end(); ++it )
{ {
try try
{ {
...@@ -946,7 +946,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList() ...@@ -946,7 +946,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
(*res)[i].tlist.length( it->second.list.size() ); (*res)[i].tlist.length( it->second.list.size() );
unsigned int k=0; unsigned int k=0;
for( ThresholdExtList::const_iterator it2= it->second.list.begin(); it2!=it->second.list.end(); ++it2 ) for( auto it2=it->second.list.begin(); it2!=it->second.list.end(); ++it2 )
{ {
(*res)[i].tlist[k].id = it2->id; (*res)[i].tlist[k].id = it2->id;
(*res)[i].tlist[k].hilimit = it2->hilimit; (*res)[i].tlist[k].hilimit = it2->hilimit;
...@@ -993,7 +993,7 @@ void IONotifyController::onChangeUndefinedState( IOStateList::iterator& lit, IOC ...@@ -993,7 +993,7 @@ void IONotifyController::onChangeUndefinedState( IOStateList::iterator& lit, IOC
{ // lock { // lock
uniset_rwmutex_rlock lock(askIOMutex); uniset_rwmutex_rlock lock(askIOMutex);
AskMap::iterator it1 = askIOList.find(it.si.id); auto it1 = askIOList.find(it.si.id);
if( it1!=askIOList.end() ) if( it1!=askIOList.end() )
send(it1->second, sm); send(it1->second, sm);
} // unlock } // unlock
......
...@@ -117,8 +117,8 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC ...@@ -117,8 +117,8 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC
} }
// default init iterators // default init iterators
for( IONotifyController::ThresholdExtList::iterator it=lst.begin(); it!=lst.end(); ++it ) for( auto &it: lst )
it->sit = ic->myioEnd(); it.sit = ic->myioEnd();
ic->askTMap[inf.si.id].si = inf.si; ic->askTMap[inf.si.id].si = inf.si;
ic->askTMap[inf.si.id].type = inf.type; ic->askTMap[inf.si.id].type = inf.type;
...@@ -146,7 +146,7 @@ NCRestorer::SInfo& NCRestorer::SInfo::operator=( IOController_i::SensorIOInfo& i ...@@ -146,7 +146,7 @@ NCRestorer::SInfo& NCRestorer::SInfo::operator=( IOController_i::SensorIOInfo& i
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer::init_depends_signals( IONotifyController* ic ) void NCRestorer::init_depends_signals( IONotifyController* ic )
{ {
for( IOController::IOStateList::iterator it=ic->ioList.begin(); it!=ic->ioList.end(); ++it ) for( auto it=ic->ioList.begin(); it!=ic->ioList.end(); ++it )
{ {
// обновляем итераторы... // обновляем итераторы...
it->second.it = it; it->second.it = it;
......
...@@ -284,22 +284,22 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -284,22 +284,22 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
new_argv[i] = strdup(argv[i]); new_argv[i] = strdup(argv[i]);
// формируем новые, используя i в качестве индекса // формируем новые, используя i в качестве индекса
for( UniSetTypes::ListOfNode::iterator it=lnodes.begin(); it!=lnodes.end(); ++it ) for( auto &it: lnodes )
{ {
new_argv[i] = "-ORBInitRef"; new_argv[i] = "-ORBInitRef";
string name(oind->getNodeName(it->id)); string name(oind->getNodeName(it.id));
ostringstream param; ostringstream param;
param << this << name; param << this << name;
name = param.str(); name = param.str();
param << "=corbaname::" << it->host << ":" << it->port; param << "=corbaname::" << it.host << ":" << it.port;
new_argv[i+1] = strdup(param.str().c_str()); new_argv[i+1] = strdup(param.str().c_str());
uinfo << "(Configuration): внесли параметр " << param.str() << endl; uinfo << "(Configuration): внесли параметр " << param.str() << endl;
i+=2; i+=2;
ostringstream uri; ostringstream uri;
uri << "corbaname::" << it->host << ":" << it->port; uri << "corbaname::" << it.host << ":" << it.port;
if( !omni::omniInitialReferences::setFromArgs(name.c_str(), uri.str().c_str()) ) if( !omni::omniInitialReferences::setFromArgs(name.c_str(), uri.str().c_str()) )
cerr << "**********************!!!! FAILED ADD name=" << name << " uri=" << uri.str() << endl; cerr << "**********************!!!! FAILED ADD name=" << name << " uri=" << uri.str() << endl;
......
...@@ -74,7 +74,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -74,7 +74,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
{ // lock { // lock
uniset_rwmutex_wrlock lock(lstMutex); uniset_rwmutex_wrlock lock(lstMutex);
sleepTime = UniSetTimer::WaitUpTime; sleepTime = UniSetTimer::WaitUpTime;
for( TimersList::iterator li=tlst.begin(); li!=tlst.end(); ++li ) for( auto li=tlst.begin(); li!=tlst.end(); ++li )
{ {
if( li->tmr.checkTime() ) if( li->tmr.checkTime() )
{ {
...@@ -138,7 +138,7 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -138,7 +138,7 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
// поищем а может уж такой есть // поищем а может уж такой есть
if( !tlst.empty() ) if( !tlst.empty() )
{ {
for( TimersList::iterator li=tlst.begin(); li!=tlst.end(); ++li ) for( auto li=tlst.begin(); li!=tlst.end(); ++li )
{ {
if( li->id == timerid ) if( li->id == timerid )
{ {
......
...@@ -46,15 +46,15 @@ void SMonitor::sysCommand( const SystemMessage *sm ) ...@@ -46,15 +46,15 @@ void SMonitor::sysCommand( const SystemMessage *sm )
{ {
case SystemMessage::StartUp: case SystemMessage::StartUp:
{ {
for( MyIDList::iterator it=lst.begin(); it!=lst.end(); it++ ) for( auto &it: lst )
{ {
if( it->si.node == DefaultObjectId ) if( it.si.node == DefaultObjectId )
it->si.node = conf->getLocalNode(); it.si.node = conf->getLocalNode();
try try
{ {
if( it->si.id != DefaultObjectId ) if( it.si.id != DefaultObjectId )
ui.askRemoteSensor(it->si.id,UniversalIO::UIONotify,it->si.node); ui.askRemoteSensor(it.si.id,UniversalIO::UIONotify,it.si.node);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
......
...@@ -30,7 +30,7 @@ ui_CPPFLAGS = -I$(top_builddir)/include ...@@ -30,7 +30,7 @@ ui_CPPFLAGS = -I$(top_builddir)/include
umutex_SOURCES = umutex.cc umutex_SOURCES = umutex.cc
umutex_LDADD = $(top_builddir)/lib/libUniSet2.la $(COMCPP_LIBS) umutex_LDADD = $(top_builddir)/lib/libUniSet2.la $(COMCPP_LIBS)
umutex_CPPFLAGS = -I$(top_builddir)/include $(COMCPP_CFLAGS) umutex_CPPFLAGS = -S -O2 -I$(top_builddir)/include $(COMCPP_CFLAGS)
conftest_SOURCES = conftest.cc conftest_SOURCES = conftest.cc
conftest_LDADD = $(top_builddir)/lib/libUniSet2.la conftest_LDADD = $(top_builddir)/lib/libUniSet2.la
......
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