Skip to content

Commit

Permalink
Positive space capability (#2654)
Browse files Browse the repository at this point in the history
Add a capability for finding out if machine is working in positive space
breiler authored Dec 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3f1b34c commit 19430be
Showing 25 changed files with 479 additions and 217 deletions.
30 changes: 13 additions & 17 deletions ugs-core/src/com/willwinder/universalgcodesender/Capabilities.java
Original file line number Diff line number Diff line change
@@ -181,30 +181,21 @@ public boolean hasReturnToZero() {
return hasCapability(CapabilitiesConstants.RETURN_TO_ZERO);
}


/**
* Returns if the controller has support for the given axis
*
* @param axis - the axis to check support for
* @return true if the axis is supported
*/
public boolean hasAxis(Axis axis) {
switch (axis) {
case X:
return hasCapability(CapabilitiesConstants.X_AXIS);
case Y:
return hasCapability(CapabilitiesConstants.Y_AXIS);
case Z:
return hasCapability(CapabilitiesConstants.Z_AXIS);
case A:
return hasCapability(CapabilitiesConstants.A_AXIS);
case B:
return hasCapability(CapabilitiesConstants.B_AXIS);
case C:
return hasCapability(CapabilitiesConstants.C_AXIS);
default:
return false;
}
return switch (axis) {
case X -> hasCapability(CapabilitiesConstants.X_AXIS);
case Y -> hasCapability(CapabilitiesConstants.Y_AXIS);
case Z -> hasCapability(CapabilitiesConstants.Z_AXIS);
case A -> hasCapability(CapabilitiesConstants.A_AXIS);
case B -> hasCapability(CapabilitiesConstants.B_AXIS);
case C -> hasCapability(CapabilitiesConstants.C_AXIS);
};
}

/**
@@ -215,4 +206,9 @@ public boolean hasAxis(Axis axis) {
public boolean hasOpenDoor() {
return hasCapability(CapabilitiesConstants.OPEN_DOOR);
}

@Override
public String toString() {
return String.join(", ", capabilities);
}
}
Original file line number Diff line number Diff line change
@@ -76,9 +76,10 @@ public class CapabilitiesConstants {
public static final String RETURN_TO_ZERO = "RETURN_TO_ZERO";

/**
* A key for identifying if the firmware supports opening the door
* A key for identifying if the firmware supports triggering the DOOR state
* from the sender.
*/
public static final String OPEN_DOOR = "DOOR_DOOR";
public static final String OPEN_DOOR = "OPEN_DOOR";

public static final String X_AXIS = "X_AXIS";
public static final String Y_AXIS = "Y_AXIS";
@@ -91,4 +92,21 @@ public class CapabilitiesConstants {
* A key for identifying if the firmware supports handling the device file system
*/
public static final String FILE_SYSTEM = "FILE_SYSTEM";

/**
* Traditionally CNC:s works in a negative machine space. When the machine is homed it is usually done
* in the right, far, upper corner which is then set to 0, therefore all coordinates in the machine space is
* defined with negative values.
* <p>
* Some controllers have the option to inverse this, making the machine zero at the left, lower, close corner of
* the machine.
* <p>
* By defining this capability we can account for this in the visualizer.
*/
public static final String MACHINE_POSITION_IN_POSITIVE_SPACE = "MACHINE_POSITION_IN_POSITIVE_SPACE";

/**
* Does the controller support variable spindles (typically PWM or through RS484 interfaces)
*/
public static final String VARIABLE_SPINDLE = "VARIABLE_SPINDLE";
}
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.universalgcodesender.communicator.ICommunicator;
import com.willwinder.universalgcodesender.connection.ConnectionDriver;
import com.willwinder.universalgcodesender.firmware.IFirmwareSettings;
import com.willwinder.universalgcodesender.firmware.grbl.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.firmware.grbl.GrblCommandCreator;
import com.willwinder.universalgcodesender.firmware.grbl.GrblFirmwareSettings;
import com.willwinder.universalgcodesender.firmware.grbl.GrblFirmwareSettingsInterceptor;
@@ -192,7 +193,8 @@ private void initialize() {
return;
}

capabilities = GrblUtils.getGrblStatusCapabilities(initializer.getVersion().getVersionNumber(), initializer.getVersion().getVersionLetter());
capabilities = GrblUtils.getGrblStatusCapabilities(initializer.getVersion().getVersionNumber(), initializer.getVersion().getVersionLetter(), initializer.getOptions());
logger.info("Identified controller capabilities: " + capabilities);

// Toggle the state to force UI update
setControllerState(ControllerState.CONNECTING);
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.willwinder.universalgcodesender;

import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.firmware.grbl.GrblVersion;
import com.willwinder.universalgcodesender.firmware.grbl.commands.GetBuildInfoCommand;
import com.willwinder.universalgcodesender.firmware.grbl.commands.GetParserStateCommand;
@@ -32,13 +33,14 @@ public class GrblControllerInitializer implements IControllerInitializer {
private final AtomicBoolean isInitialized = new AtomicBoolean(false);
private final GrblController controller;
private GrblVersion version = GrblVersion.NO_VERSION;
private GrblBuildOptions options = new GrblBuildOptions();

public GrblControllerInitializer(GrblController controller) {
this.controller = controller;
}

@Override
public boolean initialize() throws ControllerException{
public boolean initialize() throws ControllerException {
// Only allow one initialization at a time
if (isInitializing.get() || isInitialized.get()) {
return false;
@@ -100,6 +102,7 @@ private void fetchControllerVersion() throws InterruptedException {
}

version = optionalVersion.get();
options = getBuildInfoCommand.getBuildOptions();
}

@Override
@@ -121,4 +124,8 @@ public boolean isInitializing() {
public GrblVersion getVersion() {
return version;
}

public GrblBuildOptions getOptions() {
return options;
}
}
13 changes: 12 additions & 1 deletion ugs-core/src/com/willwinder/universalgcodesender/GrblUtils.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,9 @@ This file is part of Universal Gcode Sender (UGS).

package com.willwinder.universalgcodesender;

import com.willwinder.universalgcodesender.firmware.grbl.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOption;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.firmware.grbl.commands.GetStatusCommand;
import com.willwinder.universalgcodesender.firmware.grbl.commands.GrblSystemCommand;
import com.willwinder.universalgcodesender.listeners.AccessoryStates;
@@ -232,7 +235,7 @@ protected static String getViewParserStateCommand(final double version, final Ch
/**
* Determines version of GRBL position capability.
*/
protected static Capabilities getGrblStatusCapabilities(final double version, final Character letter) {
protected static Capabilities getGrblStatusCapabilities(final double version, final Character letter, GrblBuildOptions options) {
Capabilities ret = new Capabilities();
ret.addCapability(CapabilitiesConstants.JOGGING);
ret.addCapability(CapabilitiesConstants.CHECK_MODE);
@@ -266,6 +269,14 @@ protected static Capabilities getGrblStatusCapabilities(final double version, fi
ret.addCapability(CapabilitiesConstants.OPEN_DOOR);
}

if (options.isEnabled(GrblBuildOption.HOMING_FORCE_ORIGIN_ENABLED)) {
ret.addCapability(CapabilitiesConstants.MACHINE_POSITION_IN_POSITIVE_SPACE);
}

if (options.isEnabled(GrblBuildOption.VARIABLE_SPINDLE_ENABLED)) {
ret.addCapability(CapabilitiesConstants.VARIABLE_SPINDLE);
}

return ret;
}

Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.universalgcodesender.Capabilities;
import com.willwinder.universalgcodesender.ConnectionWatchTimer;
import com.willwinder.universalgcodesender.ControllerException;
import com.willwinder.universalgcodesender.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.GrblUtils;
import com.willwinder.universalgcodesender.IController;
import com.willwinder.universalgcodesender.IFileService;
@@ -41,12 +40,13 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.DetectEchoCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.FluidNCCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetAlarmCodesCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetBuildInfoCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetErrorCodesCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetFirmwareVersionCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetParserStateCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetStartupMessagesCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetStatusCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.SystemCommand;
import com.willwinder.universalgcodesender.firmware.grbl.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.firmware.grbl.GrblOverrideManager;
import com.willwinder.universalgcodesender.gcode.GcodeParser;
import com.willwinder.universalgcodesender.gcode.GcodeState;
@@ -582,9 +582,9 @@ private void disableEcho() throws Exception {
private void queryFirmwareVersion() throws Exception {
// A sleep is required to make the next query reliable
Thread.sleep(200);
GetFirmwareVersionCommand getFirmwareVersionCommand = FluidNCUtils.queryFirmwareVersion(this, messageService);
semanticVersion = getFirmwareVersionCommand.getVersion();
firmwareVariant = getFirmwareVersionCommand.getFirmware();
GetBuildInfoCommand getBuildInfoCommand = FluidNCUtils.queryBuildInformation(this, messageService);
semanticVersion = getBuildInfoCommand.getVersion();
firmwareVariant = getBuildInfoCommand.getFirmware();
capabilities.addCapability(GrblCapabilitiesConstants.V1_FORMAT);
}

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
import com.willwinder.universalgcodesender.firmware.FirmwareSetting;
import com.willwinder.universalgcodesender.firmware.FirmwareSettingsException;
import com.willwinder.universalgcodesender.firmware.IFirmwareSettings;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetFirmwareVersionCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetBuildInfoCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetStatusCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.SystemCommand;
import com.willwinder.universalgcodesender.listeners.ControllerState;
@@ -16,6 +16,8 @@
import com.willwinder.universalgcodesender.model.Position;
import com.willwinder.universalgcodesender.model.UnitUtils;
import com.willwinder.universalgcodesender.services.MessageService;
import static com.willwinder.universalgcodesender.utils.ControllerUtils.sendAndWaitForCompletion;
import static com.willwinder.universalgcodesender.utils.ControllerUtils.sendAndWaitForCompletionWithRetry;
import com.willwinder.universalgcodesender.utils.SemanticVersion;
import org.apache.commons.lang3.StringUtils;

@@ -24,9 +26,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.willwinder.universalgcodesender.utils.ControllerUtils.sendAndWaitForCompletion;
import static com.willwinder.universalgcodesender.utils.ControllerUtils.sendAndWaitForCompletionWithRetry;

public class FluidNCUtils {
public static final double GRBL_COMPABILITY_VERSION = 1.1d;
public static final SemanticVersion MINIMUM_VERSION = new SemanticVersion(3, 3, 0);
@@ -150,18 +149,18 @@ private static void addCapabilityIfSettingStartsWith(Capabilities capabilities,
* @throws Exception if the command couldn't be sent
* @throws IllegalStateException if the parsed version is not for a FluidNC controller or the version is too old
*/
public static GetFirmwareVersionCommand queryFirmwareVersion(IController controller, MessageService messageService) throws Exception {
public static GetBuildInfoCommand queryBuildInformation(IController controller, MessageService messageService) throws Exception {
messageService.dispatchMessage(MessageType.INFO, "*** Fetching device firmware version\n");
GetFirmwareVersionCommand getFirmwareVersionCommand = sendAndWaitForCompletion(controller, new GetFirmwareVersionCommand());
String firmwareVariant = getFirmwareVersionCommand.getFirmware();
SemanticVersion semanticVersion = getFirmwareVersionCommand.getVersion();
GetBuildInfoCommand getBuildInfoCommand = sendAndWaitForCompletion(controller, new GetBuildInfoCommand());
String firmwareVariant = getBuildInfoCommand.getFirmware();
SemanticVersion semanticVersion = getBuildInfoCommand.getVersion();

if (!firmwareVariant.equalsIgnoreCase("FluidNC") || semanticVersion.compareTo(MINIMUM_VERSION) < 0) {
messageService.dispatchMessage(MessageType.INFO, String.format("*** Expected a 'FluidNC %s' or later but got '%s %s'\n", MINIMUM_VERSION, firmwareVariant, semanticVersion));
throw new IllegalStateException("Unknown controller version: " + semanticVersion.toString());
}

return getFirmwareVersionCommand;
return getBuildInfoCommand;
}

/**
Original file line number Diff line number Diff line change
@@ -26,11 +26,11 @@ This file is part of Universal Gcode Sender (UGS).
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GetFirmwareVersionCommand extends SystemCommand {
public class GetBuildInfoCommand extends SystemCommand {
private static final Pattern VERSION_FLUIDNC_PATTERN = Pattern.compile("\\[VER:[0-9.]+ (?<variant>[a-zA-Z0-9]+) v?(?<version>(?<major>[0-9]*)(.(?<minor>[0-9]+)(.(?<patch>[0-9]+))?)?([a-zA-Z]+)?)(.*:.*)*]", Pattern.CASE_INSENSITIVE);
private static final Pattern VERSION_GRBL_PATTERN = Pattern.compile("\\[VER:(?<version>(?<major>[0-9]*)(.(?<minor>[0-9]+)(.(?<patch>[0-9]+))?)).*]", Pattern.CASE_INSENSITIVE);

public GetFirmwareVersionCommand() {
public GetBuildInfoCommand() {
super("$I");
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2024 Will Winder
This file is part of Universal Gcode Sender (UGS).
UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.universalgcodesender.firmware.grbl;

/**
* GRBL options are reported by the build info command ($I). This enum contains the known options.
*/
public enum GrblBuildOption {
VARIABLE_SPINDLE_ENABLED("V"),
LINE_NUMBERS_ENABLED("N"),
MIST_COOLANT_ENABLED("M"),
CORE_XY_ENABLED("C"),
PARKING_MOTION_ENABLED("P"),
HOMING_FORCE_ORIGIN_ENABLED("Z"),
HOMING_SINGLE_AXIS_COMMAND_ENABLED("H"),
TWO_LIMIT_SWITCHES_ON_AXIS_ENABLED("T"),
TWO_ALLOW_OVERRIDE_ON_PROBING_ENABLED("A"),
USE_SPINDLE_DIRECTION_AS_ENABLE_PIN_ENABLED("D"),
SPINDLE_OFF_ON_ZERO_SPEED_ENABLED("0"),
SOFTWARE_LIMIT_PIN_DEBOUNCING_ENABLED("S"),
PARKING_OVERRIDE_CONTROL_ENABLED("R"),
SAFETY_DOOR_INPUT_ENABLED("+"),
RESTORE_ALL_EEPROM_DISABLED("*"),
RESTORE_EEPROM_SETTINGS_DISABLED("$"),
RESTORE_EEPROM_PARAMETER_DATA_DISABLED("#"),
BUILD_INFO_USER_STRING_DISABLED("I"),
FORCE_SYNC_ON_EEPROM_WRITE_DISABLED("E"),
FORCE_SYNC_ON_WORK_COORDINATE_CHANGE_DISABLED("W"),
HOMING_INITIALIZATION_LOCK_DISABLED("L"),
DUAL_AXIS_MOTORS_ENABLED("2");

private final String code;

GrblBuildOption(String code) {
this.code = code;
}

public String getCode() {
return code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2024 Will Winder
This file is part of Universal Gcode Sender (UGS).
UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.universalgcodesender.firmware.grbl;

import org.apache.commons.lang3.StringUtils;

/**
* Parses options from the build info command ($I)
* <a href="https://github.com/gnea/grbl/wiki/Grbl-v1.1-Interface#feedback-messages">Documentation</a>
*
* @author Joacim Breiler
*/
public class GrblBuildOptions {
private final String options;

public GrblBuildOptions() {
this("[OPT:]");
}

public GrblBuildOptions(String options) {
this.options = options;
}

public boolean isEnabled(GrblBuildOption grblBuildOption) {
String buildOptions = StringUtils.substringBefore(StringUtils.substringBetween(options, "[OPT:", "]"), ",");
return buildOptions.contains(grblBuildOption.getCode());
}
}
Original file line number Diff line number Diff line change
@@ -16,11 +16,11 @@ This file is part of Universal Gcode Sender (UGS).
You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.universalgcodesender;
package com.willwinder.universalgcodesender.firmware.grbl;

/**
* Constants for defining additional capabilities from {@link CapabilitiesConstants} that a
* GRBL controller may support. The constants may be added to a {@link Capabilities} object.
* Constants for defining additional capabilities from {@link com.willwinder.universalgcodesender.CapabilitiesConstants} that a
* GRBL controller may support. The constants may be added to a {@link com.willwinder.universalgcodesender.Capabilities} object.
*
* @author Joacim Breiler
*/
Original file line number Diff line number Diff line change
@@ -407,8 +407,8 @@ private int getHomingInvertDirectionMask() {
}

@Override
public boolean isHomingEnabled() throws FirmwareSettingsException {
return getValueAsBoolean(KEY_HOMING_ENABLED);
public boolean isHomingEnabled() {
return getValueAsBoolean(KEY_HOMING_ENABLED, false);
}

@Override
@@ -468,4 +468,8 @@ private boolean getValueAsBoolean(String key) throws FirmwareSettingsException {
FirmwareSetting firmwareSetting = getSetting(key).orElseThrow(() -> new FirmwareSettingsException("Couldn't find setting with key: " + key));
return "1".equalsIgnoreCase(firmwareSetting.getValue());
}

private boolean getValueAsBoolean(String key, boolean defaultValue) {
return getSetting(key).map(FirmwareSetting::getValue).map("1"::equalsIgnoreCase).orElse(defaultValue);
}
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ This file is part of Universal Gcode Sender (UGS).
package com.willwinder.universalgcodesender.firmware.grbl.commands;

import com.willwinder.universalgcodesender.GrblUtils;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.firmware.grbl.GrblVersion;
import org.apache.commons.lang3.StringUtils;

@@ -61,4 +62,18 @@ public Optional<GrblVersion> getVersion() {
.map(GrblVersion::new)
.findFirst();
}

public GrblBuildOptions getBuildOptions() {
String[] lines = StringUtils.split(getResponse(), "\n");

if (lines.length == 2 && StringUtils.equals(lines[1], "ok")) {
return new GrblBuildOptions();
}

return Arrays.stream(lines)
.filter(line -> line.startsWith("[OPT:"))
.map(GrblBuildOptions::new)
.findFirst()
.orElse(new GrblBuildOptions());
}
}
72 changes: 36 additions & 36 deletions ugs-core/src/resources/MessagesBundle_af_ZA.properties
Original file line number Diff line number Diff line change
@@ -12,20 +12,20 @@ help = Hulp
save.close = Spaar en Maak toe
unknown = onbekend
mainWindow.helpDialog = Masjien Kontrole Hulp
mainWindow.resetZero = Herstel zero\\\: Verander die huidige kou00F6rdinate na zero sonder dat die masjien verskuif.
mainWindow.returnToZero = Terug na zero\\\: Beweeg masjien tot by lokasie 0, 0, 0.
mainWindow.softReset = Sagte Herstel\\\: Herstel GRBL staat sonder die om die posisie op te dateer.
mainWindow.homing = $ H\\\: Begin Inkorrel siklus. Dit benodig Grbl 0.8c vir volle ondersteuning
mainWindow.alarmLock = $ X\\\: Deaktiveer die GRBL alarm slot.
mainWindow.checkMode = $ C\\\: Skakel "check" operasie mode, waar GRBL die gcode ontleed maar nie die masjien beweeg nie.
mainWindow.getState = $ G\\\: Versoek staat inligting vanaf GRBL (resultaat verskuin op konsele).
mainWindow.resetZero = Herstel zero\: Verander die huidige kou00F6rdinate na zero sonder dat die masjien verskuif.
mainWindow.returnToZero = Terug na zero\: Beweeg masjien tot by lokasie 0, 0, 0.
mainWindow.softReset = Sagte Herstel\: Herstel GRBL staat sonder die om die posisie op te dateer.
mainWindow.homing = $H\: Begin Inkorrel siklus. Dit benodig Grbl 0.8c vir volle ondersteuning
mainWindow.alarmLock = $X\: Deaktiveer die GRBL alarm slot.
mainWindow.checkMode = $C\: Skakel "check" operasie mode, waar GRBL die gcode ontleed maar nie die masjien beweeg nie.
mainWindow.getState = $G\: Versoek staat inligting vanaf GRBL (resultaat verskuin op konsele).
mainWindow.helpKeyboard = Sleutelbord Kontrole
mainWindow.helpKeyX = X\\\: Arrow Links/Regs; Sleutels Links/Regs ; Numeriese eiland\\\: 4/6
mainWindow.helpKeyY = Y\\\: Arrow Up/Down; Sleutels Op/Af; Numeriese eiland\\\: 8/2
mainWindow.helpKeyZ = Z\\\: Page Up/Down; Sleutels Page Up/Down; Numeriese eiland\\\: 9/3
mainWindow.helpKeyPlusMinus = Vermeerder/Verminder Stappe\\\: Sleutels +/-
mainWindow.helpKeyDivMul = Verander Stappe\\\: Sleutels DEEL DEUR/MAAL
mainWindow.helpKeyZero = Herstel Zero\\\: Sleutels Insert; Numeriese eiland \\\: 0
mainWindow.helpKeyX = X\: Arrow Links/Regs; Sleutels Links/Regs ; Numeriese eiland\: 4/6
mainWindow.helpKeyY = Y\: Arrow Up/Down; Sleutels Op/Af; Numeriese eiland\: 8/2
mainWindow.helpKeyZ = Z\: Page Up/Down; Sleutels Page Up/Down; Numeriese eiland\: 9/3
mainWindow.helpKeyPlusMinus = Vermeerder/Verminder Stappe\: Sleutels +/-
mainWindow.helpKeyDivMul = Verander Stappe\: Sleutels DEEL DEUR/MAAL
mainWindow.helpKeyZero = Herstel Zero\: Sleutels Insert; Numeriese eiland \: 0
mainWindow.status.hold = Hou
mainWindow.status.queue = Tou
mainWindow.status.run = Hardloop
@@ -47,39 +47,39 @@ mainWindow.error.rxtxMac2 = gids genoem %s met die volgende opdragte
mainWindow.ui.pauseButton = Wag
mainWindow.ui.resumeButton = Hervat
mainWindow.ui.jobComplete = Werk klaargemaak na
mainWindow.swing.activeStateLabel = Aktiewe Staat\\\:
mainWindow.swing.activeStateLabel = Aktiewe Staat\:
mainWindow.swing.arrowMovementEnabled = Skakel aan Sleutelbord Beweging
mainWindow.swing.baudLabel = Baud\\\:
mainWindow.swing.baudLabel = Baud\:
mainWindow.swing.browseButton = Loer
mainWindow.swing.cancelButton = Kanselleer
mainWindow.swing.commandLabel = Opdrag\\\:
mainWindow.swing.commandLabel = Opdrag\:
mainWindow.swing.connectionPanel = Konneksie
mainWindow.swing.controlContextTabbedPane.commands = Opdragte
mainWindow.swing.controlContextTabbedPane.fileMode = Lu00EAer Mode
mainWindow.swing.controlContextTabbedPane.machineControl = Masjien Beheer
mainWindow.swing.controlContextTabbedPane.macros = Makros
mainWindow.swing.durationLabel = Duur\\\:
mainWindow.swing.durationLabel = Duur\:
mainWindow.swing.fileLabel = Lu00EAer
mainWindow.swing.firmwareLabel = Fermware\\\:
mainWindow.swing.firmwareLabel = Fermware\:
mainWindow.swing.firmwareSettingsMenu = Fermware Stellings
mainWindow.swing.grblConnectionSettingsMenuItem = Stuurder Stellings
mainWindow.swing.settingsMenu = Stellings
mainWindow.swing.statusPanel = Masjien status
mainWindow.swing.bottomTabbedPane.console = Konsole
mainWindow.swing.bottomTabbedPane.table = Opdrag Tabel
mainWindow.swing.latestCommentLabel = Laaste Kommentaar\\\:
mainWindow.swing.latestCommentLabel = Laaste Kommentaar\:
mainWindow.swing.machinePosition = Masjien Posisie
mainWindow.swing.opencloseButton = Maak Oop
mainWindow.swing.pauseButton = Wag
mainWindow.swing.portLabel = Poort\\\:
mainWindow.swing.remainingRowsLabel = Oorblywende Rye\\\:
mainWindow.swing.remainingTimeLabel = Min of meer ongeveer Tyd wat oorbly\\\:
mainWindow.swing.portLabel = Poort\:
mainWindow.swing.remainingRowsLabel = Oorblywende Rye\:
mainWindow.swing.remainingTimeLabel = Min of meer ongeveer Tyd wat oorbly\:
mainWindow.swing.resetCoordinatesButton = Herstel Zero
mainWindow.swing.returnToZeroButton = Keer terug na Zero
mainWindow.swing.rowsLabel = Rye in Lu00EAer\\\:
mainWindow.swing.rowsLabel = Rye in Lu00EAer\:
mainWindow.swing.scrollWindowCheckBox = Skrol uitset venster
mainWindow.swing.sendButton = Stuur
mainWindow.swing.sentRowsLabel = Rye Gestuur\\\:
mainWindow.swing.sentRowsLabel = Rye Gestuur\:
mainWindow.swing.showVerboseOutputCheckBox = Wys verbose uitset
mainWindow.swing.softResetMachineControl = Sagte Herstel
mainWindow.swing.stepSizeLabel = Trap groote
@@ -111,18 +111,18 @@ sender.status.rate = Status pollering tempo (ms)
sender.arcs = Omskep bou00EB na lyne
sender.arcs.threshold = Klein boog drempel (mm)
sender.arcs.length = Klein boor segment lengte (mm)
sender.help.speed.override = Skakel aan spoed oorskrywing\\\: Skakel die spoed oorskrywing aan of af.
sender.help.speed.percent = Spoed oorskrywing persentasie\\\: Faktor waarmee die spoed geskaal sal word
sender.help.command.length = Maks opdrag lengte\\\: Maskimum lengte van 'n opdrag voordat n fout boodskap opgebring sal word.
sender.help.truncate = Kapt desimale nommers\\\: Aantal nommers na die desimale punt want na die fermware toe gestuur sal word.
sender.help.singlestep = Skakel aan enkele stap mode\\\: DIt skakel aan enkele stap mode, en dit is baie stadig.
sender.help.whitespace = Verwyder alle witspasie\\\: Verwyder die witspasie wat gewoonlik onnodig is in g-kode opdragte.
sender.help.status = Skakel aan status pollering\\\: SKakel aan die pollering van fermware, indien dit moontlik is.
sender.help.status.rate = Status pollering tempo\\\: Die tempo in millisekondes waarteen status versoeke gestuur word.
sender.help.state = Staat kleur vertoning\\\: Die beheerder status word rooi/oranje/geel ingekleur, gebasseer op die huidige staat.
sender.help.arcs = Omskep bou00EB na lyne\\\: Omskep klein bou00EB opdragte (G2/G3) na 'n reeks van G1 opdragte.
sender.help.arcs.threshold = Klein boog drempel\\\: Die boog lengte (in mm) wat onder hierdie waarde is, sal na 'n reeks G1 opdragte omskep word.
sender.help.arcs.length = Klein boor segment lengte\\\: Die lengte (in mm) van segmente in 'n uitgebreide boog.
sender.help.speed.override = Skakel aan spoed oorskrywing\: Skakel die spoed oorskrywing aan of af.
sender.help.speed.percent = Spoed oorskrywing persentasie\: Faktor waarmee die spoed geskaal sal word
sender.help.command.length = Maks opdrag lengte\: Maskimum lengte van 'n opdrag voordat n fout boodskap opgebring sal word.
sender.help.truncate = Kapt desimale nommers\: Aantal nommers na die desimale punt want na die fermware toe gestuur sal word.
sender.help.singlestep = Skakel aan enkele stap mode\: DIt skakel aan enkele stap mode, en dit is baie stadig.
sender.help.whitespace = Verwyder alle witspasie\: Verwyder die witspasie wat gewoonlik onnodig is in g-kode opdragte.
sender.help.status = Skakel aan status pollering\: SKakel aan die pollering van fermware, indien dit moontlik is.
sender.help.status.rate = Status pollering tempo\: Die tempo in millisekondes waarteen status versoeke gestuur word.
sender.help.state = Staat kleur vertoning\: Die beheerder status word rooi/oranje/geel ingekleur, gebasseer op die huidige staat.
sender.help.arcs = Omskep bou00EB na lyne\: Omskep klein bou00EB opdragte (G2/G3) na 'n reeks van G1 opdragte.
sender.help.arcs.threshold = Klein boog drempel\: Die boog lengte (in mm) wat onder hierdie waarde is, sal na 'n reeks G1 opdragte omskep word.
sender.help.arcs.length = Klein boor segment lengte\: Die lengte (in mm) van segmente in 'n uitgebreide boog.
sender.help.dialog.title = Stuurder Stellings Hulp
communicator.exception.port = Geen drywer vir poort
controller.exception.booting = Grbl het nog nie klaar gelaai nie.
2 changes: 1 addition & 1 deletion ugs-core/src/resources/MessagesBundle_it_IT.properties
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ mainWindow.swing.showVerboseOutputCheckBox = Mostra uscita dettagliata
mainWindow.swing.showCommandTableCheckBox = Attiva la tavola dei comandi
mainWindow.swing.stepSizeLabel = Dimensione di passo XY\:
mainWindow.swing.visualizeButton = Visualizza
mainWindow.swing.workPositionLabel = Posizione di Lavoro\\\:
mainWindow.swing.workPositionLabel = Posizione di Lavoro\:
mainWindow.swing.macroInstructions = <html>Ogni box può contenere una serie di comandi GCode separati da '';''.<br />Per eseguire il comando premi sul pulsante a sinistra del testo.<br /><br />Sostituzioni interattive possono essere fatte con\: <br /> <ul><li>{machine_x} - La posizione della macchina sull''asse X</li><li>{machine_y} - La posizione della macchina sull''asse Y</li><li>{machine_z} - La posizione della macchina sull''asse Z</li><li>{work_x} - La posizione di lavoro sull''asse X</li><li>{work_y} - La posizione di lavoro sull''asse Y</li><li>{work_z} - La posizione di lavoro sull''asse Z</li><li>{prompt|nome} - Chiede all''utente un valore chiamato ''nome''.</li></html>
mainWindow.swing.inchRadioButton = Pollici
mainWindow.swing.mmRadioButton = Millimetri
6 changes: 3 additions & 3 deletions ugs-core/src/resources/MessagesBundle_zh_Hans.properties
Original file line number Diff line number Diff line change
@@ -25,9 +25,9 @@ mainWindow.alarmLock = 解锁:关闭控制器警报锁
mainWindow.checkMode = 自检模式:切换“检查”模式,控制器解析代码但不移动机器
mainWindow.getState = 控制器状态:请求控制器状态(结果输出到控制台显示)
mainWindow.helpKeyboard = 键盘控制
mainWindow.helpKeyX = X\\\:箭头左/右;键盘左/右;小键盘:4/6
mainWindow.helpKeyY = Y\\\:箭头上/下;键盘上/下;小键盘:8/2
mainWindow.helpKeyZ = Z\\\:箭头上/下;键盘上/下;小键盘:9/3
mainWindow.helpKeyX = X\:箭头左/右;键盘左/右;小键盘:4/6
mainWindow.helpKeyY = Y\:箭头上/下;键盘上/下;小键盘:8/2
mainWindow.helpKeyZ = Z\:箭头上/下;键盘上/下;小键盘:9/3
mainWindow.helpKeyPlusMinus = In-/步进步减:键盘+/-
mainWindow.helpKeyDivMul = 改变步进率:键盘除(/)或乘(*)
mainWindow.helpKeyZero = 重设零点:键盘Insert;数字键盘:0
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ This file is part of Universal Gcode Sender (UGS).
import static com.willwinder.universalgcodesender.GrblUtils.GRBL_PAUSE_COMMAND;
import static com.willwinder.universalgcodesender.GrblUtils.GRBL_RESET_COMMAND;
import static com.willwinder.universalgcodesender.GrblUtils.GRBL_RESUME_COMMAND;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.firmware.grbl.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.firmware.grbl.GrblVersion;
import com.willwinder.universalgcodesender.gcode.DefaultCommandCreator;
import com.willwinder.universalgcodesender.gcode.util.Code;
@@ -310,13 +312,10 @@ public void testGetSendDuration() throws Exception {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
try {
instance.commandSent(command);
instance.commandComplete();
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());
}

instance.commandSent(command);
instance.commandComplete();


expResult = 4000L;
result = instance.getSendDuration();
@@ -377,48 +376,36 @@ public void testRowsAsteriskMethods() throws Exception {

// Test 3.
// Sent 15 of them, none completed.
try {
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}

assertCounts(instance, 30, 15, 30);

// Test 4.
// Complete 15 of them.
try {
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
instance.commandComplete();
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
instance.commandComplete();
}
assertCounts(instance, 30, 15, 15);

// Test 5.
// Finish sending/completing the remaining 15 commands.
try {
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
instance.commandComplete();
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());

for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
instance.commandComplete();
}

mgc.areActiveCommands = false;
assertCounts(instance, 30, 30, 0);
}
@@ -697,17 +684,12 @@ public void cancelSendHalfwayThroughJobOnGrbl0_8c() throws Exception {
}
instance.queueStream(new SimpleGcodeStreamReader(commands));

try {
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}

instance.cancelSend();
@@ -859,17 +841,12 @@ public void testPauseAndCancelSend() throws Exception {
}
instance.queueStream(new SimpleGcodeStreamReader(commands));

try {
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}

instance.pauseStreaming();
@@ -1420,6 +1397,7 @@ private GrblController initializeAndConnectController(String grblVersionString)
when(initializer.isInitialized()).thenReturn(false);
when(initializer.isInitializing()).thenReturn(false);
when(initializer.initialize()).thenReturn(true);
when(initializer.getOptions()).thenReturn(new GrblBuildOptions());

GrblVersion version = new GrblVersion("[VER:" + grblVersionString + "]");
when(initializer.getVersion()).thenReturn(version);
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@ This file is part of Universal Gcode Sender (UGS).
*/
package com.willwinder.universalgcodesender;

import com.willwinder.universalgcodesender.firmware.grbl.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.listeners.ControllerState;
import com.willwinder.universalgcodesender.listeners.ControllerStatus;
import com.willwinder.universalgcodesender.model.Position;
@@ -210,13 +212,14 @@ public void testGetViewParserStateCommand() {
*/
@Test
public void testGetGrblStatusCapabilities() {
GrblBuildOptions options = new GrblBuildOptions();
double version;
Character letter;
Capabilities result;

version = 0.8;
letter = 'c';
result = GrblUtils.getGrblStatusCapabilities(version, letter);
result = GrblUtils.getGrblStatusCapabilities(version, letter, options);
assertTrue(result.hasCapability(GrblCapabilitiesConstants.REAL_TIME));
assertFalse(result.hasCapability(GrblCapabilitiesConstants.V1_FORMAT));
assertFalse(result.hasCapability(GrblCapabilitiesConstants.HARDWARE_JOGGING));
@@ -225,7 +228,7 @@ public void testGetGrblStatusCapabilities() {

version = 0.8;
letter = 'a';
result = GrblUtils.getGrblStatusCapabilities(version, letter);
result = GrblUtils.getGrblStatusCapabilities(version, letter, options);
assertFalse(result.hasCapability(GrblCapabilitiesConstants.REAL_TIME));
assertFalse(result.hasCapability(GrblCapabilitiesConstants.V1_FORMAT));
assertFalse(result.hasCapability(GrblCapabilitiesConstants.HARDWARE_JOGGING));
@@ -234,7 +237,7 @@ public void testGetGrblStatusCapabilities() {

version = 0.9;
letter = null;
result = GrblUtils.getGrblStatusCapabilities(version, letter);
result = GrblUtils.getGrblStatusCapabilities(version, letter, options);
assertTrue(result.hasCapability(GrblCapabilitiesConstants.REAL_TIME));
assertFalse(result.hasCapability(GrblCapabilitiesConstants.V1_FORMAT));
assertFalse(result.hasCapability(GrblCapabilitiesConstants.HARDWARE_JOGGING));
@@ -243,7 +246,7 @@ public void testGetGrblStatusCapabilities() {

version = 1.1;
letter = null;
result = GrblUtils.getGrblStatusCapabilities(version, letter);
result = GrblUtils.getGrblStatusCapabilities(version, letter, options);
assertTrue(result.hasCapability(GrblCapabilitiesConstants.REAL_TIME));
assertTrue(result.hasCapability(GrblCapabilitiesConstants.V1_FORMAT));
assertTrue(result.hasCapability(GrblCapabilitiesConstants.HARDWARE_JOGGING));
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import com.willwinder.universalgcodesender.Capabilities;
import com.willwinder.universalgcodesender.IController;
import com.willwinder.universalgcodesender.firmware.IFirmwareSettings;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetFirmwareVersionCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetBuildInfoCommand;
import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetStatusCommand;
import com.willwinder.universalgcodesender.services.MessageService;
import com.willwinder.universalgcodesender.types.GcodeCommand;
@@ -71,7 +71,7 @@ public void addCapabilitiesShouldAddFileSystem() {
}

@Test
public void queryFirmwareVersionShouldReturnTheFirmwareVersion() throws Exception {
public void queryBuildInformationShouldReturnTheFirmwareInformation() throws Exception {
IController controller = mock(IController.class);
MessageService messageService = mock(MessageService.class);

@@ -83,7 +83,7 @@ public void queryFirmwareVersionShouldReturnTheFirmwareVersion() throws Exceptio
return null;
}).when(controller).sendCommandImmediately(any());

GetFirmwareVersionCommand firmwareVersionCommand = FluidNCUtils.queryFirmwareVersion(controller, messageService);
GetBuildInfoCommand firmwareVersionCommand = FluidNCUtils.queryBuildInformation(controller, messageService);
SemanticVersion semanticVersion = firmwareVersionCommand.getVersion();
assertEquals(semanticVersion.getMajor(), 3);
assertEquals(semanticVersion.getMinor(), 6);
@@ -92,7 +92,7 @@ public void queryFirmwareVersionShouldReturnTheFirmwareVersion() throws Exceptio
}

@Test
public void queryFirmwareVersionShouldThrowErrorIfVersionToLow() throws Exception {
public void queryBuildInformationToLow() throws Exception {
IController controller = mock(IController.class);
MessageService messageService = mock(MessageService.class);

@@ -104,11 +104,11 @@ public void queryFirmwareVersionShouldThrowErrorIfVersionToLow() throws Exceptio
return null;
}).when(controller).sendCommandImmediately(any());

assertThrows(IllegalStateException.class, () -> FluidNCUtils.queryFirmwareVersion(controller, messageService));
assertThrows(IllegalStateException.class, () -> FluidNCUtils.queryBuildInformation(controller, messageService));
}

@Test
public void queryFirmwareVersionShouldThrowErrorIfNotFluidNC() throws Exception {
public void queryBuildInformationShouldThrowErrorIfNotFluidNC() {
IController controller = mock(IController.class);
MessageService messageService = mock(MessageService.class);

@@ -120,7 +120,7 @@ public void queryFirmwareVersionShouldThrowErrorIfNotFluidNC() throws Exception
return null;
}).when(controller).sendCommandImmediately(any());

assertThrows(IllegalStateException.class, () -> FluidNCUtils.queryFirmwareVersion(controller, messageService));
assertThrows(IllegalStateException.class, () -> FluidNCUtils.queryBuildInformation(controller, messageService));
}

@Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.willwinder.universalgcodesender.firmware.fluidnc.commands;

import org.junit.Test;

import static org.junit.Assert.*;

public class GetBuildInfoCommandTest {

@Test
public void getFirmwareVersionWithNoResponseShouldNotCrash() {
GetBuildInfoCommand getBuildInfoCommand = new GetBuildInfoCommand();
assertNotNull(getBuildInfoCommand.getVersion());
assertEquals(0, getBuildInfoCommand.getVersion().getMajor());
assertEquals(0, getBuildInfoCommand.getVersion().getMinor());
assertEquals(0, getBuildInfoCommand.getVersion().getPatch());
assertEquals("Unknown", getBuildInfoCommand.getFirmware());
}


@Test
public void getFirmwareVersionWithVersion() {
GetBuildInfoCommand getBuildInfoCommand = new GetBuildInfoCommand();
getBuildInfoCommand.appendResponse("[VER:3.5 FluidNC v3.5.0 (main-5db1039a):]");

assertNotNull(getBuildInfoCommand.getVersion());
assertEquals(3, getBuildInfoCommand.getVersion().getMajor());
assertEquals(5, getBuildInfoCommand.getVersion().getMinor());
assertEquals(0, getBuildInfoCommand.getVersion().getPatch());
assertEquals("FluidNC", getBuildInfoCommand.getFirmware());
}

@Test
public void getFirmwareVersionWithoutLeadingV() {
GetBuildInfoCommand getBuildInfoCommand = new GetBuildInfoCommand();
getBuildInfoCommand.appendResponse("[VER:3.7 FluidNC 3.7.10:]");

assertNotNull(getBuildInfoCommand.getVersion());
assertEquals(3, getBuildInfoCommand.getVersion().getMajor());
assertEquals(7, getBuildInfoCommand.getVersion().getMinor());
assertEquals(10, getBuildInfoCommand.getVersion().getPatch());
assertEquals("FluidNC", getBuildInfoCommand.getFirmware());
}

@Test
public void getFirmwareVersionWithOldGRBLVersion() {
GetBuildInfoCommand getBuildInfoCommand = new GetBuildInfoCommand();
getBuildInfoCommand.appendResponse("[VER:1.1f.20170801:]");

assertNotNull(getBuildInfoCommand.getVersion());
assertEquals(1, getBuildInfoCommand.getVersion().getMajor());
assertEquals(1, getBuildInfoCommand.getVersion().getMinor());
assertEquals(0, getBuildInfoCommand.getVersion().getPatch());
assertEquals("GRBL", getBuildInfoCommand.getFirmware());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.willwinder.universalgcodesender.firmware.grbl;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

import java.util.Arrays;
import java.util.stream.Collectors;

public class GrblBuildOptionsTest {

@Test
public void isEnabled_shouldWorkWithoutAnyOptions() {
GrblBuildOptions options = new GrblBuildOptions();
for (GrblBuildOption option : GrblBuildOption.values()) {
assertFalse(options.isEnabled(option));
}
}

@Test
public void isEnabled_shouldWorkWithAnEmptyOptionString() {
GrblBuildOptions options = new GrblBuildOptions("[OPT:]");
for (GrblBuildOption option : GrblBuildOption.values()) {
assertFalse(options.isEnabled(option));
}
}

@Test
public void isEnabled_shouldWorkWithJustOneOption() {
GrblBuildOptions options = new GrblBuildOptions("[OPT:I]");
for (GrblBuildOption option : GrblBuildOption.values()) {
if (option == GrblBuildOption.BUILD_INFO_USER_STRING_DISABLED) {
assertTrue(options.isEnabled(option));
} else {
assertFalse(options.isEnabled(option));
}
}
}

@Test
public void isEnabled_shouldWorkWithUnknownOptions() {
GrblBuildOptions options = new GrblBuildOptions("[OPT:-]");
for (GrblBuildOption option : GrblBuildOption.values()) {
assertFalse(options.isEnabled(option));
}
}

@Test
public void isEnabled_shouldWorkWithMoreOptions() {
GrblBuildOptions options = new GrblBuildOptions("[OPT:IV]");
for (GrblBuildOption option : GrblBuildOption.values()) {
if (option == GrblBuildOption.BUILD_INFO_USER_STRING_DISABLED || option == GrblBuildOption.VARIABLE_SPINDLE_ENABLED) {
assertTrue(options.isEnabled(option));
} else {
assertFalse(options.isEnabled(option));
}
}
}

@Test
public void isEnabled_shouldWorkWithMoreOptionsAndPlannerValues() {
GrblBuildOptions options = new GrblBuildOptions("[OPT:IV,15,128]");
for (GrblBuildOption option : GrblBuildOption.values()) {
if (option == GrblBuildOption.BUILD_INFO_USER_STRING_DISABLED || option == GrblBuildOption.VARIABLE_SPINDLE_ENABLED) {
assertTrue(options.isEnabled(option));
} else {
assertFalse(options.isEnabled(option));
}
}
}

@Test
public void isEnabled_shouldWorkWithMoreOptionsAndPlannerAndBufferValues() {
GrblBuildOptions options = new GrblBuildOptions("[OPT:IV,15,128]");
for (GrblBuildOption option : GrblBuildOption.values()) {
if (option == GrblBuildOption.BUILD_INFO_USER_STRING_DISABLED || option == GrblBuildOption.VARIABLE_SPINDLE_ENABLED) {
assertTrue(options.isEnabled(option));
} else {
assertFalse(options.isEnabled(option));
}
}
}

@Test
public void isEnabled_shouldBeAbleToParseAllOptions() {
String allOptions = Arrays.stream(GrblBuildOption.values()).map(GrblBuildOption::getCode).collect(Collectors.joining());
GrblBuildOptions options = new GrblBuildOptions("[OPT:" + allOptions + ",15,128]");
for (GrblBuildOption option : GrblBuildOption.values()) {
assertTrue(options.isEnabled(option));
}
}
}
Original file line number Diff line number Diff line change
@@ -71,21 +71,21 @@ public void settingMessagesShouldNotAddDuplicates() {
}

@Test
public void isHomingEnabledShouldBeTrue() throws FirmwareSettingsException {
public void isHomingEnabledShouldBeTrue() {
// Emulate a settings-message from the controller
setFirmwareSetting("$22", "1");
assertTrue(target.isHomingEnabled());
}

@Test
public void isHomingEnabledShouldBeFalse() throws FirmwareSettingsException {
public void isHomingEnabledShouldBeFalse() {
// Emulate a settings-message from the controller
setFirmwareSetting("$22", "0");
assertFalse(target.isHomingEnabled());
}

@Test(expected = FirmwareSettingsException.class)
public void isHomingEnabledShouldBeFalseIfNotSet() throws FirmwareSettingsException {
@Test
public void isHomingEnabledShouldBeFalseIfNotSet() {
assertFalse(target.isHomingEnabled());
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.willwinder.universalgcodesender.firmware.grbl.commands;


import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOption;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.firmware.grbl.GrblVersion;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
@@ -29,12 +33,40 @@ public void getVersionWithoutVersionStringShouldAssumeGrbl1_1() {
}

@Test
public void getVersionWithLegacySingleLineVersion() {
public void getVersionAndOptionsWithLegacySingleLineVersion() {
GetBuildInfoCommand command = new GetBuildInfoCommand();
command.appendResponse("[0.9j.20160303:]");
command.appendResponse("ok");

GrblVersion version = command.getVersion().orElseThrow(RuntimeException::new);
assertEquals(0.9, version.getVersionNumber(), 0.01);
assertEquals(Character.valueOf('j'), version.getVersionLetter());

GrblBuildOptions options = command.getBuildOptions();
for (GrblBuildOption option : GrblBuildOption.values()) {
assertFalse(options.isEnabled(option));
}
}

@Test
public void getBuildOptionsShouldReturnDefinedOptions() {
GetBuildInfoCommand command = new GetBuildInfoCommand();
command.appendResponse("[OPT: V]");
command.appendResponse("[VER:]");
command.appendResponse("ok");
GrblBuildOptions options = command.getBuildOptions();
assertTrue(options.isEnabled(GrblBuildOption.VARIABLE_SPINDLE_ENABLED));
assertFalse(options.isEnabled(GrblBuildOption.CORE_XY_ENABLED));
}

@Test
public void getBuildOptionsWhenNoOptionsReturnedShouldReturnDefaultOptions() {
GetBuildInfoCommand command = new GetBuildInfoCommand();
command.appendResponse("[VER:]");
command.appendResponse("ok");
GrblBuildOptions options = command.getBuildOptions();
for (GrblBuildOption option : GrblBuildOption.values()) {
assertFalse(options.isEnabled(option));
}
}
}
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ This file is part of Universal Gcode Sender (UGS).
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.LinkedHashMap;
@@ -96,8 +97,8 @@ private void initComponents() {
this.labels.put("controller:getSingleStepMode", new JLabel(EMPTY_VALUE));
this.labels.put("controller:getStatusUpdatesEnabled", new JLabel(EMPTY_VALUE));
this.labels.put("controller:getStatusUpdateRate", new JLabel(EMPTY_VALUE));
this.labels.put("controller:getControlState", new JLabel(EMPTY_VALUE));
this.labels.put("controller:getCommunicatorState", new JLabel(EMPTY_VALUE));
this.labels.put("controller:getCapabilities", new JLabel(EMPTY_VALUE));

this.labels.put("communicator:numActiveCommands", new JLabel(EMPTY_VALUE));
this.labels.put("communicator:isPaused", new JLabel(EMPTY_VALUE));
@@ -109,9 +110,11 @@ private void initComponents() {


JPanel labelPanel = new JPanel();
labelPanel.setLayout(new MigLayout("wrap2,fillx"));
labelPanel.setLayout(new MigLayout("wrap2, fillx"));
for (Map.Entry<String, JLabel> dp : labels.entrySet()) {
labelPanel.add(new JLabel(dp.getKey()));
JLabel keyLabel = new JLabel(dp.getKey());
keyLabel.setVerticalAlignment(SwingConstants.TOP);
labelPanel.add(keyLabel, "growy");
labelPanel.add(dp.getValue());
}

@@ -152,6 +155,7 @@ private void refreshValues() {
labels.get("controller:getStatusUpdatesEnabled").setText(String.valueOf(controller.getStatusUpdatesEnabled()));
labels.get("controller:getStatusUpdateRate").setText(String.valueOf(controller.getStatusUpdateRate()));
labels.get("controller:getCommunicatorState").setText(String.valueOf(controller.getCommunicatorState()));
labels.get("controller:getCapabilities").setText("<html>" + controller.getCapabilities().toString().replaceAll(", ", "<br/>") + "</html>");

IFirmwareSettings firmwareSettings = controller.getFirmwareSettings();
if (firmwareSettings != null) {

0 comments on commit 19430be

Please sign in to comment.