|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
24 Event* EventFactory::startEvent =
new Event(
"start");
25 Event* EventFactory::stopEvent =
new Event(
"stop");
26 Event* EventFactory::killEvent =
new Event(
"kill");
27 Event* EventFactory::failedEvent =
new Event(
"failed");
28 Event* EventFactory::recoverEvent =
new Event(
"recover");
29 Event* EventFactory::startModuleEventOk =
new Event(
"startModule:ok");
30 Event* EventFactory::startModuleEventFailed =
new Event(
"startModule:failed");
31 Event* EventFactory::stopModuleEventOk =
new Event(
"stopModule:ok");
32 Event* EventFactory::stopModuleEventFailed =
new Event(
"stopModule:failed");
33 Event* EventFactory::killModuleEventOk =
new Event(
"killModule:ok");
34 Event* EventFactory::killModuleEventFailed =
new Event(
"killModule:failed");
35 Event* EventFactory::connectAllPortsEventOk =
new Event(
"connectAllPorts:ok");
36 Event* EventFactory::connectAllPortsEventFailed =
new Event(
"connectAllPorts:failed");
37 Event* EventFactory::disconnectAllPortsEventOk =
new Event(
"disconnectAllPorts:ok");
93 executable = pExecutable;
100 bool Ready::checkPriorityPorts()
106 if((*itr).withPriority()
113 bool Ready::checkResources(
bool silent)
126 msg<<(*itr).getPort()<<
" does not exist";
132 if(strlen((*itr).getRequest()) != 0) {
135 (*itr).getTimeout());
136 if(reply ==
nullptr) {
139 msg<<
"cannot request resource "<<(*itr).getPort()<<
" for "<<(*itr).getRequest();
150 msg<<
"waiting for the expected reply from resource "<<(*itr).getPort();
151 msg<<
" for request "<<(*itr).getRequest();
152 msg<<
". (expected="<<(*itr).getReply()<<
", received="<<reply<<
")";
164 bool Ready::timeout(
double base,
double timeout)
181 while(!checkPriorityPorts())
190 double maxTimeout = 0;
194 if((*itr).getTimeout() > maxTimeout)
195 maxTimeout = (*itr).getTimeout();
200 while(!checkResources()) {
203 if(timeout(base, maxTimeout)) {
205 if(!checkResources(
false)) {
208 msg<<
" : Timeout while waiting for "<<executable->
getHost();
256 executable(pExecutable),
262 bool Connecting::checkNormalPorts()
285 while(!checkNormalPorts())
299 msg<<
"cannot connect "<<(*itr).from() <<
" to "<<(*itr).to();
342 executable = pExecutable;
393 executable = pExecutable;
457 msg<<
"cannot disconnect "<<(*itr).from() <<
" to "<<(*itr).to();
499 executable = pExecutable;
546 executable = pExecutable;
548 suspended =
new Suspended(executable,
this);
549 ready =
new Ready(executable,
this);
550 connecting =
new Connecting(executable,
this);
551 running =
new Running(executable,
this);
552 dying =
new Dying(executable,
this);
553 dead =
new Dead(executable,
this);
StateBase * currentState()
void connectAllPorts() override
virtual const char * error()=0
virtual void onCnnStablished(void *which)
Dead(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Dead.
static FSM::Event * connectAllPortsEventOk
static FSM::Event * stopEvent
void restoreOriginalPostExecWait()
static FSM::Event * killModuleEventOk
void disconnectAllPorts()
std::stringstream OSTRINGSTREAM
virtual void onCnnReleased(void *which)
static FSM::Event * recoverEvent
static FSM::Event * startModuleEventFailed
static FSM::Event * startModuleEventOk
ResourceContainer & getResources()
Singleton class ErrorLogger.
static FSM::Event * stopModuleEventOk
void disconnectAllPorts() override
all transitions are used in state machine
Connecting(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Connecting.
void moduleFailed() override
static FSM::Event * stopModuleEventFailed
std::vector< Connection >::iterator CnnIterator
virtual void killModule()
bool compareString(const char *szFirst, const char *szSecond)
Running(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Running.
void setInitState(StateBase *pState)
virtual void startModule()
static double nowSystem()
void moduleFailed() override
virtual void moduleFailed()=0
void stopModule() override
void moduleFailed() override
virtual void stopModule()
static ErrorLogger * Instance()
Singleton class ErrorLogger.
void onTransition(FSM::StateBase *previous, FSM::Event *event, FSM::StateBase *current) override
Callback onTransition represents the change in the states.
Ready(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Ready.
static void delaySystem(double seconds)
void restoreOriginalPostStopWait()
virtual void onExecutableStart(void *which)
Dying(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Dying.
void startModule() override
void addError(const char *szError)
static FSM::Event * failedEvent
virtual bool disconnect(const char *from, const char *to, const char *carrier)=0
virtual void onExecutableDied(void *which)
virtual bool connect(const char *from, const char *to, const char *carrier, bool persist=false)=0
void moduleFailed() override
virtual const char * requestRpc(const char *szport, const char *request, double timeout=0.0)=0
virtual void disconnectAllPorts()
void connectionFailed(void *which) override
void addWarning(const char *szWarning)
virtual void onError(void *which)
static FSM::Event * startEvent
Initializing event factory.
void addTransition(StateBase *source, Event *event, StateBase *target)
virtual void connectAllPorts()
void killModule() override
virtual void onExecutableStop(void *which)
static FSM::Event * killEvent
const char * getCommand()
ExecMachine(Executable *pExecutable)
Class ExecMachine.
void moduleFailed() override
static FSM::Event * killModuleEventFailed
virtual void connectionFailed(void *which)
void moduleFailed() override
void castEvent(Event *event)
CnnContainer & getConnections()
std::vector< ResYarpPort >::iterator ResourceIterator
virtual bool exists(const char *port)=0
void connectionFailed(void *which)
virtual void onExecutableFailed(void *which)
virtual void onCnnFailed(void *which)