The command queue stream was sending blocks in reverse.

Need to get pre pause position from the queued gcode not the leveling (as that is where it is injected).
This commit is contained in:
Lars Brubaker 2015-12-31 09:40:17 -08:00
parent 9b79422532
commit b3b9443846
3 changed files with 42 additions and 32 deletions

View file

@ -36,8 +36,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
public class QueuedCommandsStream : GCodeStreamProxy
{
private List<string> commandQueue = new List<string>();
protected PrinterMove lastDestination = new PrinterMove();
public PrinterMove LastDestination { get { return lastDestination; } }
public QueuedCommandsStream(GCodeStream internalStream)
public QueuedCommandsStream(GCodeStream internalStream)
: base(internalStream)
{
}
@ -53,18 +55,30 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
public override string ReadLine()
{
string lineToSend = null;
// lock queue
using (TimedLock.Lock(this, "Read GCode Line"))
{
if (commandQueue.Count > 0)
{
string line = commandQueue[0];
lineToSend = commandQueue[0];
commandQueue.RemoveAt(0);
return line;
}
}
return base.ReadLine();
if (lineToSend == null)
{
lineToSend = base.ReadLine();
}
// keep track of the position
if (lineToSend != null
&& LineIsMovement(lineToSend))
{
lastDestination = GetPosition(lineToSend, lastDestination);
}
return lineToSend;
}
}
}