use of com.willwinder.universalgcodesender.gcode.GcodeState in project Universal-G-Code-Sender by winder.
the class ArcExpanderTest method expandArcG17.
@Test
public void expandArcG17() throws Exception {
System.out.println("expandArcG17");
GcodeState state = new GcodeState();
state.currentPoint = new Position(-1, 0, 0, MM);
state.plane = XY;
// ///////////////////////////////////////////////////////
for (double segmentLength = 0.1; segmentLength < 1; segmentLength += 0.1) {
ArcExpander instance = new ArcExpander(true, segmentLength);
// Half circle clockwise, X-1 -> X1, Y0 -> Y1 -> Y0
String command = "G2 Y0 X1 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(-1, 0, 0, MM), new Position(1, 1, 0, MM), state.plane);
// Half circle counter-clockwise, X-1 -> X1, Y0 -> Y-1 -> Y0
command = "G3 Y0 X1 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(-1, -1, 0, MM), new Position(1, 0, 0, MM), state.plane);
}
}
use of com.willwinder.universalgcodesender.gcode.GcodeState 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.gcode.GcodeState 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.gcode.GcodeState 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.gcode.GcodeState in project Universal-G-Code-Sender by winder.
the class LineSplitterTest method splitterHarness.
private static void splitterHarness(double splitterLength, Position start, String command, List<String> expected) throws Exception {
LineSplitter instance = new LineSplitter(splitterLength);
GcodeState state = new GcodeState();
state.currentPoint = start;
state.inAbsoluteMode = true;
List<String> result = instance.processCommand(command, state);
assertEquals(expected, result);
}
Aggregations