00001 #ifndef MultiChannelSensors_H_
00002 #define MultiChannelSensors_H_
00003
00004 #include <list>
00005 #include <map>
00006 #include <UniSetTypes.h>
00007 #include <UniversalInterface.h>
00008 #include <MessageType.h>
00009 #include <UniXML.h>
00010 #include "MultiChannelSensors_SK.h"
00011
00012
00074 class MultiChannelSensors:
00075 public MultiChannelSensors_SK
00076 {
00077 public:
00078
00079 MultiChannelSensors( UniSetTypes::ObjectId id, xmlNode* cnode );
00080 ~MultiChannelSensors();
00081
00082 virtual void sensorInfo( UniSetTypes::SensorMessage *sm );
00083 virtual void askSensors( UniversalIO::UIOCommand cmd );
00084 virtual void sysCommand( UniSetTypes::SystemMessage* sm );
00085
00086 struct SInfo
00087 {
00088 SInfo():
00089 id(UniSetTypes::DefaultObjectId),
00090 common_id(UniSetTypes::DefaultObjectId),
00091 iotype(UniversalIO::DigitalInput),
00092 value(0)
00093 {
00094 }
00095
00096 UniSetTypes::ObjectId id;
00097 UniSetTypes::ObjectId common_id;
00098 UniversalIO::IOTypes iotype;
00099 long value;
00100 };
00101
00102 typedef std::list<SInfo> SList;
00103
00104 struct Channel
00105 {
00106 Channel():
00107 respond_id(UniSetTypes::DefaultObjectId),
00108 respond_state(false),
00109 respond_invert(false),
00110 is_default(false),
00111 priority(65535),
00112 filter_field(""),
00113 filter_value(""),
00114 myname("")
00115 {}
00116
00117 SList slst;
00118 UniSetTypes::ObjectId respond_id;
00119 bool respond_state;
00120 bool respond_invert;
00121 bool is_default;
00122 int priority;
00123
00124 std::string filter_field;
00125 std::string filter_value;
00126 std::string myname;
00127
00129 void sensorInfo( UniversalInterface* ui, UniSetTypes::SensorMessage *sm );
00130
00132 void saveTo( UniversalInterface* ui, UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId);
00133
00134 void askSensors( UniversalInterface* ui, UniversalIO::UIOCommand cmd );
00135 void init( UniXML_iterator& it );
00136 void initValue( UniversalInterface* ui );
00137
00138
00139
00140 inline bool operator < ( const Channel& g ) const
00141 {
00142 return priority < g.priority;
00143 }
00144 };
00145
00146 friend std::ostream& operator<<(std::ostream& os, Channel& c );
00147 friend std::ostream& operator<<(std::ostream& os, Channel* c );
00148
00149 typedef std::list<Channel> ChannelList;
00150
00151 static DebugStream dlog;
00152 static void init_dlog( DebugStream& dlog );
00153
00154 protected:
00155 void init( xmlNode* cn );
00156 virtual void step(){}
00157
00158 ChannelList glst;
00159 ChannelList::iterator def_channel;
00160 ChannelList::iterator cur_channel;
00161 };
00162
00163 #endif