public override void Parse() { int gType = GCodeParser.ParseInt(); switch (gType) { case -1: Logger.Log("G: no command"); return; case 90: Parse90(); break; case 91: Parse91(); break; case 92: Parse92(); break; case 40: Parse40(); break; case 17: Parse17(); break; case 18: Parse18(); break; case 19: Parse19(); break; case 0: Parse0(); break; case 1: Parse1(); break; case 2: Parse2(); break; case 3: Parse3(); break; default: Logger.Log("G: Unsupported: {0}", gType); break; } }
public override void Parse() { int mType = GCodeParser.ParseInt(); switch (mType) { case -1: Logger.Log("M: no command"); return; case 0: Logger.Log("M00: PAUSE"); return; case 1: Logger.Log("M01: PAUSE if the stop switch is ON"); return; case 2: Logger.Log("M02: END PROGRAM"); return; case 3: Logger.Log("M03: Start spindle (clockwise)"); return; case 4: Logger.Log("M04: Start spindle (counterclockwise)"); return; case 5: Logger.Log("M05: Stop spindle"); return; case 6: Logger.Log("M06: Stop spindle and CHANGE TOOL (current tool index)"); return; case 30: Logger.Log("M30: PROGRAM FINISH"); return; case 60: Logger.Log("M60: PAUSE to exchange pallet shuttles"); return; default: Logger.Log("M: Unsupported: {0}", mType); break; } }
private void Parse10() { Logger.Log("D10: move axis n steps"); char axis = GCodeParser.ReadChar(); int steps = GCodeParser.ParseInt(); if (steps == -1) { return; } switch (axis) { case 'x': case 'X': DeviceFactory.Get().MoveRawX(steps); break; case 'y': case 'Y': DeviceFactory.Get().MoveRawY(steps); break; case 'z': case 'Z': DeviceFactory.Get().MoveRawZ(steps); break; } }
private void ProcessFile(string file) { if (file == null) { return; } if (!File.Exists(file)) { MessageBox.Show("File not found: " + file); return; } try { StreamReader reader = new StreamReader(file); string line; SetLoading(true); mViewDevice.Clear(); while ((line = reader.ReadLine()) != null) { GCodeParser.ParseLine(line); } SetLoading(false); reader.Close(); ZoomTextbox.Text = mViewDevice.VisualScale.ToString(); SetupJob(); RenderPanel.Invalidate(); FileNameLabel.Text = Path.GetFileName(file); GetConfig().SetString("last.open.file", file); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddAxis(char c) { float distance = (float)GCodeParser.ParseDouble(); if (distance == float.MinValue) { Logger.Error("ERROR, axis definition without real value"); return; } switch (c) { case 'X': ToX = distance; break; case 'Y': ToY = distance; break; case 'Z': ToZ = distance; break; case 'I': ToI = distance; break; case 'J': ToJ = distance; break; case 'K': ToK = distance; break; case 'R': ToR = distance; break; default: Logger.Error("ERROR: unknown axis while parsing axes: {0}", c); break; } char next = GCodeParser.PeekChar(); switch (next) { case 'X': case 'Y': case 'Z': case 'I': case 'J': case 'K': case 'R': GCodeParser.ReadChar(); AddAxis(next); break; } }
public override void Parse() { int gType = GCodeParser.ParseInt(); switch (gType) { case -1: Logger.Log("D: no command"); return; case 1: Parse1(); return; case 10: Parse10(); return; case 11: Parse11(); return; case 21: Parse21(); return; case 92: Parse92(); return; default: Logger.Log("D: Unsupported: {0}", gType); break; } }
public virtual void end(GCodeParser parser, MachineStatus machineStatus) { }
public virtual void endBlock(GCodeParser parser, MachineStatus machineStatus, IDictionary <String, ParsedWord> currentBlock) { String currentLine = parser.getCurrentLine(); String MachiningPlane = machine.getActivePlane(); String motionMode = machine.getMotionMode(); bool helixMode = false; Vector3D toolAx = motion.GetToolAxis(MachiningPlane, machineStatus); if (parser.findWordInBlock(new StringBuilder(currentLine)) != null) { if (currentBlock.ContainsKey("A") || currentBlock.ContainsKey("B") || currentBlock.ContainsKey("C")) { helixMode = true; } else { helixMode = machineStatus.rotAxMode; } foreach (String key in currentBlock.Keys) { switch (key) { case "G91": SCM_CW.Append("SET/MODE;INCR"); SCM_CW.Append('\n'); break; case "G90": SCM_CW.Append("SET/MODE;ABSOL"); SCM_CW.Append('\n'); break; case "G0": SCM_CW.Append("RAPID"); SCM_CW.Append('\n'); break; case "F": SCM_CW.Append("FEDRAT/MMPM" + ";" + machine.getFeedrate()); SCM_CW.Append('\n'); break; case "M5": SCM_CW.Append("PAINT/TOOL;NOMORE"); SCM_CW.Append('\n'); break; case "G41": SCM_CW.Append("CUTCOM/LEFT"); SCM_CW.Append('\n'); break; case "G40": SCM_CW.Append("CUTCOM/OFF"); SCM_CW.Append('\n'); break; case "G42": SCM_CW.Append("CUTCOM/RIGHT"); SCM_CW.Append('\n'); break; } } if (currentBlock.ContainsKey("TURN")) { // Console.WriteLine(machine.getTURN()) ; } if (currentBlock.ContainsKey("C")) { Tolerance = 0.03; string CM_CW_string = motion.NX_ROT_AX_C_TABLE(motionMode, MachiningPlane, machineStatus, Tolerance, MachineStatus.Axis.C, machine.getMC(), machine.getC(), MachineStatus.Axis.X, machine.getMX(), machine.getX(), machine.getOMX(), machine.getOX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), machine.getOMY(), machine.getOY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getOMZ(), machine.getOZ()).ToString(); SCM_CW.Append(CM_CW_string); } if (currentBlock.ContainsKey("A")) { Tolerance = 0.03; string CM_CW_string = motion.NX_ROT_AX_A_TABLE(motionMode, MachiningPlane, machineStatus, Tolerance, MachineStatus.Axis.A, machine.getMA(), machine.getA(), MachineStatus.Axis.X, machine.getMX(), machine.getX(), machine.getOMX(), machine.getOX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), machine.getOMY(), machine.getOY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getOMZ(), machine.getOZ()).ToString(); SCM_CW.Append(CM_CW_string); } if (currentBlock.ContainsKey("B")) { Tolerance = 0.03; string CM_CW_string = motion.NX_ROT_AX_B_TABLE(motionMode, MachiningPlane, machineStatus, Tolerance, MachineStatus.Axis.B, machine.getMB(), machine.getB(), MachineStatus.Axis.X, machine.getMX(), machine.getX(), machine.getOMX(), machine.getOX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), machine.getOMY(), machine.getOY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getOMZ(), machine.getOZ()).ToString(); SCM_CW.Append(CM_CW_string); } if (motionMode == "G1" && helixMode == false) { SCM_CW.Append("GOTO/" + machine.getMX().ToString("F6") + ";" + machine.getMY().ToString("F6") + ";" + machine.getMZ().ToString("F6") + ";" + toolAx.X.ToString("F6") + ";" + toolAx.Y.ToString("F6") + ";" + toolAx.Z.ToString("F6")).Replace(',', '.'); SCM_CW.Append('\n'); } if (motionMode == "G0" && helixMode == false) { SCM_CW.Append("GOTO/" + machine.getMX().ToString("F6") + ";" + machine.getMY().ToString("F6") + ";" + machine.getMZ().ToString("F6") + ";" + toolAx.X.ToString("F6") + ";" + toolAx.Y.ToString("F6") + ";" + toolAx.Z.ToString("F6")).Replace(',', '.'); SCM_CW.Append('\n'); } if (motionMode == "G2" && helixMode == false) { if (currentBlock.ContainsKey("I") || currentBlock.ContainsKey("J") || currentBlock.ContainsKey("K")) { string CM_CW_string = motion.NX_circular_motion_CW(MachiningPlane, machineStatus, 0.01, MachineStatus.Axis.X, machine.getMX(), machine.getX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getI(), machine.getJ(), machine.getK(), machine.getTURN()).ToString(); // string Helix_string = motion.NX_helical_motion_CW(MachiningPlane, machineStatus, 0.01, MachineStatus.Axis.X, machine.getOMX(), machine.getOX(), MachineStatus.Axis.Y, machine.getOMY(), machine.getOY(), MachineStatus.Axis.Z, machine.getOMZ(), machine.getOZ(), machine.getI(), machine.getJ(), machine.getK()).ToString() ; // string Helix_string = motion.NX_helical_motionCW(MachiningPlane, machineStatus, 0.01, MachineStatus.Axis.X, machine.getMX(), machine.getX(), machine.getOMX(), machine.getOX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), machine.getOMY(), machine.getOY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getOMZ(), machine.getOZ(), machine.getI(), machine.getJ(), machine.getK()).ToString() ; SCM_CW.Append(CM_CW_string); } if (currentBlock.ContainsKey("CR")) { string CM_CW_string = motion.NX_circular_motion_CW(MachiningPlane, machineStatus, 0.01, MachineStatus.Axis.X, machine.getMX(), machine.getX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getCR(), machine.getTURN()).ToString(); SCM_CW.Append(CM_CW_string); // SCM_CW.Append('\n') ; } } if (motionMode == "G3" && helixMode == false) { // string toolAxis = "tAxisX"+ machineStatus.mbase.M31.ToString("F9")+ " " + "tAxisY" + machineStatus.mbase.M32.ToString("F9") + " " + "tAxisZ" + machineStatus.mbase.M33.ToString("F9"); if (currentBlock.ContainsKey("I") || currentBlock.ContainsKey("J") || currentBlock.ContainsKey("K")) { string CM_CW_string = motion.NX_circular_motion_CCW(MachiningPlane, machineStatus, 0.005, MachineStatus.Axis.X, machine.getMX(), machine.getX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getI(), machine.getJ(), machine.getK(), machine.getTURN()).ToString(); // Console.WriteLine(CM_CW_string) ; SCM_CW.Append(CM_CW_string); // SCM_CW.Append('\n') ; } if (currentBlock.ContainsKey("CR")) { string CM_CW_string = motion.NX_circular_motion_CCW(MachiningPlane, machineStatus, 0.01, MachineStatus.Axis.X, machine.getMX(), machine.getX(), MachineStatus.Axis.Y, machine.getMY(), machine.getY(), MachineStatus.Axis.Z, machine.getMZ(), machine.getZ(), machine.getCR(), machine.getTURN()).ToString(); // Console.WriteLine(CM_CW_string) ; SCM_CW.Append(CM_CW_string); // SCM_CW.Append('\n') ; } } if (currentBlock.ContainsKey("M30") || currentBlock.ContainsKey("M2")) { SCM_CW.Append("END-OF-PATH"); SCM_CW.Append('\n'); } } }
public virtual void startBlock(GCodeParser parser, MachineStatus machineStatus, IDictionary <String, ParsedWord> currentBlock) { machine.setMachineStatus(machineStatus); }
public override void Parse() { ToolIndex = GCodeParser.ParseInt(); Logger.Log("T: Select tool: {0}", ToolIndex); }
public override void Parse() { float feedRate = (float)GCodeParser.ParseDouble(); DeviceFactory.Get().SetFeedRate(feedRate); }
public override void Parse() { SpindleSpeed = GCodeParser.ParseInt(); Logger.Log("S: SetSpindleSpeed: {0}", SpindleSpeed); }