00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 #ifndef __JAUS_MOBILITY_VELOCITY_STATE_SENSOR__H 00042 #define __JAUS_MOBILITY_VELOCITY_STATE_SENSOR__H 00043 00044 #include "jaus/core/sensor.h" 00045 #include "jaus/mobility/sensors/queryvelocitystate.h" 00046 #include "jaus/mobility/sensors/reportvelocitystate.h" 00047 00048 namespace JAUS 00049 { 00050 typedef JAUS::ReportVelocityState VelocityState; 00051 00058 // The Velocity Sensor has the responsibility of reporting the instantaneous 00082 class JAUS_MOBILITY_DLL VelocityStateSensor : public Sensor, public Events::Child 00083 { 00084 public: 00085 const static std::string Name; 00086 VelocityStateSensor(const double updateRate = 10); 00087 virtual ~VelocityStateSensor(); 00088 // Sensors can always be discovered (overload if you don't want this). 00089 virtual bool IsDiscoverable() const { return true; } 00090 // Called by the platform to update this sensor. 00091 void SetVelocityState(const VelocityState& state); 00092 // Sets maximum sensor update rate. 00093 bool SetSensorUpdateRate(const double rate); 00095 double GetSensorUpdateRate() const { return mMaxUpdateRate; } 00096 // Gets the velocity state stored by the sensor. 00097 VelocityState GetVelocityState() const; 00098 // Method called when an Event has been signaled, generates an Event message. 00099 virtual bool GenerateEvent(const Events::Subscription& info) const; 00100 // Method called to determine if an Event is supported by the service. 00101 virtual bool IsEventSupported(const Events::Type type, 00102 const double requestedPeriodicRate, 00103 const Message* queryMessage, 00104 double& confirmedPeriodicRate, 00105 std::string& errorMessage) const; 00106 // Method called whenver a message is received. 00107 virtual void Receive(const Message* message); 00108 // Creates messages associated with this service. 00109 virtual Message* CreateMessage(const UShort messageCode) const; 00110 // Prints status to console. 00111 virtual void PrintStatus() const; 00112 private: 00113 virtual void CheckServiceSynchronization(const unsigned int timeSinceLastCheckMs); 00114 // Creates a ReportVelocityState from QueryVelocityState. 00115 void CreateReportFromQuery(const QueryVelocityState* query, ReportVelocityState& report) const; 00116 double mMaxUpdateRate; 00117 VelocityState mVelocityState; 00118 CxUtils::Mutex mVelocityStateMutex; 00119 }; 00120 } 00121 00122 #endif 00123 /* End of File */