00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024
00025 #ifndef NCRestorer_H_
00026 #define NCRestorer_H_
00027
00028 #include <sigc++/sigc++.h>
00029 #include <string>
00030 #include "UniXML.h"
00031 #include "Restorer.h"
00032 #include "IOController.h"
00033 #include "IONotifyController.h"
00034
00038 class NCRestorer
00039 {
00040 public:
00041
00042 NCRestorer();
00043 virtual ~NCRestorer();
00044
00045 struct SInfo:
00046 public IOController::UniAnalogIOInfo
00047 {
00048 SInfo( IOController_i::SensorInfo& si, UniversalIO::IOTypes& t,
00049 UniSetTypes::Message::Message::Priority& p, long& def )
00050 {
00051 this->si = si;
00052 this->type = t;
00053 this->priority = p;
00054 this->default_val = def;
00055 }
00056
00057 SInfo()
00058 {
00059 this->type = UniversalIO::DigitalInput;
00060 this->priority = UniSetTypes::Message::Medium;
00061 this->default_val = 0;
00062 }
00063
00064 SInfo &operator=(IOController_i::DigitalIOInfo& inf);
00065 SInfo &operator=(IOController_i::AnalogIOInfo& inf);
00066
00067 operator IOController::UniDigitalIOInfo();
00068 };
00069
00070 virtual void read(IONotifyController* ic, const std::string fn="" )=0;
00071 virtual void buildDependsList( IONotifyController* ic, const std::string fn="" )=0;
00072 virtual void dump(IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst)=0;
00073 virtual void dumpThreshold(IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst)=0;
00074
00075 protected:
00076
00077
00078 static void addlist( IONotifyController* ic, SInfo& inf, IONotifyController::ConsumerList& lst, bool force=false );
00079
00080
00081 static void addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyController::ThresholdExtList& lst, bool force=false );
00082
00084 static inline void dsRegistration( IONotifyController* ic, IOController::UniDigitalIOInfo& inf, bool force=false )
00085 {
00086 ic->dsRegistration(inf,force);
00087 }
00088
00090 static inline void asRegistration( IONotifyController* ic, IOController::UniAnalogIOInfo& inf, bool force=false )
00091 {
00092 ic->asRegistration(inf,force);
00093 }
00094
00095 static inline IOController::AIOStateList::iterator aioFind(IONotifyController* ic, UniSetTypes::KeyType k)
00096 {
00097 return ic->myafind(k);
00098 }
00099
00100 static inline IOController::DIOStateList::iterator dioFind(IONotifyController* ic, UniSetTypes::KeyType k)
00101 {
00102 return ic->mydfind(k);
00103 }
00104
00105 static inline IOController::DIOStateList::iterator dioEnd( IONotifyController* ic )
00106 {
00107 return ic->mydioEnd();
00108 }
00109 static inline IOController::AIOStateList::iterator aioEnd( IONotifyController* ic )
00110 {
00111 return ic->myaioEnd();
00112 }
00113 static inline IOController::DIOStateList::iterator dioBegin( IONotifyController* ic )
00114 {
00115 return ic->mydioBegin();
00116 }
00117 static inline IOController::AIOStateList::iterator aioBegin( IONotifyController* ic )
00118 {
00119 return ic->myaioBegin();
00120 }
00121
00122 };
00123
00128 class NCRestorer_XML:
00129 public Restorer_XML,
00130 public NCRestorer
00131 {
00132 public:
00133
00137 NCRestorer_XML(const std::string fname);
00138
00144 NCRestorer_XML( const std::string fname, const std::string sensor_filterField, const std::string sensor_filterValue="" );
00145
00146 virtual ~NCRestorer_XML();
00147 NCRestorer_XML();
00148
00152 void setDependsFilter( const std::string filterField, const std::string filterValue="" );
00153
00155 void setThresholdsFilter( const std::string filterField, const std::string filterValue="" );
00156
00157 bool setFileName( const std::string& file, bool create );
00158 inline std::string getFileName(){ return fname; }
00159
00169 void setReadThresholdItem( ReaderSlot sl );
00170
00179 void setReadDependItem( ReaderSlot sl );
00180
00181
00182 typedef sigc::slot<bool,UniXML&,UniXML_iterator&,xmlNode*,SInfo&> NCReaderSlot;
00183
00184 void setNCReadItem( NCReaderSlot sl );
00185
00186 virtual void read(IONotifyController* ic, const std::string filename="" );
00187 virtual void read(IONotifyController* ic, UniXML& xml );
00188
00189 virtual void dump(IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst);
00190 virtual void dumpThreshold(IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst);
00191
00192 virtual void buildDependsList( IONotifyController* ic, const std::string fn="" );
00193 virtual void buildDependsList( IONotifyController* ic, UniXML& xml );
00194
00195 protected:
00196
00197 bool check_thresholds_item( UniXML_iterator& it );
00198 bool check_depend_item( UniXML_iterator& it );
00199 void read_consumers(UniXML& xml, xmlNode* node, NCRestorer_XML::SInfo& inf, IONotifyController* ic );
00200 void read_list(UniXML& xml, xmlNode* node, IONotifyController* ic);
00201 void read_thresholds(UniXML& xml, xmlNode* node, IONotifyController* ic);
00202 void build_depends( UniXML& xml, xmlNode* node, IONotifyController* ic );
00203 void init( std::string fname );
00204
00205 bool getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si );
00206 bool getSensorInfo(UniXML& xml, xmlNode* snode, SInfo& si );
00207 bool getConsumerList(UniXML& xml,xmlNode* node, IONotifyController::ConsumerList& lst);
00208 bool getThresholdInfo(UniXML& xml,xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti);
00209 bool getDependsInfo( UniXML& xml, xmlNode* node, IOController::DependsInfo& di );
00210
00211 static void set_dumptime( UniXML& xml, xmlNode* node );
00212 static xmlNode* bind_node(UniXML& xml, xmlNode* root, const std::string& nodename, const std::string nm="");
00213 static xmlNode* rebind_node(UniXML& xml, xmlNode* root, const std::string& nodename, const std::string nm="");
00214
00215
00216 std::string s_filterField;
00217 std::string s_filterValue;
00218 std::string c_filterField;
00219 std::string c_filterValue;
00220 std::string d_filterField;
00221 std::string d_filterValue;
00222 std::string t_filterField;
00223 std::string t_filterValue;
00224
00225 std::string fname;
00226 UniXML uxml;
00227 ReaderSlot rtslot;
00228 ReaderSlot depslot;
00229 NCReaderSlot ncrslot;
00230
00231 private:
00232 };
00233
00234 #endif