예제 #1
0
        public static void M576GetFilamentInformation(GCode gcode, FirmwareController connection)
        {
            connection.ProcessFilamentDataFromEEPROM();
            FilamentSpool currentFilament = connection.GetCurrentFilament();

            connection.WriteLog(string.Format(">> ok S:{0} P:{1} T:{2} E:{3} I:{4} UID:{5}", (int)currentFilament.filament_color_code, currentFilament.filament_type, currentFilament.filament_temperature - 100, currentFilament.estimated_filament_length_printed, currentFilament.filament_size, currentFilament.filament_uid), Logger.TextType.Read);
        }
예제 #2
0
        public override GCode GetNextCommand()
        {
            OnGetNextCommand();
            if (Status != JobStatus.Cancelled && m_oGCodeReader != null && m_oGCodeReader.IsOpen)
            {
                Status = JobStatus.Printing;
                GCode nextLine = m_oGCodeReader.GetNextLine(true);
                if (nextLine != null)
                {
                    if (nextLine.hasM && nextLine.M == 109 || nextLine.M == 116 || nextLine.HasG && nextLine.G == 4)
                    {
                        Status = JobStatus.Heating;
                    }

                    if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && nextLine.HasE)
                    {
                        CurrentPrintJobExtrusion = nextLine.E;
                    }

                    ++CurrentLineNumber;
                    nextLine.N = (int)(CurrentLineNumber % 65536UL);
                    return(nextLine);
                }
                endreadched.Value = true;
            }
            return(null);
        }
예제 #3
0
        public override bool Connect()
        {
            con.isMarlin = con.isRepetier = con.isSprinter = false;
            connected    = true;
            virtualPrinter.open(int.Parse(baudRate));
            GCode gc = new GCode();

            gc.Parse("M105");
            virtualPrinter.receiveLine(gc);
            connected = true;
            if (transferProtocol < 2)
            {
                binaryVersion = 0;
            }
            else
            {
                binaryVersion = transferProtocol - 1;
            }
            con.binaryVersion = binaryVersion;
            readyForNextSend  = true;
            lock (nackLines)
            {
                nackLines.Clear();
            }
            linesSend = errorsReceived = bytesSend = 0;
            gc.Parse("N0 M110");
            virtualPrinter.receiveLine(gc);
            gc.Parse("M115");
            virtualPrinter.receiveLine(gc);
            gc.Parse("M105");
            virtualPrinter.receiveLine(gc);
            con.FireConnectionChange(Trans.T("L_CONNECTED") + ":" + con.printerName);
            Main.main.Invoke(Main.main.UpdateJobButtons);
            return(true);
        }
예제 #4
0
        public override void InjectManualCommand(string command)
        {
            if (!connected)
            {
                return;
            }
            GCode gc = new GCode();

            gc.Parse(command);
            if (gc.comment)
            {
                return;
            }
            lock (history)
                injectCommands.AddLast(gc);
            if (job.dataComplete == false)
            {
                if (injectCommands.Count == 0)
                {
                    con.firePrinterAction(Trans.T("L_IDLE"));
                }
                else
                {
                    con.firePrinterAction(Trans.T1("L_X_COMMANDS_WAITING", injectCommands.Count.ToString()));
                }
            }
        }
예제 #5
0
        private GCode ReadGCodeLineAscii(StreamReader readascii, bool excludeComments)
        {
            var gcode = new GCode();

            do
            {
                string line;
                try
                {
                    line = readascii.ReadLine();
                }
                catch (Exception ex)
                {
                    ErrorLogger.LogErrorMsg("Exception in GCodeReader.StartReading 1 " + ex.Message, "Exception");
                    return(null);
                }
                if (line == null)
                {
                    return(null);
                }

                gcode.Parse(line);
            }while (gcode.comment & excludeComments);
            return(gcode);
        }
 public bool Init()
 {
     try
     {
         settings = new XmlReaderSettings()
         {
             ValidationType = ValidationType.None, ProhibitDtd = false, XmlResolver = null
         };
         DP    = new DynamicPowder((int)PrinterSetting.PrintAreaWidth, (int)PrinterSetting.PrintAreaDepth);
         gCode = new GCode(gcodePath);
         //dxf = new DXF(Main.printerSettings.PrintAreaWidth, Main.printerSettings.PrintAreaDepth, dxfPath, encryptDXF);
         dxf         = new DXF(230, 230, dxfPath, encryptDXF);
         layerAmount = GetLayerAmount();
         return(true);
     }
     catch (Exception ex)
     {
         //Main.main.LogMessage("3WL Data", "Error encountered: Init");
         //Main.main.LogMessage("3WL Data", ex.Message);
         //Main.main.LogMessage("3WL Data", ex.ToString());
         Console.WriteLine("3WL Data, Error encountered: Init");
         Console.WriteLine("3WL Data", ex.ToString());
         SVGTo3WL.logFile.writer.WriteLine("3WL Data, Error encountered: Init");
         SVGTo3WL.logFile.writer.WriteLine("3WL Data", ex.ToString());
         return(false);
     }
 }
예제 #7
0
        public static void M583GetNozzleWidth(GCode gcode, FirmwareController connection)
        {
            connection.ProcessNozzleSizeExtrusionWidth();
            var nozzleSizeMicrons = connection.CurrentPrinterInfo.extruder.iNozzleSizeMicrons;

            connection.WriteLog(string.Format(">> ok S:{0}", nozzleSizeMicrons), Logger.TextType.Read);
        }
예제 #8
0
        public GCode GetNextLine(bool excludeComments)
        {
            lock (m_aoFillThreadSync[m_iCurPage])
            {
                if (m_iCurrentLineInPage >= 1024)
                {
                    m_iCurPage           = (m_iCurPage + 1) % 8;
                    m_iCurrentLineInPage = 0;
                }
            }
            var num1 = m_aiGcodeInBuffer[m_iCurPage];
            var currentLineInPage = m_iCurrentLineInPage;
            var num2 = 0;

            if (num1 <= num2)
            {
                return(null);
            }

            GCode gcode = m_agGcodeBuffer[m_iCurPage, currentLineInPage];

            ++m_iCurrentLineInPage;
            --m_aiGcodeInBuffer[m_iCurPage];
            return(gcode);
        }
예제 #9
0
        public static void M572GetBackLash(GCode gcode, FirmwareController connection)
        {
            connection.ProcessBacklashEEPROM();
            Calibration calibrationDetails = connection.CalibrationDetails;

            connection.WriteLog(string.Format(">> ok BX:{0} BY:{1}", calibrationDetails.BACKLASH_X, calibrationDetails.BACKLASH_Y), Logger.TextType.Read);
        }
예제 #10
0
        public static void M581GetBackLashSpeed(GCode gcode, FirmwareController connection)
        {
            connection.ProcessBacklashSpeedEEPROM();
            Calibration calibrationDetails = connection.CalibrationDetails;

            connection.WriteLog(string.Format(">> ok BS:{0}", calibrationDetails.BACKLASH_SPEED), Logger.TextType.Read);
        }
예제 #11
0
        public static void M684PrintAllEepromValues(GCode gcode, FirmwareController connection)
        {
            SortedList <int, EepromAddressInfo> allData = connection.MyPrinterProfile.EEPROMConstants.GetAllData();
            var text = ">> ok ";

            foreach (EepromAddressInfo eepromAddressInfo in allData.Values)
            {
                if (eepromAddressInfo.EepromAddr <= 512)
                {
                    text = text + eepromAddressInfo.Name + ": ";
                    if (eepromAddressInfo.Type.Equals(typeof(float)))
                    {
                        text = text + connection.FloatFromEEPROM(eepromAddressInfo.Name).ToString("0.00") + "\n";
                    }
                    else if (eepromAddressInfo.Type.Equals(typeof(uint)) || eepromAddressInfo.Type.Equals(typeof(int)) || (eepromAddressInfo.Type.Equals(typeof(ushort)) || eepromAddressInfo.Type.Equals(typeof(short))) || eepromAddressInfo.Type.Equals(typeof(byte)))
                    {
                        text = text + connection.eeprom_mapping.GetUInt32(eepromAddressInfo.Name).ToString() + "\n";
                    }
                    else
                    {
                        if (!eepromAddressInfo.Type.Equals(typeof(char)))
                        {
                            throw new Exception("Unexpected type");
                        }

                        text = text + connection.eeprom_mapping.GetInt32(eepromAddressInfo.Name).ToString() + "\n";
                    }
                }
            }
            connection.WriteLog(text, Logger.TextType.Read);
        }
예제 #12
0
        public static void M573GetBedLevelingValues(GCode gcode, FirmwareController connection)
        {
            connection.ProcessBedCompensationDataFromEEPROM();
            Calibration calibrationDetails = connection.CalibrationDetails;

            connection.WriteLog(string.Format(">> ok BR:{0} BL:{1} FR:{2} FL:{3} V:{4}", calibrationDetails.CORNER_HEIGHT_BACK_RIGHT, calibrationDetails.CORNER_HEIGHT_BACK_LEFT, calibrationDetails.CORNER_HEIGHT_FRONT_RIGHT, calibrationDetails.CORNER_HEIGHT_FRONT_LEFT, calibrationDetails.G32_VERSION), Logger.TextType.Read);
        }
 private void writeArray(BinaryWriter file, List <GCodeShort> list, bool binary)
 {
     foreach (GCodeShort code in list)
     {
         GCode gc = new GCode();
         gc.Parse(code.text);
         if (gc.hostCommand)
         {
             continue;
         }
         if (binary)
         {
             if (gc.hasCode)
             {
                 byte[] data = gc.getBinary(1);
                 file.Write(data);
             }
         }
         else
         {
             System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
             string cmd = gc.getAscii(false, false);
             if (cmd.Length > 0)
             {
                 file.Write(enc.GetBytes(cmd + "\n"));
             }
         }
     }
 }
예제 #14
0
        private void ProcessForTackPoints(GCodeFileWriter output_writer, GCode currLine, GCode prevLine, ref GCode Last_Tack_Point, ref int cornercount)
        {
            if (cornercount <= 1)
            {
                if (!isSharpCorner(currLine, prevLine))
                {
                    return;
                }

                if (Last_Tack_Point == null)
                {
                    doTackPoint(currLine, prevLine, output_writer);
                }

                Last_Tack_Point = currLine;
                ++cornercount;
            }
            else
            {
                if (cornercount < 1 || !isSharpCorner(currLine, Last_Tack_Point))
                {
                    return;
                }

                doTackPoint(currLine, Last_Tack_Point, output_writer);
                Last_Tack_Point = currLine;
            }
        }
        public CodeEditorViewTemplate(int tabId, GCode file = null)
        {
            InitializeComponent();
            _viewModel = new CodeEditorViewModel(tabId, file);

            DataContext = _viewModel;
        }
        private void writeString(BinaryWriter file, string code, bool binary)
        {
            GCode gc = new GCode();

            gc.Parse(code);
            if (gc.hostCommand)
            {
                return;
            }
            if (binary)
            {
                if (gc.hasCode)
                {
                    byte[] data = gc.getBinary(1);
                    file.Write(data);
                }
            }
            else
            {
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                string cmd = gc.getAscii(false, false);
                if (cmd.Length > 0)
                {
                    file.Write(enc.GetBytes(cmd + "\n"));
                }
            }
        }
예제 #17
0
        public static void M570SetFilamentUID(GCode gcode, FirmwareController connection)
        {
            EepromAddressInfo eepromInfo = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("FilamentUID");

            connection.AddManualCommandToFront("M618 S" + eepromInfo.EepromAddr + " P" + gcode.P + " T" + eepromInfo.Size);
            StandardVirtualCodes.SendOK(connection);
        }
예제 #18
0
        private void AddGCodeToBuffer(GCode new_code, int pagenumber)
        {
            var index = m_aiGcodeInBuffer[pagenumber];

            m_agGcodeBuffer[pagenumber, index] = new_code;
            ++m_aiGcodeInBuffer[pagenumber];
        }
예제 #19
0
        public static void M682SetLimitingSpeed(GCode gcode, FirmwareController connection)
        {
            EepromAddressInfo eepromInfo1 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitX");
            EepromAddressInfo eepromInfo2 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitY");
            EepromAddressInfo eepromInfo3 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitZ");
            EepromAddressInfo eepromInfo4 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEp");
            EepromAddressInfo eepromInfo5 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEn");

            if (gcode.HasX)
            {
                var num1 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo1.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.X) + " T" + eepromInfo1.Size);
            }
            if (gcode.HasY)
            {
                var num2 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo2.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.Y) + " T" + eepromInfo2.Size);
            }
            if (gcode.HasZ)
            {
                var num3 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo3.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.Z) + " T" + eepromInfo3.Size);
            }
            if (gcode.HasE)
            {
                var num4 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo4.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.E) + " T" + eepromInfo4.Size);
            }
            if (gcode.HasR)
            {
                var num5 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo5.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.R) + " T" + eepromInfo5.Size);
            }
            StandardVirtualCodes.SendOK(connection);
        }
예제 #20
0
        public void ProcessGCodeResult(GCode gcode, string resultFromPrinter, PrinterInfo printerInfo)
        {
            if (!gcode.hasM || gcode.M != 404)
            {
                return;
            }

            var num1 = (int)ClearPowerRecoveryFault(false);

            foreach (Match match in new Regex("(\\w*):(\\d+\\.?\\d?)").Matches(resultFromPrinter))
            {
                var str1 = match.Groups[2].Value;
                var str2 = match.Groups[1].Value;
                if (!(str2 == "RC"))
                {
                    if (!(str2 == "RR"))
                    {
                        if (!(str2 == "PS"))
                        {
                            if (!(str2 == "PI"))
                            {
                                if (!(str2 == "LX"))
                                {
                                    if (str2 == "LY")
                                    {
                                        m_fLocationY = SafeToFloat(match.Groups[2].Value);
                                    }
                                }
                                else
                                {
                                    m_fLocationX = SafeToFloat(match.Groups[2].Value);
                                }
                            }
                            else
                            {
                                m_iPI_ProgressIndicator = SafeToInt(match.Groups[2].Value);
                            }
                        }
                        else
                        {
                            var num2 = SafeToInt(match.Groups[2].Value);
                            if (3 <= num2)
                            {
                                num2 = 0;
                            }

                            m_oPrinterPowerRecovery.PrintingStatus = (PowerRecovery.PowerResetState)num2;
                        }
                    }
                    else
                    {
                        m_oPrinterPowerRecovery.iRR_Code = SafeToInt(match.Groups[2].Value);
                    }
                }
                else
                {
                    m_oPrinterPowerRecovery.iRC_Code = SafeToInt(match.Groups[2].Value);
                }
            }
        }
예제 #21
0
        public static void M580SetBackLashSpeed(GCode gcode, FirmwareController connection)
        {
            connection.SetBacklashSpeed(gcode.X);
            EepromAddressInfo eepromInfo = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("BacklashSpeed");
            var num = (int)connection.WriteManualCommands("M618 S" + eepromInfo.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.X) + " T" + eepromInfo.Size);

            StandardVirtualCodes.SendOK(connection);
        }
예제 #22
0
        public bool ProcessVirtualCode(GCode gcode, FirmwareController connection)
        {
            if (!code_dictionary.ContainsKey(gcode.M))
            {
                return(false);
            }

            code_dictionary[gcode.M](gcode, connection);
            return(true);
        }
 private void coordUpdate(GCode code, float x, float y, float zl, float zr)
 {
     if (x != -lastx || x == 0)
     {
         labelX.Text = "X=" + x.ToString("0.00");
         if (ann.hasXHome)
         {
             labelX.ForeColor = SystemColors.ControlText;
         }
         else
         {
             labelX.ForeColor = Color.Red;
         }
         lastx = x;
     }
     if (y != lasty || y == 0)
     {
         labelY.Text = "Y=" + y.ToString("0.00");
         if (ann.hasYHome)
         {
             labelY.ForeColor = SystemColors.ControlText;
         }
         else
         {
             labelY.ForeColor = Color.Red;
         }
         lasty = y;
     }
     if (zl != lastzl || zl == 0)
     {
         labelZL.Text = "ZL=" + zl.ToString("0.00");
         if (ann.hasZHome)
         {
             labelZL.ForeColor = SystemColors.ControlText;
         }
         else
         {
             labelZL.ForeColor = Color.Red;
         }
         lastzl = zl;
     }
     if (zr != lastzr || zr == 0)
     {
         labelZR.Text = "ZR=" + zr.ToString("0.00");
         if (ann.hasZHome)
         {
             labelZR.ForeColor = SystemColors.ControlText;
         }
         else
         {
             labelZR.ForeColor = Color.Red;
         }
         lastzr = zr;
     }
 }
예제 #24
0
        public void doTackPoint(GCode currLine, GCode Last_Tack_Point, GCodeFileWriter output_writer)
        {
            var num = (int)Math.Ceiling(distance(new BondingPreprocessor.Vector2(currLine), new BondingPreprocessor.Vector2(Last_Tack_Point)));

            if (num <= 5)
            {
                return;
            }

            output_writer.Write(new GCode("G4 P" + num.ToString()));
        }
예제 #25
0
        public static void M571SetBacklashConstants(GCode gcode, FirmwareController connection)
        {
            EepromAddressInfo eepromInfo1 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("BacklashX");
            EepromAddressInfo eepromInfo2 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("BacklashY");

            connection.SetBacklash(gcode.X, gcode.Y);
            var num1 = (int)connection.WriteManualCommands("M618 S" + eepromInfo1.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.X) + " T" + eepromInfo1.Size);
            var num2 = (int)connection.WriteManualCommands("M618 S" + eepromInfo2.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.Y) + " T" + eepromInfo2.Size);

            StandardVirtualCodes.SendOK(connection);
        }
예제 #26
0
 public void Run(PrinterConnection printerConnection)
 {
     if (printerConnection.IsConnected)
     {
         printerConnection.MacroStart();
         printerConnection.QueueLine(GCode);
         if (GCode.Contains(MacroProcessingStream.MacroPrefix))
         {
             printerConnection.QueueLine("\n" + MacroProcessingStream.MacroPrefix + "close()");
         }
     }
 }
예제 #27
0
 public void Run()
 {
     if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
     {
         PrinterConnectionAndCommunication.Instance.MacroStart();
         SendCommandToPrinter(GCode);
         if (GCode.Contains(QueuedCommandsStream.MacroPrefix))
         {
             SendCommandToPrinter("\n" + QueuedCommandsStream.MacroPrefix + "close()");
         }
     }
 }
예제 #28
0
        public static void M1014StopwatchStop(GCode gcode, FirmwareController connection)
        {
            var num = connection.NStopwatchReturnTime();

            if (0L <= num)
            {
                connection.WriteLog(string.Format(">> ok M:{0}", num), Logger.TextType.Read);
            }
            else
            {
                connection.WriteLog(">> stopwatch not running", Logger.TextType.Read);
            }
        }
예제 #29
0
        public static void M578GetCurrentBedOffsets(GCode gcode, FirmwareController connection)
        {
            connection.ProcessBedOffsetDataFromEEPROM();
            connection.ProcessCalibrationOffset();
            Calibration calibrationDetails = connection.CalibrationDetails;
            var         text = string.Format(">> ok BRO:{0} BLO:{1} FRO:{2} FLO:{3} ZO:{4}", calibrationDetails.CORNER_HEIGHT_BACK_RIGHT_OFFSET, calibrationDetails.CORNER_HEIGHT_BACK_LEFT_OFFSET, calibrationDetails.CORNER_HEIGHT_FRONT_RIGHT_OFFSET, calibrationDetails.CORNER_HEIGHT_FRONT_LEFT_OFFSET, calibrationDetails.ENTIRE_Z_HEIGHT_OFFSET);

            if (calibrationDetails.UsesCalibrationOffset)
            {
                text = string.Format("{0} CO:{1}", text, calibrationDetails.CALIBRATION_OFFSET);
            }

            connection.WriteLog(text, Logger.TextType.Read);
        }
예제 #30
0
        public static void M577SetBedOffsets(GCode gcode, FirmwareController connection)
        {
            EepromAddressInfo eepromInfo1 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("ZCalibrationBLO");
            EepromAddressInfo eepromInfo2 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("ZCalibrationBRO");
            EepromAddressInfo eepromInfo3 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("ZCalibrationFRO");
            EepromAddressInfo eepromInfo4 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("ZCalibrationFLO");
            EepromAddressInfo eepromInfo5 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("ZCalibrationZO");
            var stringList = new List <string>();

            if (gcode.HasX && eepromInfo1 != null)
            {
                var int32 = BitConverter.ToInt32(BitConverter.GetBytes(gcode.X), 0);
                stringList.Add("M618 S" + eepromInfo1.EepromAddr + " P" + int32 + " T" + eepromInfo1.Size);
            }
            if (gcode.HasY && eepromInfo2 != null)
            {
                var int32 = BitConverter.ToInt32(BitConverter.GetBytes(gcode.Y), 0);
                stringList.Add("M618 S" + eepromInfo2.EepromAddr + " P" + int32 + " T" + eepromInfo2.Size);
            }
            if (gcode.HasZ && eepromInfo3 != null)
            {
                var int32 = BitConverter.ToInt32(BitConverter.GetBytes(gcode.Z), 0);
                stringList.Add("M618 S" + eepromInfo3.EepromAddr + " P" + int32 + " T" + eepromInfo3.Size);
            }
            if (gcode.HasE && eepromInfo4 != null)
            {
                var int32 = BitConverter.ToInt32(BitConverter.GetBytes(gcode.E), 0);
                stringList.Add("M618 S" + eepromInfo4.EepromAddr + " P" + int32 + " T" + eepromInfo4.Size);
            }
            if (gcode.hasF && eepromInfo5 != null)
            {
                var int32 = BitConverter.ToInt32(BitConverter.GetBytes(gcode.F), 0);
                stringList.Add("M618 S" + eepromInfo5.EepromAddr + " P" + int32 + " T" + eepromInfo5.Size);
            }
            if (connection.CalibrationDetails.UsesCalibrationOffset)
            {
                EepromAddressInfo eepromInfo6 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("CalibrationOffset");
                if (gcode.HasI && eepromInfo6 != null)
                {
                    var int32 = BitConverter.ToInt32(BitConverter.GetBytes(gcode.I), 0);
                    stringList.Add("M618 S" + eepromInfo6.EepromAddr + " P" + int32 + " T" + eepromInfo6.Size);
                }
            }
            if (stringList.Count > 0)
            {
                connection.AddManualCommandToFront(stringList.ToArray());
            }

            StandardVirtualCodes.SendOK(connection);
        }
예제 #31
0
        private List<GCode> DeltaProcessG1(GCode code)
        {
            Position destination = (Position)current.Clone();
            foreach (GCodeParameter parm in code.Parameters)
            {
                switch (parm.Type)
                {
                    case GCodeParameterType.F:
                        feedrate = Convert.ToDouble(parm.Value);
                        break;
                    case GCodeParameterType.X:
                        destination.X = Convert.ToDouble(parm.Value);
                        break;
                    case GCodeParameterType.Y:
                        destination.X = Convert.ToDouble(parm.Value);
                        break;
                    case GCodeParameterType.Z:
                        destination.X = Convert.ToDouble(parm.Value);
                        break;
                    case GCodeParameterType.E:
                        destination.E = Convert.ToDouble(parm.Value);
                        break;
                    default:
                        throw new ApplicationException("Unknown parameter in G1");
                }
            }
            double precision = Math.Pow(0.05, 2); //mm squared
            //            double precision = 0.001; //mm

            deltaCalculations = 0;
            List<Position> candidate = PartitionInSegments(current, destination, precision, 1);
            int candidateCalcs = deltaCalculations;
            deltaCalculations = 0;
            List<Position> johann = JohannPartitionInSegments(current, destination);

            CandidateDeltaSurplus += candidateCalcs - deltaCalculations;
            JohanTotalSteps += johann.Count;
            CandidateTotalSteps += candidate.Count;

            double maxdist = TestPartitionAccuracy(candidate);
            if (maxdist > MaxCandidateError) MaxCandidateError = maxdist;
            maxdist = TestPartitionAccuracy(johann);
            if (maxdist > MaxJohannError) MaxJohannError = maxdist;
            current = destination;
            return null;
        }
예제 #32
0
        internal void Translate(GCode code)
        {
            switch (code.Command)
            {
                case GCodeCommand.G1:
                    DeltaProcessG1(code);
                    break;
                case GCodeCommand.G28:
                    current.X = current.Y = current.Z = 0;
                    break;
                default:
                    return;

            }
        }