Search in sources :

Example 46 with Position

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

the class GrblUtilsTest method getStatusFromStringVersion1WithoutMachineCoordinateStatusString.

@Test
public void getStatusFromStringVersion1WithoutMachineCoordinateStatusString() {
    String status = "<Idle|WPos:4.0,5.0,6.0|WCO:7.0,8.0,9.0|Ov:1,2,3|F:12345.6|FS:12345.7,65432.1|Pn:XYZPDHRS|A:SFMC>";
    Capabilities version = new Capabilities();
    version.addCapability(GrblCapabilitiesConstants.V1_FORMAT);
    UnitUtils.Units unit = UnitUtils.Units.MM;
    ControllerStatus controllerStatus = GrblUtils.getStatusFromStatusString(null, status, version, unit);
    assertEquals(new Position(11, 13, 15, UnitUtils.Units.MM), controllerStatus.getMachineCoord());
    assertEquals(new Position(4, 5, 6, UnitUtils.Units.MM), controllerStatus.getWorkCoord());
    assertEquals(new Position(7, 8, 9, UnitUtils.Units.MM), controllerStatus.getWorkCoordinateOffset());
}
Also used : UnitUtils(com.willwinder.universalgcodesender.model.UnitUtils) ControllerStatus(com.willwinder.universalgcodesender.listeners.ControllerStatus) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 47 with Position

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

the class GrblUtilsTest method testGetMachinePositionFromStatusString.

/**
 * Test of getMachinePositionFromStatusString method, of class GrblUtils.
 */
@Test
public void testGetMachinePositionFromStatusString() {
    System.out.println("getMachinePositionFromStatusString");
    String status = "<Idle,MPos:5.529,0.560,7.000,WPos:1.529,-5.440,-0.000>";
    Capabilities version = new Capabilities();
    version.addCapability(GrblCapabilitiesConstants.REAL_TIME);
    Position expResult = new Position(5.529, 0.560, 7.000, UnitUtils.Units.UNKNOWN);
    Position result = GrblUtils.getMachinePositionFromStatusString(status, version, UnitUtils.Units.UNKNOWN);
    assertEquals(expResult, result);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 48 with Position

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

the class GrblUtilsTest method getStatusFromStringVersion1WithCompleteStatusString.

@Test
public void getStatusFromStringVersion1WithCompleteStatusString() {
    String status = "<Idle|MPos:1.1,2.2,3.3|WPos:4.4,5.5,6.6|WCO:7.7,8.8,9.9|Ov:1,2,3|F:12345.6|FS:12345.7,65432.1|Pn:XYZPDHRS|A:SFMC>";
    Capabilities version = new Capabilities();
    version.addCapability(GrblCapabilitiesConstants.V1_FORMAT);
    UnitUtils.Units unit = UnitUtils.Units.MM;
    ControllerStatus controllerStatus = GrblUtils.getStatusFromStatusString(null, status, version, unit);
    assertEquals("Idle", controllerStatus.getState());
    assertEquals(new Position(1.1, 2.2, 3.3, UnitUtils.Units.MM), controllerStatus.getMachineCoord());
    assertEquals(new Position(4.4, 5.5, 6.6, UnitUtils.Units.MM), controllerStatus.getWorkCoord());
    assertEquals(new Position(7.7, 8.8, 9.9, UnitUtils.Units.MM), controllerStatus.getWorkCoordinateOffset());
    assertEquals(1, controllerStatus.getOverrides().feed);
    assertEquals(2, controllerStatus.getOverrides().rapid);
    assertEquals(3, controllerStatus.getOverrides().spindle);
    assertEquals(Double.valueOf(12345.7), controllerStatus.getFeedSpeed());
    assertEquals(Double.valueOf(65432.1), controllerStatus.getSpindleSpeed());
    assertTrue(controllerStatus.getEnabledPins().CycleStart);
    assertTrue(controllerStatus.getEnabledPins().Door);
    assertTrue(controllerStatus.getEnabledPins().Hold);
    assertTrue(controllerStatus.getEnabledPins().SoftReset);
    assertTrue(controllerStatus.getEnabledPins().Probe);
    assertTrue(controllerStatus.getEnabledPins().X);
    assertTrue(controllerStatus.getEnabledPins().Y);
    assertTrue(controllerStatus.getEnabledPins().Z);
    assertTrue(controllerStatus.getAccessoryStates().Flood);
    assertTrue(controllerStatus.getAccessoryStates().Mist);
    assertTrue(controllerStatus.getAccessoryStates().SpindleCCW);
    assertTrue(controllerStatus.getAccessoryStates().SpindleCW);
}
Also used : UnitUtils(com.willwinder.universalgcodesender.model.UnitUtils) ControllerStatus(com.willwinder.universalgcodesender.listeners.ControllerStatus) Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 49 with Position

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

the class GrblUtilsTest method testGetWorkPositionFromStatusString.

/**
 * Test of getWorkPositionFromStatusString method, of class GrblUtils.
 */
@Test
public void testGetWorkPositionFromStatusString() {
    System.out.println("getWorkPositionFromStatusString");
    String status = "<Idle,MPos:5.529,0.560,7.000,WPos:1.529,-5.440,-0.000>";
    Capabilities version = new Capabilities();
    version.addCapability(GrblCapabilitiesConstants.REAL_TIME);
    Position expResult = new Position(1.529, -5.440, -0.000, UnitUtils.Units.UNKNOWN);
    Position result = GrblUtils.getWorkPositionFromStatusString(status, version, UnitUtils.Units.UNKNOWN);
    assertEquals(expResult, result);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) Test(org.junit.Test)

Example 50 with Position

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

the class GcodeParserTest method nonGcodeIgnoresImplicitGcode.

@Test
public void nonGcodeIgnoresImplicitGcode() throws Exception {
    GcodeParser gcp = new GcodeParser();
    gcp.addCommandProcessor(new CommentProcessor());
    GcodeState initialState = new GcodeState();
    initialState.currentPoint = new Position(0, 0, 1, MM);
    initialState.currentMotionMode = Code.G0;
    List<String> result = gcp.preprocessCommand("M05", initialState);
    assertEquals(1, result.size());
    assertEquals("M05", result.get(0));
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) CommentProcessor(com.willwinder.universalgcodesender.gcode.processors.CommentProcessor) 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