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);
void castEvent(Event *event)
StateBase * currentState()
void setInitState(StateBase *pState)
void addTransition(StateBase *source, Event *event, StateBase *target)
virtual bool exists(const char *port)=0
virtual const char * error()=0
virtual bool connect(const char *from, const char *to, const char *carrier, bool persist=false)=0
virtual bool disconnect(const char *from, const char *to, const char *carrier)=0
virtual const char * requestRpc(const char *szport, const char *request, double timeout=0.0)=0
Connecting(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Connecting.
void moduleFailed() override
void connectAllPorts() override
Dead(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Dead.
void moduleFailed() override
Dying(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Dying.
void disconnectAllPorts() override
void stopModule() override
void moduleFailed() override
void killModule() override
Singleton class ErrorLogger.
void addError(const char *szError)
void addWarning(const char *szWarning)
static ErrorLogger * Instance()
Singleton class ErrorLogger.
static FSM::Event * startModuleEventOk
static FSM::Event * startModuleEventFailed
static FSM::Event * stopModuleEventFailed
static FSM::Event * killModuleEventOk
static FSM::Event * startEvent
Initializing event factory.
static FSM::Event * killEvent
static FSM::Event * connectAllPortsEventOk
static FSM::Event * killModuleEventFailed
static FSM::Event * failedEvent
static FSM::Event * recoverEvent
static FSM::Event * stopModuleEventOk
static FSM::Event * stopEvent
ExecMachine(Executable *pExecutable)
Class ExecMachine.
void onTransition(FSM::StateBase *previous, FSM::Event *event, FSM::StateBase *current) override
Callback onTransition represents the change in the states.
void disconnectAllPorts()
void connectionFailed(void *which)
const char * getCommand()
void restoreOriginalPostStopWait()
ResourceContainer & getResources()
CnnContainer & getConnections()
void restoreOriginalPostExecWait()
all transitions are used in state machine
virtual void stopModule()
virtual void startModule()
virtual void connectionFailed(void *which)
virtual void disconnectAllPorts()
virtual void connectAllPorts()
virtual void moduleFailed()=0
virtual void killModule()
virtual void onCnnFailed(void *which)
virtual void onExecutableFailed(void *which)
virtual void onExecutableStop(void *which)
virtual void onExecutableDied(void *which)
virtual void onCnnStablished(void *which)
virtual void onCnnReleased(void *which)
virtual void onExecutableStart(void *which)
virtual void onError(void *which)
void moduleFailed() override
Ready(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Ready.
void startModule() override
void connectionFailed(void *which) override
void moduleFailed() override
Running(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Running.
void moduleFailed() override
static double nowSystem()
static void delaySystem(double seconds)
bool compareString(const char *szFirst, const char *szSecond)
std::vector< ResYarpPort >::iterator ResourceIterator
std::vector< Connection >::iterator CnnIterator
std::stringstream OSTRINGSTREAM