Commit d28a8a9c authored by Pavel Vainerman's avatar Pavel Vainerman

Глобальный переход на unordered_map везде где возможно.

parent 95eb3b75
#ifndef Schema_H_
#define Schema_H_
// --------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include "Element.h"
#include "Schema.h"
// --------------------------------------------------------------------------
......@@ -59,7 +59,7 @@ class Schema
void setIn( Element::ElementID ID, int inNum, bool state );
bool getOut( Element::ElementID ID );
typedef std::map<Element::ElementID,Element*> ElementMap;
typedef std::unordered_map<Element::ElementID,Element*> ElementMap;
typedef std::list<INLink> InternalList;
typedef std::list<EXTLink> ExternalList;
typedef std::list<EXTOut> OutputsList;
......
......@@ -689,7 +689,6 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
if( force )
return;
for( auto &it: iomap )
{
IOProperty* p(&it.second);
......@@ -697,7 +696,7 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
{
shm->askSensor(p->si.id,cmd);
}
catch( UniSetTypes::Exception& ex )
catch( const UniSetTypes::Exception& ex )
{
dwarn << myname << "(askSensors): " << ex << std::endl;
}
......
......@@ -6,6 +6,7 @@
#include <string>
#include <memory>
#include <map>
#include <unordered_map>
#include <vector>
#include "UniSetObject_LT.h"
#include "modbus/ModbusTypes.h"
......@@ -253,6 +254,17 @@
*/
// -----------------------------------------------------------------------------
namespace std {
template<>
class hash<ModbusRTU::mbErrCode> {
public:
size_t operator()(const ModbusRTU::mbErrCode &e) const
{
return std::hash<int>()((int)e);
}
};
}
// -----------------------------------------------------------------------------
/*! Реализация slave-интерфейса */
class MBSlave:
public UniSetObject_LT
......@@ -383,6 +395,8 @@ class MBSlave:
virtual ModbusRTU::mbErrCode checkRegister( ModbusRTU::ModbusData reg, ModbusRTU::ModbusData& val )
{ return ModbusRTU::erNoError; }
// т.к. в функциях (much_real_read,nuch_real_write) рассчёт на отсортированность IOMap
// то использовать unordered_map нельзя
typedef std::map<ModbusRTU::ModbusData,IOProperty> IOMap;
IOMap iomap; /*!< список входов/выходов */
......@@ -449,7 +463,7 @@ class MBSlave:
PassiveTimer ptTimeout;
long askCount;
typedef std::map<ModbusRTU::mbErrCode,unsigned int> ExchangeErrorMap;
typedef std::unordered_map<ModbusRTU::mbErrCode,unsigned int> ExchangeErrorMap;
ExchangeErrorMap errmap; /*!< статистика обмена */
std::atomic_bool activated;
......@@ -461,7 +475,7 @@ class MBSlave:
bool mbregFromID;
typedef std::map<int,std::string> FileList;
typedef std::unordered_map<int,std::string> FileList;
FileList flist;
std::string prefix;
std::string prop_prefix;
......@@ -471,9 +485,9 @@ class MBSlave:
// данные для ответа на запрос 0x2B(43)/0x0E(14)
// 'MEI' - modbus encapsulated interface
// 'RDI' - read device identification
typedef std::map<int,std::string> MEIValMap;
typedef std::map<int,MEIValMap> MEIObjIDMap;
typedef std::map<int,MEIObjIDMap> MEIDevIDMap;
typedef std::unordered_map<int,std::string> MEIValMap;
typedef std::unordered_map<int,MEIValMap> MEIObjIDMap;
typedef std::unordered_map<int,MEIObjIDMap> MEIDevIDMap;
MEIDevIDMap meidev;
};
......
......@@ -2,7 +2,7 @@
#ifndef _MBTCPMultiSlave_H_
#define _MBTCPMultiSlave_H_
// -----------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include "MBSlave.h"
#include "modbus/ModbusTCPServer.h"
// -----------------------------------------------------------------------------
......@@ -67,7 +67,7 @@ class MBTCPMultiSlave:
}
};
typedef std::map<const std::string,ClientInfo> ClientsMap;
typedef std::unordered_map<std::string,ClientInfo> ClientsMap;
ClientsMap cmap;
......
#ifndef _RRDServer_H_
#define _RRDServer_H_
// -----------------------------------------------------------------------------
#include <unordered_map>
#include <memory>
#include "UObject_SK.h"
#include "SMInterface.h"
......@@ -93,7 +94,7 @@ class RRDServer:
dsname(dsname),value(defval){}
};
typedef std::map<UniSetTypes::ObjectId,DSInfo> DSMap;
typedef std::unordered_map<UniSetTypes::ObjectId,DSInfo> DSMap;
struct RRDInfo
{
......
......@@ -649,12 +649,12 @@ void SharedMemory::saveHistory()
}
}
// -----------------------------------------------------------------------------
void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* )
void SharedMemory::updateHistory( std::shared_ptr<USensorInfo>& s_it, IOController* )
{
if( hist.empty() )
return;
auto i = histmap.find(s_it->second.si.id);
auto i = histmap.find(s_it->si.id);
if( i == histmap.end() )
return;
......@@ -662,14 +662,14 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* )
long sm_tv_sec = 0;
long sm_tv_usec = 0;
{
uniset_rwmutex_rlock lock(s_it->second.val_lock);
value = s_it->second.value;
sm_tv_sec = s_it->second.tv_sec;
sm_tv_usec = s_it->second.tv_usec;
uniset_rwmutex_rlock lock(s_it->val_lock);
value = s_it->value;
sm_tv_sec = s_it->tv_sec;
sm_tv_usec = s_it->tv_usec;
}
dinfo << myname << "(updateHistory): "
<< " sid=" << s_it->second.si.id
<< " sid=" << s_it->si.id
<< " value=" << value
<< endl;
......@@ -677,8 +677,8 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* )
{
History::iterator it = it1;
if( s_it->second.type == UniversalIO::DI ||
s_it->second.type == UniversalIO::DO )
if( s_it->type == UniversalIO::DI ||
s_it->type == UniversalIO::DO )
{
bool st = (bool)value;
......@@ -694,8 +694,8 @@ void SharedMemory::updateHistory( IOStateList::iterator& s_it, IOController* )
m_historySignal.emit( (*it) );
}
}
else if( s_it->second.type == UniversalIO::AI ||
s_it->second.type == UniversalIO::AO )
else if( s_it->type == UniversalIO::AI ||
s_it->type == UniversalIO::AO )
{
if( !it->fuse_use_val )
{
......
......@@ -2,6 +2,7 @@
#ifndef SharedMemory_H_
#define SharedMemory_H_
// -----------------------------------------------------------------------------
#include <unordered_map>
#include <string>
#include <memory>
#include <deque>
......@@ -341,7 +342,7 @@ class SharedMemory:
// вводим не просто map, а "map списка историй".
// точнее итераторов-историй.
typedef std::list<History::iterator> HistoryItList;
typedef std::map<UniSetTypes::ObjectId,HistoryItList> HistoryFuseMap;
typedef std::unordered_map<UniSetTypes::ObjectId,HistoryItList> HistoryFuseMap;
typedef sigc::signal<void, const HistoryInfo&> HistorySlot;
HistorySlot signal_history(); /*!< сигнал о срабатывании условий "сброса" дампа истории */
......@@ -428,7 +429,7 @@ class SharedMemory:
History hist;
HistoryFuseMap histmap; /*!< map для оптимизации поиска */
virtual void updateHistory( IOStateList::iterator& it, IOController* );
virtual void updateHistory( std::shared_ptr<IOController::USensorInfo>& it, IOController* );
virtual void saveHistory();
void buildHistoryList( xmlNode* cnode );
......
......@@ -25,7 +25,7 @@
#ifndef IONotifyController_H_
#define IONotifyController_H_
//---------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <list>
#include <string>
......@@ -193,7 +193,7 @@ class IONotifyController:
};
/*! словарь: датчик -> список потребителей */
typedef std::map<UniSetTypes::KeyType,ConsumerListInfo> AskMap;
typedef std::unordered_map<UniSetTypes::KeyType,ConsumerListInfo> AskMap;
/*! Информация о пороговом значении */
......@@ -261,13 +261,13 @@ class IONotifyController:
UniSetTypes::uniset_rwmutex mut;
IOController_i::SensorInfo si; /*!< аналоговый датчик */
IOStateList::iterator ait;
std::shared_ptr<USensorInfo> ait;
UniversalIO::IOType type;
ThresholdExtList list; /*!< список порогов по данному аналоговому датчику */
};
/*! словарь: аналоговый датчик --> список порогов по нему */
typedef std::map<UniSetTypes::KeyType,ThresholdsListInfo> AskThresholdMap;
typedef std::unordered_map<UniSetTypes::KeyType,ThresholdsListInfo> AskThresholdMap;
protected:
IONotifyController();
......@@ -275,7 +275,7 @@ class IONotifyController:
virtual void initItem( IOStateList::iterator& it, IOController* ic );
// ФИЛЬТРЫ
bool myIOFilter(const USensorInfo& ai, CORBA::Long newvalue, UniSetTypes::ObjectId sup_id);
bool myIOFilter(std::shared_ptr<USensorInfo>& ai, CORBA::Long newvalue, UniSetTypes::ObjectId sup_id);
//! посылка информации об изменении состояния датчика
virtual void send( ConsumerListInfo& lst, UniSetTypes::SensorMessage& sm );
......@@ -304,7 +304,7 @@ class IONotifyController:
NCRestorer* restorer;
void onChangeUndefinedState( IOStateList::iterator& it, IOController* ic );
void onChangeUndefinedState( std::shared_ptr<USensorInfo>& it, IOController* ic );
private:
friend class NCRestorer;
......
......@@ -3,7 +3,7 @@
// -------------------------------------------------------------------------
#include <string>
#include <memory>
#include <map>
#include <unordered_map>
#include "DebugStream.h"
#include "LogServerTypes.h"
// -------------------------------------------------------------------------
......@@ -44,7 +44,7 @@ class LogAgregator:
private:
typedef std::map<std::string, LogInfo> LogMap;
typedef std::unordered_map<std::string, LogInfo> LogMap;
LogMap lmap;
};
// -------------------------------------------------------------------------
......
......@@ -25,6 +25,7 @@
#ifndef NCRestorer_H_
#define NCRestorer_H_
// ------------------------------------------------------------------------------------------
#include <memory>
#include <sigc++/sigc++.h>
#include <string>
#include "UniXML.h"
......@@ -69,24 +70,25 @@ class NCRestorer
this->default_val = 0;
}
SInfo &operator=(IOController_i::SensorIOInfo& inf);
SInfo &operator=(const IOController_i::SensorIOInfo& inf);
SInfo( const IOController_i::SensorIOInfo& inf );
};
virtual void read( IONotifyController* ic, const std::string& fn="" )=0;
virtual void dump(const IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerListInfo& lst)=0;
virtual void dumpThreshold(const IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst)=0;
virtual void dump(const IONotifyController* ic, std::shared_ptr<SInfo>& inf, const IONotifyController::ConsumerListInfo& lst)=0;
virtual void dumpThreshold(const IONotifyController* ic, std::shared_ptr<SInfo>& inf, const IONotifyController::ThresholdExtList& lst)=0;
protected:
// добавление списка заказчиков
static void addlist( IONotifyController* ic, SInfo&& inf, IONotifyController::ConsumerListInfo&& lst, bool force=false );
static void addlist( IONotifyController* ic, std::shared_ptr<IOController::USensorInfo>& inf, IONotifyController::ConsumerListInfo&& lst, bool force=false );
// добавление списка порогов и заказчиков
static void addthresholdlist( IONotifyController* ic, SInfo&& inf, IONotifyController::ThresholdExtList&& lst, bool force=false );
static void addthresholdlist( IONotifyController* ic, std::shared_ptr<IOController::USensorInfo>& inf, IONotifyController::ThresholdExtList&& lst, bool force=false );
static inline void ioRegistration( IONotifyController* ic, IOController::USensorInfo&& inf, bool force=false )
static inline void ioRegistration( IONotifyController* ic, std::shared_ptr<IOController::USensorInfo>& inf, bool force=false )
{
ic->ioRegistration( std::move(inf),force);
ic->ioRegistration(inf,force);
}
static inline IOController::IOStateList::iterator ioFind( IONotifyController* ic, UniSetTypes::KeyType k )
......@@ -149,26 +151,26 @@ class NCRestorer_XML:
*/
void setReadThresholdItem( ReaderSlot sl );
typedef sigc::slot<bool,const std::shared_ptr<UniXML>&,UniXML::iterator&,xmlNode*,SInfo&> NCReaderSlot;
typedef sigc::slot<bool,const std::shared_ptr<UniXML>&,UniXML::iterator&,xmlNode*,std::shared_ptr<IOController::USensorInfo>&> NCReaderSlot;
void setNCReadItem( NCReaderSlot sl );
virtual void read( IONotifyController* ic, const std::string& filename="" );
virtual void read( IONotifyController* ic, const std::shared_ptr<UniXML>& xml );
virtual void dump(const IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerListInfo& lst);
virtual void dumpThreshold(const IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst);
virtual void dump(const IONotifyController* ic, std::shared_ptr<NCRestorer::SInfo>& inf, const IONotifyController::ConsumerListInfo& lst) override;
virtual void dumpThreshold(const IONotifyController* ic, std::shared_ptr<NCRestorer::SInfo>& inf, const IONotifyController::ThresholdExtList& lst) override;
protected:
bool check_thresholds_item( UniXML::iterator& it );
void read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* node, NCRestorer_XML::SInfo&& inf, IONotifyController* ic );
void read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* node, std::shared_ptr<NCRestorer_XML::SInfo>& inf, IONotifyController* ic );
void read_list( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic);
void read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic);
void init( const std::string& fname );
bool getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si );
bool getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* snode, SInfo& si );
bool getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* snode, std::shared_ptr<NCRestorer_XML::SInfo>& si );
bool getConsumerList( const std::shared_ptr<UniXML>& xml,xmlNode* node, IONotifyController::ConsumerListInfo& lst);
bool getThresholdInfo(const std::shared_ptr<UniXML>& xml,xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti);
......
......@@ -24,7 +24,7 @@
#define ObjectIndex_Array_H_
// --------------------------------------------------------------------------
#include <string>
#include <map>
#include <unordered_map>
#include <ostream>
#include "UniSetTypes.h"
#include "Exceptions.h"
......@@ -56,7 +56,7 @@ class ObjectIndex_Array:
private:
int numOfObject;
typedef std::map<std::string, ObjectId> MapObjectKey;
typedef std::unordered_map<std::string, ObjectId> MapObjectKey;
MapObjectKey::iterator MapObjectKeyIterator;
MapObjectKey mok;
const ObjectInfo *objectInfo;
......
......@@ -23,7 +23,7 @@
#ifndef ObjectIndex_XML_H_
#define ObjectIndex_XML_H_
// --------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <memory>
#include <vector>
#include <string>
......@@ -57,7 +57,7 @@ class ObjectIndex_XML:
unsigned int read_nodes( const std::shared_ptr<UniXML>& xml, const std::string& sec, unsigned int ind );
private:
typedef std::map<std::string, ObjectId> MapObjectKey;
typedef std::unordered_map<std::string, ObjectId> MapObjectKey;
MapObjectKey mok; // для обратного писка
std::vector<ObjectInfo> omap; // для прямого поиска
};
......
......@@ -2,7 +2,7 @@
#ifndef ObjectIndex_idXML_H_
#define ObjectIndex_idXML_H_
// --------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <string>
#include "ObjectIndex.h"
#include "UniXML.h"
......@@ -30,10 +30,10 @@ class ObjectIndex_idXML:
void read_nodes( const std::shared_ptr<UniXML>& xml, const std::string& sec );
private:
typedef std::map<UniSetTypes::ObjectId, UniSetTypes::ObjectInfo> MapObjects;
typedef std::unordered_map<UniSetTypes::ObjectId, UniSetTypes::ObjectInfo> MapObjects;
MapObjects omap;
typedef std::map<std::string, UniSetTypes::ObjectId> MapObjectKey;
typedef std::unordered_map<std::string, UniSetTypes::ObjectId> MapObjectKey;
MapObjectKey mok; // для обратного писка
};
// -----------------------------------------------------------------------------------------
......
......@@ -24,7 +24,7 @@
#ifndef ProxyManager_H_
#define ProxyManager_H_
//---------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <memory>
#include "UniSetObject.h"
......@@ -57,7 +57,7 @@ class ProxyManager:
virtual bool deactivateObject();
private:
typedef std::map<UniSetTypes::ObjectId, PassiveObject*> PObjectMap;
typedef std::unordered_map<UniSetTypes::ObjectId, PassiveObject*> PObjectMap;
PObjectMap omap;
};
//----------------------------------------------------------------------------------------
......
......@@ -26,7 +26,7 @@
#ifndef TRIGGER_AND_H_
#define TRIGGER_AND_H_
//---------------------------------------------------------------------------
#include <map>
#include <unordered_map>
//---------------------------------------------------------------------------
/*!
Триггер \b "И", со множеством входов.
......@@ -94,7 +94,7 @@ class TriggerAND
void add(InputType in, bool state);
void remove(InputType in);
typedef std::map<InputType, bool> InputMap;
typedef std::unordered_map<InputType, bool> InputMap;
inline typename InputMap::const_iterator begin()
{
......
......@@ -25,7 +25,7 @@
#ifndef TRIGGER_OR_H_
#define TRIGGER_OR_H_
//---------------------------------------------------------------------------
#include <map>
#include <unordered_map>
//---------------------------------------------------------------------------
/*!
Триггер \b "ИЛИ", со множеством входов.
......@@ -92,7 +92,7 @@ class TriggerOR
void add(InputType in, bool state);
void remove(InputType in);
typedef std::map<InputType, bool> InputMap;
typedef std::unordered_map<InputType, bool> InputMap;
inline typename InputMap::const_iterator begin()
{
......
......@@ -25,7 +25,7 @@
#ifndef TriggerOUT_H_
#define TriggerOUT_H_
//---------------------------------------------------------------------------
#include <map>
#include <unordered_map>
//---------------------------------------------------------------------------
/*!
\par Описание
......@@ -120,7 +120,7 @@ class TriggerOUT
protected:
void resetOuts( OutIdType outIgnore );
typedef std::map<OutIdType, ValueType> OutList;
typedef std::unordered_map<OutIdType, ValueType> OutList;
OutList outs; // список выходов
Caller* cal;
......
......@@ -28,7 +28,7 @@
#include <memory>
#include <string>
#include <sstream>
#include <map>
#include <unordered_map>
#include <functional>
#include <omniORB4/CORBA.h>
#include "Exceptions.h"
......@@ -281,7 +281,7 @@ class UInterface
}
};
typedef std::map<int, Info> CacheMap;
typedef std::unordered_map<int, Info> CacheMap;
mutable CacheMap mcache;
mutable UniSetTypes::uniset_rwmutex cmutex;
unsigned int MaxSize; /*!< максимальный размер кэша */
......
......@@ -21,6 +21,8 @@
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
#include <unordered_map>
#include <map>
#include <unistd.h>
#include <signal.h>
#include <iomanip>
......@@ -477,10 +479,10 @@ struct tmpConsumerInfo
{
tmpConsumerInfo(){}
map<UniSetTypes::KeyType,VoidMessage> smap;
map<int,VoidMessage> tmap;
map<int,VoidMessage> sysmap;
map<CInfo,VoidMessage> cmap;
unordered_map<UniSetTypes::KeyType,VoidMessage> smap;
unordered_map<int,VoidMessage> tmap;
unordered_map<int,VoidMessage> sysmap;
std::map<CInfo,VoidMessage> cmap;
list<VoidMessage> lstOther;
};
......@@ -492,7 +494,7 @@ void UniSetObject::cleanMsgQueue( MessagesQueue& q )
// проходим по всем известным нам типам(базовым)
// ищем все совпадающие сообщения и оставляем только последние...
VoidMessage m;
map<UniSetTypes::ObjectId,tmpConsumerInfo> consumermap;
unordered_map<UniSetTypes::ObjectId,tmpConsumerInfo> consumermap;
// while( receiveMessage(vm) );
// while нельзя использовать потому-что, из параллельного потока
......
......@@ -40,7 +40,7 @@ NCRestorer::~NCRestorer()
{
}
// ------------------------------------------------------------------------------------------
void NCRestorer::addlist( IONotifyController* ic, SInfo&& inf, IONotifyController::ConsumerListInfo&& lst, bool force )
void NCRestorer::addlist( IONotifyController* ic, std::shared_ptr<IOController::USensorInfo>& inf, IONotifyController::ConsumerListInfo&& lst, bool force )
{
// Проверка зарегистрирован-ли данный датчик
// если такого дискретного датчика нет, то здесь сработает исключение...
......@@ -48,23 +48,23 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo&& inf, IONotifyControlle
{
try
{
ic->getIOType(inf.si.id);
ic->getIOType(inf->si.id);
}
catch(...)
{
// Регистрируем (если не найден)
switch(inf.type)
switch(inf->type)
{
case UniversalIO::DI:
case UniversalIO::DO:
case UniversalIO::AI:
case UniversalIO::AO:
ic->ioRegistration( std::move(inf) );
ic->ioRegistration(inf);
break;
default:
ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< uniset_conf()->oind->getNameById(inf.si.id) << endl;
<< uniset_conf()->oind->getNameById(inf->si.id) << endl;
return;
break;
......@@ -72,23 +72,23 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo&& inf, IONotifyControlle
}
}
switch(inf.type)
switch(inf->type)
{
case UniversalIO::DI:
case UniversalIO::AI:
case UniversalIO::DO:
case UniversalIO::AO:
ic->askIOList[inf.si.id]=std::move(lst);
ic->askIOList[inf->si.id]=std::move(lst);
break;
default:
ucrit << ic->getName() << "(NCRestorer::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА!-> "
<< uniset_conf()->oind->getNameById(inf.si.id) << endl;
<< uniset_conf()->oind->getNameById(inf->si.id) << endl;
break;
}
}
// ------------------------------------------------------------------------------------------
void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo&& inf, IONotifyController::ThresholdExtList&& lst, bool force )
void NCRestorer::addthresholdlist( IONotifyController* ic, std::shared_ptr<IOController::USensorInfo>& inf, IONotifyController::ThresholdExtList&& lst, bool force )
{
// Проверка зарегистрирован-ли данный датчик
// если такого дискретного датчика нет сдесь сработает исключение...
......@@ -96,18 +96,18 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo&& inf, IONotify
{
try
{
ic->getIOType(inf.si.id);
ic->getIOType(inf->si.id);
}
catch(...)
{
// Регистрируем (если не найден)
switch(inf.type)
switch(inf->type)
{
case UniversalIO::DI:
case UniversalIO::DO:
case UniversalIO::AI:
case UniversalIO::AO:
ic->ioRegistration( std::move(inf) );
ic->ioRegistration(inf);
break;
default:
......@@ -120,17 +120,21 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo&& inf, IONotify
for( auto &it: lst )
it.sit = ic->myioEnd();
ic->askTMap[inf.si.id].si = inf.si;
ic->askTMap[inf.si.id].type = inf.type;
ic->askTMap[inf.si.id].list = std::move(lst);
ic->askTMap[inf.si.id].ait = ic->myioEnd();
ic->askTMap[inf->si.id].si = inf->si;
ic->askTMap[inf->si.id].type = inf->type;
ic->askTMap[inf->si.id].list = std::move(lst);
}
// ------------------------------------------------------------------------------------------
NCRestorer::SInfo& NCRestorer::SInfo::operator=( IOController_i::SensorIOInfo& inf )
NCRestorer::SInfo::SInfo( const IOController_i::SensorIOInfo& inf )
{
this->si = inf.si;
this->type = inf.type;
this->priority = inf.priority;
(*this) = inf;
}
// ------------------------------------------------------------------------------------------
NCRestorer::SInfo& NCRestorer::SInfo::operator=( const IOController_i::SensorIOInfo& inf )
{
this->si = inf.si;
this->type = inf.type;
this->priority = inf.priority;
this->default_val = inf.default_val;
this->real_value = inf.real_value;
this->ci = inf.ci;
......@@ -139,27 +143,41 @@ NCRestorer::SInfo& NCRestorer::SInfo::operator=( IOController_i::SensorIOInfo& i
this->dbignore = inf.dbignore;
this->any = 0;
return *this;
// CalibrateInfo ci;
// long tv_sec;
// long v_usec;
}
// ------------------------------------------------------------------------------------------
#if 0
NCRestorer::SInfo& NCRestorer::SInfo::operator=( const std::shared_ptr<IOController_i::SensorIOInfo>& inf )
{
this->si = inf->si;
this->type = inf->type;
this->priority = inf->priority;
this->default_val = inf->default_val;
this->real_value = inf->real_value;
this->ci = inf->ci;
this->undefined = inf->undefined;
this->blocked = inf->blocked;
this->dbignore = inf->dbignore;
this->any = 0;
return *this;
}
#endif
// ------------------------------------------------------------------------------------------
void NCRestorer::init_depends_signals( IONotifyController* ic )
{
for( auto it=ic->ioList.begin(); it!=ic->ioList.end(); ++it )
{
// обновляем итераторы...
it->second.it = it;
it->second->it = it->second;
if( it->second.d_si.id == DefaultObjectId )
if( it->second->d_si.id == DefaultObjectId )
continue;
uinfo << ic->getName() << "(NCRestorer::init_depends_signals): "
<< " init depend: '" << uniset_conf()->oind->getMapName(it->second.si.id) << "'"
<< " dep_name=(" << it->second.d_si.id << ")'" << uniset_conf()->oind->getMapName(it->second.d_si.id) << "'"
<< " init depend: '" << uniset_conf()->oind->getMapName(it->second->si.id) << "'"
<< " dep_name=(" << it->second->d_si.id << ")'" << uniset_conf()->oind->getMapName(it->second->d_si.id) << "'"
<< endl;
ic->signal_change_value(it->second.d_si.id).connect( sigc::mem_fun( &it->second, &IOController::USensorInfo::checkDepend) );
ic->signal_change_value(it->second->d_si.id).connect( sigc::mem_fun( it->second.get(), &IOController::USensorInfo::checkDepend) );
}
}
// -----------------------------------------------------------------------------
......@@ -104,13 +104,13 @@ void NCRestorer_XML::init( const std::string& xmlfile )
}
}
// ------------------------------------------------------------------------------------------
void NCRestorer_XML::dump(const IONotifyController* ic, SInfo& inf,
void NCRestorer_XML::dump(const IONotifyController* ic, std::shared_ptr<SInfo>& inf,
const IONotifyController::ConsumerListInfo& lst)
{
uwarn << "NCRestorer_XML::dump NOT SUPPORT!!!!" << endl;
}
// ------------------------------------------------------------------------------------------
void NCRestorer_XML::dumpThreshold(const IONotifyController* ic, SInfo& inf,
void NCRestorer_XML::dumpThreshold(const IONotifyController* ic, std::shared_ptr<SInfo>& inf,
const IONotifyController::ThresholdExtList& lst)
{
uwarn << "NCRestorer_XML::dumpThreshold NOT SUPPORT!!!!" << endl;
......@@ -127,7 +127,7 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
if( !check_list_item(it) )
continue;
NCRestorer_XML::SInfo inf;
std::shared_ptr<NCRestorer_XML::SInfo> inf = make_shared<NCRestorer_XML::SInfo>();
if( !getSensorInfo(xml,it,inf) )
{
......@@ -135,14 +135,16 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
continue;
}
inf.undefined = false;
inf->undefined = false;
// т.к. в функции может обновится inf
// вызываем перед регистрацией
// (потому-что в xxRegistration inf будет скопирована
ncrslot(xml,it,node,inf);
std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf);
switch(inf.type)
ncrslot(xml,it,node,uinf);
switch(inf->type)
{
case UniversalIO::DO:
case UniversalIO::DI:
......@@ -151,7 +153,9 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
{
try
{
ioRegistration(ic, std::move(inf), true);
ioRegistration(ic,uinf,true);
}
catch( const Exception& ex )
{
......@@ -165,7 +169,7 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
}
rslot(xml,it,node);
read_consumers(xml, it, std::move(inf), ic);
read_consumers(xml, it, inf, ic);
}
}
// ------------------------------------------------------------------------------------------
......@@ -264,26 +268,26 @@ bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* i
return true;
}
// ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, SInfo& inf )
bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, std::shared_ptr<NCRestorer_XML::SInfo>& inf )
{
if( !getBaseInfo(xml,it,inf.si) )
if( !getBaseInfo(xml,it,inf->si) )
return false;
inf.priority = Message::Medium;
inf->priority = Message::Medium;
string prior(xml->getProp(it,"priority"));
if( prior == "Low" )
inf.priority = Message::Low;
inf->priority = Message::Low;
else if( prior == "Medium" )
inf.priority = Message::Medium;
inf->priority = Message::Medium;
else if( prior == "High" )
inf.priority = Message::High;
inf->priority = Message::High;
else if( prior == "Super" )
inf.priority = Message::Super;
inf->priority = Message::Super;
else
inf.priority = Message::Medium;
inf->priority = Message::Medium;
inf.type = UniSetTypes::getIOType(xml->getProp(it,"iotype"));
if( inf.type == UniversalIO::UnknownIOType )
inf->type = UniSetTypes::getIOType(xml->getProp(it,"iotype"));
if( inf->type == UniversalIO::UnknownIOType )
{
ucrit << "(NCRestorer_XML:getSensorInfo): unknown iotype=" << xml->getProp(it,"iotype")
<< " for " << xml->getProp(it,"name") << endl;
......@@ -291,34 +295,34 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
}
// калибровка
if( inf.type == UniversalIO::AI || inf.type == UniversalIO::AO )
if( inf->type == UniversalIO::AI || inf->type == UniversalIO::AO )
{
inf.ci.minRaw = xml->getIntProp(it,"rmin");
inf.ci.maxRaw = xml->getIntProp(it,"rmax");
inf.ci.minCal = xml->getIntProp(it,"cmin");
inf.ci.maxCal = xml->getIntProp(it,"cmax");
inf.ci.precision = xml->getIntProp(it,"precision");
inf->ci.minRaw = xml->getIntProp(it,"rmin");
inf->ci.maxRaw = xml->getIntProp(it,"rmax");
inf->ci.minCal = xml->getIntProp(it,"cmin");
inf->ci.maxCal = xml->getIntProp(it,"cmax");
inf->ci.precision = xml->getIntProp(it,"precision");
}
else
{
inf.ci.minRaw = 0;
inf.ci.maxRaw = 0;
inf.ci.minCal = 0;
inf.ci.maxCal = 0;
inf.ci.precision = 0;
inf->ci.minRaw = 0;
inf->ci.maxRaw = 0;
inf->ci.minCal = 0;
inf->ci.maxCal = 0;
inf->ci.precision = 0;
}
inf.default_val = xml->getIntProp(it,"default");
inf.dbignore = xml->getIntProp(it,"dbignore");
inf.value = inf.default_val;
inf.undefined = false;
inf.real_value = inf.value;
inf->default_val = xml->getIntProp(it,"default");
inf->dbignore = xml->getIntProp(it,"dbignore");
inf->value = inf->default_val;
inf->undefined = false;
inf->real_value = inf->value;
string d_txt( xml->getProp(it, "depend") );
if( !d_txt.empty() )
{
inf.d_si.id = uniset_conf()->getSensorID(d_txt);
if( inf.d_si.id == UniSetTypes::DefaultObjectId )
inf->d_si.id = uniset_conf()->getSensorID(d_txt);
if( inf->d_si.id == UniSetTypes::DefaultObjectId )
{
ucrit << "(NCRestorer_XML:getSensorInfo): sensor='"
<< xml->getProp(it,"name") << "' err: "
......@@ -327,11 +331,11 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
return false;
}
inf.d_si.node = uniset_conf()->getLocalNode();
inf->d_si.node = uniset_conf()->getLocalNode();
// по умолчанию срабатывание на "1"
inf.d_value = xml->getProp(it,"depend_value").empty() ? 1 : xml->getIntProp(it,"depend_value");
inf.d_off_value = xml->getPIntProp(it,"depend_off_value",0);
inf->d_value = xml->getProp(it,"depend_value").empty() ? 1 : xml->getIntProp(it,"depend_value");
inf->d_off_value = xml->getPIntProp(it,"depend_off_value",0);
}
return true;
......@@ -348,7 +352,8 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
if( !check_thresholds_item(it) )
continue;
NCRestorer_XML::SInfo inf;
std::shared_ptr<NCRestorer_XML::SInfo> inf = make_shared<NCRestorer_XML::SInfo>();
if( !getSensorInfo(xml,it.getCurrent(),inf) )
{
uwarn << ic->getName()
......@@ -371,7 +376,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
uwarn << ic->getName()
<< "(read_thresholds): не смог получить информацию о пороге"
<< " для датчика "
<< uniset_conf()->oind->getNameById(inf.si.id) << endl;
<< uniset_conf()->oind->getNameById(inf->si.id) << endl;
continue;
}
......@@ -392,7 +397,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
uwarn << ic->getName()
<< "(read_thresholds): не смог получить список заказчиков"
<< " для порога " << ti.id
<< " датчика " << uniset_conf()->oind->getNameById(inf.si.id) << endl;
<< " датчика " << uniset_conf()->oind->getNameById(inf->si.id) << endl;
}
}
}
......@@ -402,13 +407,14 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
rtslot(xml,tit,it);
}
addthresholdlist(ic, std::move(inf), std::move(tlst) );
std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf);
addthresholdlist(ic, uinf, std::move(tlst) );
}
}
// ------------------------------------------------------------------------------------------
void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* it,
NCRestorer_XML::SInfo&& inf, IONotifyController* ic )
std::shared_ptr<NCRestorer_XML::SInfo>& inf, IONotifyController* ic )
{
// в новых ask-файлах список выделен <consumers>...</consumers>,
xmlNode* cnode = find_node(xml,it,"consumers","");
......@@ -419,7 +425,10 @@ void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode
{
IONotifyController::ConsumerListInfo lst;
if( getConsumerList(xml,cit,lst) )
addlist(ic,std::move(inf),std::move(lst),true);
{
std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf);
addlist(ic,uinf,std::move(lst),true);
}
}
}
}
......
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