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

[modbus][sunspec] Fixed type and scale errors on acc32 fields #7826

Merged
merged 2 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ protected State getScaled(Optional<? extends Number> value, Short scaleFactor, U
* @return the scaled value as a DecimalType
*/
protected State getScaled(Number value, Short scaleFactor, Unit<?> unit) {
if (scaleFactor == 1) {
if (scaleFactor == 0) {
return new QuantityType<>(value.longValue(), unit);
}
return new QuantityType<>(BigDecimal.valueOf(value.longValue(), scaleFactor * -1), unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected Integer extractUInt16(ModbusRegisterArray raw, int index, int def) {
* @return the parsed value or empty if the field is not implemented
*/
protected Optional<Long> extractOptionalAcc32(ModbusRegisterArray raw, int index) {
return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.UINT32).map(DecimalType::longValue)
return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.INT32).map(DecimalType::longValue)
.filter(value -> value != 0);
}

Expand Down Expand Up @@ -121,6 +121,6 @@ protected Optional<Short> extractOptionalSunSSF(ModbusRegisterArray raw, int ind
* @return the parsed value or 1 if the field is not implemented
*/
protected Short extractSunSSF(ModbusRegisterArray raw, int index) {
return extractOptionalSunSSF(raw, index).orElse((short) 1);
return extractOptionalSunSSF(raw, index).orElse((short) 0);
}
}