void transitionToStarted(WatchStatePtr state) { /* Initialize with the default implementation before specifying the events to be handled in the started state. */ defaultImplementation(state); state->stop = stopWatch; }
void transitionToStarted(WatchStatePtr state) { // initially with the default implementation before // specifying the events to be handled in the started // state defaultImplementation(state); strcpy(state->name, "Started\0"); state->stop = stopWatch; }
/* * PUBLIC FUNCTIONS */ void transitionToMobile (RoboOneState *pState, RoboOneTaskReq *pTaskReq) { Bool success = false; Bool chargingPermitted = false; /* Fill in default handlers and name first */ defaultImplementation (pState); memcpy (&(pState->name[0]), MOBILE_STATE_NAME, strlen (MOBILE_STATE_NAME) + 1); /* +1 for terminator */ printDebug ("\n*** Transitioning to %s state.\n", &(pState->name[0])); /* Now hook in the event handlers for this state */ pState->pEventInitFailure = transitionToInit; pState->pEventTasksAvailable = eventTasksAvailable; pState->pEventNoTasksAvailable = transitionToBatteryIdle; pState->pEventMainsPowerAvailable = transitionToDocked; pState->pEventShutdown = transitionToShutdown; /* Do the entry actions */ /* Let the Battery Manager know that charging is no longer possible */ batteryManagerServerSendReceive (BATTERY_MANAGER_CHARGING_PERMITTED, &chargingPermitted, sizeof (chargingPermitted), PNULL); /* Switch Pi to battery power */ success = actionSwitchPiRioToBatteryPower(); if (success) { /* Switch Hindbrain to battery power */ success = actionSwitchHindbrainToBatteryPower (); if (success) { /* Switch on Hindbrain */ success = actionSwitchOnHindbrain (); if (success) { /* Now handle the event */ eventTasksAvailable (pState, pTaskReq); } } } if (!success) { /* If we cannot initialise, send an InitFailure event */ stateMachineServerSendReceive (STATE_MACHINE_EVENT_INIT_FAILURE, PNULL, 0, PNULL, PNULL); } }
void transitionToStarted(WatchStatePtr state) { defaultImplementation(state); state->stop = stopWatch; }