public override void Clear() { IndexOfLayerStart.Clear(); GCodeCommandQueue.Clear(); }
private void ParseGLine(string lineString, PrinterMachineInstruction processingMachineState) { // take off any comments before we check its length int commentIndex = lineString.IndexOf(';'); if (commentIndex != -1) { lineString = lineString.Substring(0, commentIndex); } string[] splitOnSpace = lineString.Split(' '); string onlyNumber = splitOnSpace[0].Substring(1).Trim(); switch (onlyNumber) { case "0": goto case "1"; case "4": case "04": // wait a given number of milliseconds break; case "1": // get the x y z to move to { double ePosition = processingMachineState.EPosition; var position = processingMachineState.Position; if (processingMachineState.MovementType == PrinterMachineInstruction.MovementTypes.Relative) { position = Vector3.Zero; ePosition = 0; } GCodeFile.GetFirstNumberAfter("X", lineString, ref position.X); GCodeFile.GetFirstNumberAfter("Y", lineString, ref position.Y); GCodeFile.GetFirstNumberAfter("Z", lineString, ref position.Z); GCodeFile.GetFirstNumberAfter("E", lineString, ref ePosition); double feedrate = 0; if (GCodeFile.GetFirstNumberAfter("F", lineString, ref feedrate)) { processingMachineState.FeedRate = (float)feedrate; } if (processingMachineState.MovementType == PrinterMachineInstruction.MovementTypes.Absolute) { processingMachineState.Position = position; processingMachineState.EPosition = (float)ePosition; } else { processingMachineState.Position += position; processingMachineState.EPosition += (float)ePosition; } } if (!gcodeHasExplicitLayerChangeInfo) { if (processingMachineState.Z != parsingLastZ || IndexOfLayerStart.Count == 0) { // if we changed z or there is a movement and we have never started a layer index IndexOfLayerStart.Add(GCodeCommandQueue.Count); } } parsingLastZ = processingMachineState.Position.Z; break; case "10": // firmware retract break; case "11": // firmware unretract break; case "21": // set to metric break; case "28": // G28 Return to home position (machine zero, aka machine reference point) break; case "29": // G29 Probe the z-bed in 3 places break; case "30": // G30 Probe z in current position break; case "90": // G90 is Absolute Distance Mode processingMachineState.MovementType = PrinterMachineInstruction.MovementTypes.Absolute; break; case "91": // G91 is Incremental Distance Mode processingMachineState.MovementType = PrinterMachineInstruction.MovementTypes.Relative; break; case "92": { // set current head position values (used to reset origin) double value = 0; if (GCodeFile.GetFirstNumberAfter("X", lineString, ref value)) { processingMachineState.PositionSet |= PositionSet.X; processingMachineState.X = value; } if (GCodeFile.GetFirstNumberAfter("Y", lineString, ref value)) { processingMachineState.PositionSet |= PositionSet.Y; processingMachineState.Y = value; } if (GCodeFile.GetFirstNumberAfter("Z", lineString, ref value)) { processingMachineState.PositionSet |= PositionSet.Z; processingMachineState.Z = value; } if (GCodeFile.GetFirstNumberAfter("E", lineString, ref value)) { processingMachineState.PositionSet |= PositionSet.E; processingMachineState.EPosition = (float)value; } } break; case "130": //Set Digital Potentiometer value break; case "161": // home x,y axis minimum break; case "162": // home z axis maximum break; default: break; } }