public override JobCreateResult Create(PrinterInfo printerInfo) { try { m_sGCodeFileOnSDCard = Details.jobParams.gcodefile; } catch (Exception ex) { return(new JobCreateResult(this, ProcessReturn.FAILURE, null)); } FilamentSpool.TypeEnum filamentTypeFromName = FirmwareSDPrintJob.GetFilamentTypeFromName(Details.jobParams.gcodefile); switch (filamentTypeFromName) { case FilamentSpool.TypeEnum.NoFilament: case FilamentSpool.TypeEnum.OtherOrUnknown: return(new JobCreateResult(this, ProcessReturn.SUCCESS, null)); default: if (FilamentProfile.CreateFilamentProfile(printerInfo.filament_info, MyPrinterProfile).Type != filamentTypeFromName) { return(new JobCreateResult(null, ProcessReturn.FAILURE_FILAMENT_MISMATCH, null)); } goto case FilamentSpool.TypeEnum.NoFilament; } }
public CommandResult RecoveryPrintFromPowerFailure(bool bHomingRequired) { if (m_oPrinterPowerRecovery.PrintingStatus == PowerRecovery.PowerResetState.NotPrinting) { return(CommandResult.Failed_Exception); } PrinterInfo currentPrinterInfo = m_oFirmwareController.CurrentPrinterInfo; if (currentPrinterInfo.persistantData.SavedJobInformation == null || currentPrinterInfo.persistantData.SavedJobInformation.Params == null) { return(CommandResult.Failed_RequiredDataNotAvailable); } JobParams jobParams = currentPrinterInfo.persistantData.SavedJobInformation.Params; FilamentSpool filament; if (jobParams.filament_temperature > 0 && jobParams.filament_type != FilamentSpool.TypeEnum.OtherOrUnknown && jobParams.filament_type != FilamentSpool.TypeEnum.NoFilament) { filament = new FilamentSpool(jobParams.filament_type, jobParams.filament_temperature); } else if (null != currentPrinterInfo.filament_info) { filament = new FilamentSpool(currentPrinterInfo.filament_info); } else { FilamentSpool.TypeEnum filamentTypeFromName = FirmwareSDPrintJob.GetFilamentTypeFromName(jobParams.gcodefile); switch (filamentTypeFromName) { case FilamentSpool.TypeEnum.NoFilament: case FilamentSpool.TypeEnum.OtherOrUnknown: return(CommandResult.Failed_RequiredDataNotAvailable); default: filament = new FilamentSpool(filamentTypeFromName, FilamentConstants.Temperature.Default(filamentTypeFromName)); break; } } var filamentProfile = FilamentProfile.CreateFilamentProfile(currentPrinterInfo.filament_info, m_oFirmwareController.MyPrinterProfile); PrepareForPrinting(jobParams, filament, filamentProfile, bHomingRequired || float.IsNaN(m_fLocationX) || float.IsNaN(m_fLocationY)); CommandResult commandResult = PowerRecovery.PowerResetState.PowerFailureSDPrint != m_oPrinterPowerRecovery.PrintingStatus ? RecoverSpooledPrint(currentPrinterInfo.persistantData.SavedJobInformation) : RecoverSDPrint(jobParams); if (commandResult == CommandResult.Success) { var num = (int)ClearPowerRecoveryFault(true); } else { m_oFirmwareController.SendEmergencyStop(); } return(commandResult); }
private void DoOperationOnLock(IAsyncCallResult ar) { if (ar.CallResult != CommandResult.Success && ar.CallResult != CommandResult.Success_LockAcquired) { return; } var asyncState = ar.AsyncState as SDCardFrame.OnLockOperationData; PrinterObject printer = asyncState.printer; PrinterObject selectedPrinter = m_oSpoolerConnection.SelectedPrinter; if (selectedPrinter != null && selectedPrinter == printer && selectedPrinter.SDCardExtension.Available) { switch (asyncState.op) { case SDCardFrame.Operation.Refresh: var num1 = (int)selectedPrinter.SDCardExtension.RefreshSDCardList(new M3D.Spooling.Client.AsyncCallback(OnRefreshCallback), selectedPrinter); return; case SDCardFrame.Operation.Print: var file1 = asyncState.file; var jobParams = new JobParams(file1, file1, "null", selectedPrinter.GetCurrentFilament().filament_type, 0.0f, 0.0f) { jobMode = JobParams.Mode.FirmwarePrintingFromSDCard }; jobParams.options.autostart_ignorewarnings = true; jobParams.options.dont_use_preprocessors = false; var filamentProfile = FilamentProfile.CreateFilamentProfile(selectedPrinter.GetCurrentFilament(), selectedPrinter.MyPrinterProfile); jobParams.preprocessor = filamentProfile.preprocessor; jobParams.filament_temperature = filamentProfile.Temperature; var num2 = (int)selectedPrinter.PrintModel(new M3D.Spooling.Client.AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, jobParams); return; case SDCardFrame.Operation.Delete: var file2 = asyncState.file; var num3 = (int)selectedPrinter.SDCardExtension.DeleteFileFromSDCard(new M3D.Spooling.Client.AsyncCallback(DoOperationOnLock), new SDCardFrame.OnLockOperationData(SDCardFrame.Operation.Refresh, selectedPrinter, (string)null), file2); return; } } var num4 = (int)printer.ReleaseLock(null, null); }
public JobController.Result Resume(out List <string> resume_gcode, FilamentSpool spool) { resume_gcode = null; AbstractJob jobImplementation = MyJobImplementation; if (jobImplementation == null) { return(JobController.Result.FAILED_Create); } JobController.Result result = jobImplementation.Resume(out List <string> resume_gcode1, spool); if (result == JobController.Result.Success) { var num1 = !(null != spool) || spool.filament_type == FilamentSpool.TypeEnum.NoFilament ? byte.MaxValue : FilamentProfile.CreateFilamentProfile(spool, m_oParentFirmwareController.MyPrinterProfile).preprocessor.initialPrint.StartingFanValue; var num2 = 90f; resume_gcode = new List <string>() { PrinterCompatibleString.Format("M106 S{0}", (object)num1), PrinterCompatibleString.Format("M109 S{0}", (object)spool.filament_temperature) }; if (m_bUpdatedDataReceivedAfterPause) { resume_gcode.Add("G90"); resume_gcode.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F{2}", m_v3DeExtruderLocationAtPause.pos.x, m_v3DeExtruderLocationAtPause.pos.y, num2)); resume_gcode.Add(PrinterCompatibleString.Format("G0 Z{0} F{1}", m_v3DeExtruderLocationAtPause.pos.z, num2)); resume_gcode.Add(PrinterCompatibleString.Format("G92 E{0}", (object)(float)(m_v3DeExtruderLocationAtPause.e - (double)m_fRetractionAtPause))); } if (resume_gcode1 != null && resume_gcode1.Count > 0) { resume_gcode.AddRange(resume_gcode1); } job_timer.Start(); } return(result); }
public bool Pause(out List <string> pause_gcode, FilamentSpool spool) { pause_gcode = null; AbstractJob jobImplementation = MyJobImplementation; if (jobImplementation == null || jobImplementation.Status == JobStatus.Paused || IsSavingToSD) { return(false); } job_timer.Stop(); var flag = jobImplementation.Pause(out pause_gcode, spool); if (flag) { if (pause_gcode == null) { pause_gcode = new List <string>(); } var num1 = 90f; var num2 = 1800f; Vector2D cornerPositionBoxTop = m_oParentFirmwareController.MyPrinterProfile.PrinterSizeConstants.BackCornerPositionBoxTop; string str; if (m_oParentFirmwareController.CurrentPrinterInfo.extruder.Temperature > 0.0) { m_fRetractionAtPause = !(null != spool) || spool.filament_type == FilamentSpool.TypeEnum.NoFilament ? 10f : FilamentProfile.CreateFilamentProfile(spool, (PrinterProfile)m_oParentFirmwareController.MyPrinterProfile).preprocessor.initialPrint.PrimeAmount; str = PrinterCompatibleString.Format("G0 Z{0} F{1} E-{2}", 8f, num1, m_fRetractionAtPause); } else { m_fRetractionAtPause = 0.0f; str = PrinterCompatibleString.Format("G0 Z{0} F{1}", 8f, num1); } pause_gcode.AddRange(new string[7] { "G4 S0", "M114", "G91", str, "G90", PrinterCompatibleString.Format("G0 X{0} Y{1} F{2}", (object)cornerPositionBoxTop.x, (object)cornerPositionBoxTop.y, (object)num2), "M104 S0" }); m_oParentFirmwareController.OnGotUpdatedPosition += new ScriptCallback(OnReceivedUpdatedPosition); m_bUpdatedDataReceivedAfterPause = false; } return(flag); }