use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class GrblFirmwareSettingsTest method setValueShouldTimeoutIfNoResponseFromController.
@Test
public void setValueShouldTimeoutIfNoResponseFromController() throws Exception {
// Given
when(controller.isStreaming()).thenReturn(false);
when(controller.isCommOpen()).thenReturn(true);
target.rawResponseListener("$0=10");
// Add a listener
IFirmwareSettingsListener firmwareSettingsListener = mock(IFirmwareSettingsListener.class);
target.addListener(firmwareSettingsListener);
// When
try {
target.setValue("$0", "11");
} catch (FirmwareSettingsException e) {
assertTrue("Make sure the exception contains the word 'Timeout'", e.getMessage().contains("Timeout"));
}
// Then
verify(controller, times(1)).sendCommandImmediately(any());
verify(firmwareSettingsListener, times(0)).onUpdatedFirmwareSetting(any());
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelSoftLimits method onSave.
private void onSave(Axis axis) {
if (getBackend().getController() != null) {
try {
IFirmwareSettings firmwareSettings = getBackend().getController().getFirmwareSettings();
switch(axis) {
case X:
double limitX = Math.abs(decimalFormat.parse(textFieldSoftLimitX.getText()).doubleValue());
firmwareSettings.setSoftLimit(axis, limitX);
buttonUpdateSettingsX.setEnabled(false);
break;
case Y:
double limitY = Math.abs(decimalFormat.parse(textFieldSoftLimitY.getText()).doubleValue());
firmwareSettings.setSoftLimit(axis, limitY);
buttonUpdateSettingsY.setEnabled(false);
break;
case Z:
double limitZ = Math.abs(decimalFormat.parse(textFieldSoftLimitZ.getText()).doubleValue());
firmwareSettings.setSoftLimit(axis, limitZ);
buttonUpdateSettingsZ.setEnabled(false);
break;
default:
}
} catch (ParseException | FirmwareSettingsException ignored) {
// Never mind
}
}
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelSoftLimits method initialize.
@Override
public void initialize() {
getBackend().addUGSEventListener(this);
refeshControls();
try {
IFirmwareSettings firmwareSettings = getBackend().getController().getFirmwareSettings();
textFieldSoftLimitX.setText(decimalFormat.format(firmwareSettings.getSoftLimit(Axis.X)));
textFieldSoftLimitY.setText(decimalFormat.format(firmwareSettings.getSoftLimit(Axis.Y)));
textFieldSoftLimitZ.setText(decimalFormat.format(firmwareSettings.getSoftLimit(Axis.Z)));
} catch (FirmwareSettingsException e) {
NotifyDescriptor nd = new NotifyDescriptor.Message("Couldn't fetch firmware settings: " + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
}
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException in project Universal-G-Code-Sender by winder.
the class WizardPanelStepCalibration method checkUpdatedValues.
/**
* Check if values are updated in the text fields. It will enable the update buttons if it's a new setting.
*/
private void checkUpdatedValues() {
if (getBackend().getController() != null && getBackend().getController().getFirmwareSettings() != null) {
try {
IFirmwareSettings firmwareSettings = getBackend().getController().getFirmwareSettings();
for (Axis axis : Axis.values()) {
double stepsPerMillimeter = MathUtils.round(firmwareSettings.getStepsPerMillimeter(axis), 3);
JTextField textField = getSettingsTextField(axis);
JButton buttonUpdateSettings = getUpdateSettingsButton(axis);
if (textField == null || buttonUpdateSettings == null) {
continue;
}
buttonUpdateSettings.setEnabled(false);
try {
DecimalFormat decimalFormat = new DecimalFormat(DECIMAL_FORMAT_PATTERN, Localization.dfs);
double newValue = decimalFormat.parse(textField.getText()).doubleValue();
if (stepsPerMillimeter != newValue) {
buttonUpdateSettings.setEnabled(true);
}
} catch (ParseException ignored) {
// Never mind
}
}
} catch (FirmwareSettingsException e) {
e.printStackTrace();
}
}
}
use of com.willwinder.universalgcodesender.firmware.FirmwareSettingsException 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