Fixe to realtime position tracking and gcode e tracking
This hopefully fixes issues with re-slice (did on test environment)
This commit is contained in:
parent
4494ac8251
commit
62b6b9ae44
4 changed files with 87 additions and 120 deletions
|
|
@ -40,9 +40,6 @@ namespace MatterControl.Printing
|
|||
{
|
||||
public class GCodeMemoryFile : GCodeFile
|
||||
{
|
||||
private double amountOfAccumulatedEWhileParsing = 0;
|
||||
|
||||
private Vector2 center = Vector2.Zero;
|
||||
private double parsingLastZ;
|
||||
private bool gcodeHasExplicitLayerChangeInfo = false;
|
||||
|
||||
|
|
@ -78,7 +75,6 @@ namespace MatterControl.Printing
|
|||
if (loadedFile != null)
|
||||
{
|
||||
this.IndexOfLayerStart = loadedFile.IndexOfLayerStart;
|
||||
this.center = loadedFile.center;
|
||||
this.parsingLastZ = loadedFile.parsingLastZ;
|
||||
this.GCodeCommandQueue = loadedFile.GCodeCommandQueue;
|
||||
}
|
||||
|
|
@ -117,7 +113,7 @@ namespace MatterControl.Printing
|
|||
GCodeCommandQueue.Insert(insertIndex, printerMachineInstruction);
|
||||
}
|
||||
|
||||
public static GCodeMemoryFile Load(Stream fileStream,
|
||||
public static GCodeMemoryFile Load(Stream fileStream,
|
||||
Vector4 maxAccelerationMmPerS2,
|
||||
Vector4 maxVelocityMmPerS,
|
||||
Vector4 velocitySameAsStopMmPerS,
|
||||
|
|
@ -129,7 +125,7 @@ namespace MatterControl.Printing
|
|||
{
|
||||
using (var reader = new StreamReader(fileStream))
|
||||
{
|
||||
var gcodeMemoryFile = ParseFileContents(reader.ReadToEnd(),
|
||||
var gcodeMemoryFile = ParseFileContents(reader.ReadToEnd(),
|
||||
maxAccelerationMmPerS2, maxVelocityMmPerS, velocitySameAsStopMmPerS, speedMultiplier,
|
||||
cancellationToken, progressReporter);
|
||||
|
||||
|
|
@ -157,7 +153,7 @@ namespace MatterControl.Printing
|
|||
{
|
||||
using (var stream = File.OpenRead(filePath))
|
||||
{
|
||||
return Load(stream,
|
||||
return Load(stream,
|
||||
maxAccelerationMmPerS2,
|
||||
maxVelocityMmPerS,
|
||||
velocitySameAsStopMmPerS,
|
||||
|
|
@ -327,7 +323,7 @@ namespace MatterControl.Printing
|
|||
lineIndex++;
|
||||
}
|
||||
|
||||
loadedGCodeFile.AnalyzeGCodeLines(cancellationToken, progressReporter,
|
||||
loadedGCodeFile.AnalyzeGCodeLines(cancellationToken, progressReporter,
|
||||
maxAccelerationMmPerS2,
|
||||
maxVelocityMmPerS,
|
||||
velocitySameAsStopMmPerS,
|
||||
|
|
@ -392,7 +388,7 @@ namespace MatterControl.Printing
|
|||
}
|
||||
}
|
||||
|
||||
if (feedRateMmPerMin > 0)
|
||||
if (feedRateMmPerMin > 0)
|
||||
{
|
||||
var timeForE = Estimator.GetSecondsForMovement(deltaEPositionThisLine,
|
||||
feedRateMmPerMin / 60.0,
|
||||
|
|
@ -413,7 +409,7 @@ namespace MatterControl.Printing
|
|||
|
||||
if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200)
|
||||
{
|
||||
progressReporter(((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, "");
|
||||
progressReporter(((double)lineIndex / GCodeCommandQueue.Count / 2) + .5, "");
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
|
|
@ -432,11 +428,6 @@ namespace MatterControl.Printing
|
|||
}
|
||||
}
|
||||
|
||||
public Vector2 Center
|
||||
{
|
||||
get { return center; }
|
||||
}
|
||||
|
||||
public override double PercentComplete(int instructionIndex)
|
||||
{
|
||||
if (GCodeCommandQueue.Count > 0)
|
||||
|
|
@ -498,11 +489,11 @@ namespace MatterControl.Printing
|
|||
// Stop on material exhausted / Switch I/O pin
|
||||
break;
|
||||
|
||||
case "72":
|
||||
// makerbot, Play tone or song
|
||||
break;
|
||||
case "72":
|
||||
// makerbot, Play tone or song
|
||||
break;
|
||||
|
||||
case "73":
|
||||
case "73":
|
||||
// makerbot, Manually set build percentage
|
||||
break;
|
||||
|
||||
|
|
@ -510,9 +501,9 @@ namespace MatterControl.Printing
|
|||
// set extruder to absolute mode
|
||||
break;
|
||||
|
||||
case "83":
|
||||
//Set extruder to relative mode
|
||||
break;
|
||||
case "83":
|
||||
//Set extruder to relative mode
|
||||
break;
|
||||
|
||||
case "84":
|
||||
// lineString = "M84 ; disable motors\r"
|
||||
|
|
@ -573,19 +564,19 @@ namespace MatterControl.Printing
|
|||
// recall stored home offsets for axis xyzab
|
||||
break;
|
||||
|
||||
case "133":
|
||||
// MakerBot wait for toolhead to heat
|
||||
break;
|
||||
case "133":
|
||||
// MakerBot wait for toolhead to heat
|
||||
break;
|
||||
|
||||
case "134":
|
||||
// MakerBot wait for platform to reach target temp
|
||||
break;
|
||||
case "134":
|
||||
// MakerBot wait for platform to reach target temp
|
||||
break;
|
||||
|
||||
case "135":
|
||||
// MakerBot change toolhead
|
||||
break;
|
||||
case "135":
|
||||
// MakerBot change toolhead
|
||||
break;
|
||||
|
||||
case "140":
|
||||
case "140":
|
||||
// set bed temperature
|
||||
break;
|
||||
|
||||
|
|
@ -630,15 +621,15 @@ namespace MatterControl.Printing
|
|||
|
||||
case "565": // M565: Set Z probe offset
|
||||
break;
|
||||
case "1200"://M1200 Makerbot Fake gCode command for start build notification
|
||||
break;
|
||||
case "1201"://M1201 Makerbot Fake gCode command for end build notification
|
||||
break;
|
||||
case "1202"://M1202 Makerbot Fake gCode command for reset board
|
||||
break;
|
||||
case "1200"://M1200 Makerbot Fake gCode command for start build notification
|
||||
break;
|
||||
case "1201"://M1201 Makerbot Fake gCode command for end build notification
|
||||
break;
|
||||
case "1202"://M1202 Makerbot Fake gCode command for reset board
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -684,19 +675,12 @@ namespace MatterControl.Printing
|
|||
double valueE = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("E", lineString, ref valueE))
|
||||
{
|
||||
if (processingMachineState.movementType == PrinterMachineInstruction.MovementTypes.Absolute)
|
||||
{
|
||||
processingMachineState.EPosition = valueE + amountOfAccumulatedEWhileParsing;
|
||||
}
|
||||
else
|
||||
{
|
||||
processingMachineState.EPosition += valueE;
|
||||
}
|
||||
processingMachineState.EPosition = (float)valueE;
|
||||
}
|
||||
double valueF = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("F", lineString, ref valueF))
|
||||
{
|
||||
processingMachineState.FeedRate = valueF;
|
||||
processingMachineState.FeedRate = (float)valueF;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -743,17 +727,11 @@ namespace MatterControl.Printing
|
|||
|
||||
case "92":
|
||||
// set current head position values (used to reset origin)
|
||||
double ePosition = 0;
|
||||
if (GetFirstNumberAfter("E", lineString, ref ePosition))
|
||||
{
|
||||
// remember how much e position we just gave up
|
||||
amountOfAccumulatedEWhileParsing = (processingMachineState.EPosition - ePosition);
|
||||
}
|
||||
break;
|
||||
|
||||
case "130":
|
||||
//Set Digital Potentiometer value
|
||||
break;
|
||||
case "130":
|
||||
//Set Digital Potentiometer value
|
||||
break;
|
||||
|
||||
case "161":
|
||||
// home x,y axis minimum
|
||||
|
|
@ -763,8 +741,8 @@ namespace MatterControl.Printing
|
|||
// home z axis maximum
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -848,8 +826,8 @@ namespace MatterControl.Printing
|
|||
}
|
||||
|
||||
filamentUsedMmCache = filamentMm;
|
||||
diameterOfFilamentUsedMmCache = filamentDiameter;
|
||||
}
|
||||
diameterOfFilamentUsedMmCache = filamentDiameter;
|
||||
}
|
||||
|
||||
return filamentUsedMmCache;
|
||||
}
|
||||
|
|
@ -890,7 +868,7 @@ namespace MatterControl.Printing
|
|||
// check the beginning of the file for the filament diameter
|
||||
for (int i = 0; i < Math.Min(100, GCodeCommandQueue.Count); i++)
|
||||
{
|
||||
if(FindDiameter(i, ref filamentDiameterCache))
|
||||
if (FindDiameter(i, ref filamentDiameterCache))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -909,7 +887,7 @@ namespace MatterControl.Printing
|
|||
}
|
||||
}
|
||||
|
||||
if(filamentDiameterCache == 0)
|
||||
if (filamentDiameterCache == 0)
|
||||
{
|
||||
// it is still 0 so set it to something so we render
|
||||
filamentDiameterCache = 1.75;
|
||||
|
|
@ -994,7 +972,7 @@ namespace MatterControl.Printing
|
|||
if (instructionIndex >= 0
|
||||
&& instructionIndex <= LineCount)
|
||||
{
|
||||
for(var i = IndexOfLayerStart.Count - 1; i >=0; i--)
|
||||
for (var i = IndexOfLayerStart.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var lineStart = IndexOfLayerStart[i];
|
||||
|
||||
|
|
@ -1036,7 +1014,7 @@ namespace MatterControl.Printing
|
|||
line = GCodeCommandQueue[Math.Min(GCodeCommandQueue.Count - 1, lastPrintLine)].Line;
|
||||
lastPrintLine++;
|
||||
|
||||
} while (line != "; MatterSlice Completed Successfully"
|
||||
} while (line != "; MatterSlice Completed Successfully"
|
||||
&& lastPrintLine < endIndex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,42 @@ namespace MatterControl.Printing
|
|||
{
|
||||
public byte[] byteLine;
|
||||
|
||||
public bool clientInsertion;
|
||||
|
||||
// Absolute is the RepRap default
|
||||
public MovementTypes movementType = MovementTypes.Absolute;
|
||||
|
||||
public float secondsThisLine;
|
||||
|
||||
public float secondsToEndFromHere;
|
||||
|
||||
private Vector3Float xyzPosition = new Vector3Float();
|
||||
|
||||
public PrinterMachineInstruction(string Line)
|
||||
{
|
||||
this.Line = Line;
|
||||
}
|
||||
|
||||
public PrinterMachineInstruction(string Line, PrinterMachineInstruction copy, bool clientInsertion = false)
|
||||
: this(Line)
|
||||
{
|
||||
xyzPosition = copy.xyzPosition;
|
||||
FeedRate = copy.FeedRate;
|
||||
EPosition = copy.EPosition;
|
||||
movementType = copy.movementType;
|
||||
secondsToEndFromHere = copy.secondsToEndFromHere;
|
||||
ExtruderIndex = copy.ExtruderIndex;
|
||||
this.clientInsertion = clientInsertion;
|
||||
}
|
||||
|
||||
public enum MovementTypes { Absolute, Relative };
|
||||
|
||||
public float EPosition { get; set; }
|
||||
|
||||
public int ExtruderIndex { get; set; }
|
||||
|
||||
public float FeedRate { get; set; }
|
||||
|
||||
public string Line
|
||||
{
|
||||
get
|
||||
|
|
@ -49,38 +85,6 @@ namespace MatterControl.Printing
|
|||
}
|
||||
}
|
||||
|
||||
private Vector3Float xyzPosition = new Vector3Float();
|
||||
private float ePosition = 0;
|
||||
private float feedRate = 0;
|
||||
|
||||
public enum MovementTypes { Absolute, Relative };
|
||||
|
||||
// Absolute is the RepRap default
|
||||
public MovementTypes movementType = MovementTypes.Absolute;
|
||||
|
||||
public float secondsThisLine;
|
||||
public float secondsToEndFromHere;
|
||||
public bool clientInsertion;
|
||||
|
||||
public PrinterMachineInstruction(string Line)
|
||||
{
|
||||
this.Line = Line;
|
||||
}
|
||||
|
||||
public PrinterMachineInstruction(string Line, PrinterMachineInstruction copy, bool clientInsertion = false)
|
||||
: this(Line)
|
||||
{
|
||||
xyzPosition = copy.xyzPosition;
|
||||
feedRate = copy.feedRate;
|
||||
ePosition = copy.ePosition;
|
||||
movementType = copy.movementType;
|
||||
secondsToEndFromHere = copy.secondsToEndFromHere;
|
||||
ExtruderIndex = copy.ExtruderIndex;
|
||||
this.clientInsertion = clientInsertion;
|
||||
}
|
||||
|
||||
public int ExtruderIndex { get; set; }
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get { return new Vector3(xyzPosition); }
|
||||
|
|
@ -133,20 +137,5 @@ namespace MatterControl.Printing
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double EPosition
|
||||
{
|
||||
get { return ePosition; }
|
||||
set
|
||||
{
|
||||
ePosition = (float)value;
|
||||
}
|
||||
}
|
||||
|
||||
public double FeedRate
|
||||
{
|
||||
get { return feedRate; }
|
||||
set { feedRate = (float)value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
{
|
||||
public class FeedRateMultiplyerStream : GCodeStreamProxy
|
||||
{
|
||||
public PrinterMove LastDestination { get; private set; }
|
||||
private PrinterMove lastDestination;
|
||||
|
||||
public FeedRateMultiplyerStream(PrinterConfig printer, GCodeStream internalStream)
|
||||
: base(printer, internalStream)
|
||||
|
|
@ -46,8 +46,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
|
||||
public override void SetPrinterPosition(PrinterMove position)
|
||||
{
|
||||
this.LastDestination.CopyKnowSettings(position);
|
||||
internalStream.SetPrinterPosition(this.LastDestination);
|
||||
this.lastDestination.CopyKnowSettings(position);
|
||||
internalStream.SetPrinterPosition(this.lastDestination);
|
||||
}
|
||||
|
||||
public override string ReadLine()
|
||||
|
|
@ -63,13 +63,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
if (lineToSend != null
|
||||
&& LineIsMovement(lineToSend))
|
||||
{
|
||||
PrinterMove currentMove = GetPosition(lineToSend, this.LastDestination);
|
||||
PrinterMove currentMove = GetPosition(lineToSend, this.lastDestination);
|
||||
|
||||
PrinterMove moveToSend = currentMove;
|
||||
moveToSend.feedRate *= FeedRateRatio;
|
||||
|
||||
lineToSend = CreateMovementLine(moveToSend, this.LastDestination);
|
||||
this.LastDestination = currentMove;
|
||||
lineToSend = CreateMovementLine(moveToSend, this.lastDestination);
|
||||
this.lastDestination = currentMove;
|
||||
return lineToSend;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
this.MaxSegmentLength = maxSegmentLength;
|
||||
}
|
||||
|
||||
PrinterMove lastDestination { get; set; } = PrinterMove.Unknown;
|
||||
PrinterMove lastDestination = PrinterMove.Unknown;
|
||||
public double MaxSegmentLength { get; set; }
|
||||
|
||||
public void Cancel()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue