Search in sources :

Example 41 with Position

use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.

the class LineSplitterTest method testDiagonalLine.

/**
 * Line running across all axes.
 */
@Test
public void testDiagonalLine() throws Exception {
    System.out.println("diagonalLine");
    List<String> expected = Arrays.asList("G1X-0.5Y-0.5Z-0.5", "G1X0Y0Z0", "G1X0.5Y0.5Z0.5", "G1X1Y1Z1");
    splitterHarness(1, new Position(-1, -1, -1, MM), "G1X1Y1Z1", expected);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 42 with Position

use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.

the class LineSplitterTest method testIgnoreShortLine.

/**
 * Lines shorter than the length should not modify the input command.
 */
@Test
public void testIgnoreShortLine() throws Exception {
    System.out.println("shortLine");
    String command = "G1X0.01";
    double length = 2;
    List<String> expected = Arrays.asList(command);
    splitterHarness(length, new Position(0, 0, 0, MM), command, expected);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 43 with Position

use of com.willwinder.universalgcodesender.model.Position 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 44 with Position

use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.

the class LineSplitterTest method testSloppyFractionRounding.

/**
 * Sloppy fractional result.
 * (0,0,0, MM) -> (1,0,0, MM) line needs to split into 3 parts.
 * Verify that the infinite fraction is truncated to 4 digits.
 * Verify that the endpoint equals the real endpoint not the interpolated endpoint.
 */
@Test
public void testSloppyFractionRounding() throws Exception {
    System.out.println("sloppyFractions");
    double maxSegmentLength = 0.4;
    String command = "G1X1";
    List<String> expected = Arrays.asList("G1X0.3333Y0Z0", "G1X0.6667Y0Z0", "G1X1Y0Z0");
    splitterHarness(maxSegmentLength, new Position(0, 0, 0, MM), command, expected);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 45 with Position

use of com.willwinder.universalgcodesender.model.Position 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

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