/****************************************************************** * This code was generated by the Astade StateChartCoderACF++. * * The generated code is not per se a derivative work of Astade; * * the original copyright to this code is held by the holder(s) * * of the copyright to the underlying model at the time this code * * was generated; this code may be distributed under terms of * * his/her/their choice. */ /** A test state chart * @file CTest.cpp ******************************************************************/ // implementation prolog #include "CTest.h" #include "ACF_events.h" CTest::CTest(struct ACF* aACF) { #ifdef _TRACE_ ACF_Trace ACF_LOCALTRACEHELPER; ACF_Trace_notify_constructor(&ACF_LOCALTRACEHELPER,&MessageReceiver_base, 5, "CTest"); #endif // Call the message framework constructor #ifdef _TRACE_ ACF_MessageReceiver_Constructor(&MessageReceiver_base, "CTest", &CTest::TakeEvent, this, aACF); #else ACF_MessageReceiver_Constructor(&MessageReceiver_base, 0, &CTest::TakeEvent, this, aACF); #endif #ifdef _TRACE_ ACF_Trace_notifyReturn(&ACF_LOCALTRACEHELPER); #endif } CTest::~CTest() { #ifdef _TRACE_ ACF_Trace ACF_LOCALTRACEHELPER; ACF_Trace_notify_destructor(&ACF_LOCALTRACEHELPER,&MessageReceiver_base, 5, "CTest"); #endif ACF_MessageReceiver_Destructor(&MessageReceiver_base); #ifdef _TRACE_ ACF_Trace_notifyReturn(&ACF_LOCALTRACEHELPER); #endif } void CTest::Initialize(ACF_Message* theEvent) { #ifdef _TRACE_ ACF_Trace ACF_LOCALTRACEHELPER; ACF_Trace_notify_function_call(&ACF_LOCALTRACEHELPER,&MessageReceiver_base, 5, "CTest", "Initialize"); #endif // Calling the initial actions prepare(theEvent); // Set the initial State function nextState = &CTest::Enter_tick; // Call the state enter function EnterState(theEvent); #ifdef _TRACE_ ACF_Trace_notifyReturn(&ACF_LOCALTRACEHELPER); #endif } void CTest::TakeEvent(void* me, ACF_Message* theEvent) { #ifdef _TRACE_ ACF_Trace ACF_LOCALTRACEHELPER; ACF_Trace_notify_self_call(&ACF_LOCALTRACEHELPER, me, 5, "CTest", "TakeEvent"); #endif CTest* pthis = (CTest*)((ACF_MessageReceiver*)me)->this_ptr; pthis->TakeTheEvent(theEvent); // Call the state enter function pthis->EnterState(theEvent); #ifdef _TRACE_ ACF_Trace_notifyReturn(&ACF_LOCALTRACEHELPER); #endif } bool CTest::NoState(ACF_Message* theEvent) { return false; } void CTest::EnterState(ACF_Message* theEvent) { while (nextState) (this->*nextState)(theEvent); } void CTest::toe(ACF_Message* theEvent) { // goon / sleep; shout ---> tick if (theEvent->ID == goon) { // next state nextState = &CTest::Enter_tick; // Actions sleep(theEvent); shout(theEvent); return; } else // reverse / ---> tack if (theEvent->ID == reverse) { // next state nextState = &CTest::Enter_tack; return; } else return; } void CTest::Enter_toe(ACF_Message* theEvent) { // Set the new state. theState = &CTest::toe; // call the virtual notify function notifyNewState("toe"); // maybe trace the state entering #ifdef _TRACE_ ACF_Trace_notify_state(&MessageReceiver_base, 5, "CTest", "toe"); #endif nextState = 0; // We stay in this state } void CTest::tack(ACF_Message* theEvent) { // push / yell ---> toe if (theEvent->ID == push) { // next state nextState = &CTest::Enter_toe; // Actions yell(theEvent); return; } else return; } void CTest::Enter_tack(ACF_Message* theEvent) { // Set the new state. theState = &CTest::tack; // call the virtual notify function notifyNewState("tack"); // maybe trace the state entering #ifdef _TRACE_ ACF_Trace_notify_state(&MessageReceiver_base, 5, "CTest", "tack"); #endif nextState = 0; // We stay in this state } void CTest::tick(ACF_Message* theEvent) { // draw / shout ---> tack if (theEvent->ID == draw) { // next state nextState = &CTest::Enter_tack; // Actions shout(theEvent); return; } else return; } void CTest::Enter_tick(ACF_Message* theEvent) { // Set the new state. theState = &CTest::tick; // call the virtual notify function notifyNewState("tick"); // maybe trace the state entering #ifdef _TRACE_ ACF_Trace_notify_state(&MessageReceiver_base, 5, "CTest", "tick"); #endif nextState = 0; // We stay in this state } // implementation epilog