use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelStepCalibration method updateEstimationFromMesurement.
private void updateEstimationFromMesurement(JTextField textFieldMesurement, Axis axis, JLabel label) {
if (getBackend().getWorkPosition() != null) {
try {
DecimalFormat decimalFormat = new DecimalFormat(DECIMAL_FORMAT_PATTERN, Localization.dfs);
double measured = decimalFormat.parse(textFieldMesurement.getText()).doubleValue();
double real = getBackend().getWorkPosition().get(axis);
double stepsPerMM = getBackend().getController().getFirmwareSettings().getStepsPerMillimeter(axis);
double computed = (real / measured) * stepsPerMM;
if (measured == 0 || real == 0) {
computed = 0;
}
label.setText(decimalFormat.format(Math.abs(computed)) + " steps/mm est.");
} catch (FirmwareSettingsException | ParseException ignored) {
// Never mind
}
}
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelHardLimits method refreshComponents.
private void refreshComponents() {
ThreadHelper.invokeLater(() -> {
try {
if (getBackend().getController() != null && getBackend().getController().getCapabilities().hasHardLimits()) {
IFirmwareSettings firmwareSettings = getBackend().getController().getFirmwareSettings();
checkboxEnableHardLimits.setSelected(firmwareSettings.isHardLimitsEnabled());
checkboxInvertLimitPins.setSelected(firmwareSettings.isHardLimitsInverted());
checkboxEnableHardLimits.setVisible(true);
checkboxInvertLimitPins.setVisible(firmwareSettings.isHardLimitsEnabled());
labelInstructions.setVisible(firmwareSettings.isHardLimitsEnabled());
labelLimitX.setVisible(firmwareSettings.isHardLimitsEnabled());
labelLimitY.setVisible(firmwareSettings.isHardLimitsEnabled());
labelLimitZ.setVisible(firmwareSettings.isHardLimitsEnabled());
labelHardLimitsNotSupported.setVisible(false);
} else {
checkboxEnableHardLimits.setVisible(false);
checkboxInvertLimitPins.setVisible(false);
labelInstructions.setVisible(false);
labelLimitX.setVisible(false);
labelLimitY.setVisible(false);
labelLimitZ.setVisible(false);
labelHardLimitsNotSupported.setVisible(true);
}
} catch (FirmwareSettingsException e) {
NotifyDescriptor nd = new NotifyDescriptor.Message("Couldn't fetch the hard limits settings: " + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
}
}, 200);
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelHoming method initComponents.
private void initComponents() {
labelDescription = new JLabel("<html><body><p>" + Localization.getString("platform.plugin.setupwizard.homing.intro") + "</p></body></html>");
checkboxEnableHoming = new JCheckBox(Localization.getString("platform.plugin.setupwizard.homing.enable"));
checkboxEnableHoming.addActionListener(event -> {
try {
getBackend().getController().getFirmwareSettings().setHomingEnabled(checkboxEnableHoming.isSelected());
} catch (FirmwareSettingsException e) {
NotifyDescriptor nd = new NotifyDescriptor.Message("Couldn't enable/disable the hard limits settings: " + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
}
});
labelHardLimitsNotEnabled = new JLabel("<html><body>" + Localization.getString("platform.plugin.setupwizard.homing.require-limit-switches") + "</body></html>", ImageUtilities.loadImageIcon("icons/information24.png", false), JLabel.LEFT);
labelHardLimitsNotEnabled.setVisible(false);
labelHomingNotSupported = new JLabel("<html><body>" + Localization.getString("platform.plugin.setupwizard.homing.not-available") + "</body></html>", ImageUtilities.loadImageIcon("icons/information24.png", false), JLabel.LEFT);
labelHomingNotSupported.setVisible(false);
separatorTop = new JSeparator(SwingConstants.HORIZONTAL);
separatorTop.setVisible(false);
labelHomingDirection = new JLabel("<html><body>" + Localization.getString("platform.plugin.setupwizard.homing.instruction1") + "</body></html>");
labelHomingDirection.setVisible(false);
initInvertComboBoxes();
separatorBottom = new JSeparator(SwingConstants.HORIZONTAL);
separatorBottom.setVisible(false);
labelHomingInstructions = new JLabel("<html><body><p>" + Localization.getString("platform.plugin.setupwizard.homing.instruction2") + "</p></body></html>");
labelHomingInstructions.setVisible(false);
initButtons();
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelMotorWiring method initComponents.
private void initComponents() {
labelDescription = new JLabel("<html><body><p>" + Localization.getString("platform.plugin.setupwizard.motor-wiring.intro") + "</p></body></html>");
softLimitsInfo = new RoundedPanel(8);
softLimitsInfo.setLayout(new MigLayout("fill, inset 10, gap 0"));
softLimitsInfo.setBackground(ThemeColors.VERY_LIGHT_BLUE_GREY);
softLimitsInfo.setForeground(ThemeColors.LIGHT_GREY);
softLimitsInfo.add(new JLabel(ImageUtilities.loadImageIcon("icons/information24.png", false)), "gapright 10");
softLimitsInfo.add(new JLabel("<html><body>" + Localization.getString("platform.plugin.setupwizard.motor-wiring.soft-limits-enabled") + "</body></html>"));
navigationButtons = new NavigationButtons(getBackend(), 0.1, 100);
checkboxReverseX = new JCheckBox(Localization.getString("platform.plugin.setupwizard.motor-wiring.reverse-direction"));
checkboxReverseX.addActionListener(event -> {
if (getBackend().getController() != null) {
try {
getBackend().getController().getFirmwareSettings().setInvertDirection(Axis.X, checkboxReverseX.isSelected());
} catch (FirmwareSettingsException e) {
e.printStackTrace();
}
}
});
checkboxReverseY = new JCheckBox(Localization.getString("platform.plugin.setupwizard.motor-wiring.reverse-direction"));
checkboxReverseY.addActionListener(event -> {
if (getBackend().getController() != null) {
try {
getBackend().getController().getFirmwareSettings().setInvertDirection(Axis.Y, checkboxReverseY.isSelected());
} catch (FirmwareSettingsException e) {
e.printStackTrace();
}
}
});
checkboxReverseZ = new JCheckBox(Localization.getString("platform.plugin.setupwizard.motor-wiring.reverse-direction"));
checkboxReverseZ.addActionListener(event -> {
if (getBackend().getController() != null) {
try {
getBackend().getController().getFirmwareSettings().setInvertDirection(Axis.Z, checkboxReverseZ.isSelected());
} catch (FirmwareSettingsException e) {
e.printStackTrace();
}
}
});
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class GrblFirmwareSettingsCommunicatorListener method updateSettingOnController.
/**
* Sends a command to update a setting on the controller. The method will block until we get a response
* from the controller or if a timeout is triggered if the setting took too long to update.
*
* @param setting the setting to update
* @return the updated setting or an empty optional if it couldn't be updated.
* @throws FirmwareSettingsException will be thrown if the controller isn't ready to receive setting updates or if
* the update took to long and caused a timeout
*/
public Optional<FirmwareSetting> updateSettingOnController(FirmwareSetting setting) throws FirmwareSettingsException {
if (isUpdatingSettings()) {
throw new FirmwareSettingsException("The settings are being updated in another thread.");
}
if (!canSendToController()) {
throw new FirmwareSettingsException("The controller is not ready to receive commands.");
}
boolean previousSingleStepMode = controller.getSingleStepMode();
boolean previousStatusUpdatesEnabled = controller.getStatusUpdatesEnabled();
controller.setStatusUpdatesEnabled(false);
controller.setSingleStepMode(true);
try {
try {
updatedSetting = null;
newSetting = setting;
GcodeCommand command = controller.createCommand(setting.getKey() + "=" + setting.getValue());
controller.sendCommandImmediately(command);
} catch (Exception e) {
throw new FirmwareSettingsException("Couldn't send update setting command to the controller: " + setting.getKey() + "=" + setting.getValue() + ".", e);
}
waitUntilUpdateFinished();
} finally {
controller.setSingleStepMode(previousSingleStepMode);
controller.setStatusUpdatesEnabled(previousStatusUpdatesEnabled);
}
// Reset internal states
Optional<FirmwareSetting> result = Optional.ofNullable(updatedSetting);
updatedSetting = null;
newSetting = null;
return result;
}
Aggregations