From bb99d8743ed1b352efb7d783af679f8553e8bedb Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 30 Mar 2018 21:14:45 -0700 Subject: [PATCH] Extract speeds as part of normal GCode iteration --- MatterControl.Printing/GCode/GCodeMemoryFile.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MatterControl.Printing/GCode/GCodeMemoryFile.cs b/MatterControl.Printing/GCode/GCodeMemoryFile.cs index 700e9cce7..d5a93f23c 100644 --- a/MatterControl.Printing/GCode/GCodeMemoryFile.cs +++ b/MatterControl.Printing/GCode/GCodeMemoryFile.cs @@ -236,6 +236,9 @@ namespace MatterControl.Printing gcodeHasExplicitLayerChangeInfo = true; } + PrinterMachineInstruction previousInstruction = null; + var speeds = new HashSet(); + GCodeMemoryFile loadedGCodeFile = new GCodeMemoryFile(gcodeHasExplicitLayerChangeInfo); int crCount = CountNumLines(gCodeString); @@ -300,6 +303,14 @@ namespace MatterControl.Printing loadedGCodeFile.GCodeCommandQueue.Add(machineInstructionForLine); + // Accumulate speeds for extruded moves + if (previousInstruction != null + && machineInstructionForLine.EPosition > previousInstruction.EPosition + && (machineInstructionForLine.Line.IndexOf('X') != -1 || machineInstructionForLine.Line.IndexOf('Y') != -1)) + { + speeds.Add((float)machineInstructionForLine.FeedRate); + } + if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200) { progressReporter((double)lineIndex / crCount / 2, ""); @@ -312,6 +323,8 @@ namespace MatterControl.Printing maxProgressReport.Restart(); } + previousInstruction = machineInstructionForLine; + lineIndex++; } @@ -321,6 +334,8 @@ namespace MatterControl.Printing velocitySameAsStopMmPerS, speedMultiplier); + loadedGCodeFile.Speeds = speeds; + loadTime.Stop(); Console.WriteLine("Time To Load Seconds: {0:0.00}".FormatWith(loadTime.Elapsed.TotalSeconds)); @@ -435,6 +450,8 @@ namespace MatterControl.Printing get { return indexOfChangeInZ.Count; } } + public HashSet Speeds { get; private set; } + private void ParseMLine(string lineString, PrinterMachineInstruction processingMachineState) { // take off any comments before we check its length