use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class ArcExpanderTest method arcExpandIgnoreNonArc.
@Test
public void arcExpandIgnoreNonArc() throws Exception {
System.out.println("arcExpandIgnoreNonArc");
GcodeState state = new GcodeState();
state.currentPoint = new Position(0, 0, 0, MM);
state.plane = XY;
ArcExpander instance = new ArcExpander(true, 1);
boolean threwException = false;
String command = "G17 G0 X12";
List<String> result = instance.processCommand(command, state);
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(command);
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class ArcExpanderTest method expandArcG19.
@Test
public void expandArcG19() throws Exception {
System.out.println("expandArcG19");
GcodeState state = new GcodeState();
state.currentPoint = new Position(0, -1, 0, MM);
state.plane = YZ;
// ///////////////////////////////////////////////////////
for (double segmentLength = 0.1; segmentLength < 1; segmentLength += 0.1) {
ArcExpander instance = new ArcExpander(true, segmentLength);
// Half circle clockwise, Y-1 -> Y1, X0 -> X1 -> X0
String command = "G2 Y1 X0 R1";
List<String> result = instance.processCommand(command, state);
assertThat(result.size()).isEqualTo((int) Math.ceil(Math.PI / segmentLength));
verifyLines(new Position(0, 0, 0, MM), result, 1., new Position(0, -1., 0, MM), new Position(0, 1, 1, MM), state.plane);
// Half circle clockwise, Y-1 -> Y1, X0 -> X-1 -> X0
command = "G3 Y1 X0 R1";
result = instance.processCommand(command, state);
assertThat(result.size()).isEqualTo((int) Math.ceil(Math.PI / segmentLength));
verifyLines(new Position(0, 0, 0, MM), result, 1., new Position(0, -1, -1, MM), new Position(0, 1, 0, MM), state.plane);
}
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class LineSplitterTest method testModalReturnedFirst.
@Test
public void testModalReturnedFirst() throws Exception {
System.out.println("testModalReturnedFirst");
LineSplitter instance = new LineSplitter(1.5);
GcodeState state = new GcodeState();
state.currentPoint = new Position(0, 0, 0, MM);
state.inAbsoluteMode = true;
String command = "G20 G1X2Y2Z0";
List<String> result = instance.processCommand(command, state);
assertThat(result).containsExactly("G20", "G1X1Y1Z0", "G1X2Y2Z0");
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class LineSplitterTest method testSingleAxis.
/**
* Lines being split across each X/Y/Z axis.
*/
@Test
public void testSingleAxis() throws Exception {
System.out.println("splitSingleAxis");
List<String> expected;
expected = Arrays.asList("G1X0Y0Z0", "G1X1Y0Z0");
splitterHarness(1, new Position(-1, 0, 0, MM), "G1X1", expected);
expected = Arrays.asList("G1X0Y0Z0", "G1X0Y1Z0");
splitterHarness(1, new Position(0, -1, 0, MM), "G1Y1", expected);
expected = Arrays.asList("G1X0Y0Z0", "G1X0Y0Z1");
splitterHarness(1, new Position(0, 0, -1, MM), "G1Z1", expected);
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class MeshLevelerTest method testMultipleCommandsWithLine.
@Test
public void testMultipleCommandsWithLine() throws GcodeParserException {
expectedEx.expect(GcodeParserException.class);
expectedEx.expectMessage(Localization.getString("parser.processor.general.multiple-commands"));
MeshLeveler ml = new MeshLeveler(0.0, BIG_FLAT_GRID_Z0, Units.MM);
GcodeState state = new GcodeState();
state.currentPoint = new Position(0, 0, 0, MM);
state.inAbsoluteMode = true;
ml.processCommand("G1X1G20", state);
}
Aggregations