/home/fwph/code/wurde/rde/core/capabilities/Power.H

Go to the documentation of this file.
00001 
00030 #ifndef _POWER_H
00031 #define _POWER_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 POWER "Power"
00041 // IDNUMBER is used to identify data events . IDNUMBER+1 is the info event. this
00042 // system will probably go away soon...
00043 //#define POWERIDNUMBER 26
00044 
00045 namespace WURDE {
00046         class Capability;
00047         class CommsManager;
00048         class Logger;
00049 
00050         
00051 
00052         
00053         class PowerInfoStruct {
00054         public:         std::string source;
00055                 std::string target;
00056                 Time timestamp;
00057                 MessageType mType;
00058         };
00059 
00060         
00061         class PowerDataStruct {
00062         public:         std::string source;
00063                 float min_volts;
00064                 float max_volts;
00065                 float volts;
00066                 Time timestamp;
00067                 bool ac_online;
00068         };
00069   
00075         class Power : virtual public Capability {
00076 
00077         public:
00083                explicit Power(const std::string & streamname);         
00084 
00090                Power(const ConnectionStrategy & strategy,const std::string & gblName);
00091 
00097                Power(const std::string & streamname,const std::string & gblName);
00098                
00099                ~Power();
00100 
00101 
00105                void init(const std::string & streamname,const ConnectionStrategy & strategy, const std::string & gblName);
00106 
00107                
00112                PowerDataStruct data;    
00113                
00117                PowerInfoStruct info;
00118                
00122                PowerInfoStruct requests;
00123                
00124                //RobotObject imps
00125                void runUpdate();
00126                void setManager(CommsManager *myManager_);
00127                void setCOMObject(COMBase *object){ myCOMObject = dynamic_cast<COMObject<PowerInfoStruct,PowerDataStruct> *> (object);}
00128                void disconnect(){if(myCOMObject){myCOMObject->disconnect();}}
00129                void activateSupplier();
00130                void activateConsumer();
00131                std::string getInterfaceName(){ return POWER;}
00132                void setStreamName(const std::string & name);
00133                void setGlobalName(const std::string & name);
00134                bool newData();
00135                bool newInfo();
00136                void setAutoPing(const bool & val);
00137                void doPing();
00138                //              int getID(){return POWERIDNUMBER;}
00139 
00143                bool getQueueMode(){return m_queue;};
00144 
00148                void setQueueMode(const bool & val);
00149                
00154                PowerDataStruct getNextData();
00155                
00160                PowerInfoStruct getNextInfo();
00161 
00165                PowerInfoStruct getNextRequest(){return getNextInfo();}
00166 
00167                void publishData();
00168                void publishInfo();
00169                //void publishRequest();
00170                
00171         protected:
00172                COMObject<PowerInfoStruct, PowerDataStruct> *myCOMObject;
00173 
00174                bool m_queue;
00175 
00176                //notes that the object should be initialized as soon as a streamname is received
00177                bool m_initialize;
00178                std::queue<PowerDataStruct> m_dataVector;
00179                std::queue<PowerInfoStruct> m_infoVector;
00180                std::queue<PowerInfoStruct> m_requestVector;
00181         
00182         };
00183 
00184 }
00185 
00186 
00187 #endif

Generated on Thu Feb 1 15:31:53 2007 for WURDE by  doxygen 1.5.1