Unjamming::Unjamming(my_context ctx) : my_base(ctx) { PRINTENGINE->SendStatus(UnjammingState, Entering); if (context<PrinterStateMachine>()._motionCompleted) post_event(EvMotionCompleted()); }
MovingToResume::MovingToResume(my_context ctx) : my_base(ctx) { PRINTENGINE->SendStatus(MovingToResumeState, Entering); if (context<PrinterStateMachine>()._motionCompleted) post_event(EvMotionCompleted()); }
AwaitingCancelation::AwaitingCancelation(my_context ctx) : my_base(ctx) { PRINTENGINE->SendStatus(AwaitingCancelationState, Entering); if (context<PrinterStateMachine>()._motionCompleted) post_event(EvMotionCompleted()); }
MovingToStartPosition::MovingToStartPosition(my_context ctx) : my_base(ctx) { PRINTENGINE->SendStatus(MovingToStartPositionState, Entering, PRINTENGINE->SkipCalibration() ? NoUISubState : CalibratePrompt); if (context<PrinterStateMachine>()._motionCompleted) post_event(EvMotionCompleted()); }
Approaching::Approaching(my_context ctx) : my_base(ctx) { UISubState uiSubState = PRINTENGINE->PauseRequested() ? AboutToPause : NoUISubState; PRINTENGINE->SendStatus(ApproachingState, Entering, uiSubState); if (context<PrinterStateMachine>()._motionCompleted) post_event(EvMotionCompleted()); }
// Handle completion (or failure) of motor command) void PrinterStateMachine::MotionCompleted(bool successfully) { if (!successfully) return; // we've already handled the error, so nothing more to do // this flag allows us to handle the event in the rare case that the motion // completed just after a pause was requested on entry to DoorOpen or // ConfirmCancel states _motionCompleted = true; process_event(EvMotionCompleted()); }
Pressing::Pressing(my_context ctx) : my_base(ctx) { UISubState uiSubState = PRINTENGINE->PauseRequested() ? AboutToPause : NoUISubState; PRINTENGINE->SendStatus(PressingState, Entering, uiSubState); // check to see if the door is still open after calibrating if (PRINTENGINE->DoorIsOpen()) post_event(EvDoorOpened()); else if (context<PrinterStateMachine>()._motionCompleted) post_event(EvMotionCompleted()); }
void ProcessPrintData() { // Put printer in Home state // Print data can only be processed in the Home state PrinterStateMachine* pPSM = printEngine.GetStateMachine(); pPSM->process_event(EvInitialized()); pPSM->process_event(EvMotionCompleted()); // Send commands std::string startPrintDataLoadCommand("StartPrintDataLoad\n"); std::string processPrintDataCommand("ProcessPrintData\n"); int fd = open(COMMAND_PIPE, O_WRONLY); write(fd, startPrintDataLoadCommand.data(), startPrintDataLoadCommand.length()); write(fd, processPrintDataCommand.data(), processPrintDataCommand.length()); close(fd); // Process event queue eventHandler.Begin(4); }