Don't send redundant M114
More tool change tests
This commit is contained in:
parent
d0181a1de2
commit
7368536188
3 changed files with 97 additions and 13 deletions
|
|
@ -55,6 +55,20 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string LastAdd()
|
||||||
|
{
|
||||||
|
// lock queue
|
||||||
|
lock (locker)
|
||||||
|
{
|
||||||
|
if (commandQueue.Count > 0)
|
||||||
|
{
|
||||||
|
return commandQueue[commandQueue.Count - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(string lineIn, bool forceTopOfQueue = false)
|
public void Add(string lineIn, bool forceTopOfQueue = false)
|
||||||
{
|
{
|
||||||
// lock queue
|
// lock queue
|
||||||
|
|
|
||||||
|
|
@ -1591,8 +1591,13 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
|
|
||||||
public void ReadPosition(PositionReadType positionReadType = PositionReadType.Other, bool forceToTopOfQueue = false)
|
public void ReadPosition(PositionReadType positionReadType = PositionReadType.Other, bool forceToTopOfQueue = false)
|
||||||
{
|
{
|
||||||
QueueLine("M114", forceToTopOfQueue);
|
var lastAddd = queuedCommandStream.LastAdd();
|
||||||
PositionReadType = positionReadType;
|
if (lastAddd == null
|
||||||
|
|| lastAddd != "M114")
|
||||||
|
{
|
||||||
|
QueueLine("M114", forceToTopOfQueue);
|
||||||
|
PositionReadType = positionReadType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadSdProgress(string line)
|
public void ReadSdProgress(string line)
|
||||||
|
|
|
||||||
|
|
@ -684,7 +684,6 @@ namespace MatterControl.Tests.MatterControl
|
||||||
"M104 S100", // set the temp
|
"M104 S100", // set the temp
|
||||||
"T0", // smoothie command to ensure still on T0 after temp set
|
"T0", // smoothie command to ensure still on T0 after temp set
|
||||||
"M114", // always ask position after T
|
"M114", // always ask position after T
|
||||||
"M114", // erroneous extra M114, FIX at some point
|
|
||||||
"G1 X11 Y11 Z11", // go to the position requested
|
"G1 X11 Y11 Z11", // go to the position requested
|
||||||
"Communication State: FinishedPrint",
|
"Communication State: FinishedPrint",
|
||||||
null,
|
null,
|
||||||
|
|
@ -726,14 +725,10 @@ namespace MatterControl.Tests.MatterControl
|
||||||
"G1 E10", // the first extrusion on T1
|
"G1 E10", // the first extrusion on T1
|
||||||
"T0", // switch back to T0
|
"T0", // switch back to T0
|
||||||
"M114",
|
"M114",
|
||||||
"M114",
|
|
||||||
"M114", // 10
|
|
||||||
"T1",
|
"T1",
|
||||||
"G1 E20", // a second extrusion without changing back to T0
|
"G1 E20", // a second extrusion without changing back to T0
|
||||||
"T0", // the no move switch back to T0
|
"T0", // the no move switch back to T0
|
||||||
"M114",
|
"M114",
|
||||||
"M114",
|
|
||||||
"M114",
|
|
||||||
"G1 E30", // extrude on T0
|
"G1 E30", // extrude on T0
|
||||||
"G1 X11 Y11 Z11", // go to the position requested
|
"G1 X11 Y11 Z11", // go to the position requested
|
||||||
"Communication State: FinishedPrint",
|
"Communication State: FinishedPrint",
|
||||||
|
|
@ -768,9 +763,43 @@ namespace MatterControl.Tests.MatterControl
|
||||||
};
|
};
|
||||||
|
|
||||||
// validate that both temperatures get set and only once each
|
// validate that both temperatures get set and only once each
|
||||||
|
string[] expected = new string[]
|
||||||
|
{
|
||||||
|
"M114",
|
||||||
|
"T0",
|
||||||
|
"M114",
|
||||||
|
"M104 T1 S240", // initial heating
|
||||||
|
"M104 T0 S230",
|
||||||
|
"T0",
|
||||||
|
"M114",
|
||||||
|
"G1 X10 Y10 Z10 F2500",
|
||||||
|
"G1 Y111",
|
||||||
|
"M114",
|
||||||
|
"T1",
|
||||||
|
"M114",
|
||||||
|
"M104 T1 S240", // **** BUG **** this should not be here
|
||||||
|
"T1",
|
||||||
|
"M114",
|
||||||
|
"G1 Y222",
|
||||||
|
"M114",
|
||||||
|
"G1 X9 Y8 F3000",
|
||||||
|
"G1 Z7 F315",
|
||||||
|
"G1 F2500",
|
||||||
|
"G1 X111",
|
||||||
|
"M114",
|
||||||
|
"T0",
|
||||||
|
"M114",
|
||||||
|
"G1 X222",
|
||||||
|
"M114",
|
||||||
|
"G1 X10 Y10 F3000",
|
||||||
|
"G1 Z10 F315",
|
||||||
|
"G1 F2500",
|
||||||
|
"Communication State: FinishedPrint",
|
||||||
|
null
|
||||||
|
};
|
||||||
|
|
||||||
PrinterConfig printer = SetupToolChangeSettings();
|
PrinterConfig printer = SetupToolChangeSettings();
|
||||||
await RunSimulatedPrint(printer, inputLines, null);
|
await RunSimulatedPrint(printer, inputLines, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, Category("GCodeStream")]
|
[Test, Category("GCodeStream")]
|
||||||
|
|
@ -802,6 +831,35 @@ namespace MatterControl.Tests.MatterControl
|
||||||
await RunSimulatedPrint(printer, inputLines, null);
|
await RunSimulatedPrint(printer, inputLines, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test, Category("GCodeStream")]
|
||||||
|
public async Task ToolChangeHeatOnlyT1()
|
||||||
|
{
|
||||||
|
string[] inputLines = new string[]
|
||||||
|
{
|
||||||
|
"T0",
|
||||||
|
// tell the printer to heat up
|
||||||
|
"M104 T1 S230",
|
||||||
|
// send some movement commands with tool switching
|
||||||
|
"; the printer is moving normally",
|
||||||
|
"G1 X10 Y10 Z10 E0 F2500",
|
||||||
|
"T1",
|
||||||
|
"G1 X10 Y10 Z10 E0",
|
||||||
|
"T0",
|
||||||
|
"G1 X10 Y10 Z10 E0",
|
||||||
|
// now do the same thing with a long enough print to cause
|
||||||
|
// cooling and heating
|
||||||
|
null,
|
||||||
|
};
|
||||||
|
|
||||||
|
PrinterConfig printer = SetupToolChangeSettings();
|
||||||
|
// register to make sure that T0 is heated (only once) and T1 is not heated
|
||||||
|
printer.Connection.HotendTargetTemperatureChanged += (s, extruderIndex) =>
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, printer.Connection.GetTargetHotendTemperature(0));
|
||||||
|
};
|
||||||
|
await RunSimulatedPrint(printer, inputLines, null);
|
||||||
|
}
|
||||||
|
|
||||||
private static PrinterConfig SetupToolChangeSettings()
|
private static PrinterConfig SetupToolChangeSettings()
|
||||||
{
|
{
|
||||||
AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||||
|
|
@ -901,13 +959,20 @@ namespace MatterControl.Tests.MatterControl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string expectedLine = expected[expectedIndex++];
|
if (true)
|
||||||
if (expectedLine != actualLineWithoutChecksum)
|
|
||||||
{
|
{
|
||||||
int a = 0;
|
string expectedLine = expected[expectedIndex++];
|
||||||
|
if (expectedLine != actualLineWithoutChecksum)
|
||||||
|
{
|
||||||
|
int a = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedLine, actualLineWithoutChecksum, "Unexpected response from testStream");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.WriteLine("\"" + actualLineWithoutChecksum + "\",");
|
||||||
}
|
}
|
||||||
//Debug.WriteLine("\"" + actualLineWithoutChecksum + "\",");
|
|
||||||
Assert.AreEqual(expectedLine, actualLineWithoutChecksum, "Unexpected response from testStream");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue