Search in sources :

Example 21 with FirmwareSettingsException

use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.

the class WizardPanelStepCalibration method updateSettingFieldsFromFirmware.

private void updateSettingFieldsFromFirmware() {
    if (getBackend().getController() != null && getBackend().getController().getFirmwareSettings() != null) {
        try {
            DecimalFormat decimalFormat = new DecimalFormat(DECIMAL_FORMAT_PATTERN, Localization.dfs);
            textFieldSettingStepsX.setText(decimalFormat.format(getBackend().getController().getFirmwareSettings().getStepsPerMillimeter(Axis.X)));
            textFieldSettingStepsY.setText(decimalFormat.format(getBackend().getController().getFirmwareSettings().getStepsPerMillimeter(Axis.Y)));
            textFieldSettingStepsZ.setText(decimalFormat.format(getBackend().getController().getFirmwareSettings().getStepsPerMillimeter(Axis.Z)));
        } catch (FirmwareSettingsException e) {
            e.printStackTrace();
        }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) FirmwareSettingsException(com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)

Example 22 with FirmwareSettingsException

use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.

the class WizardPanelHoming method refreshControls.

private void refreshControls() {
    ThreadHelper.invokeLater(() -> {
        try {
            if (getBackend().getController() != null && getBackend().getController().getCapabilities().hasHoming() && getBackend().getController().getCapabilities().hasHardLimits() && getBackend().getController().getFirmwareSettings().isHardLimitsEnabled()) {
                IFirmwareSettings firmwareSettings = getBackend().getController().getFirmwareSettings();
                checkboxEnableHoming.setSelected(firmwareSettings.isHomingEnabled());
                checkboxEnableHoming.setVisible(true);
                labelHomingDirection.setVisible(firmwareSettings.isHomingEnabled());
                comboBoxInvertDirectionX.setVisible(firmwareSettings.isHomingEnabled());
                comboBoxInvertDirectionX.setSelectedIndex(firmwareSettings.isHomingDirectionInverted(Axis.X) ? 1 : 0);
                comboBoxInvertDirectionY.setVisible(firmwareSettings.isHomingEnabled());
                comboBoxInvertDirectionY.setSelectedIndex(firmwareSettings.isHomingDirectionInverted(Axis.Y) ? 1 : 0);
                comboBoxInvertDirectionZ.setVisible(firmwareSettings.isHomingEnabled());
                comboBoxInvertDirectionZ.setSelectedIndex(firmwareSettings.isHomingDirectionInverted(Axis.Z) ? 1 : 0);
                labelHomingNotSupported.setVisible(false);
                labelHardLimitsNotEnabled.setVisible(false);
                labelHomingInstructions.setVisible(firmwareSettings.isHomingEnabled());
                buttonHomeMachine.setVisible(firmwareSettings.isHomingEnabled());
                buttonAbort.setVisible(firmwareSettings.isHomingEnabled());
                separatorTop.setVisible(firmwareSettings.isHomingEnabled());
                separatorBottom.setVisible(firmwareSettings.isHomingEnabled());
            } else if (getBackend().getController() != null && getBackend().getController().getCapabilities().hasHoming() && !getBackend().getController().getFirmwareSettings().isHardLimitsEnabled()) {
                checkboxEnableHoming.setVisible(false);
                comboBoxInvertDirectionX.setVisible(false);
                comboBoxInvertDirectionY.setVisible(false);
                comboBoxInvertDirectionZ.setVisible(false);
                labelHomingNotSupported.setVisible(false);
                labelHardLimitsNotEnabled.setVisible(true);
                labelHomingDirection.setVisible(false);
                labelHomingInstructions.setVisible(false);
                buttonHomeMachine.setVisible(false);
                buttonAbort.setVisible(false);
                separatorTop.setVisible(false);
                separatorBottom.setVisible(false);
            } else {
                checkboxEnableHoming.setVisible(false);
                comboBoxInvertDirectionX.setVisible(false);
                comboBoxInvertDirectionY.setVisible(false);
                comboBoxInvertDirectionZ.setVisible(false);
                labelHomingNotSupported.setVisible(true);
                labelHardLimitsNotEnabled.setVisible(false);
                labelHomingDirection.setVisible(false);
                labelHomingInstructions.setVisible(false);
                buttonHomeMachine.setVisible(false);
                buttonAbort.setVisible(false);
                separatorTop.setVisible(false);
                separatorBottom.setVisible(false);
            }
        } catch (FirmwareSettingsException e) {
            NotifyDescriptor nd = new NotifyDescriptor.Message("Couldn't fetch firmware settings: " + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notify(nd);
        }
    }, 200);
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) IFirmwareSettings(com.willwinder.universalgcodesender.firmware.IFirmwareSettings) FirmwareSettingsException(com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)

Example 23 with FirmwareSettingsException

use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.

the class WizardPanelHoming method createInvertComboBox.

private JComboBox<String> createInvertComboBox(Axis axis) {
    JComboBox<String> result = new JComboBox<>();
    result.setVisible(false);
    result.addItem("+" + axis.name());
    result.addItem("-" + axis.name());
    result.addActionListener(event -> {
        IController controller = getBackend().getController();
        if (controller != null) {
            try {
                controller.getFirmwareSettings().setHomingDirectionInverted(axis, result.getSelectedIndex() == 1);
            } catch (FirmwareSettingsException e) {
                NotifyDescriptor nd = new NotifyDescriptor.Message("Unexpected error while updating setting: " + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(nd);
            }
        }
    });
    return result;
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) IController(com.willwinder.universalgcodesender.IController) JComboBox(javax.swing.JComboBox) FirmwareSettingsException(com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)

Example 24 with FirmwareSettingsException

use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.

the class WizardPanelMotorWiring method refreshReverseDirectionCheckboxes.

private void refreshReverseDirectionCheckboxes() {
    IController controller = getBackend().getController();
    if (controller != null) {
        try {
            checkboxReverseX.setSelected(controller.getFirmwareSettings().isInvertDirection(Axis.X));
            checkboxReverseY.setSelected(controller.getFirmwareSettings().isInvertDirection(Axis.Y));
            checkboxReverseZ.setSelected(controller.getFirmwareSettings().isInvertDirection(Axis.Z));
        } catch (FirmwareSettingsException e) {
            NotifyDescriptor nd = new NotifyDescriptor.Message("Unexpected error while getting setting: " + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notify(nd);
        }
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) IController(com.willwinder.universalgcodesender.IController) FirmwareSettingsException(com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)

Example 25 with FirmwareSettingsException

use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.

the class NavigationButtons method refresh.

public void refresh(Position machineCoord) {
    if (backendAPI.getController() == null || backendAPI.getController().getFirmwareSettings() == null) {
        return;
    }
    try {
        IFirmwareSettings firmwareSettings = backendAPI.getController().getFirmwareSettings();
        updateNavigationButton(firmwareSettings, Axis.X, machineCoord, buttonXpos, buttonXneg);
        updateNavigationButton(firmwareSettings, Axis.Y, machineCoord, buttonYpos, buttonYneg);
        updateNavigationButton(firmwareSettings, Axis.Z, machineCoord, buttonZpos, buttonZneg);
    } catch (FirmwareSettingsException ignored) {
    // Never mind
    }
}
Also used : IFirmwareSettings(com.willwinder.universalgcodesender.firmware.IFirmwareSettings) FirmwareSettingsException(com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)

Aggregations

FirmwareSettingsException (com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)25 IFirmwareSettings (com.willwinder.universalgcodesender.firmware.IFirmwareSettings)10 FirmwareSetting (com.willwinder.universalgcodesender.firmware.FirmwareSetting)8 NotifyDescriptor (org.openide.NotifyDescriptor)7 DecimalFormat (java.text.DecimalFormat)4 ParseException (java.text.ParseException)4 IController (com.willwinder.universalgcodesender.IController)3 IFirmwareSettingsListener (com.willwinder.universalgcodesender.firmware.IFirmwareSettingsListener)3 Test (org.junit.Test)3 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)2 TimeoutException (java.util.concurrent.TimeoutException)2 NavigationButtons (com.willwinder.ugs.nbp.setupwizard.NavigationButtons)1 TinyGGcodeCommand (com.willwinder.universalgcodesender.types.TinyGGcodeCommand)1 RoundedPanel (com.willwinder.universalgcodesender.uielements.components.RoundedPanel)1 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 ArrayList (java.util.ArrayList)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1