Beispiel #1
0
        public override JobCreateResult Create(PrinterInfo printerInfo)
        {
            Status = JobStatus.SavingToFile;
            JobCreateResult jobCreateResult = base.Create(printerInfo);

            if (jobCreateResult.Result == ProcessReturn.SUCCESS)
            {
                try
                {
                    using (var gcodeFileReader = new GCodeFileReader(GCodeFilename))
                    {
                        using (var gcodeFileWriter = new GCodeFileWriter(Details.jobParams.outputfile, true))
                        {
                            GCode nextLine;
                            while ((nextLine = gcodeFileReader.GetNextLine(true)) != null)
                            {
                                gcodeFileWriter.Write(nextLine);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    jobCreateResult.Result = ProcessReturn.FAILURE;
                }
            }
            return(jobCreateResult);
        }
Beispiel #2
0
        public JobController.Result InitPrintJob(JobParams jobParams, string user, ulong ulFastForward = 0)
        {
            if (MyJobImplementation != null)
            {
                return(JobController.Result.FAILED_JobAlreadyStarted);
            }

            Processed    = false;
            Printing     = false;
            IsSavingToSD = false;
            ClearAllWarnings();
            m_sGcodeFile = jobParams.gcodefile;
            Mode         = jobParams.jobMode;
            PrinterInfo currentPrinterInfo = m_oParentFirmwareController.CurrentPrinterInfo;
            AbstractJob abstractJob;

            if (Mode == JobParams.Mode.SaveToBinaryGCodeFile)
            {
                abstractJob = new SaveGCodeToFileJob(jobParams, user, m_oParentFirmwareController.MyPrinterProfile);
            }
            else if (Mode != JobParams.Mode.FirmwarePrintingFromSDCard)
            {
                if (Mode == JobParams.Mode.SavingToSDCard || Mode == JobParams.Mode.SavingToSDCardAutoStartPrint)
                {
                    m_sGcodeFile = GetFilenameForSDCard(jobParams.jobname, currentPrinterInfo.filament_info);
                }

                IsSimultaneousPrint = false;
                IsSavingToSD        = Mode != JobParams.Mode.DirectPrinting;
                abstractJob         = new SpoolerHostedJob(jobParams, user, m_oParentFirmwareController.MyPrinterProfile, IsSavingToSD && !IsSimultaneousPrint, ulFastForward);
            }
            else
            {
                if (Mode != JobParams.Mode.FirmwarePrintingFromSDCard)
                {
                    throw new NotImplementedException("Software does not support printing from the SD card.");
                }

                abstractJob = new FirmwareSDPrintJob(jobParams, user, m_oParentFirmwareController.MyPrinterProfile);
            }
            m_oJobImplementation.Value = abstractJob;
            JobCreateResult jobCreateResult = abstractJob.Create(currentPrinterInfo);

            if (jobCreateResult.Result == ProcessReturn.SUCCESS)
            {
                m_olWarnings = jobCreateResult.Warnings;
                Processed    = true;
                return(JobController.Result.Success);
            }
            m_oJobImplementation.Value = null;
            if (jobCreateResult.Result == ProcessReturn.FAILURE_OUT_OF_BOUNDS)
            {
                return(JobController.Result.FAILED_OutOfBounds);
            }

            return(jobCreateResult.Result == ProcessReturn.FAILURE_FILAMENT_MISMATCH ? JobController.Result.FAILED_IncompatibleFilament : JobController.Result.FAILED_Create);
        }