77 }
else if (
ret == -1) {
89 executable = pExecutable;
96bool Ready::checkPriorityPorts()
102 if ((*itr).withPriority()
110bool Ready::checkResources(
bool silent)
123 msg<<(*itr).getPort()<<
" does not exist";
129 if(strlen((*itr).getRequest()) != 0) {
132 (*itr).getTimeout());
136 msg<<
"cannot request resource "<<(*itr).getPort()<<
" for "<<(*itr).getRequest();
148 msg<<
"waiting for the expected reply from resource "<<(*itr).getPort();
149 msg<<
" for request "<<(*itr).getRequest();
150 msg<<
". (expected="<<(*itr).getReply()<<
", received="<<reply<<
")";
163bool Ready::timeout(
double base,
double timeout)
181 while(!checkPriorityPorts())
192 double maxTimeout = 0;
196 if ((*itr).getTimeout() > maxTimeout) {
197 maxTimeout = (*itr).getTimeout();
203 while(!checkResources()) {
208 if(timeout(base, maxTimeout)) {
210 if(!checkResources(
false)) {
213 msg<<
" : Timeout while waiting for "<<executable->
getHost();
262 executable(pExecutable),
268bool Connecting::checkNormalPorts()
291 while(!checkNormalPorts())
307 msg<<
"cannot connect "<<(*itr).from() <<
" to "<<(*itr).to();
327 }
else if (
ret == -1) {
352 executable = pExecutable;
364 }
else if (
ret == -1) {
403 executable = pExecutable;
469 msg<<
"cannot disconnect "<<(*itr).from() <<
" to "<<(*itr).to();
488 }
else if (
ret == -1) {
512 executable = pExecutable;
544 }
else if (
ret == -1) {
559 executable = pExecutable;
561 suspended =
new Suspended(executable,
this);
562 ready =
new Ready(executable,
this);
563 connecting =
new Connecting(executable,
this);
564 running =
new Running(executable,
this);
565 dying =
new Dying(executable,
this);
566 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 std::string &port)=0
virtual bool connect(const std::string &from, const std::string &to, const std::string &carrier, bool persist=false)=0
virtual std::string requestRpc(const std::string &szport, const std::string &request, double timeout=0.0)=0
virtual bool disconnect(const std::string &from, const std::string &to, const std::string &carrier)=0
virtual std::string error()=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 * connectAllPortsEventFailed
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 * disconnectAllPortsEventOk
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)
CnnContainer & getConnections()
void restoreOriginalPostStopWait()
ResourceContainer & getResources()
const char * getCommand()
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.
Suspended(Executable *pExecutable, FSM::IEventSink *pEventSink)
Class Suspended.
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