Search in sources :

Example 16 with GcodeState

use of com.willwinder.universalgcodesender.gcode.GcodeState in project Universal-G-Code-Sender by winder.

the class ArcExpanderTest method modalsReturnedFirst.

@Test
public void modalsReturnedFirst() throws Exception {
    System.out.println("arcExpandWithModals");
    GcodeState state = new GcodeState();
    state.currentPoint = new Position(0, 0, 0, MM);
    state.plane = XY;
    ArcExpander instance = new ArcExpander(true, 1);
    List<String> result = instance.processCommand("G17 G20 G02 X5 Y0 R12 S1300", state);
    assertThat(result.get(0)).isEqualTo("G17G20S1300");
    assertThat(result).size().isGreaterThan(2);
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 17 with GcodeState

use of com.willwinder.universalgcodesender.gcode.GcodeState in project Universal-G-Code-Sender by winder.

the class ArcExpanderTest method arcExpandadState.

@Test
public void arcExpandadState() throws Exception {
    System.out.println("arcExpandBadState");
    GcodeState state = new GcodeState();
    state.currentPoint = null;
    ArcExpander instance = new ArcExpander(true, 1);
    assertThatThrownBy(() -> instance.processCommand("G02 X5 Y0 R12", state)).isInstanceOf(GcodeParserException.class).hasMessage(Localization.getString("parser.processor.arc.start-error"));
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) GcodeParserException(com.willwinder.universalgcodesender.gcode.util.GcodeParserException) Test(org.junit.Test)

Example 18 with GcodeState

use of com.willwinder.universalgcodesender.gcode.GcodeState in project Universal-G-Code-Sender by winder.

the class ArcExpanderTest method expandArcG18.

@Test
public void expandArcG18() throws Exception {
    System.out.println("expandArcG18");
    GcodeState state = new GcodeState();
    state.currentPoint = new Position(0, 0, -1, MM);
    state.plane = ZX;
    // ///////////////////////////////////////////////////////
    for (double segmentLength = 0.1; segmentLength < 1; segmentLength += 0.1) {
        ArcExpander instance = new ArcExpander(true, segmentLength);
        // Half circle clockwise, Z-1 -> Z1, X0 -> X1 -> X0
        String command = "G2 Z1 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, 0, -1, MM), new Position(1, 0, 1, MM), state.plane);
        // Half circle clockwise, Z-1 -> Z1, X0 -> X-1 -> X0
        command = "G3 Z1 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(-1, 0, -1, MM), new Position(0, 0, 1, MM), state.plane);
    }
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Aggregations

GcodeState (com.willwinder.universalgcodesender.gcode.GcodeState)18 Position (com.willwinder.universalgcodesender.model.Position)15 Test (org.junit.Test)15 GcodeParserException (com.willwinder.universalgcodesender.gcode.util.GcodeParserException)1 Before (org.junit.Before)1