Search in sources :

Example 1 with ICommunicator

use of com.willwinder.universalgcodesender.ICommunicator 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();
    }
}
Also used : IController(com.willwinder.universalgcodesender.IController) IFirmwareSettings(com.willwinder.universalgcodesender.firmware.IFirmwareSettings) ICommunicator(com.willwinder.universalgcodesender.ICommunicator)

Aggregations

ICommunicator (com.willwinder.universalgcodesender.ICommunicator)1 IController (com.willwinder.universalgcodesender.IController)1 IFirmwareSettings (com.willwinder.universalgcodesender.firmware.IFirmwareSettings)1