Extract speeds as part of normal GCode iteration

This commit is contained in:
John Lewin 2018-03-30 21:14:45 -07:00
parent 3dc77e534c
commit bb99d8743e

View file

@ -236,6 +236,9 @@ namespace MatterControl.Printing
gcodeHasExplicitLayerChangeInfo = true;
}
PrinterMachineInstruction previousInstruction = null;
var speeds = new HashSet<float>();
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<float> Speeds { get; private set; }
private void ParseMLine(string lineString, PrinterMachineInstruction processingMachineState)
{
// take off any comments before we check its length