include/UNetExchange.h

00001 #ifndef UNetExchange_H_
00002 #define UNetExchange_H_
00003 // -----------------------------------------------------------------------------
00004 #include <ostream>
00005 #include <string>
00006 #include <queue>
00007 #include <cc++/socket.h>
00008 #include "UniSetObject_LT.h"
00009 #include "Trigger.h"
00010 #include "Mutex.h"
00011 #include "SMInterface.h"
00012 #include "SharedMemory.h"
00013 #include "ThreadCreator.h"
00014 #include "UNetReceiver.h"
00015 #include "UNetSender.h"
00016 // -----------------------------------------------------------------------------
00077 // -----------------------------------------------------------------------------
00078 class UNetExchange:
00079     public UniSetObject_LT
00080 {
00081     public:
00082         UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0 );
00083         virtual ~UNetExchange();
00084     
00086         static UNetExchange* init_unetexchange( int argc, const char* argv[],
00087                                             UniSetTypes::ObjectId shmID, SharedMemory* ic=0 );
00088 
00090         static void help_print( int argc, const char* argv[] );
00091 
00092         bool checkExistUNetHost( const std::string host, ost::tpport_t port );
00093 
00094     protected:
00095 
00096         xmlNode* cnode;
00097         std::string s_field;
00098         std::string s_fvalue;
00099 
00100         SMInterface* shm;
00101         void step();
00102 
00103         virtual void processingMessage( UniSetTypes::VoidMessage *msg );
00104         void sysCommand( UniSetTypes::SystemMessage *msg );
00105         void sensorInfo( UniSetTypes::SensorMessage*sm );
00106         void timerInfo( UniSetTypes::TimerMessage *tm );
00107         void askSensors( UniversalIO::UIOCommand cmd );
00108         void waitSMReady();
00109         void receiverEvent( UNetReceiver* r, UNetReceiver::Event ev );
00110 
00111         virtual bool activateObject();
00112         
00113         // действия при завершении работы
00114         virtual void sigterm( int signo );
00115 
00116         void initIterators();
00117         void startReceivers();
00118         
00119 
00120         enum Timer
00121         {
00122             tmStep
00123         };
00124 
00125     private:
00126         UNetExchange();
00127         bool initPause;
00128         UniSetTypes::uniset_mutex mutex_start;
00129 
00130         PassiveTimer ptHeartBeat;
00131         UniSetTypes::ObjectId sidHeartBeat;
00132         int maxHeartBeat;
00133         IOController::AIOStateList::iterator aitHeartBeat;
00134         UniSetTypes::ObjectId test_id;
00135 
00136         int steptime;   
00138         bool activated;
00139         int activateTimeout;
00140 
00141         struct ReceiverInfo
00142         {
00143             ReceiverInfo():r1(0),r2(0){}
00144             ReceiverInfo(UNetReceiver* _r1, UNetReceiver* _r2 ):r1(_r1),r2(_r2){}
00145             
00146             UNetReceiver* r1;   
00147             UNetReceiver* r2;   
00148         };
00149         
00150         typedef std::list<ReceiverInfo> ReceiverList;
00151         ReceiverList recvlist;
00152 
00153         bool no_sender;  
00154         UNetSender* sender;
00155         UNetSender* sender2;
00156 };
00157 // -----------------------------------------------------------------------------
00158 #endif // UNetExchange_H_
00159 // -----------------------------------------------------------------------------

Документация по UniSet. Последние изменения: Mon Dec 26 11:26:58 2011. Создано системой  doxygen 1.5.9