00001
00002 #ifndef INCLUDED_LedNode_h_
00003 #define INCLUDED_LedNode_h_
00004
00005 #include "Behaviors/StateNode.h"
00006 #include "Events/EventRouter.h"
00007 #include "Motion/LedMC.h"
00008
00009
00010 class LedNode : public StateNode {
00011 protected:
00012 SharedObject<LedMC> leds_mc;
00013 MotionManager::MC_ID leds_id;
00014
00015 public:
00016
00017 LedNode(std::string nodename="LedNode") :
00018 StateNode("LedNode",nodename), leds_mc(), leds_id(MotionManager::invalid_MC_ID) {}
00019
00020
00021 virtual void DoStart() {
00022 leds_id = motman->addPersistentMotion(leds_mc);
00023 erouter->addListener(this,EventBase::motmanEGID,leds_id,EventBase::statusETID);
00024 StateNode::DoStart();
00025 }
00026
00027
00028 virtual void DoStop() {
00029 motman->removeMotion(leds_id);
00030 leds_id = MotionManager::invalid_MC_ID;
00031 erouter->removeListener(this);
00032 StateNode::DoStop();
00033 }
00034
00035
00036 virtual void processEvent(const EventBase&) {
00037 erouter->postEvent(EventBase::stateMachineEGID,reinterpret_cast<unsigned int>(this),EventBase::statusETID,0,getName(),1);
00038 }
00039
00040
00041 SharedObject<LedMC>& getMC() { return leds_mc; }
00042
00043
00044 MotionManager::MC_ID& getMC_ID() { return leds_id; }
00045
00046 protected:
00047
00048 LedNode(std::string &classname, std::string &nodename) :
00049 StateNode(classname,nodename), leds_mc(), leds_id(MotionManager::invalid_MC_ID) {}
00050
00051
00052 };
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #endif