/** simpleCommunicator.c This file automatically generated by FSMLang */ #include "simpleCommunicator_priv.h" #include <stddef.h> #ifndef DBG_PRINTF #define DBG_PRINTF(...) #endif static const SIMPLE_COMMUNICATOR_ACTION_TRANS simpleCommunicator_action_array[THIS(numEvents)][simpleCommunicator_numStates] = { { /* -- SEND_MESSAGE -- */ /* -- IDLE -- */ {UFMN(sendMessage),simpleCommunicator_AWAITING_ACK} /* -- AWAITING_ACK -- */ , {UFMN(queueMessage),simpleCommunicator_AWAITING_ACK} }, { /* -- ACK -- */ /* -- IDLE -- */ {UFMN(noAction), simpleCommunicator_IDLE} /* -- AWAITING_ACK -- */ , {UFMN(checkQueue),simpleCommunicator_IDLE} }, }; SIMPLE_COMMUNICATOR simpleCommunicator = { simpleCommunicator_IDLE, THIS(SEND_MESSAGE), &simpleCommunicator_action_array, simpleCommunicatorFSM }; pSIMPLE_COMMUNICATOR psimpleCommunicator = &simpleCommunicator; void run_simpleCommunicator(SIMPLE_COMMUNICATOR_EVENT e) { if (psimpleCommunicator) { psimpleCommunicator->fsm(psimpleCommunicator,e); } } #ifndef EVENT_IS_NOT_EXCLUDED_FROM_LOG #define EVENT_IS_NOT_EXCLUDED_FROM_LOG(e) ((e) == (e)) #endif void simpleCommunicatorFSM(pSIMPLE_COMMUNICATOR pfsm, SIMPLE_COMMUNICATOR_EVENT event) { SIMPLE_COMMUNICATOR_EVENT new_e; SIMPLE_COMMUNICATOR_EVENT e = event; while (e != THIS(noEvent)) { #ifdef SIMPLE_COMMUNICATOR_DEBUG if (EVENT_IS_NOT_EXCLUDED_FROM_LOG(e)) { DBG_PRINTF("event: %s; state: %s" ,SIMPLE_COMMUNICATOR_EVENT_NAMES[e] ,SIMPLE_COMMUNICATOR_STATE_NAMES[pfsm->state] ); } #endif /* This is read-only data to facilitate error reporting in action functions */ pfsm->event = e; new_e = ((* (*pfsm->actionArray)[e][pfsm->state].action)(pfsm)); pfsm->state = (*pfsm->actionArray)[e][pfsm->state].transition; e = new_e; } } SIMPLE_COMMUNICATOR_EVENT __attribute__((weak)) UFMN(sendMessage)(FSM_TYPE_PTR pfsm) { DBG_PRINTF("weak: %s", __func__); (void) pfsm; return THIS(noEvent); } SIMPLE_COMMUNICATOR_EVENT __attribute__((weak)) UFMN(queueMessage)(FSM_TYPE_PTR pfsm) { DBG_PRINTF("weak: %s", __func__); (void) pfsm; return THIS(noEvent); } SIMPLE_COMMUNICATOR_EVENT __attribute__((weak)) UFMN(checkQueue)(FSM_TYPE_PTR pfsm) { DBG_PRINTF("weak: %s", __func__); (void) pfsm; return THIS(noEvent); } SIMPLE_COMMUNICATOR_EVENT __attribute__((weak)) UFMN(noAction)(FSM_TYPE_PTR pfsm) { DBG_PRINTF("weak: %s", __func__); (void) pfsm; return THIS(noEvent); } #ifdef SIMPLE_COMMUNICATOR_DEBUG char *SIMPLE_COMMUNICATOR_EVENT_NAMES[] = { "simpleCommunicator_SEND_MESSAGE" ,"simpleCommunicator_ACK" , "simpleCommunicator_noEvent" , "simpleCommunicator_numEvents" }; char *SIMPLE_COMMUNICATOR_STATE_NAMES[] = { "simpleCommunicator_IDLE" ,"simpleCommunicator_AWAITING_ACK" }; #endif