00001 #ifndef Switchboard_H_
00002 #define Switchboard_H_
00003
00004 #include <list>
00005 #include <TriggerOR.h>
00006 #include <UniXML.h>
00007 #include "Switchboard_SK.h"
00008
00027
00028 class Switchboard:
00029 public Switchboard_SK
00030 {
00031 public:
00032 Switchboard( const std::string& sname, xmlNode* confnode );
00033 ~Switchboard();
00034
00035 static DebugStream dlog;
00036 static void init_dlog( DebugStream& dlog );
00037
00038 protected:
00039 Switchboard();
00040
00041 virtual void step();
00042 virtual void sensorInfo( UniSetTypes::SensorMessage *sm );
00043 virtual void askSensors( UniversalIO::UIOCommand cmd );
00044 virtual void sigterm( int signo );
00045 void setOut( bool state );
00046
00047 typedef TriggerOR<Switchboard,UniSetTypes::ObjectId>::InputMap IMap;
00048
00049 typedef std::list<UniSetTypes::ObjectId> IDList;
00050
00051 struct UnionGroups
00052 {
00053 UnionGroups( Switchboard* im ):
00054 qgON(0),nopower_s(UniSetTypes::DefaultObjectId),gname("")
00055 {
00056 qgON = new TriggerOR<Switchboard,UniSetTypes::ObjectId>(im, &Switchboard::setOut);
00057 }
00058 ~UnionGroups()
00059 {
00060 delete qgON;
00061 }
00062
00063 TriggerOR<Switchboard,UniSetTypes::ObjectId>* qgON;
00064 IMap qglist;
00065 UniSetTypes::ObjectId nopower_s;
00066 std::string gname;
00067 };
00068
00069
00070
00071 struct StructureItem
00072 {
00073 StructureItem():
00074 gr(0),
00075 avt_s(UniSetTypes::DefaultObjectId),
00076 avt_state(false)
00077 {}
00078
00079 UnionGroups* gr;
00080 UniSetTypes::ObjectId avt_s;
00081 bool avt_state;
00082 };
00083
00084 typedef std::list<StructureItem> Structure;
00085
00086 void updateNoPower();
00087
00088 private:
00089
00090 IDList alist;
00091 Structure st;
00092
00093 UniSetTypes::ObjectId no_power_s;
00094
00095 };
00096
00097 #endif // Switchboard_H_
00098