LedNode.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_LedNode_h_
00003 #define INCLUDED_LedNode_h_
00004
00005 #include "MCNode.h"
00006 #include "Motion/LedMC.h"
00007
00008
00009
00010
00011 class LedNode : public MCNode<LedMC> {
00012 public:
00013
00014 LedNode() : MCNode<LedMC>(), lastAccess(0) {}
00015
00016
00017 LedNode(const std::string& nm) : MCNode<LedMC>(nm), lastAccess(0) {}
00018
00019 static std::string getClassDescription() { return "Displays a pattern on the LEDs for as long as the state is active"; }
00020 virtual std::string getDescription() const { return getClassDescription(); }
00021
00022 protected:
00023
00024 virtual SharedObject<LedMC>& getPrivateMC() {
00025 unsigned int curtime=get_time();
00026 bool isFirstCreation=(mc==NULL);
00027 SharedObject<LedMC>& lobj=MCNode<LedMC>::getPrivateMC();
00028 if(!isFirstCreation)
00029 lobj->extendFlash(curtime-lastAccess);
00030 lastAccess=curtime;
00031 return lobj;
00032 }
00033
00034 unsigned int lastAccess;
00035 };
00036
00037
00038 class LedActivate : public LedNode {
00039 public:
00040
00041 LedActivate(const std::string &nm, LEDBitMask_t mask) : LedNode(nm), theMask(mask) {
00042 SharedObject<LedMC>& lobj=getPrivateMC();
00043 lobj->setWeights(AllLEDMask,0);
00044 lobj->setWeights(theMask, 1);
00045 lobj->set(theMask, 1);
00046 }
00047
00048 virtual void stop() {
00049 LedNode::stop();
00050 SharedObject<LedMC> douser;
00051 douser->setWeights(AllLEDMask,0);
00052 douser->setWeights(theMask, 1);
00053 douser->set(theMask, 0);
00054 motman->addPrunableMotion(douser);
00055 }
00056
00057 protected:
00058 LEDBitMask_t theMask;
00059 };
00060
00061
00062
00063
00064
00065
00066
00067
00068 #endif