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