Search in sources :

Example 1 with IController

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

Example 2 with IController

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;
}
Also used : ControllerStatus(com.willwinder.universalgcodesender.listeners.ControllerStatus) Status(com.willwinder.universalgcodesender.pendantui.v1.model.Status) IController(com.willwinder.universalgcodesender.IController) UnitUtils(com.willwinder.universalgcodesender.model.UnitUtils) ControllerStatus(com.willwinder.universalgcodesender.listeners.ControllerStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with IController

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);
}
Also used : IController(com.willwinder.universalgcodesender.IController) Test(org.junit.Test)

Example 4 with IController

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);
}
Also used : IController(com.willwinder.universalgcodesender.IController) BackendAPI(com.willwinder.universalgcodesender.model.BackendAPI) FileObject(org.openide.filesystems.FileObject) Before(org.junit.Before)

Example 5 with IController

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

Aggregations

IController (com.willwinder.universalgcodesender.IController)7 FirmwareSettingsException (com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)3 IFirmwareSettings (com.willwinder.universalgcodesender.firmware.IFirmwareSettings)2 NotifyDescriptor (org.openide.NotifyDescriptor)2 ICommunicator (com.willwinder.universalgcodesender.ICommunicator)1 ControllerStatus (com.willwinder.universalgcodesender.listeners.ControllerStatus)1 BackendAPI (com.willwinder.universalgcodesender.model.BackendAPI)1 UnitUtils (com.willwinder.universalgcodesender.model.UnitUtils)1 Status (com.willwinder.universalgcodesender.pendantui.v1.model.Status)1 JComboBox (javax.swing.JComboBox)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Before (org.junit.Before)1 Test (org.junit.Test)1 FileObject (org.openide.filesystems.FileObject)1