Skip to content

Commit

Permalink
Read max spindle speed as double
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed Nov 5, 2024
1 parent e21f23f commit 8a9e5c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ public double getMaximumRate(Axis axis) throws FirmwareSettingsException {
public int getMaxSpindleSpeed() throws FirmwareSettingsException {
return getSetting(KEY_MAX_SPINDLE_SPEED)
.map(FirmwareSetting::getValue)
.map(Integer::valueOf)
.map(value -> value.replaceAll(",", "."))
.map(Double::valueOf)
.map(Double::intValue)
.orElse(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,19 @@ public void setInvertDirectionZShouldSetBit() throws FirmwareSettingsException,

assertEquals("7", target.getSetting("$3").get().getValue());
}

@Test
public void getMaxSpindleSpeedShouldReturnIntegerValue() throws FirmwareSettingsException {
target.rawResponseListener("$30=1000.0");
assertEquals(1000, target.getMaxSpindleSpeed());

target.rawResponseListener("$30=1000");
assertEquals(1000, target.getMaxSpindleSpeed());

target.rawResponseListener("$30=1000,00");
assertEquals(1000, target.getMaxSpindleSpeed());

target.rawResponseListener("$30=1000.9");
assertEquals(1000, target.getMaxSpindleSpeed());
}
}

0 comments on commit 8a9e5c6

Please sign in to comment.