IOxfReactive::TakeEventStatus Karussell::rootState_processEvent() { IOxfReactive::TakeEventStatus res = eventNotConsumed; // State idle if(rootState_active == idle) { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == rootState_timeout) { NOTIFY_TRANSITION_STARTED("1"); cancel(rootState_timeout); //#[ state idle.(Exit) dreht = true; //#] NOTIFY_STATE_EXITED("ROOT.idle"); //#[ transition 1 drehen(); //#] NOTIFY_STATE_ENTERED("ROOT.idle"); rootState_subState = idle; rootState_active = idle; //#[ state idle.(Entry) dreht = false; //#] rootState_timeout = scheduleTimeout(1000, "ROOT.idle"); NOTIFY_TRANSITION_TERMINATED("1"); res = eventConsumed; } } } return res; }
IOxfReactive::TakeEventStatus Controller::Timing_processEvent() { IOxfReactive::TakeEventStatus res = eventNotConsumed; if(Timing_active == Time) { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == Timing_timeout) { NOTIFY_TRANSITION_STARTED("13"); if(Timing_timeout != NULL) { Timing_timeout->cancel(); Timing_timeout = NULL; } //#[ state ROOT.On.Timing.Time.(Exit) Reduce_time(); //#] NOTIFY_STATE_EXITED("ROOT.On.Timing.Time"); NOTIFY_STATE_ENTERED("ROOT.On.Timing.Time"); Timing_subState = Time; Timing_active = Time; Timing_timeout = scheduleTimeout(1000, "ROOT.On.Timing.Time"); NOTIFY_TRANSITION_TERMINATED("13"); res = eventConsumed; } } } return res; }
//----------------------------------------------------------------------------- // // VLightObjectAnimationTrack::onControllerEvent( pEvent ); // // // //----------------------------------------------------------------------------- bool VLightObjectAnimationTrack::onControllerEvent( VController::eControllerEventType pEvent ) { if ( !Parent::onControllerEvent( pEvent ) ) { // Skip. return false; } // Enabled? if ( !isEnabled() ) { // Continue Processing Events. return true; } // Fetch the Light Object. VTorque::LightObjectType *lightObject; if ( !getSceneObject( lightObject ) ) { // Skip. return true; } switch ( pEvent ) { case VController::k_EventPlay : { // Play Animation? VLightObjectAnimationEvent *event; if ( getCurrentEvent( event ) ) { // Play. VTorque::playAnimation( lightObject ); } } break; case VController::k_EventPause : case VController::k_EventStop : { // Stop the Animation. VTorque::pauseAnimation( lightObject ); } break; } return true; }
IOxfReactive::TakeEventStatus Dosierer::rootState_processEvent() { IOxfReactive::TakeEventStatus res = eventNotConsumed; switch (rootState_active) { // State Idle case Idle: { if(IS_EVENT_TYPE_OF(evRun_System_id)) { NOTIFY_TRANSITION_STARTED("1"); NOTIFY_STATE_EXITED("ROOT.Idle"); NOTIFY_STATE_ENTERED("ROOT.Running"); rootState_subState = Running; rootState_active = Running; //#[ state Running.(Entry) dosiere(); //#] rootState_timeout = scheduleTimeout(100, "ROOT.Running"); NOTIFY_TRANSITION_TERMINATED("1"); res = eventConsumed; } } break; // State Running case Running: { if(IS_EVENT_TYPE_OF(evStop_System_id)) { NOTIFY_TRANSITION_STARTED("2"); cancel(rootState_timeout); NOTIFY_STATE_EXITED("ROOT.Running"); NOTIFY_STATE_ENTERED("ROOT.Idle"); rootState_subState = Idle; rootState_active = Idle; NOTIFY_TRANSITION_TERMINATED("2"); res = eventConsumed; } else if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == rootState_timeout) { NOTIFY_TRANSITION_STARTED("3"); cancel(rootState_timeout); NOTIFY_STATE_EXITED("ROOT.Running"); //#[ transition 3 runde++; //#] NOTIFY_STATE_ENTERED("ROOT.Running"); rootState_subState = Running; rootState_active = Running; //#[ state Running.(Entry) dosiere(); //#] rootState_timeout = scheduleTimeout(100, "ROOT.Running"); NOTIFY_TRANSITION_TERMINATED("3"); res = eventConsumed; } } } break; default: break; } return res; }
IOxfReactive::TakeEventStatus Controller::state_10_processEvent() { IOxfReactive::TakeEventStatus res = eventNotConsumed; switch (state_10_active) { case On_000: { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == state_10_timeout) { NOTIFY_TRANSITION_STARTED("3"); if(state_10_timeout != NULL) { state_10_timeout->cancel(); state_10_timeout = NULL; } NOTIFY_STATE_EXITED("ROOT.On.state_10.On_000"); //#[ transition 3 z=true; //#] NOTIFY_STATE_ENTERED("ROOT.On.state_10.On_001"); state_10_subState = On_001; state_10_active = On_001; //#[ state ROOT.On.state_10.On_001.(Entry) if(x==false && y==false && z==true) { Reset(); NS_ORANGE=1; EW_ORANGE=1; NS_ORANGETIME=5; EW_ORANGETIME=5; NS_MSG=" READY"; EW_MSG=" WAIT"; } //#] state_10_timeout = scheduleTimeout(5000, "ROOT.On.state_10.On_001"); NOTIFY_TRANSITION_TERMINATED("3"); res = eventConsumed; } } } break; case On_001: { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == state_10_timeout) { NOTIFY_TRANSITION_STARTED("4"); if(state_10_timeout != NULL) { state_10_timeout->cancel(); state_10_timeout = NULL; } NOTIFY_STATE_EXITED("ROOT.On.state_10.On_001"); //#[ transition 4 y=true; //#] NOTIFY_STATE_ENTERED("ROOT.On.state_10.On_011"); state_10_subState = On_011; state_10_active = On_011; //#[ state ROOT.On.state_10.On_011.(Entry) if(x==false && y==true && z==true) { Reset(); EW_RED=1; NS_GREEN=1; EW_REDTIME=10; NS_GREENTIME=10; EW_MSG=" STOP"; NS_MSG=" GO"; } //#] state_10_timeout = scheduleTimeout(5000, "ROOT.On.state_10.On_011"); NOTIFY_TRANSITION_TERMINATED("4"); res = eventConsumed; } } } break; case On_011: { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == state_10_timeout) { NOTIFY_TRANSITION_STARTED("5"); if(state_10_timeout != NULL) { state_10_timeout->cancel(); state_10_timeout = NULL; } NOTIFY_STATE_EXITED("ROOT.On.state_10.On_011"); //#[ transition 5 x=true; //#] NOTIFY_STATE_ENTERED("ROOT.On.state_10.On_111"); state_10_subState = On_111; state_10_active = On_111; //#[ state ROOT.On.state_10.On_111.(Entry) if(x==true && y==true && z==true) { Reset(); EW_RED=1; NS_GREEN=1; EW_REDTIME=5; NS_GREENTIME=5; EW_MSG=" STOP"; NS_MSG=" GO"; } //#] state_10_timeout = scheduleTimeout(5000, "ROOT.On.state_10.On_111"); NOTIFY_TRANSITION_TERMINATED("5"); res = eventConsumed; } } } break; case On_100: { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == state_10_timeout) { NOTIFY_TRANSITION_STARTED("8"); if(state_10_timeout != NULL) { state_10_timeout->cancel(); state_10_timeout = NULL; } NOTIFY_STATE_EXITED("ROOT.On.state_10.On_100"); //#[ transition 8 x=false; //#] NOTIFY_STATE_ENTERED("ROOT.On.state_10.On_000"); state_10_subState = On_000; state_10_active = On_000; //#[ state ROOT.On.state_10.On_000.(Entry) if(x==false && y==false && z==false) { Reset(); NS_RED=1; EW_GREEN=1; NS_REDTIME=5; EW_GREENTIME=5; NS_MSG=" STOP"; EW_MSG=" GO"; } //#] state_10_timeout = scheduleTimeout(5000, "ROOT.On.state_10.On_000"); NOTIFY_TRANSITION_TERMINATED("8"); res = eventConsumed; } } } break; case On_110: { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == state_10_timeout) { NOTIFY_TRANSITION_STARTED("7"); if(state_10_timeout != NULL) { state_10_timeout->cancel(); state_10_timeout = NULL; } NOTIFY_STATE_EXITED("ROOT.On.state_10.On_110"); //#[ transition 7 y=false; //#] NOTIFY_STATE_ENTERED("ROOT.On.state_10.On_100"); state_10_subState = On_100; state_10_active = On_100; //#[ state ROOT.On.state_10.On_100.(Entry) if(x==true && y==false && z==false) { Reset(); NS_RED=1; EW_GREEN=1; NS_REDTIME=10; EW_GREENTIME=10; NS_MSG=" STOP"; EW_MSG=" GO"; } //#] state_10_timeout = scheduleTimeout(5000, "ROOT.On.state_10.On_100"); NOTIFY_TRANSITION_TERMINATED("7"); res = eventConsumed; } } } break; case On_111: { if(IS_EVENT_TYPE_OF(OMTimeoutEventId)) { if(getCurrentEvent() == state_10_timeout) { NOTIFY_TRANSITION_STARTED("6"); if(state_10_timeout != NULL) { state_10_timeout->cancel(); state_10_timeout = NULL; } NOTIFY_STATE_EXITED("ROOT.On.state_10.On_111"); //#[ transition 6 z=false; //#] NOTIFY_STATE_ENTERED("ROOT.On.state_10.On_110"); state_10_subState = On_110; state_10_active = On_110; //#[ state ROOT.On.state_10.On_110.(Entry) if(x==true && y==true && z==false) { Reset(); NS_ORANGE=1; EW_ORANGE=1; NS_ORANGETIME=5; EW_ORANGETIME=5; NS_MSG=" WAIT"; EW_MSG=" READY"; } //#] state_10_timeout = scheduleTimeout(5000, "ROOT.On.state_10.On_110"); NOTIFY_TRANSITION_TERMINATED("6"); res = eventConsumed; } } } break; default: break; } return res; }
/** * FSM implementation. */ EventStatus processEvent() { EventStatus status = EventStatus::NotConsumed; // Get event. IXFEvent * event = getCurrentEvent(); // Calculate transitions. State _oldState = _state; switch( _state ) { case InitialState: if ( event->getEventType() == IXFEvent::Initial ) { _state = StartGameState; status = EventStatus::Consumed; } break; case StartGameState: if ( event->getEventType() == IXFEvent::NullTransition ) { _state = WaitForPlayer1State; status = EventStatus::Consumed; } break; case WaitForPlayer1State: if ( event->getEventType() == IXFEvent::Event && event->getId() == FieldSelectionEvent::Id ) { _state = PlacePlayer1SymbolState; status = EventStatus::Consumed; } break; case PlacePlayer1SymbolState: if ( event->getEventType() == IXFEvent::NullTransition ) { if ( _model.gamefield().winner() != Air3T::GameField::None ) _state = ShowWinnerState; else _state = WaitForPlayer2State; status = EventStatus::Consumed; } break; case WaitForPlayer2State: if ( event->getEventType() == IXFEvent::Event && event->getId() == FieldSelectionEvent::Id ) { _state = PlacePlayer2SymbolState; status = EventStatus::Consumed; } break; case PlacePlayer2SymbolState: if ( event->getEventType() == IXFEvent::NullTransition ) { if ( _model.gamefield().winner() != Air3T::GameField::None ) _state = ShowWinnerState; else _state = WaitForPlayer1State; status = EventStatus::Consumed; } break; case ShowWinnerState: if ( event->getEventType() == IXFEvent::Timeout ) { _state = StartGameState; status = EventStatus::Consumed; } break; } // Execute on entry code. if ( _state != _oldState ) { switch( _state ) { case InitialState: GEN( XFNullTransition() ); break; case StartGameState: _model.gamefield().clear(); _view->setCursorPosition( Air3T::GameField::Field( 0 , 0 ) ); _view->setCursorEnabled( true ); GEN( XFNullTransition() ); break; case WaitForPlayer1State: break; case PlacePlayer1SymbolState: { FieldSelectionEvent *se = static_cast<FieldSelectionEvent *>( event ); _model.gamefield().setSymbol( se->field() , Air3T::GameField::Circle ); GEN( XFNullTransition() ); } break; case WaitForPlayer2State: break; case PlacePlayer2SymbolState: { FieldSelectionEvent *se = static_cast<FieldSelectionEvent *>( event ); _model.gamefield().setSymbol( se->field() , Air3T::GameField::Cross ); GEN( XFNullTransition() ); } break; case ShowWinnerState: _view->setCursorEnabled( false ); getThread()->scheduleTimeout( 0 , 2500 , this ); break; } } return status; }