Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified the version string parser #2244

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ It is usually helpful to have the log file from UGS, locations for different typ
Which UGS version are you using?
multiple: false
options:
- "2.0.18"
- "2.0.17"
- "2.0.15"
- "2.0.14"
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ The next generation, feature packed variant based on the Netbeans Platform.<br>
Unpack and start the program ```bin/ugsplatform```


| Latest release (v2.0.17) | Previous release (v2.0.15) | Nightly build |
|:-------------------------|:---------------------------|:--------------|
| [![Windows 32-bit](pictures/os_windows.png) Windows 32-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/win-ugs-platform-app-2.0.17.zip) | [![Windows 32-bit](pictures/os_windows.png) Windows 32-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/win-ugs-platform-app-2.0.15.zip) | [![Windows 32-bit](pictures/os_windows.png) Windows 32-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/win-ugs-platform-app-2.0-SNAPSHOT.zip) |
| [![Windows 64-bit](pictures/os_windows.png) Windows 64-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/win64-ugs-platform-app-2.0.17.zip) | [![Windows 64-bit](pictures/os_windows.png) Windows 64-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/win64-ugs-platform-app-2.0.15.zip) | [![Windows 64-bit](pictures/os_windows.png) Windows 64-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/win64-ugs-platform-app-2.0-SNAPSHOT.zip) |
| [![Mac OSX](pictures/os_mac.png) Mac OSX](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/ios-ugs-platform-app-2.0.17.dmg) | [![Mac OSX](pictures/os_mac.png) Mac OSX](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/ios-ugs-platform-app-2.0.15.dmg) | [![Mac OSX](pictures/os_mac.png) Mac OSX](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/ios-ugs-platform-app-2.0-SNAPSHOT.dmg) |
| [![Linux x64](pictures/os_linux.png) Linux](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/linux-ugs-platform-app-2.0.17.tar.gz) | [![Linux x64](pictures/os_linux.png) Linux](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/linux-ugs-platform-app-2.0.15.tar.gz) | [![Linux x64](pictures/os_linux.png) Linux](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/linux-ugs-platform-app-2.0-SNAPSHOT.tar.gz) |
| [![Linux ARM 32-bit](pictures/os_linux_arm.png) RaspberryPI](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/pi-ugs-platform-app-2.0.17.tar.gz) | [![Linux ARM](pictures/os_linux_arm.png) RaspberryPI](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/pi-ugs-platform-app-2.0.15.tar.gz) | [![Linux ARM](pictures/os_linux_arm.png) RaspberryPI](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/pi-ugs-platform-app-2.0-SNAPSHOT.tar.gz) |
| [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/ugs-platform-app-2.0.17.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/ugs-platform-app-2.0.15.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/ugs-platform-app-2.0-SNAPSHOT.zip) |
| Latest release (v2.0.18) | Previous release (v2.0.17) | Nightly build |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------|
| [![Windows 32-bit](pictures/os_windows.png) Windows 32-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/win-ugs-platform-app-2.0.18.zip) | [![Windows 32-bit](pictures/os_windows.png) Windows 32-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/win-ugs-platform-app-2.0.17.zip) | [![Windows 32-bit](pictures/os_windows.png) Windows 32-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/win-ugs-platform-app-2.0-SNAPSHOT.zip) |
| [![Windows 64-bit](pictures/os_windows.png) Windows 64-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/win64-ugs-platform-app-2.0.18.zip) | [![Windows 64-bit](pictures/os_windows.png) Windows 64-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/win64-ugs-platform-app-2.0.17.zip) | [![Windows 64-bit](pictures/os_windows.png) Windows 64-bit](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/win64-ugs-platform-app-2.0-SNAPSHOT.zip) |
| [![Mac OSX](pictures/os_mac.png) Mac OSX](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/ios-ugs-platform-app-2.0.18.dmg) | [![Mac OSX](pictures/os_mac.png) Mac OSX](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/ios-ugs-platform-app-2.0.17.dmg) | [![Mac OSX](pictures/os_mac.png) Mac OSX](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/ios-ugs-platform-app-2.0-SNAPSHOT.dmg) |
| [![Linux x64](pictures/os_linux.png) Linux](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/linux-ugs-platform-app-2.0.18.tar.gz) | [![Linux x64](pictures/os_linux.png) Linux](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/linux-ugs-platform-app-2.0.17.tar.gz) | [![Linux x64](pictures/os_linux.png) Linux](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/linux-ugs-platform-app-2.0-SNAPSHOT.tar.gz) |
| [![Linux ARM 32-bit](pictures/os_linux_arm.png) RaspberryPI](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/pi-ugs-platform-app-2.0.18.tar.gz) | [![Linux ARM](pictures/os_linux_arm.png) RaspberryPI](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/pi-ugs-platform-app-2.0.17.tar.gz) | [![Linux ARM](pictures/os_linux_arm.png) RaspberryPI](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/pi-ugs-platform-app-2.0-SNAPSHOT.tar.gz) |
| [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/ugs-platform-app-2.0.18.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/ugs-platform-app-2.0.17.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/ugs-platform-app-2.0-SNAPSHOT.zip) |

**UGS Classic**<br>
A clean and lightweight variant of UGS (requires [Java](https://java.com/en/download/manual.jsp)). <br>
Unpack and start the program by double clicking the jar file. On some platforms you may need to run the included start script. <br>

| Latest release (v2.0.17) | Previous release (v2.0.15) | Nightly build |
|:---------------|:---------------|:--------------|
| [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.17/UniversalGcodeSender.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/UniversalGcodeSender.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/UniversalGcodeSender.zip) |
| Latest release (v2.0.18) | Previous release (v2.0.17) | Nightly build |
|:-----------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|:--------------|
| [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.18/UniversalGcodeSender.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/v2.0.15/UniversalGcodeSender.zip) | [![Zip](pictures/zip.png) All platforms](https://github.com/winder/Universal-G-Code-Sender/releases/download/nightly/UniversalGcodeSender.zip) |

## Screenshots

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
*/
public class GrblVersion {
public static final GrblVersion NO_VERSION = new GrblVersion("");
public static final String VERSION_REGEX = "^\\[VER:[v]?(?<version>(?<major>\\d+)\\.(?<minor>\\d+)(?<char>.)?(?<snapshotnumber>.)?([-\\s](?<snapshot>[a-zA-Z0-9\\s]+))?)?([\\.:](?<date>[0-9a-z]+))?([\\.:](?<name>.*))?]$";
public static final String VERSION_REGEX = "^\\[VER:[v]?(?<version>(?<major>\\d+)\\.(?<minor>\\d+)(?<char>[a-zA-Z])?).*?]$";
private final double versionNumber; // The 0.8 in '[VER:0.8c.20220620:Machine1]'
private final Character versionLetter; // The c in '[VER:0.8c.20220620:Machine1]'
private final String buildDate; // The 20220620 in '[VER:0.8c.20220620:Machine1]'
private final String machineName; // The Machine1 in '[VER:0.8c.20220620:Machine1]'

/**
* Parses the GRBL version string from the format [VER:v1.1f.20170131:Some string]
Expand All @@ -27,13 +25,9 @@ public GrblVersion(String versionString) {
if (matcher.matches()) {
versionNumber = Double.parseDouble(StringUtils.defaultString(matcher.group("major"), "0") + "." + StringUtils.defaultString(matcher.group("minor"), "0"));
versionLetter = StringUtils.defaultString(matcher.group("char"), "-").charAt(0);
buildDate = StringUtils.defaultString(matcher.group("date"), "");
machineName = StringUtils.defaultString(matcher.group("name"), "");
} else {
versionNumber = 0;
versionLetter = '-';
buildDate = "";
machineName = "";
}
}

Expand All @@ -45,14 +39,6 @@ public Character getVersionLetter() {
return versionLetter;
}

public String getBuildDate() {
return buildDate;
}

public String getMachineName() {
return machineName;
}

@Override
public String toString() {
String result = "GRBL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,69 @@ public void parseCompleteVersionString() {
GrblVersion version = new GrblVersion("[VER:v1.1f.20170131:Some string]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('f', version.getVersionLetter().charValue());
assertEquals("20170131", version.getBuildDate());
assertEquals("Some string", version.getMachineName());
}

@Test
public void parseMillRightVersionString() {
GrblVersion version = new GrblVersion("[VER:1.1i MegaV 4 Axis Router.20190120:]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('i', version.getVersionLetter().charValue());
assertEquals("20190120", version.getBuildDate());
assertEquals("", version.getMachineName());
}

@Test
public void parseMillRightVersionString1() {
GrblVersion version = new GrblVersion("[VER:1.1i MR MegaV Tri-CAM Open Frame Bed.V4-20230217:]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('i', version.getVersionLetter().charValue());
}

@Test
public void parseUnknownMegaVersionString() {
GrblVersion version = new GrblVersion("[VER:1.1g3.20211002.Mega:]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('g', version.getVersionLetter().charValue());
assertEquals("20211002", version.getBuildDate());
assertEquals("Mega:", version.getMachineName());
}

@Test
public void parseCompleteVersionString2() {
GrblVersion version = new GrblVersion("[VER:1.1f.20170801:MINIMILL]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('f', version.getVersionLetter().charValue());
assertEquals("20170801", version.getBuildDate());
assertEquals("MINIMILL", version.getMachineName());
}

@Test
public void parseVersionStringWithoutName() {
GrblVersion version = new GrblVersion("[VER:v1.1f.20170131]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('f', version.getVersionLetter().charValue());
assertEquals("20170131", version.getBuildDate());
assertEquals("", version.getMachineName());
}

@Test
public void parseVersionStringWithoutBuildNumber() {
GrblVersion version = new GrblVersion("[VER:v1.1f:Some string]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('f', version.getVersionLetter().charValue());
assertEquals("", version.getBuildDate());
assertEquals("Some string", version.getMachineName());
}

@Test
public void parseVersionStringWithoutChar() {
GrblVersion version = new GrblVersion("[VER:v1.1.20170131:Some string]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('-', version.getVersionLetter().charValue());
assertEquals("20170131", version.getBuildDate());
assertEquals("Some string", version.getMachineName());
}

@Test
public void parseVersionStringWithSnapshotBuildDateAndMachine() {
GrblVersion version = new GrblVersion("[VER:1.1h-XCP.20220314a:abc]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('h', version.getVersionLetter().charValue());
assertEquals("20220314a", version.getBuildDate());
assertEquals("abc", version.getMachineName());
}

@Test
public void parseVersionStringWithSnapshot() {
GrblVersion version = new GrblVersion("[VER:1.1h-XCP]");
assertEquals(1.1d, version.getVersionNumber(), 0.001);
assertEquals('h', version.getVersionLetter().charValue());
assertEquals("", version.getBuildDate());
assertEquals("", version.getMachineName());
}

@Test
Expand Down