SetPrinterPosition no longer returns a value
Every function that tracks position implements SetPerinterPosition Moved GCodeStreamProxy to its own file Created a new PauseHandlingStream Wrote a test for same Fixed the bug with pausing not returning to correct extrusion Fixed print leveling to pass on the correct offset to SetPrinterPosition Made sure we always send the shut off extruders on exit Make agg parse double able to handle a space between the negative sign and the number "- 10". Put in a test for same.
This commit is contained in:
parent
05e087d966
commit
71f22acc75
14 changed files with 497 additions and 276 deletions
|
|
@ -33,94 +33,137 @@ using NUnit.Framework;
|
|||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
[TestFixture]
|
||||
public class GCodeStreamTests
|
||||
{
|
||||
[Test, Category("GCodeStream")]
|
||||
public void BabyStepsStreamTets()
|
||||
{
|
||||
}
|
||||
[TestFixture]
|
||||
public class GCodeMaxLengthStreamTests
|
||||
{
|
||||
[Test, Category("GCodeStream")]
|
||||
public void MaxLengthStreamTests()
|
||||
{
|
||||
string[] lines = new string[]
|
||||
{
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
"M105",
|
||||
"G1 X18 Y0 Z0 F2500",
|
||||
"G28",
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
null,
|
||||
};
|
||||
|
||||
[Test, Category("GCodeStream")]
|
||||
public void MaxLengthStreamTests()
|
||||
{
|
||||
string[] lines = new string[]
|
||||
{
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
"M105",
|
||||
"G1 X18 Y0 Z0 F2500",
|
||||
"G28",
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
null,
|
||||
};
|
||||
// We should go back to the above code when possible. It requires making pause part and move while paused part of the stream.
|
||||
// All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence).
|
||||
string[] expected = new string[]
|
||||
{
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
"M105",
|
||||
"G1 X6 Y0 Z0 F2500",
|
||||
"G1 X12 Y0 Z0",
|
||||
"G1 X18 Y0 Z0",
|
||||
"G28",
|
||||
"G1 X12 Y0 Z0 F500",
|
||||
"G1 X6 Y0 Z0",
|
||||
"G1 X0 Y0 Z0",
|
||||
null,
|
||||
};
|
||||
|
||||
/* // this is the correct code but we don't have pause in the gcode stream so we are always outputing x y z (FIX this)
|
||||
string[] expected = new string[]
|
||||
{
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
"M105",
|
||||
"G1 X6 F2500",
|
||||
"G1 X12",
|
||||
"G1 X18",
|
||||
"G28",
|
||||
"G1 X12 F500",
|
||||
"G1 X6",
|
||||
"G1 X0",
|
||||
null,
|
||||
};
|
||||
*/
|
||||
MaxLengthStream maxLengthStream = new MaxLengthStream(new TestGCodeStream(lines), 6);
|
||||
|
||||
// We should go back to the above code when possible. It requires making pause part and move while paused part of the stream.
|
||||
// All communication should go through stream to minimize the difference between printing and controling while not printing (all printing in essence).
|
||||
string[] expected = new string[]
|
||||
{
|
||||
"G1 X0 Y0 Z0 E0 F500",
|
||||
"M105",
|
||||
"G1 X6 Y0 Z0 F2500",
|
||||
"G1 X12 Y0 Z0",
|
||||
"G1 X18 Y0 Z0",
|
||||
"G28",
|
||||
"G1 X12 Y0 Z0 F500",
|
||||
"G1 X6 Y0 Z0",
|
||||
"G1 X0 Y0 Z0",
|
||||
null,
|
||||
};
|
||||
int expectedIndex = 0;
|
||||
string correctedLine = maxLengthStream.ReadLine();
|
||||
Assert.IsTrue(correctedLine == expected[expectedIndex++]);
|
||||
while (correctedLine != null)
|
||||
{
|
||||
correctedLine = maxLengthStream.ReadLine();
|
||||
Assert.IsTrue(correctedLine == expected[expectedIndex++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MaxLengthStream maxLengthStream = new MaxLengthStream(new TestGCodeStream(lines), 6);
|
||||
[TestFixture]
|
||||
public class GCodePauseStreamTests
|
||||
{
|
||||
[Test, Category("GCodeStream")]
|
||||
public void PauseHandlingStreamTests()
|
||||
{
|
||||
string[] inputLines = new string[]
|
||||
{
|
||||
"; the printer is moving normally",
|
||||
"G1 X10 Y10 Z10 E0",
|
||||
"G1 X10 Y10 Z10 E10",
|
||||
"G1 X10 Y10 Z10 E30",
|
||||
|
||||
int expectedIndex = 0;
|
||||
string correctedLine = maxLengthStream.ReadLine();
|
||||
Assert.IsTrue(correctedLine == expected[expectedIndex++]);
|
||||
while (correctedLine != null)
|
||||
{
|
||||
correctedLine = maxLengthStream.ReadLine();
|
||||
Assert.IsTrue(correctedLine == expected[expectedIndex++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
"; the printer pauses",
|
||||
"G91",
|
||||
"G1 Z10 E - 10 F12000",
|
||||
"G90",
|
||||
|
||||
public class TestGCodeStream : GCodeStream
|
||||
{
|
||||
private int index = 0;
|
||||
private string[] lines;
|
||||
"; the user moves the printer",
|
||||
|
||||
public TestGCodeStream(string[] lines)
|
||||
{
|
||||
this.lines = lines;
|
||||
}
|
||||
"; the printer un-pauses",
|
||||
"G91",
|
||||
"G1 Z-10 E10.8 F12000",
|
||||
"G90",
|
||||
null,
|
||||
};
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
// We should go back to the above code when possible. It requires making pause part and move while paused part of the stream.
|
||||
// All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence).
|
||||
string[] expected = new string[]
|
||||
{
|
||||
"; the printer is moving normally",
|
||||
"G1 X10 Y10 Z10 E0",
|
||||
"G1 X10 Y10 Z10 E10",
|
||||
"G1 X10 Y10 Z10 E30",
|
||||
|
||||
public override string ReadLine()
|
||||
{
|
||||
return lines[index++];
|
||||
}
|
||||
"; the printer pauses",
|
||||
"", // G91 is removed
|
||||
"G1 X10 Y10 Z20 E20 F12000", // altered to be absolute
|
||||
"G90",
|
||||
|
||||
public override Vector3 SetPrinterPosition(Vector3 position)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
}
|
||||
"; the user moves the printer",
|
||||
|
||||
"; the printer un-pauses",
|
||||
"", // G91 is removed
|
||||
"G1 X10 Y10 Z10 E30.8",
|
||||
"G90",
|
||||
null,
|
||||
};
|
||||
|
||||
PauseHandlingStream pauseHandlingStream = new PauseHandlingStream(new TestGCodeStream(inputLines));
|
||||
|
||||
int expectedIndex = 0;
|
||||
string correctedLine = pauseHandlingStream.ReadLine();
|
||||
string expectedLine = expected[expectedIndex++];
|
||||
Assert.IsTrue(correctedLine == expectedLine);
|
||||
while (correctedLine != null)
|
||||
{
|
||||
expectedLine = expected[expectedIndex++];
|
||||
correctedLine = pauseHandlingStream.ReadLine();
|
||||
Assert.IsTrue(correctedLine == expectedLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TestGCodeStream : GCodeStream
|
||||
{
|
||||
private int index = 0;
|
||||
private string[] lines;
|
||||
|
||||
public TestGCodeStream(string[] lines)
|
||||
{
|
||||
this.lines = lines;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ReadLine()
|
||||
{
|
||||
return lines[index++];
|
||||
}
|
||||
|
||||
public override void SetPrinterPosition(PrinterMove position)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue