Made the feed rate stream track and update correctly.
This commit is contained in:
parent
ea9f3a4826
commit
1d25c5740c
2 changed files with 55 additions and 67 deletions
|
|
@ -32,37 +32,36 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||
{
|
||||
public class FeedRateMultiplyerStream : GCodeStreamProxy
|
||||
{
|
||||
public FeedRateMultiplyerStream(GCodeStream internalStream)
|
||||
: base(internalStream)
|
||||
{
|
||||
}
|
||||
public class FeedRateMultiplyerStream : GCodeStreamProxy
|
||||
{
|
||||
protected PrinterMove lastDestination = new PrinterMove();
|
||||
public PrinterMove LastDestination { get { return lastDestination; } }
|
||||
|
||||
public double FeedRateRatio { get; set; } = 1;
|
||||
public FeedRateMultiplyerStream(GCodeStream internalStream)
|
||||
: base(internalStream)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ReadLine()
|
||||
{
|
||||
return ApplyFeedRateMultiplier(internalStream.ReadLine());
|
||||
}
|
||||
public double FeedRateRatio { get; set; } = 1;
|
||||
|
||||
private string ApplyFeedRateMultiplier(string lineBeingSent)
|
||||
{
|
||||
if (lineBeingSent != null
|
||||
&& FeedRateRatio != 1)
|
||||
{
|
||||
lineBeingSent = lineBeingSent.ToUpper().Trim();
|
||||
if (lineBeingSent.StartsWith("G0") || lineBeingSent.StartsWith("G1"))
|
||||
{
|
||||
double feedRate = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref feedRate))
|
||||
{
|
||||
lineBeingSent = GCodeFile.ReplaceNumberAfter('F', lineBeingSent, feedRate * FeedRateRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override string ReadLine()
|
||||
{
|
||||
string lineToSend = internalStream.ReadLine();
|
||||
|
||||
return lineBeingSent;
|
||||
}
|
||||
}
|
||||
if (lineToSend != null
|
||||
&& LineIsMovement(lineToSend))
|
||||
{
|
||||
PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
|
||||
|
||||
PrinterMove moveToSend = currentMove;
|
||||
moveToSend.feedRate *= FeedRateRatio;
|
||||
|
||||
lineToSend = CreateMovementLine(moveToSend, lastDestination);
|
||||
lastDestination = currentMove;
|
||||
return lineToSend;
|
||||
}
|
||||
|
||||
return lineToSend;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue