00001 00030 #ifndef _VISIONCONTROL_H 00031 #define _VISIONCONTROL_H 00032 #include <WritableType.H> 00033 #include <Capability.H> 00034 #include <COMObject.H> 00035 #include <queue> 00036 #include <vector> 00037 00038 // $Id: Type.H 66 2007-01-23 20:53:23Z fwph $ 00039 00040 #define VISIONCONTROL "VisionControl" 00041 // IDNUMBER is used to identify data events . IDNUMBER+1 is the info event. this 00042 // system will probably go away soon... 00043 //#define VISIONCONTROLIDNUMBER 38 00044 00045 namespace WURDE { 00046 class Capability; 00047 class CommsManager; 00048 class Logger; 00049 00050 00051 class VisionOption { 00052 public: std::string value; 00053 std::string option; 00054 std::string module; 00055 }; 00056 class VisionOperatorSpec { 00057 public: std::string name; 00058 std::string type; 00059 }; 00060 00061 00062 class VisionControlInfoStruct { 00063 public: std::string source; 00064 std::string target; 00065 Writable< std::vector< VisionOption > > options; 00066 Time timestamp; 00067 Writable< bool > stopOperators; 00068 Writable< std::vector< VisionOperatorSpec > > visionOperators; 00069 MessageType mType; 00070 }; 00071 00072 00073 class VisionControlDataStruct { 00074 public: std::string source; 00075 Time timestamp; 00076 }; 00077 00083 class VisionControl : virtual public Capability { 00084 00085 public: 00091 explicit VisionControl(const std::string & streamname); 00092 00098 VisionControl(const ConnectionStrategy & strategy,const std::string & gblName); 00099 00105 VisionControl(const std::string & streamname,const std::string & gblName); 00106 00107 ~VisionControl(); 00108 00109 00113 void init(const std::string & streamname,const ConnectionStrategy & strategy, const std::string & gblName); 00114 00115 00120 VisionControlDataStruct data; 00121 00125 VisionControlInfoStruct info; 00126 00130 VisionControlInfoStruct requests; 00131 00132 //RobotObject imps 00133 void runUpdate(); 00134 void setManager(CommsManager *myManager_); 00135 void setCOMObject(COMBase *object){ myCOMObject = dynamic_cast<COMObject<VisionControlInfoStruct,VisionControlDataStruct> *> (object);} 00136 void disconnect(){if(myCOMObject){myCOMObject->disconnect();}} 00137 void activateSupplier(); 00138 void activateConsumer(); 00139 std::string getInterfaceName(){ return VISIONCONTROL;} 00140 void setStreamName(const std::string & name); 00141 void setGlobalName(const std::string & name); 00142 bool newData(); 00143 bool newInfo(); 00144 void setAutoPing(const bool & val); 00145 void doPing(); 00146 // int getID(){return VISIONCONTROLIDNUMBER;} 00147 00151 bool getQueueMode(){return m_queue;}; 00152 00156 void setQueueMode(const bool & val); 00157 00162 VisionControlDataStruct getNextData(); 00163 00168 VisionControlInfoStruct getNextInfo(); 00169 00173 VisionControlInfoStruct getNextRequest(){return getNextInfo();} 00174 00175 void publishData(); 00176 void publishInfo(); 00177 //void publishRequest(); 00178 00179 protected: 00180 COMObject<VisionControlInfoStruct, VisionControlDataStruct> *myCOMObject; 00181 00182 bool m_queue; 00183 00184 //notes that the object should be initialized as soon as a streamname is received 00185 bool m_initialize; 00186 std::queue<VisionControlDataStruct> m_dataVector; 00187 std::queue<VisionControlInfoStruct> m_infoVector; 00188 std::queue<VisionControlInfoStruct> m_requestVector; 00189 00190 }; 00191 00192 } 00193 00194 00195 #endif