Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

StateNode that executes a LedMC motion command and posts a status event upon completion. More...

#include <LedNode.h>

Inheritance diagram for LedNode:

Detailed Description

StateNode that executes a LedMC motion command and posts a status event upon completion.

Extends MCNode slightly so that each time the LedMC is accessed, any flash commands are reset. This allows a flash to be triggered each time the node starts

Definition at line 11 of file LedNode.h.

Public Member Functions

 LedNode ()
 default constructor, use type name as instance name More...
 
 LedNode (const std::string &nm)
 constructor, take an instance name More...
 
virtual std::string getDescription () const
 Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis) More...
 
- Public Member Functions inherited from MCNode< LedMC >
 MCNode ()
 default constructor More...
 
 MCNode (const std::string &nm)
 constructor, take an instance name More...
 
 MCNode (const char *nm)
 constructor, take an instance name More...
 
virtual ~MCNode ()
 destructor More...
 
virtual MMAccessor< LedMCgetMC ()
 reveal the MotionCommand through an MMAccessor More...
 
virtual void preStart ()
 Adds the motion command to the motion manager, but stops it from running until the user has a chance to program it. More...
 
virtual void postStart ()
 Adds a listener and then starts the motion command. More...
 
- Public Member Functions inherited from MCNodeBase
virtual ~MCNodeBase ()
 destructor, free mc More...
 
virtual void stop ()
 Removes the motion command from the motion manager if it was our own creation. More...
 
virtual void doEvent ()
 Assumes the event is a completion event from the motion, throws a corresponding state node completion event. More...
 
virtual void setMC (MotionManager::MC_ID mcid)
 Allows you to assign a previously created motion, which might be shared among several MCNodes. More...
 
virtual MotionManager::MC_ID getMC_ID ()
 reveal the MC_ID; if the motion isn't currently active, returns MotionManager::invalid_MC_ID More...
 
virtual float getPriority () const
 Return the priority assigned to this node's motion command. More...
 
virtual void setPriority (const float p)
 Set the priority that will be used when adding this motion command; if the command is already active, change its priority in the MotionManager. More...
 
virtual void motionFails ()
 Post a failure event and abort the motion command. More...
 
- Public Member Functions inherited from StateNode
 StateNode ()
 constructor, class name from typeid is used as instance name More...
 
 StateNode (const std::string &name)
 constructor, pass a name to use More...
 
virtual ~StateNode ()
 destructor, removes references to its outgoing transitions (be careful of incoming ones - they're still around!), and calls removeReference() on subnodes More...
 
virtual TransitionaddTransition (Transition *trans)
 Adds the specified StateTransition to the transition table. More...
 
std::vector< Transition * > & getTransitions ()
 Returns the std::vector of transitions so you can modify them yourself if need be. More...
 
const std::vector< Transition * > & getTransitions () const
 Returns the const std::vector of transitions so you can read through them if need be. More...
 
virtual StateNodeaddNode (StateNode *node)
 Adds a StateNode to nodes so it can be automatically dereferenced later, returns what it's passed (for convenience), calls addReference() on node. Also sets the node's parent to this if it is null. More...
 
template<class T >
T * addNode (T *node)
 Adds a StateNode to nodes so it can be automatically dereferenced later, returns what it's passed (for convenience), calls addReference() on node. Also sets the node's parent to this if it is null. More...
 
std::vector< StateNode * > & getNodes ()
 Returns the std::vector of sub-nodes so you can modify them yourself if need be. More...
 
const std::vector< StateNode * > & getNodes () const
 Returns the const std::vector of sub-nodes so you can read through them if need be. More...
 
void setRetain (bool f)
 Sets the retain flag - if not retained, will removeReference() subnodes upon stop() and recreate them on start (by calling setup()) - may be too expensive to be worth saving memory... More...
 
virtual void start ()
 Transitions should call this when entering the state, so it can enable its transitions. More...
 
virtual void setup ()
 This is called by start() when it should setup the network of subnodes (if any) More...
 
virtual void teardown ()
 This is called by stop() when you should destruct subnodes. More...
 
virtual StateNodegetParent () const
 returns pointer to parent as a generic StateNode More...
 
template<class T >
T * getAncestor () const
 returns a correctly typed pointer to ancestor of the specified type; user by $reference More...
 
template<class T >
T * parentAs () const
 returns correctly typed pointer to parent for access to its members More...
 
virtual StateNodegetChild (const std::string &name) const
 returns node with specified name that is a child of this node More...
 
virtual StateNodegetSibling (const std::string &name) const
 returns node with specified name that is a child of parent, or of parent's parent, etc. More...
 
virtual void setSpeechText (const std::string &text)
 Set text to speak on node start. More...
 
- Public Member Functions inherited from BehaviorBase
virtual ~BehaviorBase ()
 destructor - if is active when deleted, will display a warning (don't delete directly - use removeReference()) More...
 
virtual void processEvent (const EventBase &curEvent)
 Assigns curEvent to event and calls to doEvent() for user processing. More...
 
virtual std::string getName () const
 Identifies the behavior in menus and such. More...
 
virtual void setName (const std::string &name)
 Allows dynamic renaming of behaviors. More...
 
virtual std::string getClassName () const
 Returns the name of the class of this behavior (aka its type) using typeid and gcc's demangle. More...
 
virtual bool isActive () const
 Returns true if the behavior is currently running. More...
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter ()
 constructor More...
 
 ReferenceCounter (const ReferenceCounter &rc)
 copy constructor - uses autodelete setting of rc, but references will still start at 0 More...
 
ReferenceCounteroperator= (const ReferenceCounter &)
 assignment operator - does nothing because the reference count shouldn't be copied More...
 
virtual ~ReferenceCounter ()
 destructor - will std::cout a warning if still has references More...
 
virtual void addReference ()
 adds one to references More...
 
virtual bool removeReference ()
 subtracts one from references AND DELETES the object IF ZERO (and RC_autodelete is set) More...
 
virtual unsigned int getReferences () const
 returns the number of references More...
 
void setAutoDelete (bool b)
 if true, next time a removeReference() causes references to hit 0, the object will delete itself More...
 
bool getAutoDelete ()
 returns RC_autodelete More...
 
- Public Member Functions inherited from EventListener
virtual ~EventListener ()
 destructor More...
 

Static Public Member Functions

static std::string getClassDescription ()
 
- Static Public Member Functions inherited from MCNode< LedMC >
static std::string getClassDescription ()
 
- Static Public Member Functions inherited from MCNodeBase
static std::string getClassDescription ()
 
- Static Public Member Functions inherited from StateNode
template<typename T >
static const T extractSignal (const EventBase *ev)
 Extract data from a signal sent to this state via Transition::fire(const EventBase&) More...
 
template<typename T >
static const T * tryExtractSignal (const EventBase *ev)
 Try to extract data from a signal sent to this state via Transition::fire(const EventBase&) More...
 
- Static Public Member Functions inherited from BehaviorBase
static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to) More...
 
static const std::set
< BehaviorBase * > & 
getRegistry ()
 This read-only set allows us list all the currently instantiated behaviors. More...
 
template<class T >
static BehaviorSwitchControlBaseregisterControllerEntry (const std::string &name, const std::string &menu, int flags=BEH_DEFAULTS)
 Registers a behavior class to be added to the specified Controller menu, use '/' to specify sub-menus, see REGISTER_BEHAVIOR macro. More...
 
static std::string humanifyClassName (const std::string &name)
 A simple utility call for REGISTER_BEHAVIOR and friends to remove trailing "Behavior" suffix from display names and fix CamelCase. Disabled because it interferes with the Storyboard and other components; should be re-implemented inside ControllerGUI. More...
 

Protected Member Functions

virtual SharedObject< LedMC > & getPrivateMC ()
 extends MCNode implementation so that each time the LedMC is accessed, any flash commands are reset. More...
 
- Protected Member Functions inherited from MCNode< LedMC >
 MCNode (bool subCompletes)
 
 MCNode (const std::string &nm, bool subCompletes)
 constructor, take an instance name More...
 
- Protected Member Functions inherited from MCNodeBase
 MCNodeBase (bool expectCompletion)
 constructor for subclasses More...
 
 MCNodeBase (const std::string &node_name, bool expectCompletion=true)
 constructor for subclasses which provide instance name More...
 
virtual bool hasPrivateMC ()
 returns true if the motion command being used was created internally via getPrivateMC() More...
 
- Protected Member Functions inherited from StateNode
virtual void postStateStart ()
 will post an activation event through stateMachineEGID, used when doStart() is called More...
 
virtual void postStateStop ()
 will post an deactivation event through stateMachineEGID, used when doStop() is called More...
 
virtual void postStateCompletion (float magnitude=0)
 will post a status event through stateMachineEGID to signal "completion" of the node More...
 
virtual void postStateFailure ()
 posts a DataEvent<SuccessOrFailure>(failure) indicating failure of the node; meaning of failure is used-defined More...
 
virtual void postStateSuccess ()
 posts a DataEvent<SuccessOrFailure>(success) indicating success of the node; meaning of success is used-defined More...
 
virtual void postParentCompletion ()
 Causes the parent state machine to complete; use this to return from a nested state machine. More...
 
virtual void postParentFailure ()
 Causes the parent state machine to fail; use this to return failure from a nested state machine. More...
 
virtual void postParentSuccess ()
 Causes the parent state machine to succeed; use this to return success from a nested state machine. More...
 
template<typename T >
void postParentSignal (const T &value=T())
 Causes the parent state machine to post a DataEvent through stateSignalEGID. value is optional. More...
 
template<typename T >
void postStateSignal (const T &value=T())
 Posts a DataEvent through stateSignalEGID that can be picked up by a SignalTrans. value is optional. More...
 
- Protected Member Functions inherited from BehaviorBase
virtual void doStart ()
 Delegate function for subclasses to be notified when the behavior starts up. More...
 
virtual void doStop ()
 Delegate function for subclasses to be notified when the behavior starts up. More...
 
virtual MC_ID addMotion (const SharedObjectBase &mc, Prunability_t prune=PERSISTENT)
 Registers the MotionCommand (contained within a shared memory region) with the MotionManager, and allows the behavior to track active motions so they can be automatically removed on stop() More...
 
virtual MC_ID addMotion (const SharedObjectBase &mc, Prunability_t prune, float priority)
 Registers the MotionCommand (contained within a shared memory region) with the MotionManager, and allows the behavior to track active motions so they can be automatically removed on stop() More...
 
virtual void removeMotion (MC_ID mcid)
 Removes the motion from the MotionManager. More...
 
template<template< typename T > class M, class T >
void removeMotion (const M< T > &mc)
 forwarding function so you can pass SharedObject<T> or MotionPtr<T> directly; extracts the MC_ID and passes to the other removeMotion More...
 
 BehaviorBase ()
 constructor, will use getClassName() as the instance name More...
 
 BehaviorBase (const std::string &name)
 constructor, name is used as both instance name and class name More...
 
 BehaviorBase (const BehaviorBase &b)
 copy constructor; assumes subclass handles copying approriately - i.e. if b is active, the copy will be as well, even though doStart was never called.. More...
 
BehaviorBaseoperator= (const BehaviorBase &b)
 assignment operator; assumes subclass handles assignment appropriately - i.e. if b is active, the copy will be as well, even though doStart was never called.. More...
 

Protected Attributes

unsigned int lastAccess
 stores time of last call to getPrivateMC() for resetting flash commands More...
 
- Protected Attributes inherited from MCNodeBase
SharedObjectBasemc
 MotionCommand used by this node (may be NULL if sharing the MC with other nodes) More...
 
MotionManager::MC_ID mc_id
 id number for the MotionCommand More...
 
float priority
 Priority to use when adding this motion commmand to the MotionManager. More...
 
bool mcCompletes
 if true, will post a completion when the underlying MotionCommand posts a status More...
 
- Protected Attributes inherited from StateNode
StateNodeparent
 pointer to the machine that contains this node More...
 
std::vector< Transition * > transitions
 a vector of outgoing transitions More...
 
bool issetup
 this is set to true if the network has been setup but not destroyed (i.e. don't need to call setupSubNodes again) More...
 
bool retain
 this is set to true if the network should be retained between activations. Otherwise it's dereferenced upon doStop(). (or at least removeReference() is called on subnodes) More...
 
unsigned int startedTime
 the timestamp of last call to start() More...
 
std::vector< StateNode * > nodes
 vector of StateNodes, just so they can be dereferenced again on doStop() (unless retained) or ~StateNode() More...
 
StateNodestartnode
 starting node (should be a member of nodes) More...
 
std::string speechText
 Text to speak on node start (for debugging) More...
 
- Protected Attributes inherited from BehaviorBase
std::map< MC_ID, MonitorMotionautoMotions
 A list of active motions registered with this behavior to be removed when the behavior stops. More...
 
bool started
 true when the behavior is active More...
 
std::string instanceName
 holds the name of this instance of behavior, if empty then getName() forwards to getClassName() More...
 
const EventBaseevent
 the event, received by processEvent, stored for duration of call to doEvent() (also doStart() in the case of a StateNode receiving a transition), NULL at all other times More...
 
- Protected Attributes inherited from ReferenceCounter
unsigned int references
 the current number of references More...
 
bool RC_autodelete
 if false, prevents deletion when counter hits 0 (needed in case of stack allocation or if the subclass is a direct member variable of another class) More...
 

Additional Inherited Members

- Public Types inherited from StateNode
enum  SuccessOrFailure { failureSignal =0, successSignal =1 }
 Values used in a SignalTrans for postStateSuccess and postStateFailure. More...
 
- Static Public Attributes inherited from MCNodeBase
static const char defName [] ="MCNode"
 the default name for MCNodes – can be overridden via MCNode's template arguments More...
 
static const char defDesc [] ="A generic wrapper for any MotionCommand"
 the default description for MCNodes – can be overridden via MCNode's template arguments More...
 
- Protected Types inherited from BehaviorBase
enum  Prunability_t { PERSISTENT, PRUNABLE }
 Specifies parameters for addMotion() More...
 
typedef MotionManagerMsg::MC_ID MC_ID
 Typically would use MotionManager::MC_ID, but re-specified here for convenience and to avoid dependence on MotionManager.h. More...
 
- Static Protected Member Functions inherited from BehaviorBase
static std::set< BehaviorBase * > & getRegistryInstance ()
 static function to provide well-defined initialization order More...
 
- Static Protected Attributes inherited from BehaviorBase
static const MC_ID invalid_MC_ID =MotionManagerMsg::invalid_MC_ID
 Typically would use MotionManager::invalid_MC_ID, but re-specified here for convenience and to avoid dependence on MotionManager.h. More...
 

Constructor & Destructor Documentation

LedNode::LedNode ( )

default constructor, use type name as instance name

Definition at line 14 of file LedNode.h.

LedNode::LedNode ( const std::string &  nm)

constructor, take an instance name

Definition at line 17 of file LedNode.h.

Member Function Documentation

static std::string LedNode::getClassDescription ( )
static

Definition at line 19 of file LedNode.h.

Referenced by getDescription().

virtual std::string LedNode::getDescription ( ) const
virtual

Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis)

By default simply returns getName(), because any calls from a BehaviorBase function to getClassDescription() are going to call BehaviorBase::getClassDescription(), not ~YourSubClass~::getClassDescription(), because static functions can't be virtual in C++ (doh!)

This means that getDescription called on a pointer to a BehaviorBase of unknown subtype would always return an empty string, which is pretty useless. So instead we return the name in this situation. If you want getDescription to return getClassDescription, you'll have to override it in your subclass to do so.

Reimplemented from MCNode< LedMC >.

Definition at line 20 of file LedNode.h.

virtual SharedObject<LedMC>& LedNode::getPrivateMC ( )
protectedvirtual

extends MCNode implementation so that each time the LedMC is accessed, any flash commands are reset.

Reimplemented from MCNode< LedMC >.

Definition at line 24 of file LedNode.h.

Referenced by LedActivate::LedActivate().

Member Data Documentation

unsigned int LedNode::lastAccess
protected

stores time of last call to getPrivateMC() for resetting flash commands

Definition at line 34 of file LedNode.h.

Referenced by getPrivateMC().


The documentation for this class was generated from the following file:

Tekkotsu v5.1CVS
Generated Thu Jul 21 2016 22:26:11 by Doxygen 1.8.6