Beispiel #1
0
        public static string GotoPoint(float x1, float y1, float x2, float y2, float layer_height, float line_thickness, float flow_rate, float filament_diameter, ref float E)
        {
            var extrusion = GCodeGeneration.CalculateExtrusion(x1, y1, x2, y2, layer_height, line_thickness, flow_rate, filament_diameter);

            E += extrusion;
            return(PrinterCompatibleString.Format("G0 X{0} Y{1} E{2}", x2, y2, E));
        }
Beispiel #2
0
        public static List <string> CreateXSpeedTest(PrinterProfile profile)
        {
            var x = profile.PrinterSizeConstants.printBedSize.x;

            return(new List <string>()
            {
                "G91", PrinterCompatibleString.Format("G0 X{0} F{1}", x, 3000f), PrinterCompatibleString.Format("G0 X-{0}", (object)x), PrinterCompatibleString.Format("G0 X{0}", (object)x), PrinterCompatibleString.Format("G0 X-{0}", (object)x), PrinterCompatibleString.Format("G0 X{0}", (object)x), PrinterCompatibleString.Format("G0 X-{0}", (object)x)
            });
        }
Beispiel #3
0
        private void MoveToPoint(CatScreenTab.ProbeLocation location, bool bMoveUp = true)
        {
            PrinterObject selectedPrinter = spooler_connection.SelectedPrinter;

            if (selectedPrinter == null || !selectedPrinter.Connected)
            {
                return;
            }

            var compensationPreprocessor = new BedCompensationPreprocessor();

            compensationPreprocessor.UpdateConfigurations(GetCalibrationSettingsFromOptions(selectedPrinter.Info), selectedPrinter.MyPrinterProfile.PrinterSizeConstants);
            Vector vector;

            switch (location)
            {
            case CatScreenTab.ProbeLocation.Center:
                vector = compensationPreprocessor.Center;
                break;

            case CatScreenTab.ProbeLocation.FrontLeft:
                vector = compensationPreprocessor.FrontLeft;
                break;

            case CatScreenTab.ProbeLocation.FrontRight:
                vector = compensationPreprocessor.FrontRight;
                break;

            case CatScreenTab.ProbeLocation.BackLeft:
                vector = compensationPreprocessor.BackLeft;
                break;

            case CatScreenTab.ProbeLocation.BackRight:
                vector = compensationPreprocessor.BackRight;
                break;

            default:
                return;
            }
            vector.z            = 0.1f + compensationPreprocessor.GetHeightAdjustmentRequired(vector.x, vector.y) + compensationPreprocessor.entire_z_height_offset;
            m_lastProbeLocation = location;
            var stringList = new List <string>
            {
                "M1012",
                "G90"
            };

            if (bMoveUp)
            {
                stringList.Add("G0 Z2");
            }

            stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F3000", vector.x, vector.y));
            stringList.Add(PrinterCompatibleString.Format("G0 Z{0} F100", (object)vector.z));
            stringList.Add("M1011");
            selectedPrinter.SendCommandAutoLock(false, true, new AsyncCallback(AutoLockCallBack), selectedPrinter, stringList.ToArray());
        }
Beispiel #4
0
        public static List <string> CreateYSpeedTest(PrinterProfile profile)
        {
            var y = profile.PrinterSizeConstants.printBedSize.y;

            return(new List <string>()
            {
                "G91", PrinterCompatibleString.Format("G0 Y{0} F{1}", y, 3000f), PrinterCompatibleString.Format("G0 Y-{0}", (object)y), PrinterCompatibleString.Format("G0 Y{0}", (object)y), PrinterCompatibleString.Format("G0 Y-{0}", (object)y), PrinterCompatibleString.Format("G0 Y{0}", (object)y), PrinterCompatibleString.Format("G0 Y-{0}", (object)y)
            });
        }
Beispiel #5
0
        public static List <string> FastRecenter(PrinterProfile profile)
        {
            var x = profile.PrinterSizeConstants.printBedSize.x;
            var y = profile.PrinterSizeConstants.printBedSize.y;

            return(new List <string>()
            {
                "G91", PrinterCompatibleString.Format("G0 Y{0} F{1}", y, 3000f), PrinterCompatibleString.Format("G0 X{0} F{1}", x, 3000f), PrinterCompatibleString.Format("G0 Y-{0} X-{1}", (float)((double)y / 2.0), (float)((double)x / 2.0))
            });
        }
Beispiel #6
0
        private void MovePrinterAxis(PrinterObject selected_printer, EditBoxWidget amountEditBox, string axis, string errorString, float speed)
        {
            var text = amountEditBox.Text;

            if (!PrinterCompatibleString.VerifyNumber(text))
            {
                messagebox.AddMessageToQueue(errorString);
            }
            else
            {
                var floatCurrentCulture = PrinterCompatibleString.ToFloatCurrentCulture(text);
                selected_printer.SendCommandAutoLockRelease(new AsyncCallback(selected_printer.ShowLockError), selected_printer, "G91", PrinterCompatibleString.Format("G0 {0}{1} F{2}", axis, floatCurrentCulture, speed));
            }
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        public static List <string> CreatePrintTestBorder(float x1, float y1, float x2, float y2, float flow_rate, float temperature, float filament_diameter)
        {
            var stringList = new List <string>();
            var num1       = 0.0f;

            stringList.Add("M106");
            stringList.Add(PrinterCompatibleString.Format("M109 S{0}", (object)temperature));
            stringList.Add(PrinterCompatibleString.Format(";ideal temp:{0}", (object)temperature));
            stringList.Add("G90");
            stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} Z0.15 F900", x1, y1));
            var num2 = num1 + 6f;

            stringList.Add(PrinterCompatibleString.Format("G0 Z0.4 E{0}", (object)num2));
            stringList.Add("G4 S10");
            var E1 = num2 + 0.3f;

            stringList.Add(PrinterCompatibleString.Format("G0 E{0}", (object)E1));
            stringList.Add(GCodeGeneration.GotoPoint(x1, y1, x2, y1, 0.4f, 2.15f, 1f, filament_diameter, ref E1));
            stringList.Add("G4 S10");
            var E2 = E1 + 0.3f;

            stringList.Add(PrinterCompatibleString.Format("G0 E{0}", (object)E2));
            stringList.Add(GCodeGeneration.GotoPoint(x2, y1, x2, y2, 0.4f, 2.15f, 1f, filament_diameter, ref E2));
            stringList.Add("G4 S10");
            var E3 = E2 + 0.3f;

            stringList.Add(PrinterCompatibleString.Format("G0 E{0}", (object)E3));
            stringList.Add(GCodeGeneration.GotoPoint(x2, y2, x1, y2, 0.4f, 2.15f, 1f, filament_diameter, ref E3));
            stringList.Add("G4 S10");
            var E4 = E3 + 0.3f;

            stringList.Add(PrinterCompatibleString.Format("G0 E{0}", (object)E4));
            stringList.Add(GCodeGeneration.GotoPoint(x1, y2, x1, y1, 0.4f, 2.15f, 1f, filament_diameter, ref E4));
            stringList.Add("G4 S10");
            var num3 = E4 + 0.3f;

            stringList.Add(PrinterCompatibleString.Format("G0 E{0}", (object)num3));
            var num4 = num3 + 1.5169f;

            stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} Z0.4 E{2}", (float)((double)x1 - 1.5), (float)((double)y1 - 1.0), num4));
            var num5 = num4 + 5.3093f;

            stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} Z2.4 E{2} F1800", (float)((double)x1 - 3.0), (float)((double)y1 - 2.5), num5));
            var num6 = num5 - 3f;

            stringList.Add(PrinterCompatibleString.Format("G0 E{0}", (object)num6));
            stringList.Add("G0 X4 Y12.5 Z25 F1800");
            return(stringList);
        }
        public static List <string> GenerateEndGCode(JobDetails jobdetails, InternalPrinterProfile printerProfile, bool retract)
        {
            var stringList = new List <string>();
            InitialPrintPreProcessorData initialPrint         = jobdetails.jobParams.preprocessor.initialPrint;
            PrinterSizeProfile           printerSizeConstants = printerProfile.PrinterSizeConstants;

            stringList.Add("G91");
            if (retract)
            {
                var primeAmount = (float)initialPrint.PrimeAmount;
                var num1        = (float)Math.Round(0.25 * primeAmount);
                var num2        = primeAmount - num1;
                var num3        = 1800f;
                stringList.Add(PrinterCompatibleString.Format("G0 X5 Y5 E{1} F{0}", num3, (float)-(double)num1));
                var num4 = 360f;
                stringList.Add(PrinterCompatibleString.Format("G0 E{1} F{0}", num4, (float)-(double)num2));
            }
            stringList.Add("M104 S0");
            if (printerProfile.AccessoriesConstants.HeatedBedConstants.HasBuiltinHeatedBed && jobdetails.jobParams.options.use_heated_bed)
            {
                stringList.Add("M140 S0");
            }

            if (jobdetails.bounds.max.z > (double)printerSizeConstants.BoxTopLimitZ)
            {
                BoundingBox bounds = printerSizeConstants.WarningRegion.bounds_list[printerSizeConstants.WarningRegion.bounds_list.Count - 1];
                if (jobdetails.bounds.max.z + 1.0 < bounds.max.z)
                {
                    var num = 90f;
                    stringList.Add(PrinterCompatibleString.Format("G0 Z1 F{0}", (object)num));
                }
                var num1 = 1800f;
                stringList.Add("G90");
                stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F{2}", printerSizeConstants.BackCornerPositionBoxTop.x, printerSizeConstants.BackCornerPositionBoxTop.y, num1));
            }
            else
            {
                var num1 = 90f;
                stringList.Add(PrinterCompatibleString.Format("G0 Z3 F{0}", (object)num1));
                stringList.Add("G90");
                var num2 = 1800f;
                stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F{2}", printerSizeConstants.BackCornerPosition.x, printerSizeConstants.BackCornerPosition.y, num2));
            }
            stringList.Add("M18");
            return(stringList);
        }
Beispiel #10
0
        private static List <string> CreateSkipTestInternal(float max, int stride, char param)
        {
            var stringList = new List <string>();
            var num1       = (int)(max / (double)Math.Abs(stride));
            var num2       = stride < 0 ? 1 : -1;

            stringList.Add("G91");
            for (var index1 = 0; index1 < 1; ++index1)
            {
                stringList.Add("G4 S1");
                stringList.Add(PrinterCompatibleString.Format("G0 {0}{1} F{2}", param, (float)((double)max * (double)num2), 3000f));
                for (var index2 = 0; index2 < num1; ++index2)
                {
                    stringList.Add("G4 S1");
                    stringList.Add(PrinterCompatibleString.Format("G0 {0}{1}", param, stride));
                }
            }
            return(stringList);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        public void basicControlsFrameButtonCallback(ButtonWidget button)
        {
            PrinterObject selectedPrinter = spooler_connection.SelectedPrinter;

            if (selectedPrinter == null || !selectedPrinter.IsConnected())
            {
                return;
            }

            switch (button.ID)
            {
            case 1000:
                var num = (int)selectedPrinter.SendEmergencyStop(null, null);
                break;

            case 1001:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1016), "Z-", "The Z Value is not a number. Please correct and try again.", 90f);
                break;

            case 1002:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1016), "Z", "The Z Value is not a number. Please correct and try again.", 90f);
                break;

            case 1003:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1017), "X-", "The X Value is not a number. Please correct and try again.", 3000f);
                break;

            case 1004:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1017), "X", "The X Value is not a number. Please correct and try again.", 3000f);
                break;

            case 1005:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1018), "Y-", "The Y Value is not a number. Please correct and try again.", 3000f);
                break;

            case 1006:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1018), "Y", "The Y Value is not a number. Please correct and try again.", 3000f);
                break;

            case 1007:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1019), "E-", "The E Value is not a number. Please correct and try again.", 345f);
                break;

            case 1008:
                MovePrinterAxis(selectedPrinter, (EditBoxWidget)FindChildElement(1019), "E", "The E Value is not a number. Please correct and try again.", 345f);
                break;

            case 1010:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M17");
                break;

            case 1011:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M18");
                break;

            case 1012:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M106 S255");
                break;

            case 1013:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M106 S0");
                break;

            case 1014:
                FilamentSpool currentFilament = selectedPrinter.GetCurrentFilament();
                if (currentFilament == null)
                {
                    messagebox.AddMessageToQueue("Sorry, but you must insert filament first.");
                    break;
                }
                var filamentTemperature = currentFilament.filament_temperature;
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, PrinterCompatibleString.Format("M109 S{0}", (object)filamentTemperature));
                break;

            case 1015:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M104 S0");
                break;
            }
        }
Beispiel #13
0
        public void MyButtonCallback(ButtonWidget button)
        {
            PrinterObject selectedPrinter = spooler_connection.SelectedPrinter;

            if (selectedPrinter == null || !selectedPrinter.IsConnected())
            {
                return;
            }

            switch (button.ID)
            {
            case 1000:
                var num1 = (int)selectedPrinter.SendEmergencyStop(null, null);
                break;

            case 1014:
                FilamentSpool currentFilament = selectedPrinter.GetCurrentFilament();
                if (currentFilament == null)
                {
                    messagebox.AddMessageToQueue("Sorry, but you must insert filament first.");
                    break;
                }
                var num2 = FilamentConstants.Temperature.BedDefault(currentFilament.filament_type);
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, PrinterCompatibleString.Format("M190 S{0}", (object)num2));
                break;

            case 1015:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M140 S0");
                break;
            }
        }
        private void ProcessGCode_AddStartGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, JobOptions jobOptions, Calibration calibration, InternalPrinterProfile printerProfile, InitialPrintPreProcessorData initial_print_settings)
        {
            var num = 0;

            if (jobOptions.use_heated_bed && printerProfile.AccessoriesConstants.HeatedBedConstants.HasBuiltinHeatedBed)
            {
                num = initial_print_settings.BedTemperature;
            }

            output_writer.Write(new GCode("M106 S1"));
            if (0 < num)
            {
                output_writer.Write(new GCode("M18"));
                output_writer.Write(new GCode("M104 S0"));
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M140 S{0}", (object)num)));
                for (var index = 0; index < 8; ++index)
                {
                    output_writer.Write(new GCode("G4 S15"));
                }

                output_writer.Write(new GCode("M140 S0"));
            }
            output_writer.Write(new GCode("M17"));
            output_writer.Write(new GCode("G4 S1"));
            if (0 < num)
            {
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M104 S{0}", (object)175)));
            }
            else
            {
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M104 S{0}", (object)initial_print_settings.StartingTemp)));
            }

            output_writer.Write(new GCode("G90"));
            output_writer.Write(new GCode(PrinterCompatibleString.Format("G0 Z5 F{0}", (object)(float)(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_Z * 60.0))));
            if (0 < num)
            {
                output_writer.Write(new GCode("M18"));
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M109 S{0}", (object)175)));
                output_writer.Write(new GCode("G4 S5"));
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M104 S{0}", (object)130)));
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M140 S{0}", (object)num)));
                for (var index = 0; index < 8; ++index)
                {
                    output_writer.Write(new GCode("G4 S15"));
                }

                output_writer.Write(new GCode(PrinterCompatibleString.Format("M104 S{0}", (object)initial_print_settings.StartingTemp)));
                for (var index = 0; index < 3; ++index)
                {
                    output_writer.Write(new GCode("G4 S15"));
                }

                output_writer.Write(new GCode("M17"));
                for (var index = 0; index < 1; ++index)
                {
                    output_writer.Write(new GCode("G4 S15"));
                }
            }
            output_writer.Write(new GCode("G28"));
            if (0 < num)
            {
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M190 S{0}", (object)num)));
            }

            output_writer.Write(new GCode("M106 S1"));
            output_writer.Write(new GCode("G90"));
            output_writer.Write(new GCode(PrinterCompatibleString.Format("M109 S{0}", (object)initial_print_settings.StartingTemp)));
            if (initial_print_settings.StartingTempStabilizationDelay != 0)
            {
                output_writer.Write(new GCode(PrinterCompatibleString.Format("G4 S{0}", (object)initial_print_settings.StartingTempStabilizationDelay)));
            }

            if (jobOptions.use_fan_preprocessor && initial_print_settings.StartingFanValue != 0)
            {
                output_writer.Write(new GCode(PrinterCompatibleString.Format("M106 S{0}", (object)initial_print_settings.StartingFanValue)));
            }

            output_writer.Write(new GCode(PrinterCompatibleString.Format("G0 F{0}", (object)1800)));
            output_writer.Write(new GCode("; can extrude"));
        }
Beispiel #15
0
        private void CleanNozzleAfterRetraction(IAsyncCallResult ar)
        {
            var asyncState = (PrinterObject)ar.AsyncState;

            switch (ar.CallResult)
            {
            case CommandResult.Success:
            case CommandResult.Success_LockReleased:
            case CommandResult.Success_LockAcquired:
                var num = (int)asyncState.SendManualGCode(new AsyncCallback(GotoCleanNozzlePageAfterCommand), asyncState, "G91", PrinterCompatibleString.Format("G0 E-{0}", (object)asyncState.MyFilamentProfile.preprocessor.initialPrint.PrimeAmount), "G90");
                return;

            case CommandResult.Failed_PrinterAlreadyLocked:
                messagebox.AddMessageToQueue("Unable to connect to the printer because it is already in use.");
                break;

            default:
                messagebox.AddMessageToQueue("There was an error connecting to the printer. Please try again.");
                break;
            }
            MainWindow.ResetToStartup();
        }
Beispiel #16
0
        public override void OnActivate(Mangage3DInkStageDetails details)
        {
            base.OnActivate(details);
            text_main.Text = "";
            text_main.Text = CurrentDetails.current_spool.filament_type != FilamentSpool.TypeEnum.CAM ? "Please wait. \n\nRemove filament is extruding a small amount of filament first to prevent clogs." : "Please wait. \n\nRemove filament is extruding a small amount of filament first to prevent clogs.\n\nWarning: Chameleon Ink may appear white when heated and exiting nozzle.";
            PrinterObject selectedPrinter = MainWindow.GetSelectedPrinter();

            if (selectedPrinter == null)
            {
                return;
            }

            if (CurrentDetails.current_spool == null)
            {
                MainWindow.ResetToStartup();
            }
            else
            {
                var num = (int)selectedPrinter.SendManualGCode(new AsyncCallback(MainWindow.GotoPageAfterOperation), new Manage3DInkMainWindow.PageAfterLockDetails(selectedPrinter, Manage3DInkMainWindow.PageID.Page2_RetractingFilament, CurrentDetails), "G4 S5", "G91", PrinterCompatibleString.Format("G0 E{0} F{1}", 50f, 90.0));
            }
        }
        private bool ProcessGCode_HelperLayerComments(GCodeFileReader input_reader, GCodeFileWriter output_writer, JobDetails jobdetails, InternalPrinterProfile printerProfile, InitialPrintPreProcessorData initial_print_settings)
        {
            var   flag1 = false;
            var   num1  = 0;
            var   num2  = 0;
            var   flag2 = false;
            var   flag3 = false;
            var   flag4 = false;
            var   flag5 = false;
            var   useFanPreprocessor = jobdetails.jobParams.options.use_fan_preprocessor;
            GCode nextLine;

            while ((nextLine = input_reader.GetNextLine(false)) != null)
            {
                if (nextLine.orig.StartsWith(";LAYER:"))
                {
                    if (nextLine.ToString().ToLower().Contains(";layer:-"))
                    {
                        flag5 = true;
                    }

                    flag1 = true;
                    flag2 = true;
                }
                else if (nextLine.HasZ & flag3 && !flag1)
                {
                    output_writer.Write(new GCode(";LAYER:" + num1++));
                    flag2 = true;
                }
                else if (nextLine.HasG)
                {
                    if (nextLine.G == 90)
                    {
                        flag3 = true;
                    }
                    else if (nextLine.G == 91)
                    {
                        flag3 = false;
                    }
                }
                if (!(nextLine.orig.ToLower() == "t0") && nextLine.orig.ToLower().IndexOf(" t0 ") <= -1 && (!nextLine.hasM || nextLine.M != 104 && nextLine.M != 109) && (!useFanPreprocessor || !nextLine.hasM || nextLine.M != 106 && nextLine.M != 107))
                {
                    var flag6 = false;
                    if (nextLine.orig.StartsWith(";LAYER:"))
                    {
                        output_writer.Write(nextLine);
                        flag6 = true;
                    }
                    if (flag2)
                    {
                        int num3;
                        switch (num2)
                        {
                        case 0:
                            var layerTemperature = (float)initial_print_settings.FirstRaftLayerTemperature;
                            output_writer.Write(new GCode("M109 S" + layerTemperature.ToString()));
                            output_writer.Write(new GCode("G90"));
                            BoundingBox bounds = printerProfile.PrinterSizeConstants.WarningRegion.bounds_list[0];
                            output_writer.Write(new GCode(PrinterCompatibleString.Format("G0 X{0} Y{1} Z0.5 F3600", (float)((double)bounds.max.x - 1.0), (float)(((double)bounds.min.y + (double)bounds.max.y) / 2.0 + 10.0))));
                            output_writer.Write(new GCode("G91                  ;Go relative"));
                            output_writer.Write(new GCode(PrinterCompatibleString.Format("G0 E{0} F{1}          ;prime the nozzle", initial_print_settings.PrimeAmount, 72f)));
                            output_writer.Write(new GCode("G4 S0"));
                            output_writer.Write(new GCode("G92 E0               ;reset E"));
                            output_writer.Write(new GCode("G90                  ;Go absolute"));
                            goto label_22;

                        case 1:
                            num3 = initial_print_settings.SecondRaftResetTemp ? 1 : 0;
                            break;

                        default:
                            num3 = 0;
                            break;
                        }
                        var num4 = flag5 ? 1 : 0;
                        if ((num3 & num4) != 0)
                        {
                            var filamentTemperature = (float)jobdetails.jobParams.filament_temperature;
                            output_writer.Write(new GCode(";Reset to the ideal temperature"));
                            output_writer.Write(new GCode("M104 S" + filamentTemperature.ToString()));
                            flag4 = true;
                        }
label_22:
                        ++num2;
                        flag2 = false;
                    }
                    if (!flag4 && (flag5 && nextLine.ToString().ToLower() == ";layer:0" || !flag5 && num2 > 2 || num2 > 4))
                    {
                        var filamentTemperature = (float)jobdetails.jobParams.filament_temperature;
                        output_writer.Write(new GCode(";Reset to the ideal temperature"));
                        output_writer.Write(new GCode("M104 S" + filamentTemperature.ToString()));
                        flag4 = true;
                    }
                    if (!flag6)
                    {
                        output_writer.Write(nextLine);
                    }
                }
            }
            return(true);
        }
Beispiel #18
0
        private void RaiseExtruder(IAsyncCallResult ar)
        {
            var asyncState = ar.AsyncState as PrinterObject;

            if (asyncState == null)
            {
                MainWindow.ResetToStartup();
            }

            if (ar.CallResult != CommandResult.Success)
            {
                messagebox.AddMessageToQueue("There was a problem sending commands to the printer. Please try again.");
                MainWindow.ResetToStartup();
            }
            else if (!asyncState.Info.extruder.Z_Valid)
            {
                messagebox.AddMessageToQueue("Sorry. The extruder can't move to a safe position for heating because the Z location has not be calibrated.", PopupMessageBox.MessageBoxButtons.OK);
                MainWindow.ResetToStartup();
            }
            else
            {
                var fastestPossible = asyncState.MyPrinterProfile.SpeedLimitConstants.FastestPossible;
                PrinterSizeProfile printerSizeConstants = asyncState.MyPrinterProfile.PrinterSizeConstants;
                var num1       = asyncState.Info.extruder.ishomed == Trilean.True ? 1 : 0;
                var num2       = asyncState.Info.extruder.position.pos.z;
                var stringList = new List <string>();
                if (num1 == 0)
                {
                    if (num2 > (double)printerSizeConstants.BoxTopLimitZ)
                    {
                        stringList.Add("G90");
                        stringList.Add(PrinterCompatibleString.Format("G0 Z{0} F{1}", printerSizeConstants.BoxTopLimitZ, fastestPossible));
                        num2 = printerSizeConstants.BoxTopLimitZ;
                    }
                    stringList.Add("G28");
                    stringList.Add("M114");
                }
                Manage3DInkMainWindow.PageID nextPage;
                if (CurrentDetails.current_spool.filament_location == FilamentSpool.Location.Internal)
                {
                    var boxTopLimitZ = printerSizeConstants.BoxTopLimitZ;
                    stringList.Add("G90");
                    stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F{2} Z{3}", printerSizeConstants.BackCornerPosition.x, printerSizeConstants.BackCornerPosition.y, fastestPossible, boxTopLimitZ));
                    nextPage = CurrentDetails.mode != Manage3DInkMainWindow.Mode.RemoveFilament ? Manage3DInkMainWindow.PageID.Page14_InternalSpoolInstructions : Manage3DInkMainWindow.PageID.Page16_RemoveInternalSpoolInstructions;
                }
                else
                {
                    var   num3 = num2 > 15.0 ? num2 : 15f;
                    float x;
                    float y;
                    if (asyncState.IsPausedorPausing)
                    {
                        if (num3 > (double)printerSizeConstants.BoxTopLimitZ)
                        {
                            x = printerSizeConstants.BackCornerPositionBoxTop.x;
                            y = printerSizeConstants.BackCornerPositionBoxTop.y;
                        }
                        else
                        {
                            x = printerSizeConstants.BackCornerPosition.x;
                            y = printerSizeConstants.BackCornerPosition.y;
                        }
                    }
                    else
                    {
                        x = printerSizeConstants.HomeLocation.x;
                        y = printerSizeConstants.HomeLocation.y;
                    }
                    stringList.Add("G90");
                    stringList.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F{2} Z{3}", x, y, fastestPossible, num3));
                    nextPage = Manage3DInkMainWindow.PageID.Page1_HeatingNozzle;
                }
                var num4 = (int)asyncState.SendManualGCode(new M3D.Spooling.Client.AsyncCallback(MainWindow.GotoPageAfterOperation), new Manage3DInkMainWindow.PageAfterLockDetails(asyncState, nextPage, CurrentDetails), stringList.ToArray());
            }
        }
 private void DoNextRetractionStep(IAsyncCallResult ar)
 {
     if (ar.CallResult != CommandResult.Success)
     {
         MainWindow.ResetToStartup();
     }
     else
     {
         var asyncState = ar.AsyncState as FilamentRetractingFilament.RetractionProcessData;
         var num1       = asyncState.amount_retracted / 80f;
         asyncState.progressBar.PercentComplete = num1;
         if (asyncState.amount_retracted == 80.0)
         {
             MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page3_HasRetractedFilament, CurrentDetails);
         }
         else
         {
             asyncState.amount_retracted += 10;
             var num2 = (int)asyncState.printer.SendManualGCode(new AsyncCallback(DoNextRetractionStep), asyncState, PrinterCompatibleString.Format("G0 F450 E-{0}", (object)asyncState.amount_retracted));
         }
     }
 }