Commit 136c3694 authored by Pavel Vainerman's avatar Pavel Vainerman

В целях оптимизации: ОТКАЗАЛСЯ от (так и не ставшей необходимой) идеи "alias"…

В целях оптимизации: ОТКАЗАЛСЯ от (так и не ставшей необходимой) идеи "alias" для "node", и соответственно избавился от необходимости передавать и работать в IOContoller(IONotifyController,ShraredMemory) с ПАРОЙ id,node НО nеперь стало НЕЛЬЗЯ на одном узле запустить "ДВА НАБОРА ОДИНАКОВЫХ ДАТЧИКОВ ОТЛИЧАЮЩИХСЯ ТОЛЬКО УЗЛОМ(node)".
parent 64f06792
...@@ -62,24 +62,24 @@ interface IOController_i : UniSetManager_i ...@@ -62,24 +62,24 @@ interface IOController_i : UniSetManager_i
UniSetTypes::ObjectId node; /*!< узел на котором он находится */ UniSetTypes::ObjectId node; /*!< узел на котором он находится */
}; };
long getValue(in SensorInfo si) raises(NameNotFound,Undefined); long getValue(in UniSetTypes::ObjectId sid) raises(NameNotFound,Undefined);
void setValue(in SensorInfo si, in long value, void setValue(in UniSetTypes::ObjectId sid, in long value,
in UniSetTypes::ObjectId sup_id) raises(NameNotFound); in UniSetTypes::ObjectId sup_id) raises(NameNotFound);
// установка неопределённого состояния // установка неопределённого состояния
// (пока работает только для аналоговых датчиков) // (пока работает только для аналоговых датчиков)
void setUndefinedState(in SensorInfo si, 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 (не вырабатывает исключения)
oneway void fastSetValue(in SensorInfo si, in long value, in UniSetTypes::ObjectId sup_id); oneway void fastSetValue(in UniSetTypes::ObjectId sid, in long value, in UniSetTypes::ObjectId sup_id);
UniversalIO::IOType getIOType(in SensorInfo si) raises(NameNotFound); UniversalIO::IOType getIOType(in UniSetTypes::ObjectId sid) raises(NameNotFound);
// --- Интерфейс для конфигурирования --- // --- Интерфейс для конфигурирования ---
/*! Получение неколиброванного значения */ /*! Получение неколиброванного значения */
long getRawValue( in SensorInfo si ) raises(NameNotFound); long getRawValue( in UniSetTypes::ObjectId sid ) raises(NameNotFound);
struct CalibrateInfo struct CalibrateInfo
{ {
...@@ -90,8 +90,8 @@ interface IOController_i : UniSetManager_i ...@@ -90,8 +90,8 @@ interface IOController_i : UniSetManager_i
short precision; /*!< точность */ short precision; /*!< точность */
}; };
void calibrate( in SensorInfo si, in CalibrateInfo ci, in UniSetTypes::ObjectId adminId ) raises(NameNotFound); void calibrate( in UniSetTypes::ObjectId sid, in CalibrateInfo ci, in UniSetTypes::ObjectId adminId ) raises(NameNotFound);
CalibrateInfo getCalibrateInfo( in SensorInfo si ) raises(NameNotFound); CalibrateInfo getCalibrateInfo( in UniSetTypes::ObjectId sid ) raises(NameNotFound);
// --- Интерфес получения информации о всех датчиках --- // --- Интерфес получения информации о всех датчиках ---
/*! Информация об аналоговом датчике */ /*! Информация об аналоговом датчике */
...@@ -114,7 +114,7 @@ interface IOController_i : UniSetManager_i ...@@ -114,7 +114,7 @@ interface IOController_i : UniSetManager_i
typedef sequence<SensorIOInfo> SensorInfoSeq; typedef sequence<SensorIOInfo> SensorInfoSeq;
SensorInfoSeq getSensorsMap(); SensorInfoSeq getSensorsMap();
SensorIOInfo getSensorIOInfo( in SensorInfo si ) raises(NameNotFound); SensorIOInfo getSensorIOInfo( in UniSetTypes::ObjectId sid ) raises(NameNotFound);
// -- Функции работы со списком датчиков -- // -- Функции работы со списком датчиков --
...@@ -146,7 +146,7 @@ interface IOController_i : UniSetManager_i ...@@ -146,7 +146,7 @@ interface IOController_i : UniSetManager_i
long tv_usec; /*!< время последнего изменения датчика, мксек (gettimeofday) */ long tv_usec; /*!< время последнего изменения датчика, мксек (gettimeofday) */
}; };
ShortIOInfo getChangedTime(in SensorInfo si) raises(NameNotFound); ShortIOInfo getChangedTime( in UniSetTypes::ObjectId sid ) raises(NameNotFound);
/*! Информация о дискретном датчике */ /*! Информация о дискретном датчике */
...@@ -183,7 +183,7 @@ interface IONotifyController_i : IOController_i ...@@ -183,7 +183,7 @@ interface IONotifyController_i : IOController_i
* Позволяет заказывать как дискретные так и аналоговые датчики * Позволяет заказывать как дискретные так и аналоговые датчики
* \sa UniversalIO::UniversalIOController::askSensor() * \sa UniversalIO::UniversalIOController::askSensor()
*/ */
void askSensor(in SensorInfo si, in UniSetTypes::ConsumerInfo ci, in UniversalIO::UIOCommand cmd ) raises(NameNotFound,IOBadParam); void askSensor(in UniSetTypes::ObjectId sid, in UniSetTypes::ConsumerInfo ci, in UniversalIO::UIOCommand cmd ) raises(NameNotFound,IOBadParam);
/*! /*!
Заказ сразу списка объектов. Заказ сразу списка объектов.
...@@ -225,7 +225,7 @@ interface IONotifyController_i : IOController_i ...@@ -225,7 +225,7 @@ interface IONotifyController_i : IOController_i
* Если invert=false, порог срабатывает при условии >= hilimit и отпускается при <= lowlimit * Если invert=false, порог срабатывает при условии >= hilimit и отпускается при <= lowlimit
* Если invert=true, порог срабатывает при условии <= lowlimit и отпускается при <= hilimit * Если invert=true, порог срабатывает при условии <= lowlimit и отпускается при <= hilimit
*/ */
void askThreshold(in SensorInfo si, in UniSetTypes::ConsumerInfo ci, in UniSetTypes::ThresholdId tid, void askThreshold(in UniSetTypes::ObjectId sid, in UniSetTypes::ConsumerInfo ci, in UniSetTypes::ThresholdId tid,
in long lowLimit, in long hiLimit, in boolean invert, in long lowLimit, in long hiLimit, in boolean invert,
in UniversalIO::UIOCommand cmd ) raises(NameNotFound, IOBadParam, BadRange); in UniversalIO::UIOCommand cmd ) raises(NameNotFound, IOBadParam, BadRange);
...@@ -233,7 +233,7 @@ interface IONotifyController_i : IOController_i ...@@ -233,7 +233,7 @@ interface IONotifyController_i : IOController_i
/*! Получение информации о пороге /*! Получение информации о пороге
* Т.к. пороги могут иметь одинаковый tid для разных аналоговых датчиков, то передаётся и SensorInfo * Т.к. пороги могут иметь одинаковый tid для разных аналоговых датчиков, то передаётся и SensorInfo
*/ */
ThresholdInfo getThresholdInfo( in SensorInfo si, in UniSetTypes::ThresholdId tid ) raises(NameNotFound); ThresholdInfo getThresholdInfo( in UniSetTypes::ObjectId sid, in UniSetTypes::ThresholdId tid ) raises(NameNotFound);
struct ThresholdList struct ThresholdList
{ {
...@@ -246,7 +246,7 @@ interface IONotifyController_i : IOController_i ...@@ -246,7 +246,7 @@ interface IONotifyController_i : IOController_i
typedef sequence<ThresholdList> ThresholdsListSeq; typedef sequence<ThresholdList> ThresholdsListSeq;
/*! получить список порогов для датчка "si" */ /*! получить список порогов для датчка "si" */
ThresholdList getThresholds( in SensorInfo si ) raises(NameNotFound); ThresholdList getThresholds( in UniSetTypes::ObjectId sid ) raises(NameNotFound);
/*! получить список ВСЕХ датчиков по которым созданы пороги */ /*! получить список ВСЕХ датчиков по которым созданы пороги */
ThresholdsListSeq getThresholdsList(); ThresholdsListSeq getThresholdsList();
......
...@@ -31,7 +31,7 @@ void SharedMemory::help_print( int argc, const char* const* argv ) ...@@ -31,7 +31,7 @@ void SharedMemory::help_print( int argc, const char* const* argv )
cout << "--pulsar-msec - период 'мигания'. По умолчанию: 5000." << endl; cout << "--pulsar-msec - период 'мигания'. По умолчанию: 5000." << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ): SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std::string& confname ):
IONotifyController_LT(id), IONotifyController_LT(id),
heartbeatCheckTime(5000), heartbeatCheckTime(5000),
histSaveTime(0), histSaveTime(0),
...@@ -101,20 +101,18 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ) ...@@ -101,20 +101,18 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname )
activateTimeout = conf->getArgPInt("--activate-timeout", 10000); activateTimeout = conf->getArgPInt("--activate-timeout", 10000);
siPulsar.id = DefaultObjectId; sidPulsar = DefaultObjectId;
siPulsar.node = DefaultObjectId;
string p = conf->getArgParam("--pulsar-id",it.getProp("pulsar_id")); string p = conf->getArgParam("--pulsar-id",it.getProp("pulsar_id"));
if( !p.empty() ) if( !p.empty() )
{ {
siPulsar.id = conf->getSensorID(p); sidPulsar = conf->getSensorID(p);
if( siPulsar.id == DefaultObjectId ) if( sidPulsar == DefaultObjectId )
{ {
ostringstream err; ostringstream err;
err << myname << ": ID not found ('pulsar') for " << p; err << myname << ": ID not found ('pulsar') for " << p;
dcrit << myname << "(init): " << err.str() << endl; dcrit << myname << "(init): " << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
siPulsar.node = conf->getLocalNode();
msecPulsar = conf->getArgPInt("--pulsar-msec",it.getProp("pulsar_msec"), 5000); msecPulsar = conf->getArgPInt("--pulsar-msec",it.getProp("pulsar_msec"), 5000);
} }
} }
...@@ -149,11 +147,11 @@ void SharedMemory::timerInfo( const TimerMessage *tm ) ...@@ -149,11 +147,11 @@ void SharedMemory::timerInfo( const TimerMessage *tm )
saveHistory(); saveHistory();
else if( tm->id == tmPulsar ) else if( tm->id == tmPulsar )
{ {
if( siPulsar.id != DefaultObjectId ) if( sidPulsar != DefaultObjectId )
{ {
bool st = (bool)localGetValue(itPulsar,siPulsar); bool st = (bool)localGetValue(itPulsar,sidPulsar);
st ^= true; st ^= true;
localSetValue(itPulsar,siPulsar, (st ? 1:0), getId() ); localSetValue(itPulsar,sidPulsar, (st ? 1:0), getId() );
} }
} }
} }
...@@ -283,24 +281,19 @@ void SharedMemory::checkHeartBeat() ...@@ -283,24 +281,19 @@ void SharedMemory::checkHeartBeat()
return; return;
} }
IOController_i::SensorInfo si;
si.node = conf->getLocalNode();
bool wdtpingOK = true; bool wdtpingOK = true;
for( HeartBeatList::iterator it=hlist.begin(); it!=hlist.end(); ++it ) for( HeartBeatList::iterator it=hlist.begin(); it!=hlist.end(); ++it )
{ {
try try
{ {
si.id = it->a_sid; long val = localGetValue(it->ioit,it->a_sid);
long val = localGetValue(it->ioit,si);
val --; val --;
if( val < -1 ) if( val < -1 )
val = -1; val = -1;
localSetValue(it->ioit,si,val,getId()); localSetValue(it->ioit,it->a_sid,val,getId());
si.id = it->d_sid; localSetValue(it->ioit,it->d_sid,( val >= 0 ? true:false),getId());
localSetValue(it->ioit,si,( val >= 0 ? true:false),getId());
// проверяем нужна ли "перезагрузка" по данному датчику // проверяем нужна ли "перезагрузка" по данному датчику
if( wdt && it->ptReboot.getInterval() ) if( wdt && it->ptReboot.getInterval() )
...@@ -642,16 +635,13 @@ void SharedMemory::saveHistory() ...@@ -642,16 +635,13 @@ void SharedMemory::saveHistory()
for( HistoryList::iterator hit=it->hlst.begin(); hit!=it->hlst.end(); ++hit ) for( HistoryList::iterator hit=it->hlst.begin(); hit!=it->hlst.end(); ++hit )
{ {
if( hit->ioit != myioEnd() ) if( hit->ioit != myioEnd() )
hit->add( localGetValue( hit->ioit, hit->ioit->second.si ), it->size ); hit->add( localGetValue( hit->ioit, hit->ioit->second.si.id ), it->size );
else else
{ {
IOController_i::SensorInfo si;
si.id = hit->id;
si.node = conf->getLocalNode();
try try
{ {
hit->add( localGetValue( hit->ioit, si ), it->size ); hit->add( localGetValue( hit->ioit, hit->id ), it->size );
continue; continue;
} }
catch(...){} catch(...){}
......
...@@ -217,21 +217,21 @@ ...@@ -217,21 +217,21 @@
filter - поле используемое в качестве фильтра, определяющего датчики filter - поле используемое в качестве фильтра, определяющего датчики
входящие в данную группу (историю). входящие в данную группу (историю).
\endcode \endcode
Каждый датчик может входить в любое количество групп (историй). Каждый датчик может входить в любое количество групп (историй).
Механизм фукнционирует по следующей логике: Механизм фукнционирует по следующей логике:
При запуске происходит считывание параметров секции <History> При запуске происходит считывание параметров секции <History>
и заполнение соответствующих структур хранения. При этом происходит и заполнение соответствующих структур хранения. При этом происходит
проход по секции <sensors> и если встречается "не пустое" поле заданное проход по секции <sensors> и если встречается "не пустое" поле заданное
в качестве фильтра (\b filter), датчик включается в соответствующую историю. в качестве фильтра (\b filter), датчик включается в соответствующую историю.
Далее каждые \b savetime мсек происходит запись очередной точки истории. Далее каждые \b savetime мсек происходит запись очередной точки истории.
При этом в конец буфера добавляется новое (текущее) значение датчика, При этом в конец буфера добавляется новое (текущее) значение датчика,
а одно устаревшее удаляется, тем самым всегда поддерживается буфер не более а одно устаревшее удаляется, тем самым всегда поддерживается буфер не более
\b size точек. \b size точек.
Помимо этого в фукнциях изменения датчиков (saveXXX, setXXX) отслеживается Помимо этого в фукнциях изменения датчиков (saveXXX, setXXX) отслеживается
изменение состояния "детонаторов". Если срабатывает заданое условие для изменение состояния "детонаторов". Если срабатывает заданое условие для
"сброса" дампа, инициируется сигнал, в который передаётся идентификатор истории "сброса" дампа, инициируется сигнал, в который передаётся идентификатор истории
...@@ -251,13 +251,12 @@ ...@@ -251,13 +251,12 @@
(реализованное в базовом классе IONotifyController). (реализованное в базовом классе IONotifyController).
Параметр командной строки \b --db-logging 1 позволяет включить этот механизм Параметр командной строки \b --db-logging 1 позволяет включить этот механизм
(в свою очередь работа с БД требует отдельной настройки). (в свою очередь работа с БД требует отдельной настройки).
*/ */
class SharedMemory: class SharedMemory:
public IONotifyController_LT public IONotifyController_LT
{ {
public: public:
SharedMemory( UniSetTypes::ObjectId id, std::string datafile, std::string confname="" ); SharedMemory( UniSetTypes::ObjectId id, const std::string& datafile, const std::string& confname="" );
virtual ~SharedMemory(); virtual ~SharedMemory();
/*! глобальная функция для инициализации объекта */ /*! глобальная функция для инициализации объекта */
...@@ -417,9 +416,9 @@ class SharedMemory: ...@@ -417,9 +416,9 @@ class SharedMemory:
int evntPause; int evntPause;
int activateTimeout; int activateTimeout;
virtual void loggingInfo(UniSetTypes::SensorMessage& sm); virtual void loggingInfo( UniSetTypes::SensorMessage& sm );
virtual void dumpOrdersList(const IOController_i::SensorInfo& si, const IONotifyController::ConsumerList& lst){} virtual void dumpOrdersList( const UniSetTypes::ObjectId sid, const IONotifyController::ConsumerList& lst ){}
virtual void dumpThresholdList(const IOController_i::SensorInfo& si, const IONotifyController::ThresholdExtList& lst){} virtual void dumpThresholdList( const UniSetTypes::ObjectId sid, const IONotifyController::ThresholdExtList& lst ){}
bool dblogging; bool dblogging;
...@@ -434,7 +433,7 @@ class SharedMemory: ...@@ -434,7 +433,7 @@ class SharedMemory:
bool isActivated(); bool isActivated();
IOStateList::iterator itPulsar; IOStateList::iterator itPulsar;
IOController_i::SensorInfo siPulsar; UniSetTypes::ObjectId sidPulsar;
int msecPulsar; int msecPulsar;
private: private:
......
...@@ -99,63 +99,56 @@ SMInterface::~SMInterface() ...@@ -99,63 +99,56 @@ SMInterface::~SMInterface()
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void SMInterface::setValue ( UniSetTypes::ObjectId id, long value ) void SMInterface::setValue( UniSetTypes::ObjectId id, long value )
{ {
IOController_i::SensorInfo si;
si.id = id;
si.node = conf->getLocalNode();
if( ic ) if( ic )
{ {
BEG_FUNC1(SMInterface::setValue) BEG_FUNC1(SMInterface::setValue)
ic->fastSetValue(si,value,myid); ic->fastSetValue(id,value,myid);
return; return;
END_FUNC(SMInterface::setValue) END_FUNC(SMInterface::setValue)
} }
IOController_i::SensorInfo si;
si.id = id;
si.node = conf->getLocalNode();
BEG_FUNC1(SMInterface::setValue) BEG_FUNC1(SMInterface::setValue)
ui->fastSetValue(si,value,myid); ui->fastSetValue(si,value,myid);
return; return;
END_FUNC(SMInterface::setValue) END_FUNC(SMInterface::setValue)
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
long SMInterface::getValue ( UniSetTypes::ObjectId id ) long SMInterface::getValue( UniSetTypes::ObjectId id )
{ {
IOController_i::SensorInfo si;
si.id = id;
si.node = conf->getLocalNode();
if( ic ) if( ic )
{ {
BEG_FUNC1(SMInterface::getValue) BEG_FUNC1(SMInterface::getValue)
return ic->getValue(si); return ic->getValue(id);
END_FUNC(SMInterface::getValue) END_FUNC(SMInterface::getValue)
} }
BEG_FUNC1(SMInterface::getValue) BEG_FUNC1(SMInterface::getValue)
return ui->getValue(si.id,si.node); return ui->getValue(id);
END_FUNC(SMInterface::getValue) END_FUNC(SMInterface::getValue)
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void SMInterface::askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId backid ) void SMInterface::askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId backid )
{ {
IOController_i::SensorInfo_var si;
si->id = id;
si->node = conf->getLocalNode();
ConsumerInfo_var ci; ConsumerInfo_var ci;
ci->id = (backid==DefaultObjectId) ? myid : backid; ci->id = (backid==DefaultObjectId) ? myid : backid;
ci->node = conf->getLocalNode(); ci->node = conf->getLocalNode();
if( ic ) if( ic )
{ {
BEG_FUNC1(SMInterface::askSensor) BEG_FUNC1(SMInterface::askSensor)
ic->askSensor(si, ci, cmd ); ic->askSensor(id, ci, cmd);
return; return;
END_FUNC(SMInterface::askSensor) END_FUNC(SMInterface::askSensor)
} }
BEG_FUNC1(SMInterface::askSensor) BEG_FUNC1(SMInterface::askSensor)
ui->askRemoteSensor(si->id,cmd,si->node,ci->id); ui->askRemoteSensor(id,cmd,conf->getLocalNode(),ci->id);
return; return;
END_FUNC(SMInterface::askSensor) END_FUNC(SMInterface::askSensor)
} }
...@@ -194,12 +187,12 @@ void SMInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefi ...@@ -194,12 +187,12 @@ void SMInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefi
if( ic ) if( ic )
{ {
BEG_FUNC1(SMInterface::setUndefinedState) BEG_FUNC1(SMInterface::setUndefinedState)
ic->setUndefinedState(si,undefined,sup_id); ic->setUndefinedState(si.id,undefined,sup_id);
return; return;
END_FUNC(SMInterface::setUndefinedState) END_FUNC(SMInterface::setUndefinedState)
} }
BEG_FUNC(SMInterface::setUndefinedState) BEG_FUNC(SMInterface::setUndefinedState)
shm->setUndefinedState(si,undefined,sup_id); shm->setUndefinedState(si.id,undefined,sup_id);
return; return;
END_FUNC(SMInterface::setUndefinedState) END_FUNC(SMInterface::setUndefinedState)
} }
...@@ -232,7 +225,7 @@ void SMInterface::localSetValue( IOController::IOStateList::iterator& it, ...@@ -232,7 +225,7 @@ void SMInterface::localSetValue( IOController::IOStateList::iterator& it,
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
si.node = conf->getLocalNode(); si.node = conf->getLocalNode();
ic->localSetValue(it,si,value,sup_id); ic->localSetValue(it,si.id,value,sup_id);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
long SMInterface::localGetValue( IOController::IOStateList::iterator& it, UniSetTypes::ObjectId sid ) long SMInterface::localGetValue( IOController::IOStateList::iterator& it, UniSetTypes::ObjectId sid )
...@@ -241,10 +234,7 @@ long SMInterface::localGetValue( IOController::IOStateList::iterator& it, UniSet ...@@ -241,10 +234,7 @@ long SMInterface::localGetValue( IOController::IOStateList::iterator& it, UniSet
return getValue( sid ); return getValue( sid );
// CHECK_IC_PTR(localGetValue) // CHECK_IC_PTR(localGetValue)
IOController_i::SensorInfo si; return ic->localGetValue(it,sid);
si.id = sid;
si.node = conf->getLocalNode();
return ic->localGetValue(it,si);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& it, void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& it,
...@@ -257,14 +247,11 @@ void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& i ...@@ -257,14 +247,11 @@ void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& i
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
si.node = conf->getLocalNode(); si.node = conf->getLocalNode();
setUndefinedState( si,undefined,myid); setUndefinedState(si,undefined,myid);
return; return;
} }
IOController_i::SensorInfo si; ic->localSetUndefinedState(it,undefined,sid);
si.id = sid;
si.node = conf->getLocalNode();
ic->localSetUndefinedState(it,undefined,si);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void SMInterface::initIterator( IOController::IOStateList::iterator& it ) void SMInterface::initIterator( IOController::IOStateList::iterator& it )
......
...@@ -46,7 +46,7 @@ void TestProc::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -46,7 +46,7 @@ void TestProc::sysCommand( const UniSetTypes::SystemMessage* sm )
askTimer(tmLogControl,checkLogTime); askTimer(tmLogControl,checkLogTime);
// В начальный момент времени блокирующий датчик =0, поэтому d2_check_s должен быть равен depend_off_value (-50). // В начальный момент времени блокирующий датчик =0, поэтому d2_check_s должен быть равен depend_off_value (-50).
cerr << myname << "(startup): check init depend: " << ( getValue(d2_check_s) == -50 ? "OK" : "FAIL" ) << endl; cerr << myname << "(startup): check init depend: " << ( getValue(d2_check_s) == -50 ? "ok" : "FAIL" ) << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -73,7 +73,7 @@ void TestProc::sensorInfo( const SensorMessage *sm ) ...@@ -73,7 +73,7 @@ void TestProc::sensorInfo( const SensorMessage *sm )
} }
else if( sm->id == check_undef_s ) else if( sm->id == check_undef_s )
{ {
cerr << myname << "(sensorInfo): CHECK UNDEFINED STATE ==> " << (sm->undefined==undef ? "OK" : "FAIL") << endl; cerr << myname << "(sensorInfo): CHECK UNDEFINED STATE ==> " << (sm->undefined==undef ? "ok" : "FAIL") << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -118,13 +118,13 @@ void TestProc::test_depend() ...@@ -118,13 +118,13 @@ void TestProc::test_depend()
setValue(depend_c,0); setValue(depend_c,0);
setValue(set_d1_check_s,test_val); setValue(set_d1_check_s,test_val);
setValue(set_d2_check_s,test_val); setValue(set_d2_check_s,test_val);
cerr << myname << ": check depend OFF: d1: " << ( getValue(d1_check_s) == 0 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend OFF: d1: " << ( getValue(d1_check_s) == 0 ? "ok" : "FAIL" ) << endl;
cerr << myname << ": check depend OFF: d2: " << ( getValue(d2_check_s) == -50 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend OFF: d2: " << ( getValue(d2_check_s) == -50 ? "ok" : "FAIL" ) << endl;
// set depend 1 // set depend 1
setValue(depend_c,1); setValue(depend_c,1);
cerr << myname << ": check depend ON: d1: " << ( getValue(d1_check_s) == test_val ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend ON: d1: " << ( getValue(d1_check_s) == test_val ? "ok" : "FAIL" ) << endl;
cerr << myname << ": check depend ON: d2: " << ( getValue(d2_check_s) == test_val ? "OK" : "FAIL" ) << endl; cerr << myname << ": check depend ON: d2: " << ( getValue(d2_check_s) == test_val ? "ok" : "FAIL" ) << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void TestProc::test_undefined_state() void TestProc::test_undefined_state()
...@@ -145,10 +145,10 @@ void TestProc::test_thresholds() ...@@ -145,10 +145,10 @@ void TestProc::test_thresholds()
cerr << myname << ": Check thresholds..." << endl; cerr << myname << ": Check thresholds..." << endl;
setValue(t_set_c,0); setValue(t_set_c,0);
cerr << myname << ": check threshold OFF value: " << ( getValue(t_check_s) == 0 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check threshold OFF value: " << ( getValue(t_check_s) == 0 ? "ok" : "FAIL" ) << endl;
setValue(t_set_c,378); setValue(t_set_c,378);
cerr << myname << ": check threshold ON value: " << ( getValue(t_check_s) == 1 ? "OK" : "FAIL" ) << endl; cerr << myname << ": check threshold ON value: " << ( getValue(t_check_s) == 1 ? "ok" : "FAIL" ) << endl;
cerr << myname << ": ask threshold and check.. " << endl; cerr << myname << ": ask threshold and check.. " << endl;
...@@ -159,10 +159,10 @@ void TestProc::test_thresholds() ...@@ -159,10 +159,10 @@ void TestProc::test_thresholds()
ui.askThreshold( t_set_c, tid, UniversalIO::UIONotify, 10, 20 ); ui.askThreshold( t_set_c, tid, UniversalIO::UIONotify, 10, 20 );
IONotifyController_i::ThresholdInfo ti = ui.getThresholdInfo(t_set_c,tid); IONotifyController_i::ThresholdInfo ti = ui.getThresholdInfo(t_set_c,tid);
cerr << myname << ": ask OFF threshold: " << ( ti.state == IONotifyController_i::NormalThreshold ? "OK" : "FAIL" ) << endl; cerr << myname << ": ask OFF threshold: " << ( ti.state == IONotifyController_i::NormalThreshold ? "ok" : "FAIL" ) << endl;
setValue(t_set_c, 25); setValue(t_set_c, 25);
ti = ui.getThresholdInfo(t_set_c,tid); ti = ui.getThresholdInfo(t_set_c,tid);
cerr << myname << ": ask ON threshold: " << ( ti.state == IONotifyController_i::HiThreshold ? "OK" : "FAIL" ) << endl; cerr << myname << ": ask ON threshold: " << ( ti.state == IONotifyController_i::HiThreshold ? "ok" : "FAIL" ) << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
......
...@@ -118,7 +118,7 @@ namespace UniSetTypes ...@@ -118,7 +118,7 @@ namespace UniSetTypes
UniSetTypes::ObjectId getControllerID( const std::string& name ); UniSetTypes::ObjectId getControllerID( const std::string& name );
UniSetTypes::ObjectId getObjectID( const std::string& name ); UniSetTypes::ObjectId getObjectID( const std::string& name );
UniSetTypes::ObjectId getServiceID( const std::string& name ); UniSetTypes::ObjectId getServiceID( const std::string& name );
UniSetTypes::ObjectId getNodeID( const std::string& name, const std::string& alias="" ); UniSetTypes::ObjectId getNodeID( const std::string& name );
inline const std::string getConfFileName() const { return fileConfName; } inline const std::string getConfFileName() const { return fileConfName; }
inline std::string getImagesDir() const { return imagesDir; } // временно inline std::string getImagesDir() const { return imagesDir; } // временно
......
...@@ -41,25 +41,25 @@ class IOController: ...@@ -41,25 +41,25 @@ class IOController:
{ {
public: public:
IOController(const std::string& name, const std::string& section); IOController( const std::string& name, const std::string& section );
IOController(UniSetTypes::ObjectId id); IOController( const UniSetTypes::ObjectId id );
~IOController(); ~IOController();
virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::ObjectType("IOController"); } virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::ObjectType("IOController"); }
virtual CORBA::Long getValue( const IOController_i::SensorInfo& si ); virtual CORBA::Long getValue( UniSetTypes::ObjectId sid );
// -------------------- !!!!!!!!! --------------------------------- // -------------------- !!!!!!!!! ---------------------------------
// Реализуются конкретным i/o контроллером // Реализуются конкретным i/o контроллером
// Не забывайте писать реализацию этих функций // Не забывайте писать реализацию этих функций
virtual void setValue( const IOController_i::SensorInfo& si, CORBA::Long value, virtual void setValue( UniSetTypes::ObjectId sid, CORBA::Long value,
UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId );
virtual void fastSetValue( const IOController_i::SensorInfo& si, CORBA::Long value, virtual void fastSetValue( UniSetTypes::ObjectId sid, CORBA::Long value,
UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId );
// ---------------------------------------------------------------- // ----------------------------------------------------------------
virtual void setUndefinedState(const IOController_i::SensorInfo& si, virtual void setUndefinedState( UniSetTypes::ObjectId sid,
CORBA::Boolean undefined, CORBA::Boolean undefined,
UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId sup_id = UniSetTypes::DefaultObjectId );
...@@ -68,30 +68,30 @@ class IOController: ...@@ -68,30 +68,30 @@ class IOController:
virtual UniSetTypes::IDSeq* setOutputSeq( const IOController_i::OutSeq& lst, UniSetTypes::ObjectId sup_id ); virtual UniSetTypes::IDSeq* setOutputSeq( const IOController_i::OutSeq& lst, UniSetTypes::ObjectId sup_id );
// ---------------------------------------------------------------- // ----------------------------------------------------------------
virtual UniversalIO::IOType getIOType( const IOController_i::SensorInfo& si ); virtual UniversalIO::IOType getIOType( UniSetTypes::ObjectId sid );
virtual IOController_i::SensorInfoSeq* getSensorsMap(); virtual IOController_i::SensorInfoSeq* getSensorsMap();
virtual IOController_i::SensorIOInfo getSensorIOInfo( const IOController_i::SensorInfo& si ); virtual IOController_i::SensorIOInfo getSensorIOInfo( UniSetTypes::ObjectId sid );
virtual CORBA::Long getRawValue(const IOController_i::SensorInfo& si); virtual CORBA::Long getRawValue(UniSetTypes::ObjectId sid);
virtual void calibrate(const IOController_i::SensorInfo& si, 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( const IOController_i::SensorInfo& si ); IOController_i::CalibrateInfo getCalibrateInfo( UniSetTypes::ObjectId sid );
inline IOController_i::SensorInfo SensorInfo(UniSetTypes::ObjectId id, inline IOController_i::SensorInfo SensorInfo( const UniSetTypes::ObjectId sid,
UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode()) const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode())
{ {
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = id; si.id = sid;
si.node = node; si.node = node;
return si; return si;
}; };
UniSetTypes::Message::Priority getPriority( const IOController_i::SensorInfo& si, UniversalIO::IOType type ); UniSetTypes::Message::Priority getPriority( const UniSetTypes::ObjectId id );
virtual IOController_i::ShortIOInfo getChangedTime( const IOController_i::SensorInfo& si ); virtual IOController_i::ShortIOInfo getChangedTime( const UniSetTypes::ObjectId id );
virtual IOController_i::ShortMapSeq* getSensors(); virtual IOController_i::ShortMapSeq* getSensors();
...@@ -99,7 +99,7 @@ class IOController: ...@@ -99,7 +99,7 @@ class IOController:
// предварительное объявление, чтобы в структуре объявить итератор.. // предварительное объявление, чтобы в структуре объявить итератор..
struct USensorInfo; struct USensorInfo;
typedef std::map<UniSetTypes::KeyType, USensorInfo> IOStateList; typedef std::map<UniSetTypes::ObjectId, USensorInfo> IOStateList;
// ================== Достпуные сигналы ================= // ================== Достпуные сигналы =================
/*! /*!
...@@ -111,14 +111,13 @@ class IOController: ...@@ -111,14 +111,13 @@ class IOController:
typedef sigc::signal<void, IOStateList::iterator&, IOController*> ChangeUndefinedStateSignal; typedef sigc::signal<void, IOStateList::iterator&, IOController*> ChangeUndefinedStateSignal;
// signal по изменению определённого датчика // signal по изменению определённого датчика
ChangeSignal signal_change_value( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ); ChangeSignal signal_change_value( UniSetTypes::ObjectId sid );
ChangeSignal signal_change_value( const IOController_i::SensorInfo& si );
// signal по изменению любого датчика // signal по изменению любого датчика
ChangeSignal signal_change_value(); ChangeSignal signal_change_value();
// сигналы по изменению флага "неопределённое состояние" (обрыв датчика например) // сигналы по изменению флага "неопределённое состояние" (обрыв датчика например)
ChangeUndefinedStateSignal signal_change_undefined_state( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ); ChangeUndefinedStateSignal signal_change_undefined_state( UniSetTypes::ObjectId sid );
ChangeUndefinedStateSignal signal_change_undefined_state( const IOController_i::SensorInfo& si );
ChangeUndefinedStateSignal signal_change_undefined_state(); ChangeUndefinedStateSignal signal_change_undefined_state();
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
...@@ -175,10 +174,10 @@ class IOController: ...@@ -175,10 +174,10 @@ class IOController:
inline int ioCount(){ return ioList.size(); } inline int ioCount(){ return ioList.size(); }
// доступ к элементам через итератор // доступ к элементам через итератор
virtual void localSetValue( IOStateList::iterator& it, const IOController_i::SensorInfo& si, virtual void localSetValue( IOStateList::iterator& it, const UniSetTypes::ObjectId sid,
CORBA::Long value, UniSetTypes::ObjectId sup_id ); CORBA::Long value, UniSetTypes::ObjectId sup_id );
virtual long localGetValue( IOStateList::iterator& it, const IOController_i::SensorInfo& si ); virtual long localGetValue( IOStateList::iterator& it, const UniSetTypes::ObjectId sid );
/*! функция выставления признака неопределённого состояния для аналоговых датчиков /*! функция выставления признака неопределённого состояния для аналоговых датчиков
...@@ -186,7 +185,7 @@ class IOController: ...@@ -186,7 +185,7 @@ class IOController:
// см. логику выставления в функции localSaveState // см. логику выставления в функции localSaveState
*/ */
virtual void localSetUndefinedState( IOStateList::iterator& it, bool undefined, virtual void localSetUndefinedState( IOStateList::iterator& it, bool undefined,
const IOController_i::SensorInfo& si ); const UniSetTypes::ObjectId sid );
protected: protected:
// переопределяем для добавления вызова регистрации датчиков // переопределяем для добавления вызова регистрации датчиков
...@@ -211,9 +210,7 @@ class IOController: ...@@ -211,9 +210,7 @@ class IOController:
void ioRegistration( const USensorInfo&, bool force=false ); void ioRegistration( const USensorInfo&, bool force=false );
/*! разрегистрация датчика */ /*! разрегистрация датчика */
void ioUnRegistration( const IOController_i::SensorInfo& si ); void ioUnRegistration( const UniSetTypes::ObjectId sid );
UniSetTypes::Message::Priority getMessagePriority(UniSetTypes::KeyType k, UniversalIO::IOType type);
// ------------------------------ // ------------------------------
inline IOController_i::SensorIOInfo inline IOController_i::SensorIOInfo
...@@ -243,7 +240,7 @@ class IOController: ...@@ -243,7 +240,7 @@ class IOController:
}; };
//! сохранение информации об изменении состояния датчика //! сохранение информации об изменении состояния датчика
virtual void logging(UniSetTypes::SensorMessage& sm); virtual void logging( UniSetTypes::SensorMessage& sm );
//! сохранение состояния всех датчиков в БД //! сохранение состояния всех датчиков в БД
virtual void dumpToDB(); virtual void dumpToDB();
......
...@@ -132,20 +132,20 @@ class IONotifyController: ...@@ -132,20 +132,20 @@ class IONotifyController:
public: public:
IONotifyController(const std::string& name, const std::string& section, NCRestorer* dumper=0); IONotifyController(const std::string& name, const std::string& section, NCRestorer* dumper=0);
IONotifyController(UniSetTypes::ObjectId id, NCRestorer* dumper=0); IONotifyController(const UniSetTypes::ObjectId id, NCRestorer* dumper=0);
virtual ~IONotifyController(); virtual ~IONotifyController();
virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::ObjectType("IONotifyController"); } virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::ObjectType("IONotifyController"); }
virtual void askSensor(const IOController_i::SensorInfo& si, 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 IOController_i::SensorInfo& si, 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 );
virtual IONotifyController_i::ThresholdInfo getThresholdInfo( const IOController_i::SensorInfo& si, UniSetTypes::ThresholdId tid ); virtual IONotifyController_i::ThresholdInfo getThresholdInfo( const UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid );
virtual IONotifyController_i::ThresholdList* getThresholds(const IOController_i::SensorInfo& si ); virtual IONotifyController_i::ThresholdList* getThresholds(const UniSetTypes::ObjectId sid );
virtual IONotifyController_i::ThresholdsListSeq* getThresholdsList(); virtual IONotifyController_i::ThresholdsListSeq* getThresholdsList();
virtual UniSetTypes::IDSeq* askSensorsSeq(const UniSetTypes::IDSeq& lst, virtual UniSetTypes::IDSeq* askSensorsSeq(const UniSetTypes::IDSeq& lst,
...@@ -155,7 +155,7 @@ class IONotifyController: ...@@ -155,7 +155,7 @@ class IONotifyController:
// функция для работы напрямую черех iterator (оптимизация) // функция для работы напрямую черех iterator (оптимизация)
virtual void localSetValue( IOController::IOStateList::iterator& it, virtual void localSetValue( IOController::IOStateList::iterator& it,
const IOController_i::SensorInfo& si, UniSetTypes::ObjectId sid,
CORBA::Long value, UniSetTypes::ObjectId sup_id ); CORBA::Long value, UniSetTypes::ObjectId sup_id );
// -------------------------------------------- // --------------------------------------------
...@@ -263,27 +263,26 @@ class IONotifyController: ...@@ -263,27 +263,26 @@ class IONotifyController:
bool myIOFilter(const USensorInfo& ai, CORBA::Long newvalue, UniSetTypes::ObjectId sup_id); bool myIOFilter(const USensorInfo& ai, CORBA::Long newvalue, UniSetTypes::ObjectId sup_id);
//! посылка информации об изменении состояния датчика //! посылка информации об изменении состояния датчика
virtual void send(ConsumerListInfo& lst, UniSetTypes::SensorMessage& sm); virtual void send( ConsumerListInfo& lst, UniSetTypes::SensorMessage& sm );
//! проверка срабатывания пороговых датчиков //! проверка срабатывания пороговых датчиков
virtual void checkThreshold( IOStateList::iterator& li, virtual void checkThreshold( IOStateList::iterator& li, const UniSetTypes::ObjectId sid, bool send=true );
const IOController_i::SensorInfo& si, bool send=true );
//! поиск информации о пороговом датчике //! поиск информации о пороговом датчике
ThresholdExtList::iterator findThreshold( UniSetTypes::KeyType k, UniSetTypes::ThresholdId tid ); ThresholdExtList::iterator findThreshold( const UniSetTypes::ObjectId sid, const UniSetTypes::ThresholdId tid );
//! сохранение информации об изменении состояния датчика в базу //! сохранение информации об изменении состояния датчика в базу
virtual void loggingInfo(UniSetTypes::SensorMessage& sm); virtual void loggingInfo( UniSetTypes::SensorMessage& sm );
/*! сохранение списка заказчиков /*! сохранение списка заказчиков
По умолчанию делает dump, если объявлен dumper. По умолчанию делает dump, если объявлен dumper.
*/ */
virtual void dumpOrdersList(const IOController_i::SensorInfo& si, const IONotifyController::ConsumerListInfo& lst); virtual void dumpOrdersList( const UniSetTypes::ObjectId sid, const IONotifyController::ConsumerListInfo& lst );
/*! сохранение списка заказчиков пороговых датчиков /*! сохранение списка заказчиков пороговых датчиков
По умолчанию делает dump, если объявлен dumper. По умолчанию делает dump, если объявлен dumper.
*/ */
virtual void dumpThresholdList(const IOController_i::SensorInfo& si, const IONotifyController::ThresholdExtList& lst); virtual void dumpThresholdList( const UniSetTypes::ObjectId sid, const IONotifyController::ThresholdExtList& lst );
/*! чтение dump-файла */ /*! чтение dump-файла */
virtual void readDump(); virtual void readDump();
...@@ -292,9 +291,6 @@ class IONotifyController: ...@@ -292,9 +291,6 @@ class IONotifyController:
void onChangeUndefinedState( IOStateList::iterator& it, IOController* ic ); void onChangeUndefinedState( IOStateList::iterator& it, IOController* ic );
// UniSetTypes::uniset_rwmutex sig_mutex;
// ChangeSignal changeSignal;
private: private:
friend class NCRestorer; friend class NCRestorer;
...@@ -303,7 +299,7 @@ class IONotifyController: ...@@ -303,7 +299,7 @@ class IONotifyController:
bool removeConsumer(ConsumerListInfo& lst, const UniSetTypes::ConsumerInfo& cons ); //!< удалить потребителя сообщения bool removeConsumer(ConsumerListInfo& lst, const UniSetTypes::ConsumerInfo& cons ); //!< удалить потребителя сообщения
//! обработка заказа //! обработка заказа
void ask(AskMap& askLst, const IOController_i::SensorInfo& si, void ask(AskMap& askLst, const UniSetTypes::ObjectId sid,
const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd); const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd);
/*! добавить новый порог для датчика */ /*! добавить новый порог для датчика */
...@@ -311,7 +307,6 @@ class IONotifyController: ...@@ -311,7 +307,6 @@ class IONotifyController:
/*! удалить порог для датчика */ /*! удалить порог для датчика */
bool removeThreshold(ThresholdExtList& lst, ThresholdInfoExt& ti, const UniSetTypes::ConsumerInfo& ci); bool removeThreshold(ThresholdExtList& lst, ThresholdInfoExt& ti, const UniSetTypes::ConsumerInfo& ci);
AskMap askIOList; /*!< список потребителей по аналоговым датчикам */ AskMap askIOList; /*!< список потребителей по аналоговым датчикам */
AskThresholdMap askTMap; /*!< список порогов по аналоговым датчикам */ AskThresholdMap askTMap; /*!< список порогов по аналоговым датчикам */
......
...@@ -37,12 +37,12 @@ class IORFile ...@@ -37,12 +37,12 @@ class IORFile
public: public:
IORFile(); IORFile();
std::string getIOR( const ObjectId id, const ObjectId node ) const; std::string getIOR( const ObjectId id ) const;
void setIOR( const ObjectId id, const ObjectId node, const std::string& sior ) const; void setIOR( const ObjectId id, const std::string& sior ) const;
void unlinkIOR( const ObjectId id, const ObjectId node ) const; void unlinkIOR( const ObjectId id ) const;
protected: protected:
std::string genFName( const ObjectId id, const ObjectId node ) const; std::string genFName( const ObjectId id ) const;
private: private:
}; };
......
...@@ -35,58 +35,32 @@ class ObjectIndex ...@@ -35,58 +35,32 @@ class ObjectIndex
ObjectIndex(){}; ObjectIndex(){};
virtual ~ObjectIndex(){}; virtual ~ObjectIndex(){};
static const std::string sepName;
static const std::string sepNode;
// info // info
virtual const ObjectInfo* getObjectInfo( const ObjectId )=0; virtual const ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId )=0;
virtual const ObjectInfo* getObjectInfo( const std::string& name )=0; virtual const ObjectInfo* getObjectInfo( const std::string& name )=0;
// создание полного имени в репозитории по паре имя:узел
static std::string mkRepName( const std::string& repname, const std::string& nodename );
// создание имени узла по реальному и виртуальному
static std::string mkFullNodeName( const std::string& realnode, const std::string& virtnode );
// получить имя для регистрации в репозитории (т.е. без секции)
static std::string getBaseName( const std::string& fname ); static std::string getBaseName( const std::string& fname );
// object id // object id
virtual ObjectId getIdByName(const std::string& name)=0; virtual ObjectId getIdByName(const std::string& name)=0;
virtual std::string getNameById( const ObjectId id ); virtual std::string getNameById( const UniSetTypes::ObjectId id );
virtual std::string getNameById( const ObjectId id, const ObjectId node );
// node // node
virtual std::string getFullNodeName(const std::string& fullname); inline std::string getNodeName( const UniSetTypes::ObjectId id )
virtual std::string getVirtualNodeName(const std::string& fullNodeName); {
virtual std::string getRealNodeName(const std::string& fullNodeName); return getNameById(id);
virtual std::string getRealNodeName( const ObjectId id ); }
virtual std::string getName( const std::string& fullname ); inline ObjectId getNodeId( const std::string& name ) { return getIdByName(name); }
// src name // src name
virtual std::string getMapName(const ObjectId id)=0; virtual std::string getMapName( const UniSetTypes::ObjectId id )=0;
virtual std::string getTextName(const ObjectId id)=0; virtual std::string getTextName( const UniSetTypes::ObjectId id )=0;
// //
virtual std::ostream& printMap(std::ostream& os)=0; virtual std::ostream& printMap(std::ostream& os)=0;
// ext void initLocalNode( const UniSetTypes::ObjectId nodeid );
inline ObjectId getIdByFullName(const std::string& fname)
{
return getIdByName(getName(fname));
}
inline ObjectId getNodeId( const std::string& fullname )
{
return getIdByName( getFullNodeName(fullname) );
}
inline std::string getFullNodeName( const ObjectId nodeid )
{
return getMapName(nodeid);
}
void initLocalNode( ObjectId nodeid );
protected: protected:
std::string nmLocalNode; // для оптимизации std::string nmLocalNode; // для оптимизации
......
...@@ -41,11 +41,11 @@ class ObjectIndex_XML: ...@@ -41,11 +41,11 @@ class ObjectIndex_XML:
ObjectIndex_XML(UniXML& xml, int minSize=1000 ); ObjectIndex_XML(UniXML& xml, int minSize=1000 );
virtual ~ObjectIndex_XML(); virtual ~ObjectIndex_XML();
virtual const UniSetTypes::ObjectInfo* getObjectInfo(const ObjectId); virtual const UniSetTypes::ObjectInfo* getObjectInfo( const ObjectId );
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string& name ); virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string& name );
virtual ObjectId getIdByName(const std::string& name); virtual ObjectId getIdByName( const std::string& name );
virtual std::string getMapName(const ObjectId id); virtual std::string getMapName( const ObjectId id );
virtual std::string getTextName(const ObjectId id); virtual std::string getTextName( const ObjectId id );
virtual std::ostream& printMap(std::ostream& os); virtual std::ostream& printMap(std::ostream& os);
friend std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi ); friend std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi );
...@@ -59,7 +59,6 @@ class ObjectIndex_XML: ...@@ -59,7 +59,6 @@ class ObjectIndex_XML:
typedef std::map<std::string, ObjectId> MapObjectKey; typedef std::map<std::string, ObjectId> MapObjectKey;
MapObjectKey mok; // для обратного писка MapObjectKey mok; // для обратного писка
std::vector<ObjectInfo> omap; // для прямого поиска std::vector<ObjectInfo> omap; // для прямого поиска
}; };
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
} // end of namespace } // end of namespace
......
...@@ -83,7 +83,7 @@ class UInterface ...@@ -83,7 +83,7 @@ class UInterface
// fast - это удалённый вызов "без подтверждения", он быстрее, но менее надёжен // fast - это удалённый вызов "без подтверждения", он быстрее, но менее надёжен
// т.к. вызывающий никогда не узнает об ошибке, если она была (датчик такой не найдён и т.п.) // т.к. вызывающий никогда не узнает об ошибке, если она была (датчик такой не найдён и т.п.)
void fastSetValue( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier ); void fastSetValue( const IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier );
//! Получение состояния для списка указанных датчиков //! Получение состояния для списка указанных датчиков
IOController_i::SensorInfoSeq_var getSensorSeq( UniSetTypes::IDList& lst ); IOController_i::SensorInfoSeq_var getSensorSeq( UniSetTypes::IDList& lst );
...@@ -108,7 +108,7 @@ class UInterface ...@@ -108,7 +108,7 @@ class UInterface
// ------------------------------------------------------ // ------------------------------------------------------
// установка неопределённого состояния // установка неопределённого состояния
void setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId supplier ); void setUndefinedState( const IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId supplier );
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Калибровка... пороги... // Калибровка... пороги...
...@@ -160,11 +160,9 @@ class UInterface ...@@ -160,11 +160,9 @@ class UInterface
// /*! регистрация объекта в репозитории */ // /*! регистрация объекта в репозитории */
void registered(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)const throw(UniSetTypes::ORepFailed); void registered(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)const throw(UniSetTypes::ORepFailed);
void registered(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node, const UniSetTypes::ObjectPtr oRef, bool force=false)const throw(UniSetTypes::ORepFailed);
// /*! разрегистрация объекта */ // /*! разрегистрация объекта */
void unregister(const UniSetTypes::ObjectId id)throw(UniSetTypes::ORepFailed); void unregister(const UniSetTypes::ObjectId id)throw(UniSetTypes::ORepFailed);
void unregister(const UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) throw(UniSetTypes::ORepFailed);
/*! получение ссылки на объект */ /*! получение ссылки на объект */
inline UniSetTypes::ObjectPtr resolve( const std::string& name ) const inline UniSetTypes::ObjectPtr resolve( const std::string& name ) const
...@@ -174,7 +172,6 @@ class UInterface ...@@ -174,7 +172,6 @@ class UInterface
inline UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id ) const inline UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id ) const
{ {
// std::string nm = oind->getNameById(id);
return rep.resolve( oind->getNameById(id) ); return rep.resolve( oind->getNameById(id) );
} }
...@@ -211,30 +208,19 @@ class UInterface ...@@ -211,30 +208,19 @@ class UInterface
return oind->getNameById(id); return oind->getNameById(id);
} }
inline std::string getNameById( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{
return oind->getNameById(id, node);
}
inline UniSetTypes::ObjectId getNodeId( const std::string& fullname ) const inline UniSetTypes::ObjectId getNodeId( const std::string& fullname ) const
{ {
return oind->getNodeId(fullname); return oind->getNodeId(fullname);
} }
inline std::string getName( const std::string& fullname ) const
{
return oind->getName(fullname);
}
inline std::string getTextName( const UniSetTypes::ObjectId id ) const inline std::string getTextName( const UniSetTypes::ObjectId id ) const
{ {
return oind->getTextName(id); return oind->getTextName(id);
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Получение указателей на вспомогательные классы. // Получение указателей на вспомогательные классы.
inline UniSetTypes::ObjectIndex* getObjectIndex() { return oind; } inline const UniSetTypes::ObjectIndex* getObjectIndex() { return oind; }
inline const UniSetTypes::Configuration* getConf() { return uconf; } inline const UniSetTypes::Configuration* getConf() { return uconf; }
// --------------------------------------------------------------- // ---------------------------------------------------------------
......
/* This file is part of the UniSet project /* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc. * Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Pavel Vainerman * Copyright (c) 2002 Pavel Vainerman
...@@ -77,7 +78,7 @@ void UInterface::init() ...@@ -77,7 +78,7 @@ void UInterface::init()
try try
{ {
ostringstream s; ostringstream s;
s << uconf << oind->getRealNodeName(uconf->getLocalNode()); s << uconf << oind->getNodeName(uconf->getLocalNode());
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
{ {
...@@ -114,10 +115,10 @@ void UInterface::initBackId( const UniSetTypes::ObjectId backid ) ...@@ -114,10 +115,10 @@ void UInterface::initBackId( const UniSetTypes::ObjectId backid )
* \exception IOBadParam - генерируется если указано неправильное имя датчика или секции * \exception IOBadParam - генерируется если указано неправильное имя датчика или секции
* \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ * \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ
*/ */
long UInterface::getValue( const ObjectId name, const ObjectId node ) const long UInterface::getValue( const ObjectId id, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(getValue): error id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getValue): error id=UniSetTypes::DefaultObjectId");
try try
...@@ -125,7 +126,7 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const ...@@ -125,7 +126,7 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(name, node); oref = rcache.resolve(id, node);
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -134,13 +135,10 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const ...@@ -134,13 +135,10 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve( name, node ); oref = resolve( id, node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
IOController_i::SensorInfo_var si; return iom->getValue(id);
si->id = name;
si->node = node;
return iom->getValue(si.in());
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){} catch(CORBA::OBJECT_NOT_EXIST){}
...@@ -152,29 +150,29 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const ...@@ -152,29 +150,29 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const
catch(UniSetTypes::TimeOut){} catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::NameNotFound("UI(getValue): "+string(ex.err)); throw UniSetTypes::NameNotFound("UI(getValue): "+string(ex.err));
} }
catch(IOController_i::IOBadParam& ex) catch(IOController_i::IOBadParam& ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getValue): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(getValue): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(name, node); rcache.erase(id, node);
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(getValue): ORepFailed",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getValue): ORepFailed",id,node));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(getValue): method no implement",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getValue): method no implement",id,node));
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(getValue): object not exist",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getValue): object not exist",id,node));
} }
catch(CORBA::COMM_FAILURE& ex) catch(CORBA::COMM_FAILURE& ex)
{ {
...@@ -185,8 +183,8 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const ...@@ -185,8 +183,8 @@ long UInterface::getValue( const ObjectId name, const ObjectId node ) const
// ошибка системы коммуникации // ошибка системы коммуникации
// uwarn << "UI(getValue): CORBA::SystemException" << endl; // uwarn << "UI(getValue): CORBA::SystemException" << endl;
} }
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::TimeOut(set_err("UI(getValue): TimeOut",name,node)); throw UniSetTypes::TimeOut(set_err("UI(getValue): TimeOut",id,node));
} }
long UInterface::getValue( const ObjectId name ) const long UInterface::getValue( const ObjectId name ) const
...@@ -196,7 +194,7 @@ long UInterface::getValue( const ObjectId name ) const ...@@ -196,7 +194,7 @@ long UInterface::getValue( const ObjectId name ) const
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId sup_id ) void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId sup_id )
{ {
if( si.id == DefaultObjectId ) if( si.id == DefaultObjectId )
{ {
...@@ -224,7 +222,7 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin ...@@ -224,7 +222,7 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin
oref = resolve( si.id, si.node ); oref = resolve( si.id, si.node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
iom->setUndefinedState(si, undefined, sup_id ); iom->setUndefinedState(si.id, undefined, sup_id );
return; return;
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
...@@ -275,10 +273,10 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin ...@@ -275,10 +273,10 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin
* \return текущее значение датчика * \return текущее значение датчика
* \exception IOBadParam - генерируется если указано неправильное имя вывода или секции * \exception IOBadParam - генерируется если указано неправильное имя вывода или секции
*/ */
void UInterface::setValue( const ObjectId name, long value, const ObjectId node ) const void UInterface::setValue( const ObjectId id, long value, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(setValue): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(setValue): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
try try
...@@ -286,7 +284,7 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node ...@@ -286,7 +284,7 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(name, node); oref = rcache.resolve(id, node);
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -295,13 +293,10 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node ...@@ -295,13 +293,10 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve( name, node ); oref = resolve( id, node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
IOController_i::SensorInfo_var si; iom->setValue(id, value, myid);
si->id = name;
si->node = node;
iom->setValue(si, value, myid);
return; return;
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
...@@ -314,29 +309,29 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node ...@@ -314,29 +309,29 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node
catch(UniSetTypes::TimeOut){} catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::NameNotFound(set_err("UI(setValue): NameNotFound для объекта",name,node)); throw UniSetTypes::NameNotFound(set_err("UI(setValue): NameNotFound для объекта",id,node));
} }
catch(IOController_i::IOBadParam& ex) catch(IOController_i::IOBadParam& ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(setValue): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(setValue): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(name, node); rcache.erase(id, node);
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(setValue): resolve failed ",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(setValue): resolve failed ",id,node));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(setValue): method no implement",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(setValue): method no implement",id,node));
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(setValue): object not exist",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(setValue): object not exist",id,node));
} }
catch(CORBA::COMM_FAILURE& ex) catch(CORBA::COMM_FAILURE& ex)
{ {
...@@ -344,11 +339,9 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node ...@@ -344,11 +339,9 @@ void UInterface::setValue( const ObjectId name, long value, const ObjectId node
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
// ошибка системы коммуникации
// uwarn << "UI(setValue): CORBA::SystemException" << endl;
} }
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::TimeOut(set_err("UI(setValue): Timeout",name,node)); throw UniSetTypes::TimeOut(set_err("UI(setValue): Timeout",id,node));
} }
void UInterface::setValue( const ObjectId name, long value ) const void UInterface::setValue( const ObjectId name, long value ) const
...@@ -376,7 +369,7 @@ void UInterface::setValue( IOController_i::SensorInfo& si, long value, const Uni ...@@ -376,7 +369,7 @@ void UInterface::setValue( IOController_i::SensorInfo& si, long value, const Uni
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
// функция не вырабатывает исключий! // функция не вырабатывает исключий!
void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId sup_id ) void UInterface::fastSetValue( const IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId sup_id )
{ {
if ( si.id == DefaultObjectId ) if ( si.id == DefaultObjectId )
{ {
...@@ -404,7 +397,7 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe ...@@ -404,7 +397,7 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe
oref = resolve( si.id,si.node ); oref = resolve( si.id,si.node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
iom->fastSetValue(si, value,sup_id); iom->fastSetValue(si.id, value,sup_id);
return; return;
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
...@@ -459,12 +452,12 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe ...@@ -459,12 +452,12 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
/*! /*!
* \param sensor - идентификатор датчика * \param id - идентификатор датчика
* \param node - идентификатор узла на котором заказывается датчик * \param node - идентификатор узла на котором заказывается датчик
* \param cmd - команда см. \ref UniversalIO::UIOCommand * \param cmd - команда см. \ref UniversalIO::UIOCommand
* \param backid - обратный адрес (идентификатор заказчика) * \param backid - обратный адрес (идентификатор заказчика)
*/ */
void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const ObjectId node, void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd, const ObjectId node,
UniSetTypes::ObjectId backid ) const throw(IO_THROW_EXCEPTIONS) UniSetTypes::ObjectId backid ) const throw(IO_THROW_EXCEPTIONS)
{ {
if( backid==UniSetTypes::DefaultObjectId ) if( backid==UniSetTypes::DefaultObjectId )
...@@ -473,7 +466,7 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c ...@@ -473,7 +466,7 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c
if( backid==UniSetTypes::DefaultObjectId ) if( backid==UniSetTypes::DefaultObjectId )
throw UniSetTypes::IOBadParam("UI(askRemoteSensor): unknown back ID"); throw UniSetTypes::IOBadParam("UI(askRemoteSensor): unknown back ID");
if ( name == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(askRemoteSensor): id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(askRemoteSensor): id=UniSetTypes::DefaultObjectId");
try try
...@@ -481,7 +474,7 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c ...@@ -481,7 +474,7 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(name, node); oref = rcache.resolve(id, node);
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -490,17 +483,13 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c ...@@ -490,17 +483,13 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve( name, node ); oref = resolve( id, node );
IONotifyController_i_var inc = IONotifyController_i::_narrow(oref); IONotifyController_i_var inc = IONotifyController_i::_narrow(oref);
IOController_i::SensorInfo_var si;
si->id = name;
si->node = node;
ConsumerInfo_var ci; ConsumerInfo_var ci;
ci->id = backid; ci->id = backid;
ci->node = uconf->getLocalNode(); ci->node = uconf->getLocalNode();
inc->askSensor(si, ci, cmd ); inc->askSensor(id, ci, cmd );
return; return;
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
...@@ -513,29 +502,29 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c ...@@ -513,29 +502,29 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c
catch(UniSetTypes::TimeOut){} catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::NameNotFound("UI(askSensor): "+string(ex.err) ); throw UniSetTypes::NameNotFound("UI(askSensor): "+string(ex.err) );
} }
catch(IOController_i::IOBadParam& ex) catch(IOController_i::IOBadParam& ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(askSensor): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(askSensor): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(name, node); rcache.erase(id, node);
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(askSensor): resolve failed ",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(askSensor): resolve failed ",id,node));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(askSensor): method no implement",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(askSensor): method no implement",id,node));
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(askSensor): object not exist",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(askSensor): object not exist",id,node));
} }
catch(CORBA::COMM_FAILURE& ex) catch(CORBA::COMM_FAILURE& ex)
{ {
...@@ -548,8 +537,8 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c ...@@ -548,8 +537,8 @@ void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand c
// uwarn << "UI(askSensor): CORBA::SystemException" << endl; // uwarn << "UI(askSensor): CORBA::SystemException" << endl;
} }
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::TimeOut(set_err("UI(askSensor): Timeout",name,node)); throw UniSetTypes::TimeOut(set_err("UI(askSensor): Timeout",id,node));
} }
void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId backid ) const void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId backid ) const
...@@ -559,13 +548,13 @@ void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, co ...@@ -559,13 +548,13 @@ void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, co
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
/*! /*!
* \param name - идентификатор объекта * \param id - идентификатор объекта
* \param node - идентификатор узла * \param node - идентификатор узла
*/ */
IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const IOType UInterface::getIOType( const ObjectId id, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(getIOType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getIOType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
try try
...@@ -573,7 +562,7 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const ...@@ -573,7 +562,7 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(name, node); oref = rcache.resolve(id, node);
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -582,13 +571,10 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const ...@@ -582,13 +571,10 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve(name, node); oref = resolve(id, node);
IOController_i_var inc = IOController_i::_narrow(oref); IOController_i_var inc = IOController_i::_narrow(oref);
IOController_i::SensorInfo_var si; return inc->getIOType(id);
si->id = name;
si->node = node;
return inc->getIOType(si);
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){} catch(CORBA::OBJECT_NOT_EXIST){}
...@@ -599,29 +585,29 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const ...@@ -599,29 +585,29 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const
} }
catch(IOController_i::NameNotFound& ex) catch(IOController_i::NameNotFound& ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::NameNotFound("UI(getIOType): "+string(ex.err)); throw UniSetTypes::NameNotFound("UI(getIOType): "+string(ex.err));
} }
catch(IOController_i::IOBadParam& ex) catch(IOController_i::IOBadParam& ex)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getIOType): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(getIOType): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(name, node); rcache.erase(id, node);
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(getIOType): resolve failed ",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getIOType): resolve failed ",id,node));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(getIOType): method no implement",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getIOType): method no implement",id,node));
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam(set_err("UI(getIOType): object not exist",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getIOType): object not exist",id,node));
} }
catch(CORBA::COMM_FAILURE& ex) catch(CORBA::COMM_FAILURE& ex)
{ {
...@@ -634,17 +620,17 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const ...@@ -634,17 +620,17 @@ IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const
// uwarn << "UI(getIOType): CORBA::SystemException" << endl; // uwarn << "UI(getIOType): CORBA::SystemException" << endl;
} }
rcache.erase(name, node); rcache.erase(id, node);
throw UniSetTypes::TimeOut(set_err("UI(getIOType): Timeout",name, node)); throw UniSetTypes::TimeOut(set_err("UI(getIOType): Timeout",id, node));
} }
IOType UInterface::getIOType( const ObjectId name ) const IOType UInterface::getIOType( const ObjectId id ) const
{ {
return getIOType(name, uconf->getLocalNode() ); return getIOType(id, uconf->getLocalNode() );
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
/*! /*!
* \param name - идентификатор объекта * \param id - идентификатор объекта
* \param node - идентификатор узла * \param node - идентификатор узла
*/ */
ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const
...@@ -727,15 +713,7 @@ ObjectType UInterface::getType( const ObjectId name ) const ...@@ -727,15 +713,7 @@ ObjectType UInterface::getType( const ObjectId name ) const
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force ) const void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force ) const throw(ORepFailed)
throw(UniSetTypes::ORepFailed)
{
registered(id,uconf->getLocalNode(), oRef,force);
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::registered( const ObjectId id, const ObjectId node,
const UniSetTypes::ObjectPtr oRef, bool force ) const throw(ORepFailed)
{ {
// если влючён режим использования локальных файлов // если влючён режим использования локальных файлов
// то пишем IOR в файл // то пишем IOR в файл
...@@ -744,46 +722,40 @@ void UInterface::registered( const ObjectId id, const ObjectId node, ...@@ -744,46 +722,40 @@ void UInterface::registered( const ObjectId id, const ObjectId node,
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
uconf->iorfile.setIOR(id,node,orb->object_to_string(oRef)); uconf->iorfile.setIOR(id,orb->object_to_string(oRef));
return; return;
} }
try try
{ {
rep.registration(oind->getNameById(id, node),oRef,(bool)force); rep.registration( oind->getNameById(id), oRef, force );
} }
catch(Exception& ex ) catch( Exception& ex )
{ {
throw; throw;
} }
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::unregister( const ObjectId id, const ObjectId node )throw(ORepFailed) void UInterface::unregister( const ObjectId id )throw(ORepFailed)
{ {
if( uconf->isLocalIOR() ) if( uconf->isLocalIOR() )
{ {
uconf->iorfile.unlinkIOR(id,node); uconf->iorfile.unlinkIOR(id);
return; return;
} }
try try
{ {
rep.unregistration(oind->getNameById(id,node)); rep.unregistration( oind->getNameById(id) );
} }
catch(Exception& ex ) catch( Exception& ex )
{ {
throw; throw;
} }
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::unregister( const ObjectId id )throw(UniSetTypes::ORepFailed)
{
unregister(id,uconf->getLocalNode());
}
// ------------------------------------------------------------------------------------------------------------
ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int timeoutSec ) const ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int timeoutSec ) const
throw(ResolveNameError, UniSetTypes::TimeOut ) throw(ResolveNameError, UniSetTypes::TimeOut )
{ {
...@@ -799,7 +771,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -799,7 +771,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
string sior(uconf->iorfile.getIOR(rid,node)); string sior(uconf->iorfile.getIOR(rid));
if( !sior.empty() ) if( !sior.empty() )
{ {
CORBA::Object_var nso = orb->string_to_object(sior.c_str()); CORBA::Object_var nso = orb->string_to_object(sior.c_str());
...@@ -810,7 +782,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -810,7 +782,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
{ {
// если NameService недоступен то, // если NameService недоступен то,
// сразу выдаём ошибку // сразу выдаём ошибку
uwarn << "not found IOR-file for " << uconf->oind->getNameById(rid,node) << endl; uwarn << "not found IOR-file for " << uconf->oind->getNameById(rid) << endl;
throw UniSetTypes::ResolveNameError(); throw UniSetTypes::ResolveNameError();
} }
} }
...@@ -819,7 +791,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -819,7 +791,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
{ {
// Получаем доступ к NameService на данном узле // Получаем доступ к NameService на данном узле
ostringstream s; ostringstream s;
s << uconf << oind->getRealNodeName(node); s << uconf << oind->getNodeName(node);
string nodeName(s.str()); string nodeName(s.str());
string bname(nodeName); // сохраняем базовое название string bname(nodeName); // сохраняем базовое название
for(unsigned int curNet=1; curNet<=uconf->getCountOfNet(); curNet++) for(unsigned int curNet=1; curNet<=uconf->getCountOfNet(); curNet++)
...@@ -833,7 +805,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -833,7 +805,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
break; break;
} }
// catch(CORBA::COMM_FAILURE& ex ) // catch(CORBA::COMM_FAILURE& ex )
catch(ORepFailed& ex) catch( ORepFailed& ex )
{ {
// нет связи с этим узлом // нет связи с этим узлом
// пробуем связатся по другой сети // пробуем связатся по другой сети
...@@ -855,7 +827,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -855,7 +827,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
if( CORBA::is_nil(localctx) ) if( CORBA::is_nil(localctx) )
{ {
ostringstream s; ostringstream s;
s << uconf << oind->getRealNodeName(node); s << uconf << oind->getNodeName(node);
string nodeName(s.str()); string nodeName(s.str());
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
{ {
...@@ -869,7 +841,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -869,7 +841,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
ctx = localctx; ctx = localctx;
} }
CosNaming::Name_var oname = omniURI::stringToName( oind->getNameById(rid,node).c_str() ); CosNaming::Name_var oname = omniURI::stringToName( oind->getNameById(rid).c_str() );
for (unsigned int i=0; i<uconf->getRepeatCount(); i++) for (unsigned int i=0; i<uconf->getRepeatCount(); i++)
{ {
try try
...@@ -986,16 +958,12 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ...@@ -986,16 +958,12 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
if( id == DefaultObjectId ) if( id == DefaultObjectId )
throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
IOController_i::SensorInfo si;
si.id = id;
si.node = node;
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(si.id, si.node); oref = rcache.resolve(id, node);
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -1004,10 +972,10 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ...@@ -1004,10 +972,10 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve( si.id, si.node ); oref = resolve( id, node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
return iom->getChangedTime(si); return iom->getChangedTime(id);
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){} catch(CORBA::OBJECT_NOT_EXIST){}
...@@ -1019,28 +987,28 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ...@@ -1019,28 +987,28 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
catch(UniSetTypes::TimeOut){} catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
rcache.erase(si.id, si.node); rcache.erase(id, node);
uwarn << "UI(getChangedTime): " << ex.err << endl; uwarn << "UI(getChangedTime): " << ex.err << endl;
} }
catch(IOController_i::IOBadParam& ex ) catch(IOController_i::IOBadParam& ex )
{ {
rcache.erase(si.id, si.node); rcache.erase(id, node);
throw UniSetTypes::IOBadParam("UI(getChangedTime): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(getChangedTime): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(si.id, si.node); rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): resolve failed ",si.id,si.node) << endl; uwarn << set_err("UI(getChangedTime): resolve failed ",id,node) << endl;
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(si.id, si.node); rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): method no implement",si.id,si.node) << endl; uwarn << set_err("UI(getChangedTime): method no implement",id,node) << endl;
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(si.id, si.node); rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): object not exist",si.id,si.node) << endl; uwarn << set_err("UI(getChangedTime): object not exist",id,node) << endl;
} }
catch(CORBA::COMM_FAILURE) catch(CORBA::COMM_FAILURE)
{ {
...@@ -1054,8 +1022,8 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ...@@ -1054,8 +1022,8 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
} }
catch(...){} catch(...){}
rcache.erase(si.id, si.node); rcache.erase(id, node);
throw UniSetTypes::TimeOut(set_err("UI(getChangedTime): Timeout",si.id, si.node)); throw UniSetTypes::TimeOut(set_err("UI(getChangedTime): Timeout",id, node));
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
...@@ -1135,7 +1103,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const ...@@ -1135,7 +1103,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
string sior(uconf->iorfile.getIOR(id,uconf->getLocalNode())); string sior( uconf->iorfile.getIOR(id) );
if( !sior.empty() ) if( !sior.empty() )
{ {
CORBA::Object_var oref = orb->string_to_object(sior.c_str()); CORBA::Object_var oref = orb->string_to_object(sior.c_str());
...@@ -1145,8 +1113,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const ...@@ -1145,8 +1113,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const
return false; return false;
} }
string nm = oind->getNameById(id); return rep.isExist( oind->getNameById(id) );
return rep.isExist(nm);
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
...@@ -1185,13 +1152,12 @@ string UInterface::set_err( const std::string& pre, const ObjectId id, const Obj ...@@ -1185,13 +1152,12 @@ string UInterface::set_err( const std::string& pre, const ObjectId id, const Obj
if( id==UniSetTypes::DefaultObjectId ) if( id==UniSetTypes::DefaultObjectId )
return string(pre+" DefaultObjectId"); return string(pre+" DefaultObjectId");
string nm(oind->getNameById(id,node)); string nm( oind->getNameById(node) );
if( nm.empty() ) if( nm.empty() )
nm = "UnknownName"; nm = "UnknownName";
ostringstream s; ostringstream s;
s << pre << " (" << id << ")" << nm; s << pre << " (" << id << ":" << node <<")" << nm;
return s.str(); return s.str();
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
...@@ -1234,15 +1200,11 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node, ...@@ -1234,15 +1200,11 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
oref = resolve( sid, node ); oref = resolve( sid, node );
IONotifyController_i_var inc = IONotifyController_i::_narrow(oref); IONotifyController_i_var inc = IONotifyController_i::_narrow(oref);
IOController_i::SensorInfo_var si;
si->id = sid;
si->node = node;
ConsumerInfo_var ci; ConsumerInfo_var ci;
ci->id = backid; ci->id = backid;
ci->node = uconf->getLocalNode(); ci->node = uconf->getLocalNode();
inc->askThreshold(si,ci,tid,lowLimit,hiLimit,invert,cmd); inc->askThreshold(sid,ci,tid,lowLimit,hiLimit,invert,cmd);
return; return;
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
...@@ -1325,7 +1287,7 @@ IONotifyController_i::ThresholdInfo ...@@ -1325,7 +1287,7 @@ IONotifyController_i::ThresholdInfo
oref = resolve( si.id, si.node ); oref = resolve( si.id, si.node );
IONotifyController_i_var iom = IONotifyController_i::_narrow(oref); IONotifyController_i_var iom = IONotifyController_i::_narrow(oref);
return iom->getThresholdInfo(si,tid); return iom->getThresholdInfo(si.id,tid);
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){} catch(CORBA::OBJECT_NOT_EXIST){}
...@@ -1396,7 +1358,7 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si ) ...@@ -1396,7 +1358,7 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si )
oref = resolve( si.id, si.node ); oref = resolve( si.id, si.node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
return iom->getRawValue(si); return iom->getRawValue(si.id);
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){} catch(CORBA::OBJECT_NOT_EXIST){}
...@@ -1475,7 +1437,7 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si, ...@@ -1475,7 +1437,7 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
oref = resolve( si.id, si.node ); oref = resolve( si.id, si.node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
iom->calibrate(si,ci,admId); iom->calibrate(si.id,ci,admId);
return; return;
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
...@@ -1547,7 +1509,7 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i ...@@ -1547,7 +1509,7 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i
oref = resolve( si.id, si.node ); oref = resolve( si.id, si.node );
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
return iom->getCalibrateInfo(si); return iom->getCalibrateInfo(si.id);
} }
catch(CORBA::TRANSIENT){} catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){} catch(CORBA::OBJECT_NOT_EXIST){}
......
...@@ -37,9 +37,9 @@ IORFile::IORFile() ...@@ -37,9 +37,9 @@ IORFile::IORFile()
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::getIOR( const ObjectId id, const ObjectId node ) const string IORFile::getIOR( const ObjectId id ) const
{ {
string fname( genFName(id,node) ); string fname( genFName(id) );
ifstream ior_file(fname.c_str()); ifstream ior_file(fname.c_str());
string sior; string sior;
ior_file >> sior; ior_file >> sior;
...@@ -47,9 +47,9 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node ) const ...@@ -47,9 +47,9 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node ) const
return sior; return sior;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior ) const void IORFile::setIOR( const ObjectId id, const string& sior ) const
{ {
string fname( genFName(id,node) ); string fname( genFName(id) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc); ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
if( !ior_file ) if( !ior_file )
...@@ -62,16 +62,16 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior ...@@ -62,16 +62,16 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior
ior_file.close(); ior_file.close();
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::unlinkIOR( const ObjectId id, const ObjectId node ) const void IORFile::unlinkIOR( const ObjectId id ) const
{ {
string fname( genFName(id,node) ); string fname( genFName(id) );
unlink(fname.c_str()); unlink(fname.c_str());
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::genFName( const ObjectId id, const ObjectId node ) const string IORFile::genFName( const ObjectId id ) const
{ {
ostringstream fname; ostringstream fname;
fname << conf->getLockDir() << id << "." << node; fname << conf->getLockDir() << id;
return fname.str(); return fname.str();
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
...@@ -196,26 +196,12 @@ namespace ORepHelpers ...@@ -196,26 +196,12 @@ namespace ORepHelpers
*/ */
const string getShortName( const string& fname, const std::string& brk ) const string getShortName( const string& fname, const std::string& brk )
{ {
/*
string::size_type pos = fname.rfind(brk); string::size_type pos = fname.rfind(brk);
if( pos == string::npos ) if( pos == string::npos )
return fname; return fname;
return fname.substr( pos+1, fname.length() ); return fname.substr( pos+1, fname.length() );
*/
string::size_type pos1 = fname.rfind(brk);
string::size_type pos2 = fname.rfind(conf->oind->sepName);
if( pos2 == string::npos && pos1 == string::npos )
return fname;
if( pos1 == string::npos )
return fname.substr( 0, pos2 );
if( pos2 == string::npos )
return fname.substr( pos1+1, fname.length() );
return fname.substr( pos1+1, pos2-pos1-1 );
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
...@@ -238,7 +224,7 @@ namespace ORepHelpers ...@@ -238,7 +224,7 @@ namespace ORepHelpers
* Запрещенные символы см. UniSetTypes::BadSymbols[] * Запрещенные символы см. UniSetTypes::BadSymbols[]
* \return Если не найдено запрещенных символов то будет возвращен 0, иначе найденный символ * \return Если не найдено запрещенных символов то будет возвращен 0, иначе найденный символ
*/ */
char checkBadSymbols(const string& str) char checkBadSymbols( const string& str )
{ {
using namespace UniSetTypes; using namespace UniSetTypes;
...@@ -269,4 +255,3 @@ namespace ORepHelpers ...@@ -269,4 +255,3 @@ namespace ORepHelpers
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
} }
...@@ -30,42 +30,13 @@ ...@@ -30,42 +30,13 @@
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
using namespace UniSetTypes; using namespace UniSetTypes;
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
const std::string ObjectIndex::sepName = "@"; //const std::string ObjectIndex::sepName = "@";
const std::string ObjectIndex::sepNode = ":"; //const std::string ObjectIndex::sepNode = ":";
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex::getNameById( const ObjectId id ) string ObjectIndex::getNameById( const ObjectId id )
{ {
string n(getMapName(id)); return getMapName(id);
if( n.empty() )
return "";
return mkRepName(n,nmLocalNode);
}
// -----------------------------------------------------------------------------------------
string ObjectIndex::getNameById( const ObjectId id, const ObjectId node )
{
const string t(getMapName(id));
if( t.empty() )
return "";
// оптимизация
if( node == conf->getLocalNode() )
return mkRepName(t,nmLocalNode);
return mkRepName(t,getMapName(node));
}
// -----------------------------------------------------------------------------------------
string ObjectIndex::mkRepName( const std::string& repname, const std::string& nodename )
{
return repname + sepName + nodename;
}
// -----------------------------------------------------------------------------------------
string ObjectIndex::mkFullNodeName( const std::string& realnode, const std::string& virtnode )
{
// realnode справа, что поиск и вырезание происходили быстрее
// эта функция часто используется...
return virtnode + sepNode + realnode;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
std::string ObjectIndex::getBaseName( const std::string& fname ) std::string ObjectIndex::getBaseName( const std::string& fname )
...@@ -77,78 +48,7 @@ std::string ObjectIndex::getBaseName( const std::string& fname ) ...@@ -77,78 +48,7 @@ std::string ObjectIndex::getBaseName( const std::string& fname )
return fname; return fname;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex::getFullNodeName( const string& oname ) void ObjectIndex::initLocalNode( const ObjectId nodeid )
{
string::size_type pos = oname.rfind(sepName);
if( pos != string::npos )
return oname.substr(pos+1);
// Если не нашли разделитель name@vnode:rnode
// то пытаемся найти в данной строке сочетание vnode:rnode
string vnode = getVirtualNodeName(oname);
string rnode = getRealNodeName(oname);
if( !rnode.empty() )
{
if( vnode.empty() )
vnode = rnode;
return mkFullNodeName(rnode,vnode);
}
// Если не нашли, то возвращаем, полное имя
// ЛОКАЛЬНОГО узла...(для оптимизации хранимого в классе)
if( !nmLocalNode.empty() )
return mkFullNodeName(nmLocalNode,nmLocalNode);
nmLocalNode = getMapName(UniSetTypes::conf->getLocalNode());
return mkFullNodeName(nmLocalNode,nmLocalNode);
}
// -----------------------------------------------------------------------------------------
string ObjectIndex::getVirtualNodeName( const string& fname )
{
string::size_type pos1 = fname.rfind(sepName);
string::size_type pos2 = fname.rfind(sepNode);
if( pos2 == string::npos )
return "";
if( pos1!=string::npos )
return fname.substr( pos1+1, pos2-pos1-1 );
return "";
}
// -----------------------------------------------------------------------------------------
string ObjectIndex::getRealNodeName( const string& fname )
{
string::size_type pos = fname.rfind(sepNode);
if( pos != string::npos )
return fname.substr(pos+1);
if( !nmLocalNode.empty() )
return nmLocalNode;
nmLocalNode = getMapName(UniSetTypes::conf->getLocalNode());
return nmLocalNode;
}
// -----------------------------------------------------------------------------------------
std::string ObjectIndex::getRealNodeName( const ObjectId id )
{
string n(getMapName(id));
if( n.empty() )
return "";
return getRealNodeName(n);
}
// -----------------------------------------------------------------------------------------
string ObjectIndex::getName( const string& fname )
{
string::size_type pos = fname.rfind(sepName);
if( pos != string::npos )
return fname.substr(0,pos);
return "";
}
// -----------------------------------------------------------------------------------------
void ObjectIndex::initLocalNode( ObjectId nodeid )
{ {
nmLocalNode = getMapName(nodeid); nmLocalNode = getMapName(nodeid);
} }
......
...@@ -239,12 +239,8 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -239,12 +239,8 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
for( ;it.getCurrent(); it.goNext() ) for( ;it.getCurrent(); it.goNext() )
{ {
omap[ind].id = ind; omap[ind].id = ind;
string name(xml.getProp(it,"name")); string nodename(xml.getProp(it,"name"));
string alias(xml.getProp(it,"alias"));
if( alias.empty() )
alias = name;
string nodename = mkFullNodeName(name,alias);
delete[] omap[ind].repName; delete[] omap[ind].repName;
omap[ind].repName = new char[nodename.size()+1]; omap[ind].repName = new char[nodename.size()+1];
strcpy( omap[ind].repName, nodename.c_str() ); strcpy( omap[ind].repName, nodename.c_str() );
......
...@@ -195,18 +195,14 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec ) ...@@ -195,18 +195,14 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
} }
string name(it.getProp("name")); string name(it.getProp("name"));
string alias(it.getProp("alias"));
if( alias.empty() )
alias = name;
string nodename = mkFullNodeName(name,alias); inf.repName = new char[name.size()+1];
inf.repName = new char[nodename.size()+1]; strcpy( inf.repName, name.c_str() );
strcpy( inf.repName, nodename.c_str() );
// textname // textname
string textname(xml.getProp(it,"textname")); string textname(xml.getProp(it,"textname"));
if( textname.empty() ) if( textname.empty() )
textname = nodename; textname = name;
inf.textName = new char[textname.size()+1]; inf.textName = new char[textname.size()+1];
strcpy( inf.textName, textname.c_str() ); strcpy( inf.textName, textname.c_str() );
...@@ -214,7 +210,7 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec ) ...@@ -214,7 +210,7 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
inf.data = (void*)(xmlNode*)(it); inf.data = (void*)(xmlNode*)(it);
omap.insert(MapObjects::value_type(inf.id,inf)); // omap[inf.id] = inf; omap.insert(MapObjects::value_type(inf.id,inf)); // omap[inf.id] = inf;
mok.insert(MapObjectKey::value_type(nodename,inf.id)); // mok[name] = inf.id; mok.insert(MapObjectKey::value_type(name,inf.id)); // mok[name] = inf.id;
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
......
...@@ -80,14 +80,13 @@ bool IOController::disactivateObject() ...@@ -80,14 +80,13 @@ bool IOController::disactivateObject()
void IOController::sensorsUnregistration() void IOController::sensorsUnregistration()
{ {
// Разрегистрируем аналоговые датчики // Разрегистрируем аналоговые датчики
for( IOStateList::iterator li = ioList.begin(); for( IOStateList::iterator li = ioList.begin(); li!=ioList.end(); ++li)
li != ioList.end(); ++li)
{ {
try try
{ {
ioUnRegistration( li->second.si ); ioUnRegistration( li->second.si.id );
} }
catch(Exception& ex) catch( Exception& ex )
{ {
ucrit << myname << "(sensorsUnregistration): "<< ex << endl; ucrit << myname << "(sensorsUnregistration): "<< ex << endl;
} }
...@@ -122,17 +121,16 @@ void IOController::activateInit() ...@@ -122,17 +121,16 @@ void IOController::activateInit()
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
CORBA::Long IOController::getValue( const IOController_i::SensorInfo& si ) CORBA::Long IOController::getValue( UniSetTypes::ObjectId sid )
{ {
IOStateList::iterator li(ioList.end()); IOStateList::iterator li(ioList.end());
return localGetValue(li,si); return localGetValue(li,sid);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
long IOController::localGetValue( IOController::IOStateList::iterator& li, long IOController::localGetValue( IOController::IOStateList::iterator& li, const UniSetTypes::ObjectId sid )
const IOController_i::SensorInfo& si )
{ {
if( li == ioList.end() ) if( li == ioList.end() )
li = ioList.find( key(si.id,si.node) ); li = ioList.find(sid);
if( li!=ioList.end() ) if( li!=ioList.end() )
{ {
...@@ -145,33 +143,31 @@ long IOController::localGetValue( IOController::IOStateList::iterator& li, ...@@ -145,33 +143,31 @@ long IOController::localGetValue( IOController::IOStateList::iterator& li,
// ------------- // -------------
ostringstream err; ostringstream err;
err << myname << "(localGetValue): Not found sensor (" << si.id << ":" << si.node << ") " err << myname << "(localGetValue): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(si.id); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IOController::setUndefinedState(const IOController_i::SensorInfo& si, void IOController::setUndefinedState(UniSetTypes::ObjectId sid, CORBA::Boolean undefined, UniSetTypes::ObjectId sup_id )
CORBA::Boolean undefined, UniSetTypes::ObjectId sup_id )
{ {
IOController::IOStateList::iterator li(ioList.end()); IOController::IOStateList::iterator li(ioList.end());
localSetUndefinedState( li,undefined,si ); localSetUndefinedState( li,undefined, sid );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOController::localSetUndefinedState( IOStateList::iterator& li, void IOController::localSetUndefinedState( IOStateList::iterator& li,
bool undefined, const IOController_i::SensorInfo& si ) bool undefined, const UniSetTypes::ObjectId sid )
{ {
// сохранение текущего состояния // сохранение текущего состояния
if( li == ioList.end() ) if( li == ioList.end() )
li = ioList.find(key(si.id, si.node)); li = ioList.find(sid);
if( li==ioList.end() ) if( li==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(localSetUndefined): Unknown sensor (" << si.id << ":" << si.node << ")" err << myname << "(localSetUndefined): Unknown sensor (" << sid << ")"
<< "name: " << conf->oind->getNameById(si.id) << "name: " << conf->oind->getNameById(sid);
<< "node: " << conf->oind->getMapName(si.node);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
...@@ -227,40 +223,38 @@ void IOController::localSetUndefinedState( IOStateList::iterator& li, ...@@ -227,40 +223,38 @@ void IOController::localSetUndefinedState( IOStateList::iterator& li,
catch(...){} catch(...){}
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IOController::fastSetValue( const IOController_i::SensorInfo& si, CORBA::Long value, UniSetTypes::ObjectId sup_id ) void IOController::fastSetValue( UniSetTypes::ObjectId sid, CORBA::Long value, UniSetTypes::ObjectId sup_id )
{ {
try try
{ {
IOController::IOStateList::iterator li(ioList.end()); IOController::IOStateList::iterator li(ioList.end());
localSetValue( li, si, value, sup_id ); localSetValue( li, sid, value, sup_id );
} }
catch(...){} catch(...){}
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IOController::setValue( const IOController_i::SensorInfo& si, CORBA::Long value, void IOController::setValue( UniSetTypes::ObjectId sid, CORBA::Long value, UniSetTypes::ObjectId sup_id )
UniSetTypes::ObjectId sup_id )
{ {
IOController::IOStateList::iterator li(ioList.end()); IOController::IOStateList::iterator li(ioList.end());
localSetValue( li, si, value, sup_id ); localSetValue( li, sid, value, sup_id );
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IOController::localSetValue( IOController::IOStateList::iterator& li, void IOController::localSetValue( IOController::IOStateList::iterator& li,
const IOController_i::SensorInfo& si, 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 )
sup_id = getId(); sup_id = getId();
// сохранение текущего состояния // сохранение текущего состояния
if( li == ioList.end() ) if( li == ioList.end() )
li = ioList.find(key(si.id, si.node)); li = ioList.find(sid);
if( li==ioList.end() ) if( li==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(localSaveValue): Unknown sensor (" << si.id << ":" << si.node << ")" err << myname << "(localSaveValue): Unknown sensor (" << sid << ")"
<< "name: " << conf->oind->getNameById(si.id) << "name: " << conf->oind->getNameById(sid);
<< "node: " << conf->oind->getMapName(si.node);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
...@@ -275,9 +269,8 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -275,9 +269,8 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li,
if( checkIOFilters(&li->second,value,sup_id) || blocked ) if( checkIOFilters(&li->second,value,sup_id) || blocked )
{ {
uinfo << myname << ": save sensor value (" << si.id << ":" << si.node << ")" uinfo << myname << ": save sensor value (" << sid << ")"
<< " name: " << conf->oind->getNameById(si.id) << " name: " << conf->oind->getNameById(sid)
<< " node: " << conf->oind->getMapName(si.node)
<< " value="<< value << endl; << " value="<< value << endl;
long prev = li->second.value; long prev = li->second.value;
...@@ -298,11 +291,11 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -298,11 +291,11 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li,
// запоминаем время изменения // запоминаем время изменения
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);
li->second.tv_sec = tm.tv_sec; li->second.tv_sec = tm.tv_sec;
li->second.tv_usec = tm.tv_usec; li->second.tv_usec = tm.tv_usec;
} }
} // unlock } // unlock
...@@ -327,16 +320,14 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -327,16 +320,14 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li,
catch(...){} catch(...){}
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
IOType IOController::getIOType( const IOController_i::SensorInfo& si ) IOType IOController::getIOType( UniSetTypes::ObjectId sid )
{ {
UniSetTypes::KeyType k = key(si.id,si.node); IOStateList::iterator ali = ioList.find(sid);
IOStateList::iterator ali = ioList.find(k);
if( ali!=ioList.end() ) if( ali!=ioList.end() )
return ali->second.type; return ali->second.type;
ostringstream err; ostringstream err;
err << myname << "(getIOType): датчик имя: " << conf->oind->getNameById(si.id) << " не найден"; err << myname << "(getIOType): датчик имя: " << conf->oind->getNameById(sid) << " не найден";
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -351,18 +342,16 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force ) ...@@ -351,18 +342,16 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force )
throw ResolveNameError(err.str().c_str()); throw ResolveNameError(err.str().c_str());
} }
UniSetTypes::KeyType k = key(ainf.si.id, ainf.si.node);
{ // lock { // lock
uniset_rwmutex_wrlock lock(ioMutex); uniset_rwmutex_wrlock lock(ioMutex);
if( !force ) if( !force )
{ {
IOStateList::iterator li = ioList.find(k); IOStateList::iterator li = ioList.find(ainf.si.id);
if( li!=ioList.end() ) if( li!=ioList.end() )
{ {
ostringstream err; ostringstream err;
err << "Попытка повторной регистрации датчика("<< k << "). имя: " err << "Попытка повторной регистрации датчика("<< ainf.si.id << "). имя: "
<< conf->oind->getNameById(ainf.si.id) << conf->oind->getNameById(ainf.si.id);
<< " узел: " << conf->oind->getMapName(ainf.si.node);
throw ObjectNameAlready(err.str().c_str()); throw ObjectNameAlready(err.str().c_str());
} }
} }
...@@ -371,15 +360,15 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force ) ...@@ -371,15 +360,15 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force )
// запоминаем начальное время // запоминаем начальное время
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);
ai.tv_sec = tm.tv_sec; ai.tv_sec = tm.tv_sec;
ai.tv_usec = tm.tv_usec; ai.tv_usec = tm.tv_usec;
ai.value = ai.default_val; ai.value = ai.default_val;
// более оптимальный способ(при условии вставки первый раз) // более оптимальный способ(при условии вставки первый раз)
ioList.insert(IOStateList::value_type(k,ai)); ioList.insert(IOStateList::value_type(ainf.si.id,ai));
} }
try try
...@@ -390,15 +379,15 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force ) ...@@ -390,15 +379,15 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force )
{ {
uinfo << myname uinfo << myname
<< "(ioRegistration): регистрирую " << "(ioRegistration): регистрирую "
<< conf->oind->getNameById(ainf.si.id, ainf.si.node) << endl; << conf->oind->getNameById(ainf.si.id) << endl;
ui.registered( ainf.si.id, ainf.si.node, getRef(), true ); ui.registered( ainf.si.id, getRef(), true );
return; return;
} }
catch(ObjectNameAlready& ex ) catch(ObjectNameAlready& ex )
{ {
uwarn << myname << "(asRegistration): ЗАМЕНЯЮ СУЩЕСТВУЮЩИЙ ОБЪЕКТ (ObjectNameAlready)" << endl; uwarn << myname << "(asRegistration): ЗАМЕНЯЮ СУЩЕСТВУЮЩИЙ ОБЪЕКТ (ObjectNameAlready)" << endl;
ui.unregister(ainf.si.id,ainf.si.node); ui.unregister(ainf.si.id);
} }
} }
} }
...@@ -412,9 +401,9 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force ) ...@@ -412,9 +401,9 @@ void IOController::ioRegistration( const USensorInfo& ainf, bool force )
} }
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void IOController::ioUnRegistration( const IOController_i::SensorInfo& si ) void IOController::ioUnRegistration( const UniSetTypes::ObjectId sid )
{ {
ui.unregister( si.id, si.node ); ui.unregister(sid);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void IOController::logging( UniSetTypes::SensorMessage& sm ) void IOController::logging( UniSetTypes::SensorMessage& sm )
...@@ -489,24 +478,18 @@ IOController_i::SensorInfoSeq* IOController::getSensorsMap() ...@@ -489,24 +478,18 @@ IOController_i::SensorInfoSeq* IOController::getSensorsMap()
return res; return res;
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
UniSetTypes::Message::Priority IOController::getMessagePriority(UniSetTypes::KeyType k, UniversalIO::IOType type ) UniSetTypes::Message::Priority IOController::getPriority( const UniSetTypes::ObjectId sid )
{ {
IOStateList::iterator it = ioList.find(k); IOStateList::iterator it = ioList.find(sid);
if( it!=ioList.end() ) if( it!=ioList.end() )
return (UniSetTypes::Message::Priority)it->second.priority; return (UniSetTypes::Message::Priority)it->second.priority;
return UniSetTypes::Message::Medium; // ?? return UniSetTypes::Message::Medium; // ??
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
UniSetTypes::Message::Priority IOController::getPriority(const IOController_i::SensorInfo& si, IOController_i::SensorIOInfo IOController::getSensorIOInfo( const UniSetTypes::ObjectId sid )
UniversalIO::IOType type)
{
return getMessagePriority(key(si.id,si.node), type);
}
// --------------------------------------------------------------------------------------------------------------
IOController_i::SensorIOInfo IOController::getSensorIOInfo( const IOController_i::SensorInfo& si )
{ {
IOStateList::iterator it = ioList.find( key(si.id, si.node) ); IOStateList::iterator it = ioList.find(sid);
if( it!=ioList.end() ) if( it!=ioList.end() )
{ {
uniset_rwmutex_rlock lock(it->second.val_lock); uniset_rwmutex_rlock lock(it->second.val_lock);
...@@ -515,22 +498,22 @@ IOController_i::SensorIOInfo IOController::getSensorIOInfo( const IOController_i ...@@ -515,22 +498,22 @@ IOController_i::SensorIOInfo IOController::getSensorIOInfo( const IOController_i
// ------------- // -------------
ostringstream err; ostringstream err;
err << myname << "(getSensorIOInfo): Unknown sensor (" << si.id << ":" << si.node << ")" err << myname << "(getSensorIOInfo): Unknown sensor (" << sid << ")"
<< conf->oind->getNameById(si.id,si.node); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
CORBA::Long IOController::getRawValue(const IOController_i::SensorInfo& si) CORBA::Long IOController::getRawValue( UniSetTypes::ObjectId sid )
{ {
IOStateList::iterator it = ioList.find( key(si.id, si.node) ); IOStateList::iterator it = ioList.find(sid);
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(getRawValue): Unknown analog sensor (" << si.id << ":" << si.node << ")" err << myname << "(getRawValue): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(si.id,si.node); << conf->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
...@@ -549,16 +532,16 @@ CORBA::Long IOController::getRawValue(const IOController_i::SensorInfo& si) ...@@ -549,16 +532,16 @@ CORBA::Long IOController::getRawValue(const IOController_i::SensorInfo& si)
return it->second.value; return it->second.value;
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IOController::calibrate(const IOController_i::SensorInfo& si, void IOController::calibrate( UniSetTypes::ObjectId sid,
const IOController_i::CalibrateInfo& ci, const IOController_i::CalibrateInfo& ci,
UniSetTypes::ObjectId adminId ) UniSetTypes::ObjectId adminId )
{ {
IOStateList::iterator it = ioList.find( key(si.id, si.node) ); IOStateList::iterator it = ioList.find(sid);
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(calibrate): Unknown analog sensor (" << si.id << ":" << si.node << ")" err << myname << "(calibrate): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(si.id,si.node); << conf->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
...@@ -567,25 +550,25 @@ void IOController::calibrate(const IOController_i::SensorInfo& si, ...@@ -567,25 +550,25 @@ void IOController::calibrate(const IOController_i::SensorInfo& si,
it->second.ci = ci; it->second.ci = ci;
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
IOController_i::CalibrateInfo IOController::getCalibrateInfo(const IOController_i::SensorInfo& si) IOController_i::CalibrateInfo IOController::getCalibrateInfo( UniSetTypes::ObjectId sid )
{ {
IOStateList::iterator it = ioList.find( key(si.id, si.node) ); IOStateList::iterator it = ioList.find(sid);
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(calibrate): Unknown analog sensor (" << si.id << ":" << si.node << ")" err << myname << "(calibrate): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(si.id,si.node); << conf->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
return it->second.ci; return it->second.ci;
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
IOController::USensorInfo::USensorInfo(IOController_i::SensorIOInfo& ai): IOController::USensorInfo::USensorInfo( IOController_i::SensorIOInfo& ai ):
IOController_i::SensorIOInfo(ai), IOController_i::SensorIOInfo(ai),
any(0) any(0)
{} {}
IOController::USensorInfo::USensorInfo(const IOController_i::SensorIOInfo& ai): IOController::USensorInfo::USensorInfo( const IOController_i::SensorIOInfo& ai ):
IOController_i::SensorIOInfo(ai), IOController_i::SensorIOInfo(ai),
any(0) any(0)
{} {}
...@@ -700,25 +683,27 @@ IDSeq* IOController::setOutputSeq(const IOController_i::OutSeq& lst, ObjectId su ...@@ -700,25 +683,27 @@ IDSeq* IOController::setOutputSeq(const IOController_i::OutSeq& lst, ObjectId su
for(int i=0; i<size; i++) for(int i=0; i<size; i++)
{ {
ObjectId sid = lst[i].si.id;
{ {
IOStateList::iterator it = ioList.find( UniSetTypes::key(lst[i].si.id,lst[i].si.node) ); IOStateList::iterator it = ioList.find(sid);
if( it!=ioList.end() ) if( it!=ioList.end() )
{ {
localSetValue(it,lst[i].si,lst[i].value, sup_id); localSetValue(it,sid,lst[i].value, sup_id);
continue; continue;
} }
} }
// не найден // не найден
badlist.add( lst[i].si.id ); badlist.add(sid);
} }
return badlist.getIDSeq(); return badlist.getIDSeq();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController_i::ShortIOInfo IOController::getChangedTime( const IOController_i::SensorInfo& si ) IOController_i::ShortIOInfo IOController::getChangedTime( UniSetTypes::ObjectId sid )
{ {
IOStateList::iterator ait = ioList.find( key(si.id, si.node) ); IOStateList::iterator ait = ioList.find(sid);
if( ait!=ioList.end() ) if( ait!=ioList.end() )
{ {
IOController_i::ShortIOInfo i; IOController_i::ShortIOInfo i;
...@@ -732,7 +717,7 @@ IOController_i::ShortIOInfo IOController::getChangedTime( const IOController_i:: ...@@ -732,7 +717,7 @@ IOController_i::ShortIOInfo IOController::getChangedTime( const IOController_i::
// ------------- // -------------
ostringstream err; ostringstream err;
err << myname << "(getChangedTime): вход(выход) с именем " err << myname << "(getChangedTime): вход(выход) с именем "
<< conf->oind->getNameById(si.id) << " не найден"; << conf->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
...@@ -761,19 +746,14 @@ IOController_i::ShortMapSeq* IOController::getSensors() ...@@ -761,19 +746,14 @@ IOController_i::ShortMapSeq* IOController::getSensors()
return res; return res;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController::ChangeSignal IOController::signal_change_value( const IOController_i::SensorInfo& si ) IOController::ChangeSignal IOController::signal_change_value( UniSetTypes::ObjectId sid )
{ {
return signal_change_value( si.id, si.node ); IOStateList::iterator it = ioList.find(sid);
}
// -----------------------------------------------------------------------------
IOController::ChangeSignal IOController::signal_change_value( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
{
IOStateList::iterator it = ioList.find( key(id,node) );
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(signal_change_value): вход(выход) с именем " err << myname << "(signal_change_value): вход(выход) с именем "
<< conf->oind->getNameById(id) << " не найден"; << conf->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
...@@ -788,19 +768,14 @@ IOController::ChangeSignal IOController::signal_change_value() ...@@ -788,19 +768,14 @@ IOController::ChangeSignal IOController::signal_change_value()
return sigAnyChange; return sigAnyChange;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController::ChangeUndefinedStateSignal IOController::signal_change_undefined_state( const IOController_i::SensorInfo& si ) IOController::ChangeUndefinedStateSignal IOController::signal_change_undefined_state( UniSetTypes::ObjectId sid )
{
return signal_change_undefined_state( si.id, si.node );
}
// -----------------------------------------------------------------------------
IOController::ChangeUndefinedStateSignal IOController::signal_change_undefined_state( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
{ {
IOStateList::iterator it = ioList.find( key(id,node) ); IOStateList::iterator it = ioList.find(sid);
if( it==ioList.end() ) if( it==ioList.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(signal_change_undefine): вход(выход) с именем " err << myname << "(signal_change_undefine): вход(выход) с именем "
<< conf->oind->getNameById(id) << " не найден"; << conf->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl; uinfo << err.str() << endl;
...@@ -828,6 +803,6 @@ void IOController::USensorInfo::checkDepend( IOStateList::iterator& d_it, IOCont ...@@ -828,6 +803,6 @@ void IOController::USensorInfo::checkDepend( IOStateList::iterator& d_it, IOCont
} }
if( changed ) if( changed )
ic->localSetValue( it, si, real_value, ic->getId() ); ic->localSetValue( it, si.id, real_value, ic->getId() );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -145,43 +145,43 @@ bool IONotifyController::removeConsumer( ConsumerListInfo& lst, const ConsumerIn ...@@ -145,43 +145,43 @@ bool IONotifyController::removeConsumer( ConsumerListInfo& lst, const ConsumerIn
* \param ci - информация о заказчике * \param ci - информация о заказчике
* \param cmd - команда см. UniversalIO::UIOCommand * \param cmd - команда см. UniversalIO::UIOCommand
*/ */
void IONotifyController::askSensor(const IOController_i::SensorInfo& si, void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd ) const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd )
{ {
uinfo << "(askSensor): поступил " << ( cmd == UIODontNotify ? "отказ" :"заказ" ) << " от " uinfo << "(askSensor): поступил " << ( cmd == UIODontNotify ? "отказ" :"заказ" ) << " от "
<< conf->oind->getNameById(ci.id, ci.node) << conf->oind->getNameById(ci.id) << "@" << ci.node
<< " на аналоговый датчик " << " на аналоговый датчик "
<< conf->oind->getNameById(si.id,si.node) << endl; << conf->oind->getNameById(sid) << endl;
// если такого аналогового датчика нет, здесь сработает исключение... // если такого аналогового датчика нет, здесь сработает исключение...
IOStateList::iterator li = myioEnd(); IOStateList::iterator li = myioEnd();
localGetValue(li,si); localGetValue(li,sid);
{ // lock { // lock
uniset_rwmutex_wrlock lock(askIOMutex); uniset_rwmutex_wrlock lock(askIOMutex);
// а раз есть заносим(исключаем) заказчика // а раз есть заносим(исключаем) заказчика
ask( askIOList, si, ci, cmd); ask(askIOList, sid, ci, cmd);
} // unlock } // unlock
// посылка первый раз состояния // посылка первый раз состояния
if( cmd==UniversalIO::UIONotify || (cmd==UIONotifyFirstNotNull && li->second.value) ) if( cmd==UniversalIO::UIONotify || (cmd==UIONotifyFirstNotNull && li->second.value) )
{ {
SensorMessage smsg; SensorMessage smsg;
smsg.id = si.id; smsg.id = sid;
smsg.node = si.node; 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;
smsg.ci = li->second.ci; smsg.ci = li->second.ci;
{ {
uniset_rwmutex_rlock lock(li->second.val_lock); uniset_rwmutex_rlock lock(li->second.val_lock);
smsg.value = li->second.value; smsg.value = li->second.value;
smsg.undefined = li->second.undefined; smsg.undefined = li->second.undefined;
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;
} }
TransportMessage tm(smsg.transport_msg()); TransportMessage tm(smsg.transport_msg());
...@@ -189,31 +189,30 @@ void IONotifyController::askSensor(const IOController_i::SensorInfo& si, ...@@ -189,31 +189,30 @@ void IONotifyController::askSensor(const IOController_i::SensorInfo& si,
{ {
ui.send(ci.id, tm, ci.node); ui.send(ci.id, tm, ci.node);
} }
catch(Exception& ex) catch( Exception& ex )
{ {
uwarn << myname << "(askSensor): " << conf->oind->getNameById(si.id, si.node) << " catch "<< ex << endl; uwarn << myname << "(askSensor): " << conf->oind->getNameById(sid) << " error: "<< ex << endl;
} }
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;
} }
catch(...) catch(...)
{ {
uwarn << myname << "(askSensor): " << conf->oind->getNameById(ci.id, ci.node) uwarn << myname << "(askSensor): " << conf->oind->getNameById(ci.id) << "@" << ci.node
<< " catch..." << endl; << " catch..." << endl;
} }
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& si, void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd) const UniSetTypes::ConsumerInfo& cons, UniversalIO::UIOCommand cmd)
{ {
// поиск датчика в списке // поиск датчика в списке
UniSetTypes::KeyType k( key(si.id,si.node) ); AskMap::iterator askIterator = askLst.find(sid);
AskMap::iterator askIterator = askLst.find(k);
switch (cmd) switch (cmd)
{ {
...@@ -226,11 +225,11 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s ...@@ -226,11 +225,11 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s
ConsumerListInfo lst; // создаем новый список ConsumerListInfo lst; // создаем новый список
addConsumer(lst,cons); addConsumer(lst,cons);
// более оптимальный способ(при условии вставки первый раз) // askLst[key]=lst; // более оптимальный способ(при условии вставки первый раз) // askLst[key]=lst;
askLst.insert(AskMap::value_type(k,lst)); askLst.insert(AskMap::value_type(sid,lst));
try try
{ {
dumpOrdersList(si,lst); dumpOrdersList(sid,lst);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -247,7 +246,7 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s ...@@ -247,7 +246,7 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s
{ {
try try
{ {
dumpOrdersList(si,askIterator->second); dumpOrdersList(sid,askIterator->second);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -278,7 +277,7 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s ...@@ -278,7 +277,7 @@ void IONotifyController::ask(AskMap& askLst, const IOController_i::SensorInfo& s
{ {
try try
{ {
dumpOrdersList(si,askIterator->second); dumpOrdersList(sid,askIterator->second);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -309,27 +308,27 @@ bool IONotifyController::myIOFilter( const USensorInfo& ai, ...@@ -309,27 +308,27 @@ bool IONotifyController::myIOFilter( const USensorInfo& ai,
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IONotifyController::localSetValue( IOController::IOStateList::iterator& li, void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
const IOController_i::SensorInfo& si, UniSetTypes::ObjectId sid,
CORBA::Long value, UniSetTypes::ObjectId sup_id ) CORBA::Long value, UniSetTypes::ObjectId sup_id )
{ {
// Если датчик не найден сдесь сработает исключение // Если датчик не найден сдесь сработает исключение
long prevValue = IOController::localGetValue( li, si ); long prevValue = IOController::localGetValue( li, sid );
if( li == myioEnd() ) // ??? if( li == myioEnd() ) // ???
{ {
ostringstream err; ostringstream err;
err << myname << "(localSetValue): вход(выход) с именем " err << myname << "(localSetValue): вход(выход) с именем "
<< conf->oind->getNameById(si.id) << " не найден"; << conf->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
IOController::localSetValue(li, si, value, sup_id); IOController::localSetValue(li, sid, value, sup_id);
// сравниваем именно с li->second.value // сравниваем именно с li->second.value
// т.к. фактическое сохранённое значение может быть изменено // т.к. фактическое сохранённое значение может быть изменено
// фильтрами или блокировками.. // фильтрами или блокировками..
SensorMessage sm(si.id,li->second.value); SensorMessage sm(sid,li->second.value);
{ // lock { // lock
uniset_rwmutex_rlock lock(li->second.val_lock); uniset_rwmutex_rlock lock(li->second.val_lock);
...@@ -337,8 +336,8 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -337,8 +336,8 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
return; return;
// Рассылаем уведомления только в слуае изменения значения // Рассылаем уведомления только в слуае изменения значения
sm.id = si.id; sm.id = sid;
sm.node = si.node; sm.node = conf->getLocalNode();
sm.value = li->second.value; sm.value = li->second.value;
sm.undefined = li->second.undefined; sm.undefined = li->second.undefined;
sm.priority = (Message::Priority)li->second.priority; sm.priority = (Message::Priority)li->second.priority;
...@@ -358,7 +357,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -358,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( key(si.id,si.node) ); AskMap::iterator it = askIOList.find(sid);
if( it!=askIOList.end() ) if( it!=askIOList.end() )
send(it->second, sm); send(it->second, sm);
} }
...@@ -366,7 +365,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -366,7 +365,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
// проверка порогов // проверка порогов
try try
{ {
checkThreshold(li,si,true); checkThreshold(li,sid,true);
} }
catch(...){} catch(...){}
} }
...@@ -409,18 +408,18 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage ...@@ -409,18 +408,18 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage
catch(Exception& ex) catch(Exception& ex)
{ {
uwarn << myname << "(IONotifyController::send): " << ex uwarn << myname << "(IONotifyController::send): " << ex
<< " for " << conf->oind->getNameById(li->id, li->node) << endl; << " for " << conf->oind->getNameById(li->id) << "@" << li->node << endl;
} }
catch( CORBA::SystemException& ex ) catch( CORBA::SystemException& ex )
{ {
uwarn << myname << "(IONotifyController::send): " uwarn << myname << "(IONotifyController::send): "
<< conf->oind->getNameById(li->id, li->node) << " (CORBA::SystemException): " << conf->oind->getNameById(li->id) << "@" << li->node << " (CORBA::SystemException): "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
catch(...) catch(...)
{ {
ucrit << myname << "(IONotifyController::send): " ucrit << myname << "(IONotifyController::send): "
<< conf->oind->getNameById(li->id, li->node) << conf->oind->getNameById(li->id) << "@" << li->node
<< " catch..." << endl; << " catch..." << endl;
} }
...@@ -436,7 +435,7 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage ...@@ -436,7 +435,7 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage
} }
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IONotifyController::loggingInfo(UniSetTypes::SensorMessage& sm) void IONotifyController::loggingInfo( UniSetTypes::SensorMessage& sm )
{ {
IOController::logging(sm); IOController::logging(sm);
} }
...@@ -469,11 +468,11 @@ void IONotifyController::initItem( IOStateList::iterator& li, IOController* ic ) ...@@ -469,11 +468,11 @@ void IONotifyController::initItem( IOStateList::iterator& li, IOController* ic )
USensorInfo& s(li->second); USensorInfo& s(li->second);
if( s.type == UniversalIO::AI || s.type == UniversalIO::AO ) if( s.type == UniversalIO::AI || s.type == UniversalIO::AO )
checkThreshold( li, s.si, false ); checkThreshold( li, s.si.id, false );
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void IONotifyController::dumpOrdersList(const IOController_i::SensorInfo& si, void IONotifyController::dumpOrdersList( const UniSetTypes::ObjectId sid,
const IONotifyController::ConsumerListInfo& lst) const IONotifyController::ConsumerListInfo& lst)
{ {
if( restorer == NULL ) if( restorer == NULL )
return; return;
...@@ -481,18 +480,18 @@ void IONotifyController::dumpOrdersList(const IOController_i::SensorInfo& si, ...@@ -481,18 +480,18 @@ void IONotifyController::dumpOrdersList(const IOController_i::SensorInfo& si,
try try
{ {
NCRestorer::SInfo inf; NCRestorer::SInfo inf;
IOController_i::SensorIOInfo ainf( getSensorIOInfo(si) ); IOController_i::SensorIOInfo ainf( getSensorIOInfo(sid) );
inf=ainf; inf=ainf;
restorer->dump(this,inf,lst); restorer->dump(this,inf,lst);
} }
catch(Exception& ex) catch( Exception& ex )
{ {
uwarn << myname << "(IONotifyController::dumpOrderList): " << ex << endl; uwarn << myname << "(IONotifyController::dumpOrderList): " << ex << endl;
} }
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IONotifyController::dumpThresholdList(const IOController_i::SensorInfo& si, const IONotifyController::ThresholdExtList& lst) void IONotifyController::dumpThresholdList( const UniSetTypes::ObjectId sid, const IONotifyController::ThresholdExtList& lst)
{ {
if( restorer == NULL ) if( restorer == NULL )
return; return;
...@@ -500,7 +499,7 @@ void IONotifyController::dumpThresholdList(const IOController_i::SensorInfo& si, ...@@ -500,7 +499,7 @@ void IONotifyController::dumpThresholdList(const IOController_i::SensorInfo& si,
try try
{ {
NCRestorer::SInfo inf; NCRestorer::SInfo inf;
IOController_i::SensorIOInfo ainf(getSensorIOInfo(si)); IOController_i::SensorIOInfo ainf(getSensorIOInfo(sid));
inf=ainf; inf=ainf;
restorer->dumpThreshold(this,inf,lst); restorer->dumpThreshold(this,inf,lst);
} }
...@@ -511,7 +510,7 @@ void IONotifyController::dumpThresholdList(const IOController_i::SensorInfo& si, ...@@ -511,7 +510,7 @@ void IONotifyController::dumpThresholdList(const IOController_i::SensorInfo& si,
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, 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 )
...@@ -521,14 +520,13 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons ...@@ -521,14 +520,13 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
// если такого дискретного датчика нет сдесь сработает исключение... // если такого дискретного датчика нет сдесь сработает исключение...
IOStateList::iterator li = myioEnd(); IOStateList::iterator li = myioEnd();
CORBA::Long val = localGetValue(li,si); CORBA::Long val = localGetValue(li,sid);
{ // lock { // lock
uniset_rwmutex_wrlock lock(trshMutex); uniset_rwmutex_wrlock lock(trshMutex);
// поиск датчика в списке // поиск датчика в списке
UniSetTypes::KeyType skey( key(si.id,si.node) ); AskThresholdMap::iterator it = askTMap.find(sid);
AskThresholdMap::iterator it = askTMap.find(skey);
ThresholdInfoExt ti(tid,lowLimit,hiLimit,invert); ThresholdInfoExt ti(tid,lowLimit,hiLimit,invert);
ti.sit = myioEnd(); ti.sit = myioEnd();
...@@ -542,15 +540,16 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons ...@@ -542,15 +540,16 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
{ {
ThresholdExtList lst; // создаем новый список ThresholdExtList lst; // создаем новый список
ThresholdsListInfo tli; ThresholdsListInfo tli;
tli.si = si; tli.si.id = sid;
tli.list = lst; tli.si.node = conf->getLocalNode();
tli.type = li->second.type; tli.list = lst;
tli.ait = myioEnd(); tli.type = li->second.type;
tli.ait = myioEnd();
addThreshold(lst,ti,ci); addThreshold(lst,ti,ci);
askTMap.insert(AskThresholdMap::value_type(skey,tli)); askTMap.insert(AskThresholdMap::value_type(sid,tli));
try try
{ {
dumpThresholdList(si,lst); dumpThresholdList(sid,lst);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -567,7 +566,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons ...@@ -567,7 +566,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
{ {
try try
{ {
dumpThresholdList(si,it->second.list); dumpThresholdList(sid,it->second.list);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -587,17 +586,17 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons ...@@ -587,17 +586,17 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
try try
{ {
SensorMessage sm; SensorMessage sm;
sm.id = si.id; sm.id = sid;
sm.node = si.node; sm.node = conf->getLocalNode();
sm.value = val; sm.value = val;
sm.undefined = li->second.undefined; sm.undefined = li->second.undefined;
sm.sensor_type = li->second.type; sm.sensor_type = li->second.type;
sm.priority = (Message::Priority)li->second.priority; sm.priority = (Message::Priority)li->second.priority;
sm.consumer = ci.id; sm.consumer = ci.id;
sm.tid = tid; sm.tid = tid;
sm.sm_tv_sec = ti.tv_sec; sm.sm_tv_sec = ti.tv_sec;
sm.sm_tv_usec = ti.tv_usec; sm.sm_tv_usec = ti.tv_usec;
sm.ci = li->second.ci; sm.ci = li->second.ci;
// Проверка нижнего предела // Проверка нижнего предела
if( val <= lowLimit ) if( val <= lowLimit )
...@@ -642,7 +641,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons ...@@ -642,7 +641,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
{ {
try try
{ {
dumpThresholdList(si,it->second.list); dumpThresholdList(sid,it->second.list);
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -663,7 +662,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons ...@@ -663,7 +662,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
} // unlock } // unlock
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
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( ThresholdExtList::iterator it=lst.begin(); it!=lst.end(); ++it)
{ {
...@@ -683,10 +682,11 @@ bool IONotifyController::addThreshold(ThresholdExtList& lst, ThresholdInfoExt& t ...@@ -683,10 +682,11 @@ bool IONotifyController::addThreshold(ThresholdExtList& lst, ThresholdInfoExt& t
// запоминаем начальное время // запоминаем начальное время
struct timeval tm; struct timeval tm;
struct timezone tz; struct timezone tz;
tm.tv_sec = 0; tm.tv_usec = 0; tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm,&tz); gettimeofday(&tm,&tz);
ti.tv_sec = tm.tv_sec; ti.tv_sec = tm.tv_sec;
ti.tv_usec = tm.tv_usec; ti.tv_usec = tm.tv_usec;
lst.push_front(ti); lst.push_front(ti);
return true; return true;
...@@ -716,16 +716,15 @@ bool IONotifyController::removeThreshold( ThresholdExtList& lst, ThresholdInfoEx ...@@ -716,16 +716,15 @@ bool IONotifyController::removeThreshold( ThresholdExtList& lst, ThresholdInfoEx
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
void IONotifyController::checkThreshold( IOStateList::iterator& li, void IONotifyController::checkThreshold( IOStateList::iterator& li,
const IOController_i::SensorInfo& si, const UniSetTypes::ObjectId sid,
bool send_msg ) bool send_msg )
{ {
// поиск списка порогов // поиск списка порогов
UniSetTypes::KeyType skey( key(si.id,si.node) );
AskThresholdMap::iterator lst = askTMap.end(); AskThresholdMap::iterator lst = askTMap.end();
{ {
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
lst = askTMap.find(skey); lst = askTMap.find(sid);
if( lst == askTMap.end() ) if( lst == askTMap.end() )
return; return;
...@@ -734,14 +733,14 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li, ...@@ -734,14 +733,14 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
} }
if( li == myioEnd() ) if( li == myioEnd() )
li = myiofind(skey); li = myiofind(sid);
if( li == myioEnd() ) if( li == myioEnd() )
return; // ??? return; // ???
SensorMessage sm; SensorMessage sm;
sm.id = si.id; sm.id = sid;
sm.node = si.node; sm.node = conf->getLocalNode();
sm.sensor_type = li->second.type; sm.sensor_type = li->second.type;
sm.priority = (Message::Priority)li->second.priority; sm.priority = (Message::Priority)li->second.priority;
sm.ci = li->second.ci; sm.ci = li->second.ci;
...@@ -807,7 +806,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li, ...@@ -807,7 +806,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
{ {
try try
{ {
localSetValue(it->sit,SensorInfo(it->sid),(sm.threshold ? 1:0),getId()); localSetValue(it->sit,it->sid,(sm.threshold ? 1:0),getId());
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
...@@ -822,13 +821,13 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li, ...@@ -822,13 +821,13 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
} }
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold( UniSetTypes::KeyType key, UniSetTypes::ThresholdId tid ) IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold( const UniSetTypes::ObjectId sid, const UniSetTypes::ThresholdId tid )
{ {
{ // lock { // lock
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
// поиск списка порогов // поиск списка порогов
// UniSetTypes::KeyType skey( key(si.id,si.node) ); // UniSetTypes::KeyType skey( key(si.id,si.node) );
AskThresholdMap::iterator lst = askTMap.find(key); AskThresholdMap::iterator lst = askTMap.find(sid);
if( lst!=askTMap.end() ) if( lst!=askTMap.end() )
{ {
...@@ -843,17 +842,16 @@ IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold ...@@ -843,17 +842,16 @@ IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold
return ThresholdExtList::iterator(); return ThresholdExtList::iterator();
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( const IOController_i::SensorInfo& si, IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid )
UniSetTypes::ThresholdId tid )
{ {
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
AskThresholdMap::iterator it = askTMap.find( key(si) ); AskThresholdMap::iterator it = askTMap.find(sid);
if( it == askTMap.end() ) if( it == askTMap.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(getThresholds): Not found sensor (" << si.id << ":" << si.node << ") " err << myname << "(getThresholds): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(si.id); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
...@@ -866,23 +864,23 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( const ...@@ -866,23 +864,23 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( const
} }
ostringstream err; ostringstream err;
err << myname << "(getThresholds): Not found for sensor (" << si.id << ":" << si.node << ") " err << myname << "(getThresholds): Not found for sensor (" << sid << ") "
<< conf->oind->getNameById(si.id) << " ThresholdID='" << tid << "'"; << conf->oind->getNameById(sid) << " ThresholdID='" << tid << "'";
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
IONotifyController_i::ThresholdList* IONotifyController::getThresholds( const IOController_i::SensorInfo& si ) IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTypes::ObjectId sid )
{ {
uniset_rwmutex_rlock lock(trshMutex); uniset_rwmutex_rlock lock(trshMutex);
AskThresholdMap::iterator it = askTMap.find( key(si) ); AskThresholdMap::iterator it = askTMap.find(sid);
if( it == askTMap.end() ) if( it == askTMap.end() )
{ {
ostringstream err; ostringstream err;
err << myname << "(getThresholds): Not found sensor (" << si.id << ":" << si.node << ") " err << myname << "(getThresholds): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(si.id); << conf->oind->getNameById(sid);
uinfo << err.str() << endl; uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
...@@ -893,13 +891,13 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( const IO ...@@ -893,13 +891,13 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( const IO
try try
{ {
res->si = it->second.si; res->si = it->second.si;
res->value = IOController::localGetValue(it->second.ait,it->second.si); res->value = IOController::localGetValue(it->second.ait,it->second.si.id);
res->type = it->second.type; res->type = it->second.type;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
uwarn << myname << "(getThresholdsList): для датчика " uwarn << myname << "(getThresholdsList): для датчика "
<< conf->oind->getNameById(it->second.si.id, it->second.si.node) << conf->oind->getNameById(it->second.si.id)
<< " " << ex << endl; << " " << ex << endl;
} }
...@@ -935,13 +933,13 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList() ...@@ -935,13 +933,13 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
try try
{ {
(*res)[i].si = it->second.si; (*res)[i].si = it->second.si;
(*res)[i].value = IOController::localGetValue(it->second.ait,it->second.si); (*res)[i].value = IOController::localGetValue(it->second.ait,it->second.si.id);
(*res)[i].type = it->second.type; (*res)[i].type = it->second.type;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
uwarn << myname << "(getThresholdsList): для датчика " uwarn << myname << "(getThresholdsList): для датчика "
<< conf->oind->getNameById(it->second.si.id, it->second.si.node) << conf->oind->getNameById(it->second.si.id)
<< " " << ex << endl; << " " << ex << endl;
continue; continue;
} }
...@@ -1009,20 +1007,18 @@ IDSeq* IONotifyController::askSensorsSeq( const UniSetTypes::IDSeq& lst, ...@@ -1009,20 +1007,18 @@ IDSeq* IONotifyController::askSensorsSeq( const UniSetTypes::IDSeq& lst,
{ {
UniSetTypes::IDList badlist; // cписок не найденных идентификаторов UniSetTypes::IDList badlist; // cписок не найденных идентификаторов
IOController_i::SensorInfo si;
int size = lst.length(); int size = lst.length();
for(int i=0; i<size; i++) ObjectId sid;
for( int i=0; i<size; i++ )
{ {
si.id = lst[i]; sid = lst[i];
si.node = conf->getLocalNode();
try try
{ {
askSensor(si,ci,cmd); askSensor(sid,ci,cmd);
} }
catch(...) catch(...)
{ {
badlist.add( lst[i] ); badlist.add(sid);
} }
} }
......
...@@ -44,13 +44,13 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -44,13 +44,13 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
{ {
UniSetTypes::KeyType k( key(inf.si.id,inf.si.node) ); UniSetTypes::KeyType k( key(inf.si.id,inf.si.node) );
// Проверка зарегистрирован-ли данный датчик // Проверка зарегистрирован-ли данный датчик
// если такого дискретного датчика нет, то здесь сработает исключение... // если такого дискретного датчика нет, то здесь сработает исключение...
if( !force ) if( !force )
{ {
try try
{ {
ic->getIOType(inf.si); ic->getIOType(inf.si.id);
} }
catch(...) catch(...)
{ {
...@@ -66,7 +66,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -66,7 +66,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
default: default:
ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> " ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << conf->oind->getNameById(inf.si.id) << endl;
return; return;
break; break;
...@@ -85,7 +85,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -85,7 +85,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
default: default:
ucrit << ic->getName() << "(NCRestorer::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА!-> " ucrit << ic->getName() << "(NCRestorer::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА!-> "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << conf->oind->getNameById(inf.si.id) << endl;
break; break;
} }
} }
...@@ -98,7 +98,7 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC ...@@ -98,7 +98,7 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC
{ {
try try
{ {
ic->getIOType(inf.si); ic->getIOType(inf.si.id);
} }
catch(...) catch(...)
{ {
...@@ -162,7 +162,7 @@ void NCRestorer::init_depends_signals( IONotifyController* ic ) ...@@ -162,7 +162,7 @@ void NCRestorer::init_depends_signals( IONotifyController* ic )
<< " dep_name=(" << it->second.d_si.id << ")'" << conf->oind->getMapName(it->second.d_si.id) << "'" << " dep_name=(" << it->second.d_si.id << ")'" << conf->oind->getMapName(it->second.d_si.id) << "'"
<< endl; << endl;
IOController::ChangeSignal s = ic->signal_change_value(it->second.d_si); IOController::ChangeSignal s = ic->signal_change_value(it->second.d_si.id);
s.connect( sigc::mem_fun( &it->second, &IOController::USensorInfo::checkDepend) ); s.connect( sigc::mem_fun( &it->second, &IOController::USensorInfo::checkDepend) );
} }
} }
......
...@@ -363,7 +363,7 @@ void NCRestorer_XML::read_thresholds(const UniXML& xml, xmlNode* node, IONotifyC ...@@ -363,7 +363,7 @@ void NCRestorer_XML::read_thresholds(const UniXML& xml, xmlNode* node, IONotifyC
uwarn << ic->getName() uwarn << ic->getName()
<< "(read_thresholds): не смог получить информацию о пороге" << "(read_thresholds): не смог получить информацию о пороге"
<< " для датчика " << " для датчика "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << conf->oind->getNameById(inf.si.id) << endl;
continue; continue;
} }
...@@ -383,8 +383,8 @@ void NCRestorer_XML::read_thresholds(const UniXML& xml, xmlNode* node, IONotifyC ...@@ -383,8 +383,8 @@ void NCRestorer_XML::read_thresholds(const UniXML& xml, xmlNode* node, IONotifyC
{ {
uwarn << ic->getName() uwarn << ic->getName()
<< "(read_thresholds): не смог получить список заказчиков" << "(read_thresholds): не смог получить список заказчиков"
<< " для порога " << ti.id << " для порога " << ti.id
<< " датчика " << conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << " датчика " << conf->oind->getNameById(inf.si.id) << endl;
} }
} }
} }
......
...@@ -281,7 +281,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -281,7 +281,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
{ {
new_argv[i] = "-ORBInitRef"; new_argv[i] = "-ORBInitRef";
string name(oind->getRealNodeName(it->id)); string name(oind->getNodeName(it->id));
ostringstream param; ostringstream param;
param << this << name; param << this << name;
name = param.str(); name = param.str();
...@@ -513,12 +513,7 @@ void Configuration::initParameters() ...@@ -513,12 +513,7 @@ void Configuration::initParameters()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Configuration::setLocalNode( const string& nodename ) void Configuration::setLocalNode( const string& nodename )
{ {
string virtnode = oind->getVirtualNodeName(nodename); localNode = oind->getIdByName(nodename);
string nn(nodename);
if( virtnode.empty() )
nn = oind->mkFullNodeName(nodename,nodename);
localNode = oind->getIdByName(nn);
if( localNode == DefaultObjectId ) if( localNode == DefaultObjectId )
{ {
...@@ -528,7 +523,7 @@ void Configuration::setLocalNode( const string& nodename ) ...@@ -528,7 +523,7 @@ void Configuration::setLocalNode( const string& nodename )
throw Exception(err.str()); throw Exception(err.str());
} }
localNodeName = oind->getRealNodeName(nn); localNodeName = nodename;
oind->initLocalNode(localNode); oind->initLocalNode(localNode);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -620,9 +615,9 @@ void Configuration::createNodesList() ...@@ -620,9 +615,9 @@ void Configuration::createNodesList()
} }
string nodename(sname); string nodename(sname);
string virtnode = oind->getVirtualNodeName(nodename); // string virtnode = oind->getVirtualNodeName(nodename);
if( virtnode.empty() ) // if( virtnode.empty() )
nodename = oind->mkFullNodeName(nodename,nodename); // nodename = oind->mkFullNodeName(nodename,nodename);
NodeInfo ninf; NodeInfo ninf;
ninf.id = oind->getIdByName(nodename); ninf.id = oind->getIdByName(nodename);
...@@ -877,14 +872,12 @@ ObjectId Configuration::getServiceID( const std::string& name ) ...@@ -877,14 +872,12 @@ ObjectId Configuration::getServiceID( const std::string& name )
return oind->getIdByName(getServicesSection()+"/"+name); return oind->getIdByName(getServicesSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniSetTypes::ObjectId Configuration::getNodeID( const std::string& name, const std::string& alias ) UniSetTypes::ObjectId Configuration::getNodeID( const std::string& name )
{ {
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
string a( (alias.empty() ? name : alias ) ); return oind->getNodeId( name );
return oind->getIdByName( oind->mkFullNodeName(name,a) );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -94,13 +94,7 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it, ...@@ -94,13 +94,7 @@ bool Restorer_XML::getConsumerInfo( UniXML_iterator& it,
string cnodename(it.getProp("node")); string cnodename(it.getProp("node"));
if( !cnodename.empty() ) if( !cnodename.empty() )
{
string virtnode = conf->oind->getVirtualNodeName(cnodename);
if( virtnode.empty() )
cnodename = conf->oind->mkFullNodeName(cnodename,cnodename);
cnode = conf->oind->getIdByName(cnodename); cnode = conf->oind->getIdByName(cnodename);
}
else else
cnode = conf->getLocalNode(); cnode = conf->getLocalNode();
......
...@@ -140,7 +140,7 @@ void SViewer::readSection( const string& section, const string& secRoot ) ...@@ -140,7 +140,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
{ {
string ob(*li); string ob(*li);
string fname(curSection+ "/"+ ob); string fname(curSection+ "/"+ ob);
ObjectId id = conf->oind->getIdByFullName( fname ); ObjectId id = conf->oind->getIdByName( fname );
if( id == DefaultObjectId ) if( id == DefaultObjectId )
cout << "(readSection): ID?! для " << fname << endl; cout << "(readSection): ID?! для " << fname << endl;
else else
...@@ -219,8 +219,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType ...@@ -219,8 +219,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
{ {
if( amap[i].type == UniversalIO::AI || amap[i].type == UniversalIO::DI ) if( amap[i].type == UniversalIO::AI || amap[i].type == UniversalIO::DI )
{ {
// UniSetTypes::KeyType k = key(amap[i].si.id, amap[i].si.node); string name(conf->oind->getNameById(amap[i].si.id));
string name(conf->oind->getNameById(amap[i].si.id, amap[i].si.node));
if( isShort ) if( isShort )
name = ORepHelpers::getShortName(name); name = ORepHelpers::getShortName(name);
string txtname( conf->oind->getTextName(amap[i].si.id) ); string txtname( conf->oind->getTextName(amap[i].si.id) );
...@@ -236,8 +235,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType ...@@ -236,8 +235,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
{ {
if( amap[i].type == UniversalIO::AO || amap[i].type == UniversalIO::DO ) if( amap[i].type == UniversalIO::AO || amap[i].type == UniversalIO::DO )
{ {
// UniSetTypes::KeyType k = key(amap[i].si.id, amap[i].si.node); string name(conf->oind->getNameById(amap[i].si.id));
string name(conf->oind->getNameById(amap[i].si.id, amap[i].si.node));
if( isShort ) if( isShort )
name = ORepHelpers::getShortName(name); name = ORepHelpers::getShortName(name);
string txtname( conf->oind->getTextName(amap[i].si.id) ); string txtname( conf->oind->getTextName(amap[i].si.id) );
...@@ -274,7 +272,7 @@ void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tls ...@@ -274,7 +272,7 @@ void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tls
break; break;
} }
string sname(conf->oind->getNameById( tlst[i].si.id, tlst[i].si.node )); string sname(conf->oind->getNameById(tlst[i].si.id));
if( isShort ) if( isShort )
sname = ORepHelpers::getShortName(sname); sname = ORepHelpers::getShortName(sname);
......
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