Classes | Namespaces | Defines
FSM.h File Reference
#include "EventSystem.h"
#include "TaskResult.h"
Include dependency graph for FSM.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  decision_making::___ABS__ScoppedThreadsOnExit
struct  decision_making::ScoppedThreads::Cleaner
struct  decision_making::ScoppedThreads
class  decision_making::ScoppedThreadsOnExit

Namespaces

namespace  decision_making

Defines

#define __CLEAN_THREAD_AND_EVENTS   decision_making::ScoppedThreads::Cleaner SUBMACHINESTHREADSCLEANER(SUBMACHINESTHREADS);
#define __DEFCALLCONTEXT   decision_making::CallContext call_ctx(parent_call_ctx?decision_making::CallContext(*parent_call_ctx, fsm_name):decision_making::CallContext(fsm_name));
#define __DEFEVENTQUEUE   decision_making::EventQueue* events_queue(parent_event_queue);
#define __DEFSUBCTEXT(TASK)   decision_making::ScoppedThreads::CallContextPtr call_ctx##TASK( new decision_making::CallContext(state_call_ctx, #TASK) );
#define __DEFSUBEVENTQUEUE(TASK)   decision_making::ScoppedThreads::EventQueuePtr events_queu##TASK( new decision_making::EventQueue(events_queue) );
#define __ENDOFSTATE
#define __SHR_TO_REF(X)   (*(X.get()))
#define __STARTOFSTATE(X)
#define DMDEBUG(...)
#define FSM(NAME)
#define FSM_BGN
#define FSM_CALL_BT(NAME)
#define FSM_CALL_FSM(NAME)
#define FSM_CALL_TASK(TASK)
#define FSM_CONTEXT   state_call_ctx
#define FSM_DROP_EVENTS   events_queue->drop_all();
#define FSM_END
#define FSM_EVENT(EVENT)   decision_making::Event(#EVENT,state_call_ctx))
#define FSM_EVENTS_DROP   events_queue->drop_all();
#define FSM_HEADER(NAME)
#define FSM_NEXT(STATE)
#define FSM_ON_CONDITION(COND, DO)
#define FSM_ON_EVENT(EVENT, DO)
#define FSM_ON_STATE_EXIT(...)   } __VA_ARGS__ {
#define FSM_ON_STATE_EXIT_BGN
#define FSM_ON_STATE_EXIT_END
#define FSM_PRINT_EVENT   if(not event.equals(decision_making::Event::SPIN_EVENT())){ cout<<" READ("<<fsm_name<<":"<<event<<") "; }
#define FSM_RAISE(EVENT)
#define FSM_RISE(EVENT)   FSM_RAISE(EVENT)
#define FSM_START(STATE)
#define FSM_STATE(X)
#define FSM_STATES   enum STATES
#define FSM_STOP(EVENT, RESULT)
#define FSM_TRANSITIONS   __CLEAN_THREAD_AND_EVENTS {Event event; while((event=events_queue->waitEvent())==true){

Define Documentation

#define __CLEAN_THREAD_AND_EVENTS   decision_making::ScoppedThreads::Cleaner SUBMACHINESTHREADSCLEANER(SUBMACHINESTHREADS);

Definition at line 205 of file FSM.h.

#define __DEFCALLCONTEXT   decision_making::CallContext call_ctx(parent_call_ctx?decision_making::CallContext(*parent_call_ctx, fsm_name):decision_making::CallContext(fsm_name));

Definition at line 89 of file FSM.h.

#define __DEFEVENTQUEUE   decision_making::EventQueue* events_queue(parent_event_queue);

Definition at line 90 of file FSM.h.

#define __DEFSUBCTEXT (   TASK)    decision_making::ScoppedThreads::CallContextPtr call_ctx##TASK( new decision_making::CallContext(state_call_ctx, #TASK) );

Definition at line 159 of file FSM.h.

#define __DEFSUBEVENTQUEUE (   TASK)    decision_making::ScoppedThreads::EventQueuePtr events_queu##TASK( new decision_making::EventQueue(events_queue) );

Definition at line 158 of file FSM.h.

#define __ENDOFSTATE
Value:
DMDEBUG( struct _STATE_FINISHER_PRINT{std::string n;_STATE_FINISHER_PRINT( std::string n): n(n){}~_STATE_FINISHER_PRINT(){DMDEBUG( cout<<"}"<<n<<" "; )} void r(){}}_ep(outname);_ep.r(); )\
                struct _STATE_FINISHER{\
                        std::string state_name; decision_making::CallContext& ctx; decision_making::EventQueue& queue;\
                        _STATE_FINISHER(std::string state_name, decision_making::CallContext& ctx, decision_making::EventQueue& queue): state_name(state_name),ctx(ctx),queue(queue){}\
                        ~_STATE_FINISHER(){\
                                ON_FSM_STATE_END(state_name, ctx, queue);\
                        } void r(){}\
                }_e(state_name, call_ctx, *events_queue);_e.r();

Definition at line 115 of file FSM.h.

#define __SHR_TO_REF (   X)    (*(X.get()))

Definition at line 160 of file FSM.h.

#define __STARTOFSTATE (   X)
Value:
DMDEBUG( string outname("STT("+fsm_name+":"+call_ctx.str()+"/"+#X+")");cout<<outname<<"{ "; )\
                std::string state_name(#X);\
                decision_making::CallContext state_call_ctx(call_ctx, state_name);\
                ON_FSM_STATE_START(state_name, call_ctx, *events_queue);

Definition at line 109 of file FSM.h.

#define DMDEBUG (   ...)

Definition at line 16 of file FSM.h.

#define FSM (   NAME)
Value:
FSM_HEADER(NAME)\
        decision_making::TaskResult Fsm##NAME(const decision_making::CallContext* p, decision_making::EventQueue* q){return Fsm##NAME(p,q,#NAME);}\
        decision_making::TaskResult Fsm##NAME(const decision_making::CallContext* parent_call_ctx, decision_making::EventQueue* parent_event_queue, std::string fsm_name)

Definition at line 82 of file FSM.h.

#define FSM_BGN
Value:
bool fsm_stop = false; \
                while(not fsm_stop and not events_queue->isTerminated() DM_SYSTEM_STOP){ \
                        switch(state){ { {

Definition at line 98 of file FSM.h.

#define FSM_CALL_BT (   NAME)
Value:
__DEFSUBEVENTQUEUE(NAME) __DEFSUBCTEXT(NAME) \
                        SUBMACHINESTHREADS.add(events_queu##NAME); \
                        SUBMACHINESTHREADS.add(call_ctx##NAME); \
                        decision_making::EventQueue& __t_events_queu##NAME = __SHR_TO_REF(events_queu##NAME);\
                        decision_making::CallContext& __t_call_ctx##NAME = __SHR_TO_REF(call_ctx##NAME);\
                        __BT_CREATE_BT_CALL_FUNCTION(NAME, __t_call_ctx##NAME, __t_events_queu##NAME)\
                        SUBMACHINESTHREADS.add(\
                                __CALL_BT_FUNCTION(NAME, boost::ref(__t_call_ctx##NAME), boost::ref(__t_events_queu##NAME))  \
                        );

Definition at line 175 of file FSM.h.

#define FSM_CALL_FSM (   NAME)
Value:
__DEFSUBEVENTQUEUE(NAME) \
                        SUBMACHINESTHREADS.add(events_queu##NAME); \
                        SUBMACHINESTHREADS.add(\
                                        new boost::thread(boost::bind(&Fsm##NAME, &state_call_ctx, events_queu##NAME.get())  ));

Definition at line 168 of file FSM.h.

#define FSM_CALL_TASK (   TASK)
Value:
__DEFSUBEVENTQUEUE(TASK) __DEFSUBCTEXT(TASK) \
                        SUBMACHINESTHREADS.add(events_queu##TASK); \
                        SUBMACHINESTHREADS.add(call_ctx##TASK); \
                        SUBMACHINESTHREADS.add(\
                                new boost::thread(  CALL_REMOTE(TASK, boost::ref(__SHR_TO_REF(call_ctx##TASK)), boost::ref(__SHR_TO_REF(events_queu##TASK)))  ));

Definition at line 161 of file FSM.h.

#define FSM_CONTEXT   state_call_ctx

Definition at line 125 of file FSM.h.

#define FSM_DROP_EVENTS   events_queue->drop_all();

Definition at line 208 of file FSM.h.

#define FSM_END
Value:
}}}} \
                        DMDEBUG( cout<<" FSM("<<fsm_name<<":FINISH) "; ) \
                        ON_FSM_END(fsm_name, call_ctx, *events_queue, fsm_result);\
                        return fsm_result;

Definition at line 103 of file FSM.h.

#define FSM_EVENT (   EVENT)    decision_making::Event(#EVENT,state_call_ctx))

Definition at line 141 of file FSM.h.

#define FSM_EVENTS_DROP   events_queue->drop_all();

Definition at line 156 of file FSM.h.

#define FSM_HEADER (   NAME)
Value:

Definition at line 78 of file FSM.h.

#define FSM_NEXT (   STATE)
Value:
state = STATE; \
                                break;

Definition at line 133 of file FSM.h.

#define FSM_ON_CONDITION (   COND,
  DO 
)
Value:
if(COND){ \
                                DMDEBUG( cout<<" GOTO("<<fsm_name<<":"<<decision_making::Event(#COND,state_call_ctx)<< "->" #DO ") "; ) \
                                DO;\
                        }

Definition at line 143 of file FSM.h.

#define FSM_ON_EVENT (   EVENT,
  DO 
)
Value:
if(event==decision_making::Event(EVENT,state_call_ctx)){ \
                                DMDEBUG( cout<<" GOTO("<<fsm_name<<":"<<decision_making::Event(EVENT,call_ctx)<< "->" #DO ") "; ) \
                                DO;\
                        }

Definition at line 136 of file FSM.h.

#define FSM_ON_STATE_EXIT (   ...)    } __VA_ARGS__ {

Definition at line 197 of file FSM.h.

Value:
class __ON_STATE_EXIT_STRUCT:public decision_making::ScoppedThreadsOnExit{public:\
                                __ON_STATE_EXIT_STRUCT(CallContext& state_call_ctx, EventQueue* events_queue):decision_making::ScoppedThreadsOnExit(state_call_ctx, events_queue){}\
                                virtual void exit(){

Definition at line 186 of file FSM.h.

Value:
}\
                        };\
                        decision_making::ScoppedThreadsOnExit* __tmp___ON_STATE_EXIT_STRUCT = new __ON_STATE_EXIT_STRUCT(state_call_ctx, events_queue);\
                        SUBMACHINESTHREADS.add(decision_making::ScoppedThreads::ScoppedThreadsOnExitPtr(__tmp___ON_STATE_EXIT_STRUCT));

Definition at line 191 of file FSM.h.

#define FSM_PRINT_EVENT   if(not event.equals(decision_making::Event::SPIN_EVENT())){ cout<<" READ("<<fsm_name<<":"<<event<<") "; }

Definition at line 210 of file FSM.h.

#define FSM_RAISE (   EVENT)
Value:
DMDEBUG( cout<<" RAISE("<<fsm_name<<":"<<decision_making::Event(EVENT, state_call_ctx)<<") "; ) \
                        events_queue->raiseEvent(decision_making::Event(EVENT, state_call_ctx));

Definition at line 149 of file FSM.h.

#define FSM_RISE (   EVENT)    FSM_RAISE(EVENT)

Definition at line 154 of file FSM.h.

#define FSM_START (   STATE)
Value:
state ( STATE ); \
                decision_making::TaskResult fsm_result = decision_making::TaskResult::TERMINATED();\
                __DEFCALLCONTEXT __DEFEVENTQUEUE  \
		DMDEBUG( cout<<" FSM("<<fsm_name<<":START) "; )\
                ON_FSM_START(fsm_name, call_ctx, *events_queue);

Definition at line 91 of file FSM.h.

#define FSM_STATE (   X)
Value:
}}}break; \
                        case X: { \
                                decision_making::ScoppedThreads SUBMACHINESTHREADS; \
                                __STARTOFSTATE(X)  __ENDOFSTATE

Definition at line 127 of file FSM.h.

#define FSM_STATES   enum STATES

Definition at line 87 of file FSM.h.

#define FSM_STOP (   EVENT,
  RESULT 
)
Value:
fsm_stop=true; \
                        FSM_RAISE(EVENT); \
                        fsm_result = RESULT; \
                        break;

Definition at line 199 of file FSM.h.

#define FSM_TRANSITIONS   __CLEAN_THREAD_AND_EVENTS {Event event; while((event=events_queue->waitEvent())==true){

Definition at line 206 of file FSM.h.



decision_making
Author(s):
autogenerated on Wed Aug 26 2015 11:16:53