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 #ifndef __JAUS_EXTRAS_SUBSYSTEM_COMMAND__H 00041 #define __JAUS_EXTRAS_SUBSYSTEM_COMMAND__H 00042 00043 00044 #include "jaus/extras/jausextrasdll.h" 00045 #include "jaus/core/management/management.h" 00046 #include "jaus/core/discovery/vehicle.h" 00047 00048 namespace JAUS 00049 { 00062 class JAUS_EXTRAS_DLL SubsystemCommand : public Management::Child, 00063 public Discovery::Callback 00064 { 00065 public: 00066 const static std::string Name; 00067 SubsystemCommand(const Service::ID& id); 00068 virtual ~SubsystemCommand(); 00069 // Called upon initialization (if overloaded, call parent method). 00070 virtual void Initialize(); 00071 // Sets the type of global pose subscriptions to make. 00072 void SetGlobalPoseSubscriptionType(const bool everyChange = false, 00073 const double desiredPeriodicRateHz = 25); 00074 // Method called when transitioning to a ready state (overload to add behavior). 00075 virtual bool Resume() { return true; }; 00076 // Method called to transition due to reset (overload to add behavior). 00077 virtual bool Reset() { return true; }; 00078 // Method called when transitioning to a standby state (overload to add behavior). 00079 virtual bool Standby() { return true; }; 00080 // Method called when transitioning to an emergency state (overload to add behavior). 00081 virtual bool SetEmergency() { return true; }; 00082 // Method called when leaving the emergency state (overload to add behavior). 00083 virtual bool ClearEmergency() { return true; }; 00084 // Method called when control is released (overload to add behavior). 00085 virtual bool ReleaseControl() { return true; }; 00086 // Gets the Discovery service. 00087 const Discovery* DiscoveryService() const; 00088 // Gets the Discovery service. 00089 Discovery* DiscoveryService(); 00090 // Gets the Discovery service. 00091 const AccessControl* AccessControlService() const; 00092 // Gets the Discovery service. 00093 AccessControl* AccessControlService(); 00094 // Sends a command to a component by taking control (if not established) first. 00095 virtual bool SendCommand(const Message* commandMessage, 00096 const bool sendResumeFlag, 00097 const unsigned int waitTimeMs = Service::DefaultWaitMs); 00098 // Method called whenever this service acquires control of a component. 00099 virtual void ProcessAcquisitionOfControl(const Address& controlledComponent) {} 00100 // This is not a discoverable service at this time. 00101 virtual bool IsDiscoverable() const { return false; } 00102 // Method called when an Event has been signaled, generates an Event message. 00103 virtual bool GenerateEvent(const Events::Subscription& info) const { return false; } 00104 // Method called to determine if an Event is supported by the service. 00105 virtual bool IsEventSupported(const Events::Type type, 00106 const double requestedPeriodicRate, 00107 const Message* queryMessage, 00108 double& confirmedPeriodicRate, 00109 std::string& errorMessage) const { return false; } 00110 // Receives global pose data and updates status of subsystems in Discovery Service. 00111 virtual void Receive(const Message* message); 00112 // Creates messages supported by the Service. 00113 virtual Message* CreateMessage(const UShort messageCode) const; 00114 // When called, checks to see if new subscriptions need to be made. 00115 virtual void CheckServiceStatus(const unsigned int timeSinceLastCheckMs); 00116 // Prints information about the service. 00117 virtual void PrintStatus() const; 00118 protected: 00119 bool mOnChangeEventsFlag; 00120 double mDesiredPeriodicRateHz; 00121 private: 00129 class GlobalPoseCallback : public Transport::Callback 00130 { 00131 public: 00132 GlobalPoseCallback() { mpComponent = NULL; } 00133 ~GlobalPoseCallback() {} 00134 virtual void ProcessMessage(const Message* message); 00135 Component* mpComponent; 00136 }; 00137 virtual void ProcessSystemState(const Subsystem::Map& system); 00138 GlobalPoseCallback* mpGlobalPoseCallback; 00139 }; 00140 } 00141 00142 #endif 00143 /* End of File */