Commit d28a8a9c authored by Pavel Vainerman's avatar Pavel Vainerman

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

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