Exemple #1
0
        public string PreprocessGCode(string filename, PrinterInfo printerInfo, InternalPrinterProfile printerProfile, IPreprocessor processor, JobDetails bounds, int number)
        {
            var    fileInfo      = new FileInfo(filename);
            var    directoryName = fileInfo.DirectoryName;
            var    name          = fileInfo.Name;
            var    length        = name.IndexOf('_');
            string str;

            if (length > 0)
            {
                str = name.Substring(0, length) + "_" + number + "_" + processor.Name + "_processed.gcode";
            }
            else
            {
                str = name.Substring(0, name.Length - fileInfo.Extension.Length) + "_" + number + "_" + processor.Name + "_processed.gcode";
            }

            var gcodefilename = directoryName + Path.DirectorySeparatorChar.ToString() + str;
            var input_reader  = new GCodeFileReader(filename);
            var output_writer = new GCodeFileWriter(gcodefilename);

            if (!processor.ProcessGCode(input_reader, output_writer, printerInfo.calibration, bounds, printerProfile))
            {
                return(null);
            }

            input_reader.Close();
            output_writer.Close();
            return(gcodefilename);
        }
Exemple #2
0
 public BaseController(PrinterConnection base_printer, PrinterInfo info, Logger logger, IBroadcastServer broadcastserver, InternalPrinterProfile printerProfile)
 {
     this.printerProfile  = printerProfile;
     this.base_printer    = base_printer;
     this.logger          = logger;
     printerInfo          = info;
     this.broadcastserver = broadcastserver;
 }
Exemple #3
0
        public void SetPrinterProfile(InternalPrinterProfile profile)
        {
            if (MyPrinterProfile != null)
            {
                throw new InvalidOperationException("Profile can only be set once");
            }

            MyPrinterProfile        = profile ?? throw new ArgumentNullException("profile can not equal null");
            printerInfo.ProfileName = MyPrinterProfile.ProfileName;
        }
Exemple #4
0
        public SpoolerHostedJob(JobParams jobParams, string user, InternalPrinterProfile printerProfile, bool sdOnly, ulong ulFastForward)
            : base(jobParams, user, printerProfile)
        {
            aborted         = false;
            m_bSDOnly       = sdOnly;
            m_ulFastForward = ulFastForward;
            if (m_ulFastForward == 0UL)
            {
                return;
            }

            Details.jobParams.options.dont_use_preprocessors   = true;
            Details.jobParams.options.dont_use_copy_to_spooler = true;
        }
Exemple #5
0
        internal Dictionary <string, List <FirmwareBoardVersionKVP> > GetEmbeddedFirmwareList()
        {
            var dictionary = new Dictionary <string, List <FirmwareBoardVersionKVP> >();

            foreach (VID_PID vidPid in profile_dictionary.GenerateVID_PID_List())
            {
                InternalPrinterProfile internalPrinterProfile = profile_dictionary.Get(vidPid);
                var firmwareBoardVersionKvpList = new List <FirmwareBoardVersionKVP>();
                foreach (KeyValuePair <char, FirmwareDetails> firmware in internalPrinterProfile.ProductConstants.FirmwareList)
                {
                    firmwareBoardVersionKvpList.Add(new FirmwareBoardVersionKVP(firmware.Key, firmware.Value.firmware_version));
                }

                dictionary.Add(internalPrinterProfile.ProfileName, firmwareBoardVersionKvpList);
            }
            return(dictionary);
        }
        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);
        }
Exemple #7
0
 public AbstractJob(JobParams jobParams, string user, InternalPrinterProfile printerProfile)
 {
     MyPrinterProfile          = printerProfile;
     Status                    = JobStatus.Queued;
     PreviewImageFileName      = "null";
     jobDetails                = new JobDetails();
     Details.jobParams         = jobParams;
     Details.bounds            = new BoundingBox(float.MaxValue, float.MaxValue, float.MaxValue, float.MinValue, float.MinValue, float.MinValue);
     Details.ideal_temperature = 0;
     User             = user;
     job_begin_timer  = new Stopwatch();
     InitialSpoolUsed = new FilamentSpool
     {
         filament_temperature = jobParams.filament_temperature,
         filament_type        = jobParams.filament_type
     };
 }
Exemple #8
0
 public abstract bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile);
Exemple #9
0
 public FirmwareSDPrintJob(JobParams jobParams, string user, InternalPrinterProfile printerProfile)
     : base(jobParams, user, printerProfile)
 {
     m_oswRefreshTimer    = new Stopwatch();
     PreviewImageFileName = jobParams.preview_image_file_name;
 }
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            UpdateConfigurations(calibration, printerProfile.PrinterSizeConstants);
            var flag1    = true;
            var flag2    = true;
            var flag3    = false;
            var flag4    = false;
            var num1     = 0;
            var num2     = 0;
            var num3     = 0.0;
            var position = new Position();
            var num4     = (float)num3;
            var num5     = 0.0f;

            while (true)
            {
                GCode nextLine = input_reader.GetNextLine(false);
                if (nextLine != null)
                {
                    if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && !flag1)
                    {
                        if (nextLine.HasX || nextLine.HasY)
                        {
                            flag4 = true;
                        }

                        if (nextLine.HasZ)
                        {
                            nextLine.Z += entire_z_height_offset;
                        }

                        var num6 = !nextLine.HasX ? 0.0f : nextLine.X - position.relativeX;
                        var num7 = !nextLine.HasY ? 0.0f : nextLine.Y - position.relativeY;
                        var num8 = !nextLine.HasZ ? 0.0f : nextLine.Z - position.relativeZ;
                        var num9 = !nextLine.HasE ? 0.0f : nextLine.E - position.relativeE;
                        position.absoluteX += num6;
                        position.absoluteY += num7;
                        position.absoluteZ += num8;
                        position.absoluteE += num9;
                        position.relativeX += num6;
                        position.relativeY += num7;
                        position.relativeZ += num8;
                        position.relativeE += num9;
                        if (nextLine.hasF)
                        {
                            position.F = nextLine.F;
                        }

                        if (num8 > 1.40129846432482E-45 || num8 < -1.40129846432482E-45)
                        {
                            if (!flag3)
                            {
                                num2 = 1;
                            }
                            else
                            {
                                ++num2;
                            }

                            flag2 = num2 == 0 || num2 == 1;
                        }
                        var num10 = (float)Math.Sqrt(num6 * (double)num6 + num7 * (double)num7);
                        var num11 = 1;
                        if (num10 > 2.0)
                        {
                            num11 = (int)(num10 / 2.0);
                        }

                        var num12 = position.absoluteX - num6;
                        var num13 = position.absoluteY - num7;
                        var num14 = position.relativeX - num6;
                        var num15 = position.relativeY - num7;
                        var num16 = position.relativeZ - num8;
                        var num17 = position.relativeE - num9;
                        var num18 = num6 / num10;
                        var num19 = num7 / num10;
                        var num20 = num8 / num10;
                        var num21 = num9 / num10;
                        if (num9 > 0.0)
                        {
                            flag3 = true;
                        }

                        var num22 = flag2 ? 1 : 0;
                        if (num9 > 0.0)
                        {
                            for (var index = 1; index < num11 + 1; ++index)
                            {
                                float x;
                                float y;
                                float num23;
                                float num24;
                                float num25;
                                float num26;
                                if (index == num11)
                                {
                                    x     = position.absoluteX;
                                    y     = position.absoluteY;
                                    num23 = position.relativeX;
                                    num24 = position.relativeY;
                                    num25 = position.relativeZ;
                                    num26 = position.relativeE;
                                }
                                else
                                {
                                    x     = num12 + index * 2f * num18;
                                    y     = num13 + index * 2f * num19;
                                    num23 = num14 + index * 2f * num18;
                                    num24 = num15 + index * 2f * num19;
                                    num25 = num16 + index * 2f * num20;
                                    num26 = num17 + index * 2f * num21;
                                }
                                var adjustmentRequired = GetHeightAdjustmentRequired(x, y);
                                if (index != num11)
                                {
                                    var code = new GCode
                                    {
                                        G = nextLine.G
                                    };
                                    if (nextLine.HasX)
                                    {
                                        code.X = (float)(position.relativeX - (double)num6 + (num23 - (double)num14));
                                    }

                                    if (nextLine.HasY)
                                    {
                                        code.Y = (float)(position.relativeY - (double)num7 + (num24 - (double)num15));
                                    }

                                    if (nextLine.hasF && index == 1)
                                    {
                                        code.F = nextLine.F;
                                    }

                                    if (flag4)
                                    {
                                        code.Z = (float)(position.relativeZ - (double)num8 + (num25 - (double)num16)) + adjustmentRequired;
                                    }
                                    else if (nextLine.HasZ && (num8 > 1.40129846432482E-45 || num8 < -1.40129846432482E-45))
                                    {
                                        code.Z = (float)(position.relativeZ - (double)num8 + (num25 - (double)num16));
                                    }

                                    code.E = (float)(position.relativeE - (double)num9 + (num26 - (double)num17)) + num4;
                                    output_writer.Write(code);
                                }
                                else
                                {
                                    if (flag4)
                                    {
                                        if (nextLine.HasZ)
                                        {
                                            nextLine.Z += adjustmentRequired;
                                        }
                                        else
                                        {
                                            nextLine.Z = num16 + num8 + adjustmentRequired;
                                        }
                                    }
                                    nextLine.E += num4;
                                }
                                num5 = num26;
                            }
                        }
                        else
                        {
                            if (flag4)
                            {
                                var num23 = flag2 ? 1 : 0;
                                var adjustmentRequired = GetHeightAdjustmentRequired(position.absoluteX, position.absoluteY);
                                if (nextLine.HasZ)
                                {
                                    nextLine.Z += adjustmentRequired;
                                }
                                else
                                {
                                    nextLine.Z = position.relativeZ + adjustmentRequired;
                                }
                            }
                            if (nextLine.HasE)
                            {
                                nextLine.E += num4;
                            }

                            num5 = position.relativeE;
                        }
                    }
                    else if (nextLine.HasG && nextLine.G == 92)
                    {
                        if (nextLine.HasE)
                        {
                            position.relativeE = nextLine.E;
                        }

                        if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                        {
                            if (nextLine.HasX)
                            {
                                position.relativeX = nextLine.X;
                            }

                            if (nextLine.HasY)
                            {
                                position.relativeY = nextLine.Y;
                            }

                            if (nextLine.HasZ)
                            {
                                position.relativeZ = nextLine.Z;
                            }
                        }
                        if (!nextLine.HasE && !nextLine.HasX && (!nextLine.HasY && !nextLine.HasZ))
                        {
                            position.relativeE = 0.0f;
                            if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                            {
                                position.relativeX = 0.0f;
                                position.relativeY = 0.0f;
                                position.relativeZ = 0.0f;
                            }
                        }
                    }
                    else if (nextLine.HasG && nextLine.G == 90)
                    {
                        flag1 = false;
                    }
                    else if (nextLine.HasG && nextLine.G == 91)
                    {
                        flag1 = true;
                    }
                    else if (nextLine.HasG && nextLine.G == 28)
                    {
                        position.relativeX = position.absoluteX = 54f;
                        position.relativeY = position.absoluteY = 50f;
                    }
                    output_writer.Write(nextLine);
                    ++num1;
                }
                else
                {
                    break;
                }
            }
            return(true);
        }
 public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
 {
     try
     {
         var uint32      = (int)BitConverter.ToUInt32(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FirmwareVersion").EepromAddr);
         var eepromAddr1 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationBLO").EepromAddr;
         var eepromAddr2 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationBRO").EepromAddr;
         var eepromAddr3 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationFLO").EepromAddr;
         var eepromAddr4 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationFRO").EepromAddr;
         var eepromAddr5 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationZO").EepromAddr;
         var single1     = BitConverter.ToSingle(eeprom, eepromAddr1);
         var single2     = BitConverter.ToSingle(eeprom, eepromAddr2);
         var single3     = BitConverter.ToSingle(eeprom, eepromAddr3);
         var single4     = BitConverter.ToSingle(eeprom, eepromAddr4);
         var single5     = BitConverter.ToSingle(eeprom, eepromAddr5);
         var num1        = 0.0f;
         var num2        = 2015080402;
         if ((uint)uint32 < (uint)num2)
         {
             if (Math.Abs(single1) > 1.40129846432482E-45 || Math.Abs(single2) > 1.40129846432482E-45 || (Math.Abs(single3) > 1.40129846432482E-45 || Math.Abs(single4) > 1.40129846432482E-45) || Math.Abs(single5) > 1.40129846432482E-45)
             {
                 try
                 {
                     StreamWriter text = File.CreateText(Path.Combine(Paths.SpoolerFolder, "user_offsets-" + serial_number + ".txt"));
                     text.WriteLine("Old Bed level offsets");
                     text.WriteLine("  Back Left: " + single1.ToString("0.###"));
                     text.WriteLine("  Back Right: " + single2.ToString("0.###"));
                     text.WriteLine("  Front Left: " + single3.ToString("0.###"));
                     text.WriteLine("  Front Right: " + single4.ToString("0.###"));
                     text.WriteLine("  Z: " + single5.ToString("0.###"));
                     text.Close();
                 }
                 catch (Exception ex)
                 {
                     ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateResetOffsets.CheckForUpdate " + ex.Message, "Exception");
                 }
             }
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr1, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr2, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr3, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr4, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr5, BitConverter.GetBytes(num1));
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateResetOffsets.CheckForUpdate " + ex.Message, "Exception");
         return(false);
     }
     return(true);
 }
Exemple #12
0
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            var backlashX = calibration.BACKLASH_X;
            var backlashY = calibration.BACKLASH_Y;
            var flag      = true;
            var position  = new Position();
            var num1      = 1000f;

            BackLashPreprocessor.Direction direction1 = BackLashPreprocessor.Direction.Neither;
            BackLashPreprocessor.Direction direction2 = BackLashPreprocessor.Direction.Neither;
            var num2 = 0.0f;
            var num3 = 0.0f;

            for (GCode nextLine = input_reader.GetNextLine(false); nextLine != null; nextLine = input_reader.GetNextLine(false))
            {
                if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && !flag)
                {
                    if (nextLine.hasF)
                    {
                        num1 = nextLine.F;
                    }

                    var num4 = !nextLine.HasX ? 0.0f : nextLine.X - position.relativeX;
                    var num5 = !nextLine.HasY ? 0.0f : nextLine.Y - position.relativeY;
                    var num6 = !nextLine.HasZ ? 0.0f : nextLine.Z - position.relativeZ;
                    var num7 = !nextLine.HasE ? 0.0f : nextLine.E - position.relativeE;
                    BackLashPreprocessor.Direction direction3 = num4 <= 1.40129846432482E-45 ? num4 >= -1.40129846432482E-45 ? direction1 : BackLashPreprocessor.Direction.Negative : BackLashPreprocessor.Direction.Positive;
                    BackLashPreprocessor.Direction direction4 = num5 <= 1.40129846432482E-45 ? num5 >= -1.40129846432482E-45 ? direction2 : BackLashPreprocessor.Direction.Negative : BackLashPreprocessor.Direction.Positive;
                    var code = new GCode
                    {
                        G = nextLine.G
                    };
                    if (direction3 != direction1 && direction1 != BackLashPreprocessor.Direction.Neither || direction4 != direction2 && direction2 != BackLashPreprocessor.Direction.Neither)
                    {
                        if (direction3 != direction1 && direction1 != BackLashPreprocessor.Direction.Neither)
                        {
                            num2 += direction3 == BackLashPreprocessor.Direction.Positive ? backlashX : -backlashX;
                        }

                        if (direction4 != direction2 && direction2 != BackLashPreprocessor.Direction.Neither)
                        {
                            num3 += direction4 == BackLashPreprocessor.Direction.Positive ? backlashY : -backlashY;
                        }

                        var num8 = position.relativeX + num2;
                        var num9 = position.relativeY + num3;
                        code.X = num8;
                        code.Y = num9;
                        code.F = calibration.BACKLASH_SPEED;
                        output_writer.Write(code);
                        nextLine.F = num1;
                    }
                    if (nextLine.HasX)
                    {
                        nextLine.X += num2;
                    }

                    if (nextLine.HasY)
                    {
                        nextLine.Y += num3;
                    }

                    position.relativeX += num4;
                    position.relativeY += num5;
                    position.relativeZ += num6;
                    position.relativeE += num7;
                    if (nextLine.hasF)
                    {
                        position.F = nextLine.F;
                    }

                    position.absoluteX += num4;
                    position.absoluteY += num5;
                    position.absoluteZ += num6;
                    position.absoluteE += num7;
                    direction1          = direction3;
                    direction2          = direction4;
                }
                else if (nextLine.HasG && nextLine.G == 92)
                {
                    if (nextLine.HasE)
                    {
                        position.relativeE = nextLine.E;
                    }

                    if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                    {
                        if (nextLine.HasX)
                        {
                            position.relativeX = nextLine.X;
                        }

                        if (nextLine.HasY)
                        {
                            position.relativeY = nextLine.Y;
                        }

                        if (nextLine.HasZ)
                        {
                            position.relativeZ = nextLine.Z;
                        }
                    }
                    if (!nextLine.HasE && !nextLine.HasX && (!nextLine.HasY && !nextLine.HasZ))
                    {
                        position.relativeE = 0.0f;
                        if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                        {
                            position.relativeX = 0.0f;
                            position.relativeY = 0.0f;
                            position.relativeZ = 0.0f;
                        }
                    }
                }
                else if (nextLine.HasG && nextLine.G == 90)
                {
                    flag = false;
                }
                else if (nextLine.HasG && nextLine.G == 91)
                {
                    flag = true;
                }
                else if (nextLine.HasG && nextLine.G == 28)
                {
                    position.relativeX = position.absoluteX = 54f;
                    position.relativeY = position.absoluteY = 50f;
                }
                output_writer.Write(nextLine);
            }
            return(true);
        }
Exemple #13
0
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            var wave_step       = 0;
            var num1            = 0;
            var flag1           = true;
            var flag2           = true;
            var flag3           = false;
            var num2            = 0;
            var num3            = 0.0;
            var position        = new Position();
            var num4            = (float)num3;
            var num5            = 0.0f;
            var firstLayerTemp  = jobdetails.jobParams.preprocessor.bonding.FirstLayerTemp;
            var secondLayerTemp = jobdetails.jobParams.preprocessor.bonding.SecondLayerTemp;

            while (true)
            {
                GCode nextLine = input_reader.GetNextLine(false);
                if (nextLine != null)
                {
                    if (!jobdetails.jobParams.options.use_wave_bonding)
                    {
                        output_writer.Write(nextLine);
                    }
                    else
                    {
                        if (nextLine.ToString().Contains(";LAYER:"))
                        {
                            int num6;
                            try
                            {
                                num6 = int.Parse(nextLine.ToString().Substring(7));
                            }
                            catch (Exception ex)
                            {
                                num6 = 0;
                                ErrorLogger.LogException("Exception in BondingPreProcessor.ProcessGcode " + ex.Message, ex);
                            }
                            if (num6 < num1)
                            {
                                num1 = num6;
                            }

                            flag2 = num6 == num1;
                        }
                        if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && !flag1)
                        {
                            if (nextLine.HasX || nextLine.HasY)
                            {
                                flag3 = true;
                            }

                            var num6 = !nextLine.HasX ? 0.0f : nextLine.X - position.relativeX;
                            var num7 = !nextLine.HasY ? 0.0f : nextLine.Y - position.relativeY;
                            var num8 = !nextLine.HasZ ? 0.0f : nextLine.Z - position.relativeZ;
                            var num9 = !nextLine.HasE ? 0.0f : nextLine.E - position.relativeE;
                            position.absoluteX += num6;
                            position.absoluteY += num7;
                            position.absoluteZ += num8;
                            position.absoluteE += num9;
                            position.relativeX += num6;
                            position.relativeY += num7;
                            position.relativeZ += num8;
                            position.relativeE += num9;
                            if (nextLine.hasF)
                            {
                                position.F = nextLine.F;
                            }

                            var num10 = (float)Math.Sqrt(num6 * (double)num6 + num7 * (double)num7);
                            var num11 = 1;
                            if (num10 > 1.25)
                            {
                                num11 = (int)(num10 / 1.25);
                            }

                            var num12 = position.absoluteX - num6;
                            var num13 = position.absoluteY - num7;
                            var num14 = position.relativeX - num6;
                            var num15 = position.relativeY - num7;
                            var num16 = position.relativeZ - num8;
                            var num17 = position.relativeE - num9;
                            var num18 = num6 / num10;
                            var num19 = num7 / num10;
                            var num20 = num8 / num10;
                            var num21 = num9 / num10;
                            if (flag2 && num9 > 0.0)
                            {
                                for (var index = 1; index < num11 + 1; ++index)
                                {
                                    float num22;
                                    float num23;
                                    float num24;
                                    float num25;
                                    if (index == num11)
                                    {
                                        var absoluteX = (double)position.absoluteX;
                                        var absoluteY = (double)position.absoluteY;
                                        num22 = position.relativeX;
                                        num23 = position.relativeY;
                                        num24 = position.relativeZ;
                                        num25 = position.relativeE;
                                    }
                                    else
                                    {
                                        num22 = num14 + index * 1.25f * num18;
                                        num23 = num15 + index * 1.25f * num19;
                                        num24 = num16 + index * 1.25f * num20;
                                        num25 = num17 + index * 1.25f * num21;
                                    }
                                    var num26 = num25 - (double)num5;
                                    if (index != num11)
                                    {
                                        var code = new GCode
                                        {
                                            G = nextLine.G
                                        };
                                        if (nextLine.HasX)
                                        {
                                            code.X = (float)(position.relativeX - (double)num6 + (num22 - (double)num14));
                                        }

                                        if (nextLine.HasY)
                                        {
                                            code.Y = (float)(position.relativeY - (double)num7 + (num23 - (double)num15));
                                        }

                                        if (nextLine.hasF && index == 1)
                                        {
                                            code.F = nextLine.F;
                                        }

                                        if (flag3)
                                        {
                                            code.Z = (float)(position.relativeZ - (double)num8 + (num24 - (double)num16)) + CurrentAdjustmentsZ(ref wave_step);
                                        }
                                        else if (nextLine.HasZ && (num8 > 1.40129846432482E-45 || num8 < -1.40129846432482E-45))
                                        {
                                            code.Z = (float)(position.relativeZ - (double)num8 + (num24 - (double)num16));
                                        }

                                        code.E = (float)(position.relativeE - (double)num9 + (num25 - (double)num17)) + num4;
                                        output_writer.Write(code);
                                    }
                                    else
                                    {
                                        if (flag3)
                                        {
                                            if (nextLine.HasZ)
                                            {
                                                nextLine.Z += CurrentAdjustmentsZ(ref wave_step);
                                            }
                                            else
                                            {
                                                nextLine.Z = num16 + num8 + CurrentAdjustmentsZ(ref wave_step);
                                            }
                                        }
                                        nextLine.E += num4;
                                    }
                                    num5 = num25;
                                }
                            }
                        }
                        else if (nextLine.HasG && nextLine.G == 92)
                        {
                            if (nextLine.HasE)
                            {
                                position.relativeE = nextLine.E;
                            }

                            if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                            {
                                if (nextLine.HasX)
                                {
                                    position.relativeX = nextLine.X;
                                }

                                if (nextLine.HasY)
                                {
                                    position.relativeY = nextLine.Y;
                                }

                                if (nextLine.HasZ)
                                {
                                    position.relativeZ = nextLine.Z;
                                }
                            }
                            if (!nextLine.HasE && !nextLine.HasX && (!nextLine.HasY && !nextLine.HasZ))
                            {
                                position.relativeE = 0.0f;
                                if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                                {
                                    position.relativeX = 0.0f;
                                    position.relativeY = 0.0f;
                                    position.relativeZ = 0.0f;
                                }
                            }
                        }
                        else if (nextLine.HasG && nextLine.G == 90)
                        {
                            flag1 = false;
                        }
                        else if (nextLine.HasG && nextLine.G == 91)
                        {
                            flag1 = true;
                        }

                        output_writer.Write(nextLine);
                        ++num2;
                    }
                }
                else
                {
                    break;
                }
            }
            return(true);
        }
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var eepromAddr1 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitX").EepromAddr;
                var eepromAddr2 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitY").EepromAddr;
                var eepromAddr3 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitZ").EepromAddr;
                var eepromAddr4 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEp").EepromAddr;
                var eepromAddr5 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEn").EepromAddr;
                var single1     = BitConverter.ToSingle(eeprom, eepromAddr1);
                var single2     = BitConverter.ToSingle(eeprom, eepromAddr2);
                var single3     = BitConverter.ToSingle(eeprom, eepromAddr3);
                var single4     = BitConverter.ToSingle(eeprom, eepromAddr4);
                var single5     = BitConverter.ToSingle(eeprom, eepromAddr5);
                if (IsNotValid(single1, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_X, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_X))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr1, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_X));
                }

                if (IsNotValid(single2, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_Y, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_Y))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr2, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_Y));
                }

                if (IsNotValid(single3, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_Z, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_Z))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr3, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_Z));
                }

                if (IsNotValid(single4, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_E_Positive, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_E_Positive))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr4, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_E_Positive));
                }

                if (IsNotValid(single5, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_E_Negative, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_E_Negative))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr5, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_E_Negative));
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
        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);
        }
Exemple #16
0
 public CreationParameters(PrinterInfo printerInfo, InternalPrinterProfile printerProfile, EventHandler <JobCreateResult> onProcessFinished)
 {
     this.printerInfo       = printerInfo;
     this.printerProfile    = printerProfile;
     this.onProcessFinished = onProcessFinished;
 }
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            var num1 = 1;
            InitialPrintPreProcessorData initialPrint = jobdetails.jobParams.preprocessor.initialPrint;

            ProcessGCode_AddStartGCode(input_reader, output_writer, jobdetails.jobParams.options, calibration, printerProfile, initialPrint);
            var num2 = ProcessGCode_HelperLayerComments(input_reader, output_writer, jobdetails, printerProfile, initialPrint) ? 1 : 0;
            var num3 = num1 & num2;

            if (num3 == 0)
            {
                return(num3 != 0);
            }

            ProcessGCode_EndGCode(output_writer, jobdetails, printerProfile);
            return(num3 != 0);
        }
 private void ProcessGCode_EndGCode(GCodeFileWriter output_writer, JobDetails jobdetails, InternalPrinterProfile printerProfile)
 {
     foreach (var s in GCodeInitializationPreprocessor.GenerateEndGCode(jobdetails, printerProfile, true))
     {
         output_writer.Write(new GCode(s));
     }
 }
        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"));
        }
Exemple #20
0
 public SaveGCodeToFileJob(JobParams jobParams, string user, InternalPrinterProfile printerProfile)
     : base(jobParams, user, printerProfile)
 {
 }
Exemple #21
0
 public AbstractPreprocessedJob(JobParams jobParams, string user, InternalPrinterProfile printerProfile)
     : base(jobParams, user, printerProfile)
 {
 }
Exemple #22
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var serialDate = GetSerialDate(serial_number);
                switch (eeprom[printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr])
                {
                case 0:
                case byte.MaxValue:
                    FanConstValues.FanType index = FanConstValues.FanType.HengLiXin;
                    if (serialDate >= 150602)
                    {
                        index = FanConstValues.FanType.Shenzhew;
                    }

                    FanConstValues.FanValues fanConstant = FanConstValues.FanConstants[index];
                    var num    = (byte)index;
                    var offset = fanConstant.Offset;
                    var scale  = fanConstant.Scale;
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr, BitConverter.GetBytes(num));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr, BitConverter.GetBytes(offset));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr, BitConverter.GetBytes(scale));
                    break;
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstrunUpdateDefaulFan.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
            return(true);
        }
Exemple #23
0
        private ProcessReturn PrepareJobForPrinter(PrinterInfo printerInfo, InternalPrinterProfile printerProfile, List <MessageType> warnings)
        {
            var flag    = false;
            var jobGuid = Details.jobParams.jobGuid;

            if (!Details.jobParams.options.dont_use_copy_to_spooler)
            {
                GCodeFilename = Path.Combine(Paths.QueuePath, jobGuid);
                if (Details.jobParams.gcodefile.ToLower().IndexOf("backlash_calibration") > -1)
                {
                    flag = true;
                    BacklashCalibrationPrint.Create(GCodeFilename, Details.jobParams.filament_type, printerProfile.PrinterSizeConstants.HomeLocation.x, printerProfile.PrinterSizeConstants.HomeLocation.y);
                }
                else
                {
                    File.Copy(Details.jobParams.gcodefile, GCodeFilename);
                }
            }
            else
            {
                GCodeFilename = Details.jobParams.gcodefile;
            }

            if (!string.IsNullOrEmpty(Details.jobParams.preview_image_file_name))
            {
                if (Details.jobParams.preview_image_file_name != "null")
                {
                    try
                    {
                        var str = Details.jobParams.preview_image_file_name.Substring(Details.jobParams.preview_image_file_name.LastIndexOf("."));
                        PreviewImageFileName = Path.Combine(Paths.QueuePath, jobGuid) + str;
                        File.Copy(Details.jobParams.preview_image_file_name, PreviewImageFileName, true);
                        goto label_10;
                    }
                    catch (Exception ex)
                    {
                        PreviewImageFileName = "null";
                        goto label_10;
                    }
                }
            }
            PreviewImageFileName = "null";
label_10:
            if (!flag && !Details.jobParams.options.dont_use_preprocessors)
            {
                switch (GatherInitialInformation(GCodeFilename, printerProfile))
                {
                case AbstractPreprocessedJob.PrintJobWarning.Error_OutOfBounds:
                    return(ProcessReturn.FAILURE_OUT_OF_BOUNDS);

                case AbstractPreprocessedJob.PrintJobWarning.Warning_ABS_Size:
                    warnings.Add(MessageType.WarningABSPrintLarge);
                    break;
                }
                var num = 0;
                foreach (IPreprocessor preprocessor in printerProfile.PreprocessorConstants.preprocessor_list)
                {
                    try
                    {
                        GCodeFilename = PreprocessGCode(GCodeFilename, printerInfo, printerProfile, preprocessor, Details, ++num);
                    }
                    catch (Exception ex)
                    {
                        ErrorLogger.LogException(string.Format(">> {0}::", preprocessor.Name), ex);
                        throw new AbstractPreprocessedJob.PreprocessorException(string.Format("{0}::{1}", preprocessor.Name, ex.Message));
                    }
                }
            }
            Details.jobParams.gcodefile = GCodeFilename;
            return(ProcessReturn.SUCCESS);
        }
Exemple #24
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var str        = serial_number.Substring(0, 13);
                var eepromAddr = (int)printerProfile.EEPROMConstants.GetEepromInfo("ExtruderCurrent").EepromAddr;
                if (!(str == "BK15033001100") && !(str == "BK15040201050") && (!(str == "BK15040301050") && !(str == "BK15040602050")) && (!(str == "BK15040801050") && !(str == "BK15040802100") && (!(str == "GR15032702100") && !(str == "GR15033101100"))) && (!(str == "GR15040601100") && !(str == "GR15040701100") && !(str == "OR15032701100")))
                {
                    if (!(str == "SL15032601050"))
                    {
                        goto label_7;
                    }
                }
                if (BitConverter.ToUInt16(eeprom, eepromAddr) != 500)
                {
                    ushort num = 500;
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr, BitConverter.GetBytes(num));
                    eeprom = bootloader_conn.ReadAllReadableEEPROM();
                    return(BitConverter.ToUInt16(eeprom, eepromAddr) == 500);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateSetBatchto500ma.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
label_7:
            return(true);
        }
Exemple #25
0
        private AbstractPreprocessedJob.PrintJobWarning GatherInitialInformation(string filename, InternalPrinterProfile printerProfile)
        {
            GCodeFileReader gcodeFileReader;

            try
            {
                gcodeFileReader = new GCodeFileReader(filename);
                if (!gcodeFileReader.IsOpen)
                {
                    throw new Exception(string.Format("Unable to open file: {0}", filename));
                }
            }
            catch (ThreadAbortException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception("PrinterJob.GatherInitialInformation ", ex);
            }
            EstimatedFilamentUsed = 0.0f;
            if (gcodeFileReader != null)
            {
                var   boundsCheckXy = Details.jobParams.options.bounds_check_xy;
                var   flag          = false;
                var   p             = new Vector3D(float.NaN, float.NaN, float.NaN);
                GCode nextLine;
                while ((nextLine = gcodeFileReader.GetNextLine(false)) != null)
                {
                    if (nextLine.HasG)
                    {
                        if (nextLine.G == 90)
                        {
                            flag = true;
                        }
                        else if (nextLine.G == 91)
                        {
                            flag = false;
                        }
                        else if (((nextLine.G == 0 ? 1 : (nextLine.G == 1 ? 1 : 0)) & (flag ? 1 : 0)) != 0)
                        {
                            if (nextLine.HasE)
                            {
                                if (flag)
                                {
                                    EstimatedFilamentUsed = nextLine.E;
                                }
                                else
                                {
                                    EstimatedFilamentUsed += nextLine.E;
                                }
                            }
                            if (nextLine.HasZ)
                            {
                                p.z = nextLine.Z;
                                if (nextLine.Z < (double)Details.bounds.min.z)
                                {
                                    Details.bounds.min.z = nextLine.Z;
                                }

                                if (nextLine.Z > (double)Details.bounds.max.z)
                                {
                                    Details.bounds.max.z = nextLine.Z;
                                }
                            }
                            if (boundsCheckXy)
                            {
                                if (nextLine.HasX)
                                {
                                    p.x = nextLine.X;
                                    if (nextLine.X < (double)Details.bounds.min.x)
                                    {
                                        Details.bounds.min.x = nextLine.X;
                                    }

                                    if (nextLine.X > (double)Details.bounds.max.x)
                                    {
                                        Details.bounds.max.x = nextLine.X;
                                    }
                                }
                                if (nextLine.HasY)
                                {
                                    p.y = nextLine.Y;
                                    if (nextLine.Y < (double)Details.bounds.min.y)
                                    {
                                        Details.bounds.min.y = nextLine.Y;
                                    }

                                    if (nextLine.Y > (double)Details.bounds.max.y)
                                    {
                                        Details.bounds.max.y = nextLine.Y;
                                    }
                                }
                            }
                            if (!printerProfile.PrinterSizeConstants.PrintableRegion.InRegionNaN(p))
                            {
                                gcodeFileReader.Close();
                                return(AbstractPreprocessedJob.PrintJobWarning.Error_OutOfBounds);
                            }
                        }
                        if (nextLine != null && nextLine.ToString().IndexOf("ideal temp:") > -1)
                        {
                            Details.ideal_temperature = (int)float.Parse(Regex.Match(nextLine.ToString(), "ideal temp:([-.0-9]+)").Groups[1].Value);
                        }
                    }
                    if (nextLine != null && nextLine.ToString().IndexOf("ideal temp:") > -1)
                    {
                        Details.ideal_temperature = (int)float.Parse(Regex.Match(nextLine.ToString(), "ideal temp:([-.0-9]+)").Groups[1].Value);
                    }
                }
                gcodeFileReader.Close();
                if (Details.jobParams.filament_type == FilamentSpool.TypeEnum.ABS && (Details.bounds.max.x - (double)Details.bounds.min.x > printerProfile.PrinterSizeConstants.ABSWarningDim || Details.bounds.max.y - (double)Details.bounds.min.y > printerProfile.PrinterSizeConstants.ABSWarningDim || Details.bounds.max.z - (double)Details.bounds.min.z > printerProfile.PrinterSizeConstants.ABSWarningDim))
                {
                    return(AbstractPreprocessedJob.PrintJobWarning.Warning_ABS_Size);
                }
            }
            return(AbstractPreprocessedJob.PrintJobWarning.Job_OK);
        }
Exemple #26
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var num  = eeprom[printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr];
                var flag = false;
                FanConstValues.FanType   index;
                FanConstValues.FanValues fanConstant;
                if (Enum.IsDefined(typeof(FanConstValues.FanType), (int)num))
                {
                    index       = (FanConstValues.FanType)num;
                    fanConstant = FanConstValues.FanConstants[index];
                }
                else
                {
                    index       = FanConstValues.FanType.None;
                    fanConstant = FanConstValues.FanConstants[FanConstValues.FanType.HengLiXin];
                }
                var fanValues = new FanConstValues.FanValues
                {
                    Scale  = BitConverter.ToSingle(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr),
                    Offset = eeprom[(int)printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr]
                };
                if (Math.Abs(fanValues.Offset - fanConstant.Offset) >= 1)
                {
                    flag = true;
                }

                if (Math.Abs(fanValues.Scale - fanConstant.Scale) >= 1.40129846432482E-45)
                {
                    flag = true;
                }

                if (flag)
                {
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr, BitConverter.GetBytes((byte)index));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr, BitConverter.GetBytes((byte)fanConstant.Offset));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr, BitConverter.GetBytes(fanConstant.Scale));
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateFanValues.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
            return(true);
        }
Exemple #27
0
 internal abstract bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile);
 public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
 {
     try
     {
         var uint32 = (int)BitConverter.ToUInt32(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FirmwareVersion").EepromAddr);
         var num1   = 1500f;
         var num2   = 2015080402;
         if ((uint)uint32 < (uint)num2)
         {
             bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("BacklashSpeed").EepromAddr, BitConverter.GetBytes(num1));
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateSetBacklash1500.CheckForUpdate " + ex.Message, "Exception");
         return(false);
     }
     return(true);
 }
Exemple #29
0
        public BootloaderController(int bootloader_version, PrinterConnection base_printer, PrinterInfo info, Logger logger, ThreadSafeVariable <bool> shared_shutdown, IBroadcastServer broadcastserver, InternalPrinterProfile printerProfile)
            : base(base_printer, info, logger, broadcastserver, printerProfile)
        {
            PersistantDetails.bootloader_version = bootloader_version;
            if (bootloader_version >= 1 && bootloader_version <= 5)
            {
                mInterfaceVersion = BootloaderController.BootloaderInterfaceVersion.V1;
            }
            else
            {
                if (bootloader_version < 6 || bootloader_version > 8)
                {
                    throw new Exception(string.Format("Unsupported Bootloader Interface - {0}", bootloader_version));
                }

                mInterfaceVersion = BootloaderController.BootloaderInterfaceVersion.V2;
            }
            mCheckedFirmwareStatus = new Dictionary <char, BootloaderController.FirmwareStatus>();
            foreach (KeyValuePair <char, FirmwareDetails> firmware in MyPrinterProfile.ProductConstants.FirmwareList)
            {
                mCheckedFirmwareStatus.Add(firmware.Key, BootloaderController.FirmwareStatus.Unknown);
            }

            StartBootloaderMode();
        }