Search in sources :

Example 16 with Position

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);
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 17 with Position

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);
    }
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 18 with Position

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");
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 19 with Position

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);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 20 with Position

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);
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Aggregations

Position (com.willwinder.universalgcodesender.model.Position)66 Test (org.junit.Test)33 GcodeState (com.willwinder.universalgcodesender.gcode.GcodeState)15 GcodeMeta (com.willwinder.universalgcodesender.gcode.GcodeParser.GcodeMeta)7 ControllerStatus (com.willwinder.universalgcodesender.listeners.ControllerStatus)6 UnitUtils (com.willwinder.universalgcodesender.model.UnitUtils)6 GcodeParserException (com.willwinder.universalgcodesender.gcode.util.GcodeParserException)5 Units (com.willwinder.universalgcodesender.model.UnitUtils.Units)5 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)4 Settings (com.willwinder.universalgcodesender.utils.Settings)4 ArrayList (java.util.ArrayList)4 ProbeParameters (com.willwinder.ugs.platform.probe.ProbeService.ProbeParameters)3 GcodeParser (com.willwinder.universalgcodesender.gcode.GcodeParser)3 PlaneFormatter (com.willwinder.universalgcodesender.gcode.util.PlaneFormatter)3 UGSEvent (com.willwinder.universalgcodesender.model.UGSEvent)3 AutoLevelSettings (com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings)3 SplitCommand (com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils.SplitCommand)2 CommentProcessor (com.willwinder.universalgcodesender.gcode.processors.CommentProcessor)2 Code (com.willwinder.universalgcodesender.gcode.util.Code)2 PointSegment (com.willwinder.universalgcodesender.types.PointSegment)2