-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Positive space capability (#2654)
Add a capability for finding out if machine is working in positive space
Showing
25 changed files
with
479 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
ugs-core/src/com/willwinder/universalgcodesender/firmware/grbl/GrblBuildOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
ugs-core/src/com/willwinder/universalgcodesender/firmware/grbl/GrblBuildOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...om/willwinder/universalgcodesender/firmware/fluidnc/commands/GetBuildInfoCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
55 changes: 0 additions & 55 deletions
55
...lwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareVersionCommandTest.java
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
ugs-core/test/com/willwinder/universalgcodesender/firmware/grbl/GrblBuildOptionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters