-
Notifications
You must be signed in to change notification settings - Fork 69
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
Handling invalid data values #93
Comments
So the information we need to convey is that a sensor says "I'm operational & connected & ok, but I am unable to function for some reason" so it is not just the absence of data / updates. Several options:
|
I think having a special marker property like dataValid: false, would be a good solution and suitable for most sensor data. Depth and GPS are the obvious ones and we should start with these ones but we might need to add this for other sensors if we find that they have a valid flag or some other way of indicating data invalid. |
Hmm, this brings up other issues - how does a sensor communicate its condition via signalk. Looking at the simple cases:
Well 4) is easy - its just gone, so nothing, no comms etc.
|
For what it's worth I'm not sure I see any practical difference between a sensor that is dead/missing, and a sensor that is alive but not reporting any usable values. If this were a requirement then you could do this with a "last seen" timestamp on the source - this is the last communication with the source, which is distinct from the timestamp associated with any data fields it updates. But given I'm not sure I understand the problem this is trying to solve, this might not help. |
Just came to think about this. I'm not sure how a depth sensor would react when the depth is greater than it could measure. But there is value in a measurement saying "it's really deep here", rather than "the sounder is not measuring since 2 mins ago" |
Traditionally depth sounders flash the last good value and they can lose depth for a number of reasons, not just going "out of their depth" in deep water. GPS position is another value that can become invalid. @faceless2 it is not about last seen, as the values could still be streaming in from NMEA sources, it is about this is the last value but it is no longer valid. You could just stop sending SK data but then the display values on a consumer would time out and disappear and you do not know what the last value was and whether you have a system failure, data connection drop out, etc. |
I am going to have to make a decision on this one, as it is holding up iKommunicate testing. If there is an NMEA sentence or PGN that is showing the data as not available/invalid then we will send the relevant Signal K value as a Null. The same is true if the data was coming in and it then times out, we will also change the Signal K value to a Null. |
I think that is the best solution. All alternatives are worse! |
There are three practical ways for sending 'data invalid' message: Send delta with just path, no value. Send value as undefined. Send value as null. I think null, indicating the absence of value, is the proper choice. https://www.wwco.com/~wls/blog/2011/05/30/json-and-undefined-properties/ |
There are several explicit cases where a sensor can indicate that it is otherwise operational but can not produce vali ddata. Example cases are a depth sounder that can not discern bottom from the echo data and a GNSS that has no satellite fix. In these cases a gateway/server will typically receive a message indicating invalid data. It must send out a delta message where the value of the data item is null and serve the value as null in the REST api. |
SignalK/n2k-signalk#21 Should be included in the spec document. |
It seems to me that everyone is in agreement on the above solution of using "Null" in Signal K to indicate that data is not available or currently invalid. I am not sure what changes are needed to the schema files to implement this but if someone wants to do that part I am happy to make changes to the documentation. |
No change should be necessary to the schema. It just needs to be explicit in the documentation somewhere.
However, I think that this is a very JavaScript-centric approach which makes implementing consumers more difficult in other languages. JSON parsers typically treat null values and missing values as the same thing (i.e. null), but we're explicitly stating here that they're not the same thing (because in JavaScript, they're not). I've verified this to be the case in C#, Go and Ruby so far. It would be illustrative to know what common parsers for C, C++, Objective-C, Java, Python and Swift do. I suspect the results will be similar. A way to explicitly indicate that the value is invalid would be better. |
Since we use json as the data format we need to send data that conforms to json spec, and assume that different parsers dont have bugs. If they do its the parsers problem. JSON only allows In the end we can either make a value Only other option is in the delta we send a block of
|
We do have the option of sending just Other options exist, like
which is a more verbose version of just omitting PS. Python is ok with JSON nulls (None) and Java has Gson.isJsonNull() and JSONObject.isNull(key). |
I think the best option is to send the exact same JSON as we normally do but with value = null and then it is one change and can be applied to all objects. If we have the valid field it will add complexity and unless it is mandatory people will ignore it where as value = null will just happen and the client software will need no extra modification. |
For what it's worth I agree with Paul - setting a value to null (whether
it's {"navigation":{"position": null}}, {"key":"navigation.position",
"value":null} or some other syntax) is unambiguous; it's standard JSON so
should cause no technical problems for any client; it cannot be ignored by
a client, unlike an additional key; and it meets the principle of least
surprise.
…On 22 December 2016 at 07:52, sumps ***@***.***> wrote:
I think the best option is to send the exact same JSON as we normally do
but with value = null and then it is one change and can be applied to all
objects. If we have the valid field it will add complexity and unless it is
mandatory people will ignore it where as value = null will just happen and
the client software will need no extra modification.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#93 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA8YO2HF6RJzTFzjlGeiAhT4hjgWIjRIks5rKixMgaJpZM4GMzSm>
.
|
There's a interaction with the REST API as well. For a key that is known but whose value is currently unknown, the appropriate response would be 200 with a null value; for a key that is not known the server should return a 404 response. When retrieving a non-leaf path (e.g. There's a still problem in distinguishing between a full and sparse response. If the This stops being a problem if we switch from a hierarchical to the flat model. |
See #311 we need some way to identify if its a sparse or full response. I still need to catch up on recent discussions but is it possible to differentiate between sparse and full by the request or subscription? |
How should we handle invalid data values in the SK spec? Two examples are;
The text was updated successfully, but these errors were encountered: