diff --git a/OpenCNCPilot/GCode/GCodeCommands/Command.cs b/OpenCNCPilot/GCode/GCodeCommands/Command.cs index ffb5789..850fbf8 100644 --- a/OpenCNCPilot/GCode/GCodeCommands/Command.cs +++ b/OpenCNCPilot/GCode/GCodeCommands/Command.cs @@ -1,7 +1,7 @@ namespace OpenCNCPilot.GCode.GCodeCommands { - public interface Command + public abstract class Command { - + public int LineNumber = -1; } } diff --git a/OpenCNCPilot/GCode/GCodeFile.cs b/OpenCNCPilot/GCode/GCodeFile.cs index 3b1d9ba..e56a6a2 100644 --- a/OpenCNCPilot/GCode/GCodeFile.cs +++ b/OpenCNCPilot/GCode/GCodeFile.cs @@ -44,7 +44,7 @@ private GCodeFile(List toolpath) if (m.Start == m.End) { - Warnings.Add($"ignoring empty move at position {i} (not equal to line number)"); + Warnings.Add($"ignoring zero-length move from line number {m.LineNumber}"); toolpath.RemoveAt(i--); } } diff --git a/OpenCNCPilot/GCode/GCodeParser.cs b/OpenCNCPilot/GCode/GCodeParser.cs index 41ab2dd..98f57f8 100644 --- a/OpenCNCPilot/GCode/GCodeParser.cs +++ b/OpenCNCPilot/GCode/GCodeParser.cs @@ -178,7 +178,7 @@ static void Parse(string line, int lineNumber) if (param != Words[i].Parameter || param < 0) throw new ParseException("M code can only have positive integer parameters", lineNumber); - Commands.Add(new MCode() { Code = param }); + Commands.Add(new MCode() { Code = param, LineNumber = lineNumber }); Words.RemoveAt(i); i--; @@ -192,7 +192,7 @@ static void Parse(string line, int lineNumber) if (param < 0) Warnings.Add($"spindle speed must be positive. (line {lineNumber})"); - Commands.Add(new Spindle() { Speed = Math.Abs(param) }); + Commands.Add(new Spindle() { Speed = Math.Abs(param), LineNumber = lineNumber }); Words.RemoveAt(i); i--; @@ -274,7 +274,7 @@ static void Parse(string line, int lineNumber) if (Words[i + 1].Parameter < 0) Warnings.Add($"dwell time must be positive. (line {lineNumber})"); - Commands.Add(new Dwell() { Seconds = Math.Abs(Words[i + 1].Parameter) }); + Commands.Add(new Dwell() { Seconds = Math.Abs(Words[i + 1].Parameter), LineNumber = lineNumber }); Words.RemoveAt(i + 1); Words.RemoveAt(i); i--; @@ -373,6 +373,7 @@ static void Parse(string line, int lineNumber) motion.End = EndPos; motion.Feed = State.Feed; motion.Rapid = MotionMode == 0; + motion.LineNumber = lineNumber; State.PositionValid.CopyTo(motion.PositionValid, 0); Commands.Add(motion); @@ -542,6 +543,7 @@ static void Parse(string line, int lineNumber) arc.Direction = (MotionMode == 2) ? ArcDirection.CW : ArcDirection.CCW; arc.U = U; arc.V = V; + arc.LineNumber = lineNumber; arc.Plane = State.Plane; Commands.Add(arc); diff --git a/OpenCNCPilot/MainWindow.xaml.MachineStatus.cs b/OpenCNCPilot/MainWindow.xaml.MachineStatus.cs index fe8321d..e11ad2c 100644 --- a/OpenCNCPilot/MainWindow.xaml.MachineStatus.cs +++ b/OpenCNCPilot/MainWindow.xaml.MachineStatus.cs @@ -234,10 +234,12 @@ private void Machine_FileChanged() if (ToolPath.Warnings.Count > 0) { - MessageBox.Show(@"Warning! There were some errors while parsing this file! + WarningWindow ww = new WarningWindow(@"Warning! Parsing this file resulted in some warnings! Do not use OpenCNCPilot's edit functions unless you are sure that these warnings can be ignored! If you use edit functions, check the output file for errors before running the gcode! -Be aware that the affected lines will likely move when using edit functions" + "\n\n >" + string.Join("\n >", ToolPath.Warnings)); +Be aware that the affected lines will likely move when using edit functions." + "\n\n", ToolPath.Warnings); + + ww.ShowDialog(); } if (Properties.Settings.Default.EnableCodePreview) diff --git a/OpenCNCPilot/OpenCNCPilot.csproj b/OpenCNCPilot/OpenCNCPilot.csproj index 7482486..e479212 100644 --- a/OpenCNCPilot/OpenCNCPilot.csproj +++ b/OpenCNCPilot/OpenCNCPilot.csproj @@ -145,6 +145,9 @@ + + WarningWindow.xaml + Designer MSBuild:Compile @@ -182,6 +185,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/OpenCNCPilot/WarningWindow.xaml b/OpenCNCPilot/WarningWindow.xaml new file mode 100644 index 0000000..0c98204 --- /dev/null +++ b/OpenCNCPilot/WarningWindow.xaml @@ -0,0 +1,15 @@ + + + + +