use of com.willwinder.universalgcodesender.listeners.ControllerStatus in project Universal-G-Code-Sender by winder.
the class TinyGController method rawResponseHandler.
@Override
protected void rawResponseHandler(String response) {
JsonObject jo;
try {
jo = TinyGUtils.jsonToObject(response);
} catch (Exception e) {
// this.messageForConsole(response + "\n");
return;
}
if (TinyGUtils.isRestartingResponse(jo)) {
this.messageForConsole("[restarting] " + response + "\n");
this.isReady = false;
} else if (TinyGUtils.isReadyResponse(jo)) {
// this.messageForConsole("Got version: " + TinyGUtils.getVersion(jo) + "\n");
this.messageForConsole("[ready] " + response + "\n");
this.isReady = true;
} else if (TinyGUtils.isStatusResponse(jo)) {
TinyGUtils.StatusResult result = TinyGUtils.updateStatus(jo);
state = result.state;
machineLocation.set(result.machine);
workLocation.set(result.work);
ControllerStatus cs = new ControllerStatus(state, machineLocation, workLocation);
dispatchStatusString(cs);
} else if (TinyGGcodeCommand.isOkErrorResponse(response)) {
try {
this.commandComplete(response);
} catch (Exception e) {
this.errorMessageForConsole(Localization.getString("controller.error.response") + " <" + response + ">: " + e.getMessage());
}
this.messageForConsole(response + "\n");
} else {
// Display any unhandled messages
this.messageForConsole("[unhandled message] " + response + "\n");
}
}
use of com.willwinder.universalgcodesender.listeners.ControllerStatus in project Universal-G-Code-Sender by winder.
the class GrblUtilsTest method getStatusFromStringVersion1WhereFeedOverridesFeedSpindleStatusString.
@Test
public void getStatusFromStringVersion1WhereFeedOverridesFeedSpindleStatusString() {
String status = "<Idle|WPos:4.0,5.0,6.0|WCO:7.0,8.0,9.0|Ov:1,2,3|FS:12345.7,65432.1|F:12345.6|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(Double.valueOf(12345.6), controllerStatus.getFeedSpeed());
assertEquals(Double.valueOf(65432.1), controllerStatus.getSpindleSpeed());
}
use of com.willwinder.universalgcodesender.listeners.ControllerStatus in project Universal-G-Code-Sender by winder.
the class GrblUtilsTest method getStatusFromStringVersion1WithoutPinsStatusString.
@Test
public void getStatusFromStringVersion1WithoutPinsStatusString() {
String status = "<Idle|WPos:4.0,5.0,6.0|WCO:7.0,8.0,9.0|Ov:1,2,3|FS:12345.7,65432.1|F:12345.6|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);
assertFalse(controllerStatus.getEnabledPins().CycleStart);
assertFalse(controllerStatus.getEnabledPins().Door);
assertFalse(controllerStatus.getEnabledPins().Hold);
assertFalse(controllerStatus.getEnabledPins().SoftReset);
assertFalse(controllerStatus.getEnabledPins().Probe);
assertFalse(controllerStatus.getEnabledPins().X);
assertFalse(controllerStatus.getEnabledPins().Y);
assertFalse(controllerStatus.getEnabledPins().Z);
}
use of com.willwinder.universalgcodesender.listeners.ControllerStatus in project Universal-G-Code-Sender by winder.
the class GrblUtilsTest method getStatusFromStringVersion1WithoutWorkCoordinateOffsetStatusString.
@Test
public void getStatusFromStringVersion1WithoutWorkCoordinateOffsetStatusString() {
String status = "<Idle|MPos:1.1,2.2,3.3|WPos:4.4,5.5,6.6|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(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(0, 0, 0, UnitUtils.Units.MM), controllerStatus.getWorkCoordinateOffset());
}
use of com.willwinder.universalgcodesender.listeners.ControllerStatus in project Universal-G-Code-Sender by winder.
the class GrblUtilsTest method getStatusFromStringVersion1WithoutWorkCoordinateStatusString.
@Test
public void getStatusFromStringVersion1WithoutWorkCoordinateStatusString() {
String status = "<Idle|MPos:1.0,2.0,3.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(1, 2, 3, UnitUtils.Units.MM), controllerStatus.getMachineCoord());
assertEquals(new Position(-6, -6, -6, UnitUtils.Units.MM), controllerStatus.getWorkCoord());
assertEquals(new Position(7, 8, 9, UnitUtils.Units.MM), controllerStatus.getWorkCoordinateOffset());
}
Aggregations