Commit b9012840 authored by Pavel Vainerman's avatar Pavel Vainerman

Перенёс оптимизацию для ObjectIndex_idXML.h из 2.0, очень уж актуально.

parent d85c3ef9
...@@ -68,7 +68,7 @@ interface IOController_i : UniSetManager_i ...@@ -68,7 +68,7 @@ interface IOController_i : UniSetManager_i
// установка неопределённого состояния // установка неопределённого состояния
// (пока работает только для аналоговых датчиков) // (пока работает только для аналоговых датчиков)
void setUndefinedState(in UniSetTypes::ObjectId sid, in boolean undefined, in UniSetTypes::ObjectId sup_id ) void setUndefinedState(in UniSetTypes::ObjectId sid, in boolean undefined, in UniSetTypes::ObjectId sup_id )
raises(NameNotFound); raises(NameNotFound);
// fast version (не вырабатывает исключения) // fast version (не вырабатывает исключения)
...@@ -101,8 +101,8 @@ interface IOController_i : UniSetManager_i ...@@ -101,8 +101,8 @@ interface IOController_i : UniSetManager_i
boolean undefined; /*!< признак неопределённости значения */ boolean undefined; /*!< признак неопределённости значения */
boolean blocked; /*!< данное значение блокировано другим */ boolean blocked; /*!< данное значение блокировано другим */
long real_value; /*!< запомненное состояние, до блокировки */ long real_value; /*!< запомненное состояние, до блокировки */
UniversalIO::IOType type; /*!< тип */ UniversalIO::IOType type; /*!< тип */
long priority; /*!< приоритет уведомления */ long priority; /*!< приоритет уведомления */
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
long default_val; /*!< значение по умолчанию */ long default_val; /*!< значение по умолчанию */
CalibrateInfo ci; /*!< калибровочные параметры */ CalibrateInfo ci; /*!< калибровочные параметры */
......
...@@ -32,4 +32,4 @@ Version 2.0 ...@@ -32,4 +32,4 @@ Version 2.0
- отказаться от alias-ов.. (не прижилось, а накладные расходы большие) - отказаться от alias-ов.. (не прижилось, а накладные расходы большие)
- сделать ли ObjectId short? В связи с отказом от alias, нужна ли пара (id,node) - сделать ли ObjectId short? В связи с отказом от alias, нужна ли пара (id,node)
- "продумать" функцию key()... может наложить ограничение на диапазон id.. - "продумать" функцию key()... может наложить ограничение на диапазон id..
...@@ -81,8 +81,8 @@ int main( int argc, const char** argv ) ...@@ -81,8 +81,8 @@ int main( int argc, const char** argv )
obj.mylog.logFile( logname.c_str() ); obj.mylog.logFile( logname.c_str() );
</xsl:if> </xsl:if>
UniSetActivator* act = UniSetActivator::Instance(); UniSetActivator* act = UniSetActivator::Instance();
act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj)); act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj));
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
......
...@@ -334,7 +334,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -334,7 +334,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%changelog %changelog
* Thu Jan 30 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.3 * Thu Jan 30 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt0.3
- optimization: avoiding the use of 'alias mechanism' - optimization: avoiding the use of 'alias mechanism'
('objectid@virtualnode:realnode' ==> 'objectid') ('objectid@virtualnode:realnode' ==> 'objectid')
- add ObjectActivator::Instance function (singlton pattern) - add ObjectActivator::Instance function (singlton pattern)
- minor fixes - minor fixes
......
...@@ -173,7 +173,7 @@ IONotifyController_i::ThresholdsListSeq* SMInterface::getThresholdsList() ...@@ -173,7 +173,7 @@ IONotifyController_i::ThresholdsListSeq* SMInterface::getThresholdsList()
{ {
BEG_FUNC1(SMInterface::getThresholdsList) BEG_FUNC1(SMInterface::getThresholdsList)
return ic->getThresholdsList(); return ic->getThresholdsList();
END_FUNC(SMInterface::getThresholdsList) END_FUNC(SMInterface::getThresholdsList)
} }
BEG_FUNC(SMInterface::getThresholdsList) BEG_FUNC(SMInterface::getThresholdsList)
......
...@@ -59,7 +59,7 @@ class IOController: ...@@ -59,7 +59,7 @@ class IOController:
UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId );
// ---------------------------------------------------------------- // ----------------------------------------------------------------
virtual void setUndefinedState( UniSetTypes::ObjectId sid, virtual void setUndefinedState( UniSetTypes::ObjectId sid,
CORBA::Boolean undefined, CORBA::Boolean undefined,
UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId );
...@@ -74,13 +74,13 @@ class IOController: ...@@ -74,13 +74,13 @@ class IOController:
virtual IOController_i::SensorIOInfo getSensorIOInfo( UniSetTypes::ObjectId sid ); virtual IOController_i::SensorIOInfo getSensorIOInfo( UniSetTypes::ObjectId sid );
virtual CORBA::Long getRawValue(UniSetTypes::ObjectId sid); virtual CORBA::Long getRawValue(UniSetTypes::ObjectId sid);
virtual void calibrate(UniSetTypes::ObjectId sid, virtual void calibrate(UniSetTypes::ObjectId sid,
const IOController_i::CalibrateInfo& ci, const IOController_i::CalibrateInfo& ci,
UniSetTypes::ObjectId adminId ); UniSetTypes::ObjectId adminId );
IOController_i::CalibrateInfo getCalibrateInfo( UniSetTypes::ObjectId sid ); IOController_i::CalibrateInfo getCalibrateInfo( UniSetTypes::ObjectId sid );
inline IOController_i::SensorInfo SensorInfo( const UniSetTypes::ObjectId sid, inline IOController_i::SensorInfo SensorInfo( const UniSetTypes::ObjectId sid,
const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode()) const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode())
{ {
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
......
...@@ -139,7 +139,7 @@ class IONotifyController: ...@@ -139,7 +139,7 @@ class IONotifyController:
virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::ObjectType("IONotifyController"); } virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::ObjectType("IONotifyController"); }
virtual void askSensor(const UniSetTypes::ObjectId sid, const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd); virtual void askSensor(const UniSetTypes::ObjectId sid, const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd);
virtual void askThreshold(const UniSetTypes::ObjectId sid, const UniSetTypes::ConsumerInfo& ci, virtual void askThreshold(const UniSetTypes::ObjectId sid, const UniSetTypes::ConsumerInfo& ci,
UniSetTypes::ThresholdId tid, UniSetTypes::ThresholdId tid,
CORBA::Long lowLimit, CORBA::Long hiLimit, CORBA::Boolean invert, CORBA::Long lowLimit, CORBA::Long hiLimit, CORBA::Boolean invert,
UniversalIO::UIOCommand cmd ); UniversalIO::UIOCommand cmd );
......
...@@ -28,7 +28,7 @@ class ObjectIndex_idXML: ...@@ -28,7 +28,7 @@ class ObjectIndex_idXML:
virtual void build( UniXML& xml ); virtual void build( UniXML& xml );
void read_section( UniXML& xml, const std::string& sec ); void read_section( UniXML& xml, const std::string& sec );
void read_nodes( UniXML& xml, const std::string& sec ); void read_nodes( UniXML& xml, const std::string& sec );
private: private:
typedef std::map<UniSetTypes::ObjectId, UniSetTypes::ObjectInfo> MapObjects; typedef std::map<UniSetTypes::ObjectId, UniSetTypes::ObjectInfo> MapObjects;
MapObjects omap; MapObjects omap;
......
...@@ -115,7 +115,7 @@ void UInterface::initBackId( const UniSetTypes::ObjectId backid ) ...@@ -115,7 +115,7 @@ void UInterface::initBackId( const UniSetTypes::ObjectId backid )
* \exception IOBadParam - генерируется если указано неправильное имя датчика или секции * \exception IOBadParam - генерируется если указано неправильное имя датчика или секции
* \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ * \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ
*/ */
long UInterface::getValue( const ObjectId id, const ObjectId node ) const long UInterface::getValue( const ObjectId id, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( id == DefaultObjectId ) if ( id == DefaultObjectId )
...@@ -1157,7 +1157,7 @@ string UInterface::set_err( const std::string& pre, const ObjectId id, const Obj ...@@ -1157,7 +1157,7 @@ string UInterface::set_err( const std::string& pre, const ObjectId id, const Obj
nm = "UnknownName"; nm = "UnknownName";
ostringstream s; ostringstream s;
s << pre << " (" << id << ":" << node <<")" << nm; s << pre << " (" << id << ":" << node <<")" << nm;
return s.str(); return s.str();
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
......
...@@ -225,13 +225,10 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) ...@@ -225,13 +225,10 @@ 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 )
{ {
const char* n = name.c_str(); MapObjectKey::iterator it = mok.find(name);
for( MapObjects::iterator it=omap.begin(); it!=omap.end(); ++it ) if( it != mok.end() )
{ return getObjectInfo(it->second);
if( !strcmp(it->second.repName,n) )
return &(it->second);
}
return NULL; return NULL;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -143,7 +143,7 @@ long IOController::localGetValue( IOController::IOStateList::iterator& li, const ...@@ -143,7 +143,7 @@ long IOController::localGetValue( IOController::IOStateList::iterator& li, const
// ------------- // -------------
ostringstream err; ostringstream err;
err << myname << "(localGetValue): Not found sensor (" << sid << ") " err << myname << "(localGetValue): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
...@@ -240,7 +240,7 @@ void IOController::setValue( UniSetTypes::ObjectId sid, CORBA::Long value, UniSe ...@@ -240,7 +240,7 @@ void IOController::setValue( UniSetTypes::ObjectId sid, CORBA::Long value, UniSe
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IOController::localSetValue( IOController::IOStateList::iterator& li, void IOController::localSetValue( IOController::IOStateList::iterator& li,
UniSetTypes::ObjectId sid, UniSetTypes::ObjectId sid,
CORBA::Long value, UniSetTypes::ObjectId sup_id ) CORBA::Long value, UniSetTypes::ObjectId sup_id )
{ {
if( sup_id == UniSetTypes::DefaultObjectId ) if( sup_id == UniSetTypes::DefaultObjectId )
...@@ -350,7 +350,7 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force ) ...@@ -350,7 +350,7 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force )
if( li!=ioList.end() ) if( li!=ioList.end() )
{ {
ostringstream err; ostringstream err;
err << "Попытка повторной регистрации датчика("<< ainf.si.id << "). имя: " err << "Попытка повторной регистрации датчика("<< ainf.si.id << "). имя: "
<< conf->oind->getNameById(ainf.si.id); << conf->oind->getNameById(ainf.si.id);
throw ObjectNameAlready(err.str().c_str()); throw ObjectNameAlready(err.str().c_str());
} }
...@@ -498,7 +498,7 @@ IOController_i::SensorIOInfo IOController::getSensorIOInfo( const UniSetTypes::O ...@@ -498,7 +498,7 @@ IOController_i::SensorIOInfo IOController::getSensorIOInfo( const UniSetTypes::O
// ------------- // -------------
ostringstream err; ostringstream err;
err << myname << "(getSensorIOInfo): Unknown sensor (" << sid << ")" err << myname << "(getSensorIOInfo): Unknown sensor (" << sid << ")"
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
...@@ -512,7 +512,7 @@ CORBA::Long IOController::getRawValue( UniSetTypes::ObjectId sid ) ...@@ -512,7 +512,7 @@ CORBA::Long IOController::getRawValue( UniSetTypes::ObjectId sid )
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(getRawValue): Unknown analog sensor (" << sid << ")" err << myname << "(getRawValue): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
...@@ -532,7 +532,7 @@ CORBA::Long IOController::getRawValue( UniSetTypes::ObjectId sid ) ...@@ -532,7 +532,7 @@ CORBA::Long IOController::getRawValue( UniSetTypes::ObjectId sid )
return it->second.value; return it->second.value;
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IOController::calibrate( UniSetTypes::ObjectId sid, void IOController::calibrate( UniSetTypes::ObjectId sid,
const IOController_i::CalibrateInfo& ci, const IOController_i::CalibrateInfo& ci,
UniSetTypes::ObjectId adminId ) UniSetTypes::ObjectId adminId )
{ {
...@@ -540,7 +540,7 @@ void IOController::calibrate( UniSetTypes::ObjectId sid, ...@@ -540,7 +540,7 @@ void IOController::calibrate( UniSetTypes::ObjectId sid,
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(calibrate): Unknown analog sensor (" << sid << ")" err << myname << "(calibrate): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
...@@ -556,7 +556,7 @@ IOController_i::CalibrateInfo IOController::getCalibrateInfo( UniSetTypes::Objec ...@@ -556,7 +556,7 @@ IOController_i::CalibrateInfo IOController::getCalibrateInfo( UniSetTypes::Objec
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(calibrate): Unknown analog sensor (" << sid << ")" err << myname << "(calibrate): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
......
...@@ -171,7 +171,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid, ...@@ -171,7 +171,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
smsg.node = conf->getLocalNode(); smsg.node = conf->getLocalNode();
smsg.consumer = ci.id; smsg.consumer = ci.id;
smsg.supplier = getId(); smsg.supplier = getId();
smsg.sensor_type = li->second.type; smsg.sensor_type = li->second.type;
smsg.priority = (Message::Priority)li->second.priority; smsg.priority = (Message::Priority)li->second.priority;
smsg.sm_tv_sec = li->second.tv_sec; smsg.sm_tv_sec = li->second.tv_sec;
smsg.sm_tv_usec = li->second.tv_usec; smsg.sm_tv_usec = li->second.tv_usec;
...@@ -195,7 +195,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid, ...@@ -195,7 +195,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
} }
catch( CORBA::SystemException& ex ) catch( CORBA::SystemException& ex )
{ {
uwarn << myname << "(askSensor): " << conf->oind->getNameById(ci.id) << "@" << ci.node uwarn << myname << "(askSensor): " << conf->oind->getNameById(ci.id) << "@" << ci.node
<< " недоступен!!(CORBA::SystemException): " << " недоступен!!(CORBA::SystemException): "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
...@@ -208,7 +208,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid, ...@@ -208,7 +208,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid, void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd) const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd)
{ {
// поиск датчика в списке // поиск датчика в списке
...@@ -510,7 +510,7 @@ void IONotifyController::dumpThresholdList( const UniSetTypes::ObjectId sid, con ...@@ -510,7 +510,7 @@ void IONotifyController::dumpThresholdList( const UniSetTypes::ObjectId sid, con
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTypes::ConsumerInfo& ci, void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTypes::ConsumerInfo& ci,
UniSetTypes::ThresholdId tid, UniSetTypes::ThresholdId tid,
CORBA::Long lowLimit, CORBA::Long hiLimit, CORBA::Boolean invert, CORBA::Long lowLimit, CORBA::Long hiLimit, CORBA::Boolean invert,
UniversalIO::UIOCommand cmd ) UniversalIO::UIOCommand cmd )
...@@ -682,7 +682,7 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt& ...@@ -682,7 +682,7 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&
// запоминаем начальное время // запоминаем начальное время
struct timeval tm; struct timeval tm;
struct timezone tz; struct timezone tz;
tm.tv_sec = 0; tm.tv_sec = 0;
tm.tv_usec = 0; tm.tv_usec = 0;
gettimeofday(&tm,&tz); gettimeofday(&tm,&tz);
ti.tv_sec = tm.tv_sec; ti.tv_sec = tm.tv_sec;
...@@ -849,7 +849,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet ...@@ -849,7 +849,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
if( it == askTMap.end() ) if( it == askTMap.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(getThresholds): Not found sensor (" << sid << ") " err << myname << "(getThresholds): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
...@@ -863,7 +863,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet ...@@ -863,7 +863,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
} }
ostringstream err; ostringstream err;
err << myname << "(getThresholds): Not found for sensor (" << sid << ") " err << myname << "(getThresholds): Not found for sensor (" << sid << ") "
<< conf->oind->getNameById(sid) << " ThresholdID='" << tid << "'"; << conf->oind->getNameById(sid) << " ThresholdID='" << tid << "'";
uinfo << err.str() << endl; uinfo << err.str() << endl;
...@@ -878,7 +878,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy ...@@ -878,7 +878,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
if( it == askTMap.end() ) if( it == askTMap.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(getThresholds): Not found sensor (" << sid << ") " err << myname << "(getThresholds): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(sid); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
......
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