Search in sources :

Example 11 with GcodeState

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

the class TranslatorTest method setup.

@Before
public void setup() {
    instance = new Translator(new Position(10.1, 20.2, 30.3, Units.MM));
    state = new GcodeState();
    state.units = Code.G21;
    state.inAbsoluteMode = true;
    state.inAbsoluteIJKMode = false;
    state.currentPoint = null;
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Before(org.junit.Before)

Example 12 with GcodeState

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

the class StateTopComponent method createTimer.

private Timer createTimer() {
    return new Timer((int) REFRESH_RATE.toMillis(), (ae) -> {
        java.awt.EventQueue.invokeLater(() -> {
            GcodeState state = backend.getGcodeState();
            if (state == null)
                return;
            try {
                loading = true;
                motionBox.setSelectedItem(state.currentMotionMode.toString());
                unitBox.setSelectedItem(get(state.units));
                feedModeBox.setSelectedItem(get(state.feedMode));
                distanceModeBox.setSelectedItem(get(state.distanceMode));
                workOffsetBox.setSelectedItem(get(state.offset));
                planeBox.setSelectedItem(get(state.plane.code));
                this.setFeedAndSpeed(state.speed, state.spindleSpeed);
            } finally {
                loading = false;
            }
        });
    });
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState)

Example 13 with GcodeState

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

the class LineSplitterTest method testShortLineNoOp.

/**
 * Multiple commands on 1 line sent to the splitter should throw.
 */
@Test
public void testShortLineNoOp() throws Exception {
    System.out.println("testShortLineNoOp");
    LineSplitter instance = new LineSplitter(2);
    GcodeState state = new GcodeState();
    state.currentPoint = new Position(0, 0, 0, MM);
    state.inAbsoluteMode = true;
    String command = "G20 G1X1Y1Z1";
    List<String> result = instance.processCommand(command, state);
    assertThat(result).containsExactly(command);
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 14 with GcodeState

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

the class LineSplitterTest method testIgnoreNonLines.

/**
 * Commands without G0/G1 should not be modified.
 */
@Test
public void testIgnoreNonLines() throws Exception {
    System.out.println("ignoreNonLines");
    LineSplitter instance = new LineSplitter(1.5);
    String command;
    GcodeState state = new GcodeState();
    state.currentPoint = new Position(0, 0, 0, MM);
    state.inAbsoluteMode = true;
    command = "G20G2X1Y1Z1";
    List<String> result = instance.processCommand(command, state);
    assertThat(result).containsExactly(command);
    command = "G17";
    result = instance.processCommand(command, state);
    assertThat(result).containsExactly(command);
}
Also used : GcodeState(com.willwinder.universalgcodesender.gcode.GcodeState) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 15 with GcodeState

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

the class MeshLevelerTest method testUnexpectedArc.

@Test
public void testUnexpectedArc() throws GcodeParserException {
    expectedEx.expect(GcodeParserException.class);
    expectedEx.expectMessage(MeshLeveler.ERROR_UNEXPECTED_ARC);
    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("G2X1", state);
}
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