CCA
|
Base CCA Data-Flow Component. More...
#include <Component.h>
Public Member Functions | |
Component (const std::string &name, ComponentStatePtr initialState=ComponentState::EXECUTION()) | |
Constructor. | |
virtual | ~Component () |
virtual bool | requestTransition (const ComponentStatePtr &state) |
Make a transition in the component`s life-cycle. | |
virtual void | configureStateInputPort (PortConfigurationPtr portcfg) |
Configure state change input port. | |
virtual void | configureBeatInputPort (PortConfigurationPtr portcfg) |
Configure beat input port. | |
virtual void | configureStateOutputPort (PortConfigurationPtr portcfg) |
Configure component state output port. | |
virtual void | publishState () |
Publish the components state over it`s configured state output port. | |
virtual void | process () |
If processing is triggered. | |
virtual void | onProcess () |
This is the user-defined main execution method of the component. | |
virtual void | onStartExecution () |
Called once when component transitions to execution state. | |
virtual void | onStopExecution () |
Called once when component leaves execution state. | |
virtual void | onLearnOffline () |
This is the user-defined method for an off-line learning step. | |
virtual void | onStartLearnOffline () |
Called once when component transitions to off-line learning state. | |
virtual void | onStopLearnOffline () |
Called once when component leaves off-line learning state. | |
virtual void | onLearnOnlineBeforeProcess () |
During online learning, this method is called before each execution step. | |
virtual void | onStartLearnOnline () |
Called once when component transitions to online learning state. | |
virtual void | onStopLearnOnline () |
Called once when component leaves online learning state. | |
virtual void | onLearnOnlineAfterProcess () |
During online learning, this method is called after each execution step. | |
virtual std::string | print () const |
Printing information about this component. | |
Protected Member Functions | |
void | createBeatInputPort () |
void | createStateInputPort () |
void | createStateOutputPort () |
void | beatCallback (rsb::EventPtr) |
void | stateCallback (rsb::EventPtr) |
Protected Attributes | |
ComponentStatePtr | state |
ComponentState. | |
InputPort< cca::timing::Tick >::Ptr | inputBeat |
Input port for a beat. | |
InputPort< ComponentState >::Ptr | inputState |
Input port for state change requests. | |
OutputPort< ComponentState >::Ptr | outputState |
Output port for component state. | |
cca::timing::TickPtr | lastTick |
Virtual time support. | |
boost::uint64_t | circuitTime |
boost::uint64_t | circuitVirtualTime |
boost::uint64_t | circuitLastTimestep |
boost::uint64_t | circuitLastVirtualTimestep |
boost::uint64_t | circuitSequence |
Private Member Functions | |
Component (Component &node) | |
Copy constructor private for now to disallow copying. | |
void | operator= (const Component &) |
Copy operator private for now to disallow copying. | |
std::string | scopeName () |
Method to render a valid scope string from component name. | |
Private Attributes | |
std::string | scopename |
rsc::logging::LoggerPtr | logger |
Component logger. | |
ComponentStatePtr | initialState |
Initial State. |
Detailed Description
Base CCA Data-Flow Component.
Definition at line 42 of file Component.h.
Constructor & Destructor Documentation
cca::Component::Component | ( | const std::string & | name, |
ComponentStatePtr | initialState = ComponentState::EXECUTION() |
||
) |
Constructor.
- Parameters:
-
name Name of this Node initialState Initial life-cycle state of the component
Definition at line 56 of file Component.cpp.
References createBeatInputPort(), createStateInputPort(), createStateOutputPort(), cca::Node::getName(), and logger.
cca::Component::~Component | ( | ) | [virtual] |
Definition at line 88 of file Component.cpp.
References onStopExecution(), onStopLearnOffline(), onStopLearnOnline(), publishState(), state, cca::ComponentState::STATE_EXEC, cca::ComponentState::STATE_ONLLEARN, cca::Node::stop(), and cca::ComponentState::STOPPED().
cca::Component::Component | ( | Component & | node | ) | [private] |
Copy constructor private for now to disallow copying.
Member Function Documentation
void cca::Component::beatCallback | ( | rsb::EventPtr | ) | [protected] |
Definition at line 224 of file Component.cpp.
References circuitLastTimestep, circuitLastVirtualTimestep, circuitSequence, circuitTime, circuitVirtualTime, cca::InputPort< DATATYPE >::get(), cca::Node::getName(), inputBeat, cca::Node::isConfigured(), lastTick, logger, and cca::Node::tick().
Referenced by createBeatInputPort().
void cca::Component::configureBeatInputPort | ( | PortConfigurationPtr | portcfg | ) | [virtual] |
Configure beat input port.
- Parameters:
-
portcfg PortConfiguration type, either PortConfiguration::LOCAL() or PortConfiguration::REMOTE(), default is the local port.
Definition at line 406 of file Component.cpp.
References cca::Port::configure(), cca::Node::getName(), inputBeat, and logger.
Referenced by createBeatInputPort().
void cca::Component::configureStateInputPort | ( | PortConfigurationPtr | portcfg | ) | [virtual] |
Configure state change input port.
- Parameters:
-
portcfg PortConfiguration type, either PortConfiguration::LOCAL() or PortConfiguration::REMOTE(), default is the local port.
Definition at line 450 of file Component.cpp.
References cca::Port::configure(), cca::Node::getName(), inputState, and logger.
Referenced by createStateInputPort().
void cca::Component::configureStateOutputPort | ( | PortConfigurationPtr | portcfg | ) | [virtual] |
Configure component state output port.
- Parameters:
-
portcfg PortConfiguration type, either PortConfiguration::LOCAL() or PortConfiguration::REMOTE(), default is the local port.
Definition at line 490 of file Component.cpp.
References cca::Port::configure(), cca::Node::getName(), logger, and outputState.
Referenced by createStateOutputPort().
void cca::Component::createBeatInputPort | ( | ) | [protected] |
Definition at line 368 of file Component.cpp.
References beatCallback(), configureBeatInputPort(), cca::Node::create(), cca::Node::getName(), inputBeat, cca::PortConfiguration::LOCAL(), cca::PortConfiguration::LOCALREMOTE(), logger, cca::PortConfiguration::REMOTE(), and cca::InputPortBase::setHandler().
Referenced by Component().
void cca::Component::createStateInputPort | ( | ) | [protected] |
Definition at line 412 of file Component.cpp.
References configureStateInputPort(), cca::Node::create(), cca::Node::getName(), inputState, cca::PortConfiguration::LOCAL(), cca::PortConfiguration::LOCALREMOTE(), logger, cca::PortConfiguration::REMOTE(), scopeName(), scopename, cca::InputPortBase::setHandler(), and stateCallback().
Referenced by Component().
void cca::Component::createStateOutputPort | ( | ) | [protected] |
Definition at line 455 of file Component.cpp.
References configureStateOutputPort(), cca::Node::create(), cca::Node::getName(), cca::PortConfiguration::LOCAL(), cca::PortConfiguration::LOCALREMOTE(), logger, outputState, cca::PortConfiguration::REMOTE(), scopeName(), and scopename.
Referenced by Component().
void cca::Component::onLearnOffline | ( | ) | [virtual] |
This is the user-defined method for an off-line learning step.
This method will usually compute on a batch of data and can last a bit longer.
Definition at line 106 of file Component.cpp.
References cca::Node::getName(), and logger.
Referenced by process().
void cca::Component::onLearnOnlineAfterProcess | ( | ) | [virtual] |
During online learning, this method is called after each execution step.
Definition at line 117 of file Component.cpp.
References cca::Node::getName(), and logger.
Referenced by process().
void cca::Component::onLearnOnlineBeforeProcess | ( | ) | [virtual] |
During online learning, this method is called before each execution step.
Try to do the heavier computation of the online learning step *after* the execution step, see onLearnOnlineAfterProcess.
Definition at line 111 of file Component.cpp.
References cca::Node::getName(), and logger.
Referenced by process().
void cca::Component::onProcess | ( | ) | [virtual] |
This is the user-defined main execution method of the component.
Every time called, when the defined ProcessingStrategy triggers.
Implements cca::Node.
Definition at line 101 of file Component.cpp.
References cca::Node::getName(), and logger.
void cca::Component::onStartExecution | ( | ) | [virtual] |
Called once when component transitions to execution state.
Definition at line 509 of file Component.cpp.
Referenced by requestTransition().
void cca::Component::onStartLearnOffline | ( | ) | [virtual] |
Called once when component transitions to off-line learning state.
Definition at line 515 of file Component.cpp.
Referenced by requestTransition().
void cca::Component::onStartLearnOnline | ( | ) | [virtual] |
Called once when component transitions to online learning state.
Definition at line 521 of file Component.cpp.
Referenced by requestTransition().
void cca::Component::onStopExecution | ( | ) | [virtual] |
Called once when component leaves execution state.
Definition at line 512 of file Component.cpp.
Referenced by requestTransition(), and ~Component().
void cca::Component::onStopLearnOffline | ( | ) | [virtual] |
Called once when component leaves off-line learning state.
Definition at line 518 of file Component.cpp.
Referenced by requestTransition(), and ~Component().
void cca::Component::onStopLearnOnline | ( | ) | [virtual] |
Called once when component leaves online learning state.
Definition at line 524 of file Component.cpp.
Referenced by requestTransition(), and ~Component().
void cca::Component::operator= | ( | const Component & | ) | [private] |
Copy operator private for now to disallow copying.
std::string cca::Component::print | ( | ) | const [virtual] |
Printing information about this component.
Reimplemented from cca::Node.
Definition at line 357 of file Component.cpp.
References cca::Node::defaultProperties, cca::Node::getName(), cca::Node::getProcessingStrategy(), inputBeat, cca::Node::inputPorts, inputState, cca::Node::outputPorts, outputState, cca::Node::properties, and state.
Referenced by process().
void cca::Component::process | ( | ) | [virtual] |
If processing is triggered.
Reimplemented from cca::Node.
Definition at line 269 of file Component.cpp.
References cca::Node::getName(), cca::Node::getProcessingStrategy(), cca::Node::isConfigured(), logger, onLearnOffline(), onLearnOnlineAfterProcess(), onLearnOnlineBeforeProcess(), print(), state, cca::ComponentState::STATE_EXEC, cca::ComponentState::STATE_OFFLLEARN, and cca::ComponentState::STATE_ONLLEARN.
void cca::Component::publishState | ( | ) | [virtual] |
Publish the components state over it`s configured state output port.
Definition at line 343 of file Component.cpp.
References cca::Node::getName(), cca::Port::isReady(), logger, outputState, cca::OutputPort< DATATYPE >::publish(), and state.
Referenced by requestTransition(), and ~Component().
bool cca::Component::requestTransition | ( | const ComponentStatePtr & | state | ) | [virtual] |
Make a transition in the component`s life-cycle.
- Todo:
Has to be an extension point
This clearly needs clean-up
- Returns:
- Life-cycle change successful
Definition at line 123 of file Component.cpp.
References cca::Node::getName(), cca::Node::load(), logger, onStartExecution(), onStartLearnOffline(), onStartLearnOnline(), onStopExecution(), onStopLearnOffline(), onStopLearnOnline(), cca::Node::persist(), publishState(), cca::Node::reset(), cca::Node::resume(), state, cca::ComponentState::STATE_EXEC, cca::ComponentState::STATE_LOAD, cca::ComponentState::STATE_OFF, cca::ComponentState::STATE_OFFLLEARN, cca::ComponentState::STATE_ONLLEARN, cca::ComponentState::STATE_PAUSE, cca::ComponentState::STATE_PERSIST, cca::ComponentState::STATE_RESET, and cca::Node::stop().
Referenced by stateCallback().
std::string cca::Component::scopeName | ( | ) | [private] |
Method to render a valid scope string from component name.
Definition at line 495 of file Component.cpp.
References cca::Node::getName(), and scopename.
Referenced by createStateInputPort(), and createStateOutputPort().
void cca::Component::stateCallback | ( | rsb::EventPtr | ) | [protected] |
Definition at line 255 of file Component.cpp.
References cca::Node::getName(), cca::Node::isConfigured(), logger, and requestTransition().
Referenced by createStateInputPort().
Member Data Documentation
boost::uint64_t cca::Component::circuitLastTimestep [protected] |
Definition at line 187 of file Component.h.
Referenced by beatCallback().
boost::uint64_t cca::Component::circuitLastVirtualTimestep [protected] |
Definition at line 187 of file Component.h.
Referenced by beatCallback().
boost::uint64_t cca::Component::circuitSequence [protected] |
Definition at line 188 of file Component.h.
Referenced by beatCallback().
boost::uint64_t cca::Component::circuitTime [protected] |
Definition at line 186 of file Component.h.
Referenced by beatCallback().
boost::uint64_t cca::Component::circuitVirtualTime [protected] |
Definition at line 186 of file Component.h.
Referenced by beatCallback().
Initial State.
Definition at line 205 of file Component.h.
InputPort<cca::timing::Tick>::Ptr cca::Component::inputBeat [protected] |
Input port for a beat.
Definition at line 176 of file Component.h.
Referenced by beatCallback(), configureBeatInputPort(), createBeatInputPort(), and print().
InputPort<ComponentState>::Ptr cca::Component::inputState [protected] |
Input port for state change requests.
Definition at line 179 of file Component.h.
Referenced by configureStateInputPort(), createStateInputPort(), and print().
cca::timing::TickPtr cca::Component::lastTick [protected] |
rsc::logging::LoggerPtr cca::Component::logger [private] |
Component logger.
Reimplemented from cca::Node.
Definition at line 202 of file Component.h.
Referenced by beatCallback(), Component(), configureBeatInputPort(), configureStateInputPort(), configureStateOutputPort(), createBeatInputPort(), createStateInputPort(), createStateOutputPort(), onLearnOffline(), onLearnOnlineAfterProcess(), onLearnOnlineBeforeProcess(), onProcess(), process(), publishState(), requestTransition(), and stateCallback().
OutputPort<ComponentState>::Ptr cca::Component::outputState [protected] |
Output port for component state.
Definition at line 182 of file Component.h.
Referenced by configureStateOutputPort(), createStateOutputPort(), print(), and publishState().
std::string cca::Component::scopename [private] |
Definition at line 199 of file Component.h.
Referenced by createStateInputPort(), createStateOutputPort(), and scopeName().
ComponentStatePtr cca::Component::state [protected] |
Definition at line 173 of file Component.h.
Referenced by print(), process(), publishState(), requestTransition(), and ~Component().
The documentation for this class was generated from the following files:
- cca/Component.h
- cca/Component.cpp