Merge pull request #4506 from larsbrubaker/master

Make active extruder come from the tool change streams data
This commit is contained in:
johnlewin 2019-05-07 15:58:05 -07:00 committed by GitHub
commit a947f44125
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 15 deletions

View file

@ -196,7 +196,18 @@ namespace MatterHackers.MatterControl.PrinterCommunication
private double actualBedTemperature;
public int ActiveExtruderIndex { get; private set; }
public int ActiveExtruderIndex
{
get
{
if (toolChangeStream != null)
{
return toolChangeStream.RequestedTool;
}
return 0;
}
}
private readonly double[] actualHotendTemperature = new double[MaxExtruders];
@ -224,6 +235,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
private PauseHandlingStream pauseHandlingStream = null;
private QueuedCommandsStream queuedCommandStream = null;
private MaxLengthStream maxLengthStream;
private ToolChangeStream toolChangeStream;
private PrintLevelingStream printLevelingStream = null;
private WaitForTempStream waitForTempStream = null;
@ -335,7 +347,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication
writeLineStartCallBacks.Register("M109", HotendTemperatureWasWritenToPrinter);
writeLineStartCallBacks.Register("M140", BedTemperatureWasWritenToPrinter);
writeLineStartCallBacks.Register("M190", BedTemperatureWasWritenToPrinter);
writeLineStartCallBacks.Register("T", ExtruderIndexSet);
Task.Run(() =>
{
@ -402,15 +413,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication
};
}
private void ExtruderIndexSet(string line)
{
double extruderBeingSet = 0;
if (GCodeFile.GetFirstNumberAfter("T", line, ref extruderBeingSet))
{
ActiveExtruderIndex = (int)extruderBeingSet;
}
}
[Flags]
public enum Axis
{
@ -1327,8 +1329,7 @@ You will then need to logout and log back in to the computer for the changes to
if (moveAmountMm != 0)
{
// TODO: Long term we need to track the active extruder and make requiresToolChange be driven by the extruder you're actually on
bool requiresToolChange = extruderNumber != ActiveExtruderIndex
|| TotalGCodeStream.InternalStreams().OfType<ToolChangeStream>().FirstOrDefault().RequestedTool != ActiveExtruderIndex;
bool requiresToolChange = extruderNumber != ActiveExtruderIndex;
SetMovementToRelative();
@ -2276,7 +2277,7 @@ You will then need to logout and log back in to the computer for the changes to
if (ExtruderCount > 1)
{
accumulatedStream = new ToolChangeStream(Printer, accumulatedStream, queuedCommandStream, gCodeFileSwitcher);
accumulatedStream = toolChangeStream = new ToolChangeStream(Printer, accumulatedStream, queuedCommandStream, gCodeFileSwitcher);
accumulatedStream = new ToolSpeedMultiplierStream(Printer, accumulatedStream);
}

@ -1 +1 @@
Subproject commit 951aee626db1adda64e997fd703dca146a97ab72
Subproject commit 6c7038aa877b538aa1991d865b944b7a60c66f88