Initializing::Initializing(my_context ctx) : my_base(ctx) { PRINTENGINE->SendStatus(InitializingState, Entering); // see if the printer should be put into demo mode if (PRINTENGINE->DemoModeRequested()) post_event(EvEnterDemoMode()); // check to see if the door is open on startup if (PRINTENGINE->DoorIsOpen()) { post_event(EvDoorOpened()); } else { PRINTENGINE->Initialize(); post_event(EvInitialized()); } }
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); }
InitializingLayer::InitializingLayer(my_context ctx) : my_base(ctx) { // check to see if the door is still open after calibrating if (PRINTENGINE->DoorIsOpen()) post_event(EvDoorOpened()); else { // perform initialization needed for next layer // (even if the door is opened and closed again while here, // this won't be called more than once per layer, because we're going to // immediately transition to the next state) PRINTENGINE->NextLayer(); post_event(EvInitialized()); } UISubState uiSubState = PRINTENGINE->PauseRequested() ? AboutToPause : NoUISubState; // don't send status till after estimated print time has been set PRINTENGINE->SendStatus(InitializingLayerState, Entering, uiSubState); }