Repository navigation
Add a value type to the JSON decoder so whole numbers no longer change its sample type - #25
Open
Unsttopabull wants to merge 1 commit into
Open
Unsttopabull wants to merge 1 commit into
Unsttopabull wants to merge 1 commit into
Conversation
…e its sample type
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
ValueTypeproperty toMQTTJSONDecoderFBthat fixes the sample type of numeric values. Until now the decoder took the type from each message: a whole number was decoded asInt64and a decimal asFloat64. A publisher that writes whole numbers without a decimal point, as JavaScript'sJSON.stringifydoes, changed the signal's descriptor whenever the value crossed one. A client that rebuilds its acquisition on a descriptor change restarted on every switch. This was seen in DewesoftX.Changes
ValueTypeproperty (Auto/Float64/Int64), defaultFloat64:Float64converts every number, so the sample type stays the same.Int64accepts whole numbers only.22.0is decoded as22. A fractional value fails to parse with a status error instead of being truncated.Autokeeps the previous behaviour.MqttDataWrapper: a newconvertValueTypestep runs after the value is extracted and before the packets are built.Float64across whole numbers and decimals, an integer array underFloat64,Auto, andInt64accepting22.0and rejecting21.5. TheFloat64andInt64tests fail without the conversion (checked on our fork, which has the same decoder code). The existing integer tests now setInt64, andDataTransferIntArrayIsNotPromotedsetsAuto.Notes
Float64by default instead ofInt64. Integers above 2^53 lose precision unless the decoder is set toInt64.Testing
test_mqtt_stream_modulepasses all 202 tests andtest_mqtt_streaming_protocolall 25.