00001 /* 00002 * File: GyrosMoosCommsInterface.h 00003 * Author: tomi 00004 * 00005 * Created on February 14, 2011, 3:35 PM 00006 */ 00007 00008 #ifndef _GYROSMOOSCOMMSINTERFACE_H 00009 #define _GYROSMOOSCOMMSINTERFACE_H 00010 00011 #include <MOOSLIB/MOOSApp.h> 00012 #include <GyrosCommsInterface.hpp> 00013 #include <boost/thread.hpp> 00014 #include <boost/bind.hpp> 00015 #include <boost/thread/mutex.hpp> 00016 #include "MoosConfig.hpp" 00017 00018 00019 namespace LABUST 00020 { 00021 namespace COMMUNICATION 00022 { 00023 00024 class GyrosMoosCommsInterface : public GyrosCommsInterface, CMOOSApp 00025 { 00026 public: 00034 GyrosMoosCommsInterface(const labust::xml::Reader &reader, std::string configToUse = ""); 00035 00043 GyrosMoosCommsInterface(const std::string& configPath, std::string configToUse = ""); 00044 00045 virtual ~GyrosMoosCommsInterface(); 00046 00058 COMMERRORS::CommError Send(const labust::xml::GyrosWriter &data, bool wait = false); 00059 00071 COMMERRORS::CommError Send(const std::vector<labust::xml::GyrosWriter> &data, bool wait = false); 00072 00085 COMMERRORS::CommError Receive(std::vector<labust::xml::GyrosReader> &data, bool wait = false); 00086 00092 const void* GetCommObject(void); 00093 00100 virtual void RegisterCallbackObject(CommEntity *entity); 00101 00105 virtual void UnRegisterCallbackObject(); 00106 00111 bool OnNewMail(MOOSMSG_LIST &NewMail); 00112 bool Iterate(); 00113 00114 bool OnConnectToServer(); 00115 bool OnStartUp(); 00116 bool OnDisconnectFromServer(); 00117 00118 private: 00119 GyrosMoosCommsInterface(const GyrosMoosCommsInterface& orig); 00120 GyrosMoosCommsInterface & operator =(const GyrosMoosCommsInterface &); 00121 00122 MoosConfig config; 00123 std::vector<labust::xml::GyrosWriter> messagesToSend; 00124 std::vector<labust::xml::GyrosReader> messagesReceived; 00125 00126 boost::thread commsThread; 00127 boost::condition_variable dataSentSignal, dataReceivedSignal; 00128 boost::mutex locker; 00129 }; 00130 } 00131 } 00132 #endif /* _GYROSMOOSCOMMSINTERFACE_H */ 00133