include/UniExchange.h
00001
00002 #ifndef UniExchange_H_
00003 #define UniExchange_H_
00004
00005 #include <list>
00006 #include "UniXML.h"
00007 #include "IOController.h"
00008 #include "SMInterface.h"
00009 #include "SharedMemory.h"
00010 #include "PassiveTimer.h"
00011
00034
00035 class UniExchange:
00036 public IOController
00037 {
00038 public:
00039 UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID,
00040 SharedMemory* ic=0, const std::string prefix="unet" );
00041 virtual ~UniExchange();
00042
00043 void execute();
00044
00045 static UniExchange* init_exchange( int argc, const char* const* argv,
00046 UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
00047 const std::string prefix="unet" );
00048
00050 static void help_print( int argc, const char** argv );
00051
00052 virtual IOController_i::ShortMapSeq* getSensors();
00053
00054 protected:
00055
00056 virtual void processingMessage( UniSetTypes::VoidMessage* msg );
00057 virtual void sysCommand( UniSetTypes::SystemMessage* sm );
00058 virtual void askSensors( UniversalIO::UIOCommand cmd );
00059 virtual void sensorInfo( UniSetTypes::SensorMessage* sm );
00060 virtual void timerInfo( UniSetTypes::TimerMessage* tm );
00061 virtual void sigterm( int signo );
00062
00063 xmlNode* cnode;
00064 std::string s_field;
00065 std::string s_fvalue;
00066 SMInterface* shm;
00067
00068 struct SInfo
00069 {
00070 SInfo():
00071 val(0),
00072 id(UniSetTypes::DefaultObjectId),
00073 type(UniversalIO::UnknownIOType)
00074 {}
00075
00076 IOController::DIOStateList::iterator dit;
00077 IOController::AIOStateList::iterator ait;
00078 long val;
00079 long id;
00080 UniversalIO::IOTypes type;
00081 UniSetTypes::uniset_spin_mutex val_lock;
00082 };
00083
00084 typedef std::vector<SInfo> SList;
00085
00086 struct NetNodeInfo
00087 {
00088 NetNodeInfo();
00089
00090 CORBA::Object_var oref;
00091 IOController_i_var shm;
00092 UniSetTypes::ObjectId id;
00093 UniSetTypes::ObjectId node;
00094 UniSetTypes::ObjectId sidConnection;
00095 IOController::DIOStateList::iterator conn_dit;
00096 SList smap;
00097
00098 void update(IOController_i::ShortMapSeq_var& map, SMInterface* shm );
00099 };
00100
00101 typedef std::list<NetNodeInfo> NetNodeList;
00102 NetNodeList nlst;
00103
00104 void readConfiguration();
00105 bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec );
00106 bool initItem( UniXML_iterator& it );
00107 void updateLocalData();
00108 void initIterators();
00109
00110 int polltime;
00111 PassiveTimer ptUpdate;
00112 bool init_ok;
00113
00114 SList mymap;
00115 size_t maxIndex;
00116 int smReadyTimeout;
00117
00118 private:
00119 };
00120
00121 #endif // UniExchange_H_