use of com.willwinder.universalgcodesender.IController in project Universal-G-Code-Sender by winder.
the class DiagnosticsTopComponent method refreshValues.
private void refreshValues() {
try {
labels.get("backend:isConnected").setText(String.valueOf(backend.isConnected()));
labels.get("backend:isSendingFile").setText(String.valueOf(backend.isSendingFile()));
labels.get("backend:isIdle").setText(String.valueOf(backend.isIdle()));
labels.get("backend:isPaused").setText(String.valueOf(backend.isPaused()));
labels.get("backend:canPause").setText(String.valueOf(backend.canPause()));
labels.get("backend:canCancel").setText(String.valueOf(backend.canCancel()));
labels.get("backend:canSend").setText(String.valueOf(backend.canSend()));
labels.get("backend:getControllerState").setText(String.valueOf(backend.getControllerState().toString()));
} catch (Exception e) {
e.printStackTrace();
}
try {
IController controller = backend.getController();
if (controller != null) {
labels.get("controller:isPaused").setText(String.valueOf(controller.isPaused()));
labels.get("controller:isIdle").setText(String.valueOf(controller.isIdle()));
labels.get("controller:isCommOpen").setText(String.valueOf(controller.isCommOpen()));
labels.get("controller:isStreaming").setText(String.valueOf(controller.isStreaming()));
labels.get("controller:rowsInSend").setText(String.valueOf(controller.rowsInSend()));
labels.get("controller:rowsSent").setText(String.valueOf(controller.rowsSent()));
labels.get("controller:rowsRemaining").setText(String.valueOf(controller.rowsRemaining()));
labels.get("controller:getSingleStepMode").setText(String.valueOf(controller.getSingleStepMode()));
labels.get("controller:getStatusUpdatesEnabled").setText(String.valueOf(controller.getStatusUpdatesEnabled()));
labels.get("controller:getStatusUpdateRate").setText(String.valueOf(controller.getStatusUpdateRate()));
labels.get("controller:getControlState").setText(String.valueOf(controller.getControlState()));
IFirmwareSettings firmwareSettings = controller.getFirmwareSettings();
if (firmwareSettings != null) {
labels.get("settings:isHomingEnabled").setText(String.valueOf(firmwareSettings.isHomingEnabled()));
if (firmwareSettings.getReportingUnits() != null) {
labels.get("settings:getReportingUnits").setText(controller.getFirmwareSettings().getReportingUnits().toString());
} else {
labels.get("settings:getReportingUnits").setText("?");
}
}
ICommunicator communicator = controller.getCommunicator();
if (communicator != null) {
labels.get("communicator:numActiveCommands").setText(String.valueOf(communicator.numActiveCommands()));
labels.get("communicator:isPaused").setText(String.valueOf(communicator.isPaused()));
labels.get("communicator:getSingleStepMode").setText(String.valueOf(communicator.getSingleStepMode()));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.willwinder.universalgcodesender.IController in project Universal-G-Code-Sender by winder.
the class StatusResource method getStatus.
@GET
@Path("getStatus")
@Produces(MediaType.APPLICATION_JSON)
public Status getStatus() {
Status status = new Status();
IController controller = backendAPI.getController();
if (controller != null) {
UnitUtils.Units preferredUnits = backendAPI.getSettings().getPreferredUnits();
ControllerStatus controllerStatus = controller.getControllerStatus();
if (controllerStatus != null) {
status.setMachineCoord(controllerStatus.getMachineCoord().getPositionIn(preferredUnits));
status.setWorkCoord(controllerStatus.getWorkCoord().getPositionIn(preferredUnits));
status.setState(controllerStatus.getState());
status.setFeedSpeed(controllerStatus.getFeedSpeed());
status.setSpindleSpeed(controllerStatus.getSpindleSpeed());
} else {
// Hack, we are connected so we need to set it to an unknown state
status.setState(ControllerState.UNKNOWN);
}
status.setRowCount(backendAPI.getNumRows());
status.setCompletedRowCount(backendAPI.getNumCompletedRows());
status.setRemainingRowCount(backendAPI.getNumRemainingRows());
if (backendAPI.getGcodeFile() != null) {
status.setFileName(backendAPI.getGcodeFile().getName());
} else {
status.setFileName("");
}
status.setSendDuration(backendAPI.getSendDuration());
status.setSendRemainingDuration(backendAPI.getSendRemainingDuration());
}
return status;
}
use of com.willwinder.universalgcodesender.IController in project Universal-G-Code-Sender by winder.
the class GUIBackendTest method getControllerShouldBeOkWhenConnected.
@Test
public void getControllerShouldBeOkWhenConnected() throws Exception {
// Given
instance.connect(FIRMWARE, PORT, BAUD_RATE);
// When
IController result = instance.getController();
// Then
assertEquals(controller, result);
}
use of com.willwinder.universalgcodesender.IController in project Universal-G-Code-Sender by winder.
the class InvalidGrblCommandErrorParserTest method setupParser.
@Before
public void setupParser() {
FileObject fileObject = mock(FileObject.class);
BackendAPI backendAPI = mock(BackendAPI.class);
IController grblController = mock(GrblController.class);
when(backendAPI.getController()).thenReturn(grblController);
when(backendAPI.isConnected()).thenReturn(true);
parser = new InvalidGrblCommandErrorParser(fileObject, backendAPI);
}
use of com.willwinder.universalgcodesender.IController in project Universal-G-Code-Sender by winder.
the class WizardPanelStepCalibration method checkPulseIntervalLimits.
/**
* Calculates if the pulse interval would exceed the max computing speed and will set an warning message.
* <p>
* It's calculated as:
* maxFeedRate / 60 * stepsPerMM
* <p>
* Where maxFeedRate is given in mm/minute
*/
private void checkPulseIntervalLimits() {
IController controller = getBackend().getController();
IFirmwareSettings firmwareSettings = controller.getFirmwareSettings();
int maxComputingSpeed = 0;
for (Axis axis : Axis.values()) {
try {
// Get the maximum feed rate in mm/min
double maxFeedRate = firmwareSettings.getMaximumRate(axis);
// Fetch the current steps per mm setting
JTextField settingsTextField = getSettingsTextField(axis);
if (settingsTextField == null) {
continue;
}
double newStepsPerMMSetting = parseDouble(settingsTextField.getText());
double currentStepsPerMMSetting = firmwareSettings.getStepsPerMillimeter(axis);
double stepsPerMMSetting = Math.max(newStepsPerMMSetting, currentStepsPerMMSetting);
// Calculate the currently needed processing speed
double computingSpeed = (maxFeedRate / 60.0) * stepsPerMMSetting;
maxComputingSpeed = (int) Math.max(computingSpeed, maxComputingSpeed);
} catch (FirmwareSettingsException ignored) {
// Never mind
}
}
if (maxComputingSpeed > 30000) {
setErrorMessage(" " + String.format(Localization.getString("platform.plugin.setupwizard.calibration.computer-speed-warning"), (maxComputingSpeed / 1000) + "kHz"));
} else {
setErrorMessage("");
}
}
Aggregations