Avatar

upgrading from 5.6 to 5.7: best approach LogRecord & StatusData

0

So, based on these two questions...

https://helpdesk.geotab.com/entries/27991140-upgrading-from-5-6-to-5-7-missing-properties

https://helpdesk.geotab.com/entries/23265649-Log-Records-5-6-vs-5-7-Auxiliary-information

...it appears that I will need to get StatusData to get:

  • PositionValid
  • Ignition
  • Aux1 - Aux8

What is the recommended way to do this?

There are times that we will need to get LogRecords by a date range. But most of the time, we will be using feeds. If we are using a date range, should we then just get StatusData for that same date range so we can query against it locally to get these properties? If we are using a feed, we will likely have to get min/max datetime from the feed returned, and then get StatusData for that date range.

Does this sound like the correct approach, or is there an alternative?

What if there is no StatusData for each LogRecord? 

Mark Faucher

Please sign in to leave a comment.

11 comments

0
Avatar

Hi Mark,

There are times that we will need to get LogRecords by a date range.

If you are querying Log Records for a period of time you can do the same for Status Data. When searching for status data where a device and diagnostic are supplied in the search the status data values will be interpolated for the dates provided. Ie, if you search for the same period as the logs, you should have min of 1 records returned.

But most of the time, we will be using feeds.

I'm assuming here you mean you are getting Log Records via a data feed but not status data?

You could either get the required data through the Get request or have a feed of Status Data as well. If you are getting a feed of status data, the records for Position Valid, Ignition and Aux will come through the feed. This would be the more efficient approach used in conjunction with a LogRecord feed but may require a bit more logic in the application as the interpolation will not be taken care of for you.

What if there is no StatusData for each LogRecord?

The status data will be the state changes for these types of records, so the last known state is considered the current state. I think of them as a graph of all the state changes over time.

Thanks,

Steve

 

Steve Hansen 0 votes
0
Avatar

Hi Steve. I want to make sure I'm understanding this new approach. Let's take one property, LogRecord.PositionValid. If we were only interested in LogRecords where PositionValid == true, then the new approach means we need to get StatusData and associate it with each LogRecord to know if the LogRecord.PositionValid == true.

So, if we have 10,000 LogRecords, do we need to make 10,000 calls to get StatusData with a particular vehicle and datetime so we will get the correct StatusData record to associate with the LogRecord? Or is there a way to get all 10,000 StatusData records and join them so that we can access PositionValid for each LogRecord?

Mark Faucher 0 votes
0
Avatar

Hey Mark,

Sure no problem, let me see if I can clarify.

If you have x number of logs from time-a to time-b, you can query for position valid status data for time-a to time-b. This will return all the changes in state for the times provided. You can use the status data results to interpolate the state for any time.

In the case you outline where you want to know for each log record, one approach could be to get the logs and status data in a multicall, when the results are returned loop through the logs checking the valid state using the status data. If you need to store the state, you could create an object that extends LogRecord with an IsPositionValid property.

Thanks,

Steve

Steve Hansen 0 votes
0
Avatar

When we join these lists (LogRecords and StatusData), are we just working on DateTime, or is there some other relationship between the two? 

Mark Faucher 0 votes
0
Avatar

So, a device device records a StatusData record for every LogRecord it records? 

If I have a list of 10,000 LogRecords, I should be able to...

- get the min/max dates from that list
- get StatusData using that datetime range and it will return 10,000 StatusData records

?

If so, that means that joining them together will be as simple as joining on DateTime?

Mark Faucher 0 votes
0
Avatar

No, a device does not record a StatusData record for every LogRecord. They both are related to a device (think foreign key), they are not directly related.

StatusData can be recorded for many different diagnostics. For example, battery voltage, fuel level, rpm, position valid, etc.

In this case you are interested in status data that relates to the Position Valid diagnostic (KnownId.DiagnosticPositionValidId). There will be n number of records of Position Valid status data for the x number of LogRecords you retrieve. The ratio will should not be 1:1. The status data retrieved for position valid diagnostic will be state changes. This could be 6/10,000 it could be 2/10,000, it entirely depends on the data.

You can use the status data results to interpolate the state for any time.

Steve

Steve Hansen 0 votes
0
Avatar

Sorry Steve. I'm struggling a bit here. 

Can you discuss the difference between LogRecord.PositionValid, which was available for every record, and the new 5.7 approach?

"You can use the status data results to interpolate the state for any time."

Does this mean that if I have my LogRecords and I call StatusData...

List<StatusData> statusData = api.Call<List<StatusData>>("Get", typeof(StatusData), new
{
search = new StatusDataSearch
{
   FromDate = dateTimeFrom.Value.ToUniversalTime(),
   ToDate = dateTimeTo.Value.ToUniversalTime(),
   DiagnosticSearch = new DiagnosticSearch
      {
         Id = KnownId.DiagnosticPositionValidId
      }
   }
});

...I can see if the LogRecord's position is valid by selecting the StatusData closest to the DateTime of my LogRecord?

Mark Faucher 0 votes
0
Avatar

Hi Steve, quick PositionValid question.

So, when I get my feed of LogRecords, I get the min/max datetimes and use that to get a list of StatusData with Id = KnownId.DiagnosticPositionValid. 

Is it possible to get no StatusData records back for that time? These records really reflect a change in the PositionValid status. What if a change doesn't happen during that range? I won't know if these LogRecords are valid? Any suggestions?

Mark Faucher 0 votes
0
Avatar

Hi Steve,

Could you elaborate on Aux. It's now part of StatusData, but I'm not sure how this works.

 

Mark Faucher 0 votes