#347 HisRead Op modification

Alex Afflick Mon 7 Dec 2015

Alongside Shawn Jacobson's post - I would like to propose the HisRead op is modified as well to allow multiple recs to have their histories read from at the same time.

HisRead

The hisRead op is used to read a time-series data from historized point(s).

Request (single point): a grid with a single row and following columns:

  • id: Ref identifier of historized point
  • range: Str encoding of a date-time range

Response (single point): rows of the result grid represent timetamp/value pairs with a DateTime ts column and a val column for each scalar value. In addition the grid metadata includes:

  • id: Ref of the point we read
  • hisStart: DateTime timestamp for exclusive range start in point's timezone
  • hisEnd: DateTime timestamp for inclusive range end in point's timezone

Request (multi point): a grid with a single row and following columns:

  • range: Str encoding of a date-time range
  • id0: Ref identifier of the first historized point
  • id1: ...

where the id columns are named id0, id1, etc, for the successive historized points .

Response (multi point): rows of the result grid represent timestamp/value pairs with a DateTime ts column and a val column for each scalar value, named v0, v1 etc, with a Ref identifier of the writable point defined in the column metadata:

  • ts: DateTime timestamp of sample in point's timezone
  • v0: Value of the first timestamp sample
  • v1: ...

In addition, the grid metadata include:

  • hisStart: DateTime timestamp for exclusive range start in point's timezone
  • hisEnd: DateTime timestamp for inclusive range end in point's timezone

The range Str is formatted as one of the following options:

  • "today"
  • "yesterday"
  • "{date}"
  • "{date},{date}"
  • "{dateTime},{dateTime}"
  • "{dateTime}" // anything after given timestamp

Ranges are exclusive of start timestamp and inclusive of end timestamp. The {date} and {dateTime} options must be correctly Zinc encoded. DateTime based ranges must be in the same timezone of the entity (timezone conversion is explicitly disallowed). Date based ranges are always inferred to be from midnight of starting date to midnight of the day after ending date using the timezone of the his entity being queried.

Example of a single point hisRead request:

// request
ver:"2.0"
id,range
@someTemp,"2012-10-01"

// reponse
ver:"2.0" id:@someTemp hisStart:2012-10-01T00:00:00-04:00 New_York hisEnd:2012-10-02T00:00:00-04:00 New_York
ts,val
2012-10-01T00:15:00-04:00 New_York,72.1°F
2012-10-01T00:30:00-04:00 New_York,74.2°F
2012-10-01T00:45:00-04:00 New_York,75.0°F
..

Example of a multi point hisRead request:

// request
ver:"2.0"
range,id0,id1
"2012-10-01",@a,@b

// reponse
ver:"2.0" hisStart:2012-10-01T00:00:00-04:00 New_York hisEnd:2012-10-02T00:00:00-04:00 New_York
ts,v0 id:@a,v1 id:@b
2012-10-01T00:15:00-04:00 New_York,72.1°F,71.1°F
2012-10-01T00:30:00-04:00 New_York,74.2°F,73.1°F
2012-10-01T00:45:00-04:00 New_York,N,72.4°F
..

Stuart Longland Thu 28 Jan 2016

Silly question, is there any reason why the server needs to care about the column names in this circumstance?

It might be helpful for the end user if the server simply "round tripped" the column names, so that each row had a column "ts" which was the timestamp, then the remaining columns are named whatever the request named them.

e.g.

// request
ver:"2.0"
range,tempAtSiteA,tempAtSiteB
"2012-10-01",@a,@b

// reponse
ver:"2.0" hisStart:2012-10-01T00:00:00-04:00 New_York hisEnd:2012-10-02T00:00:00-04:00 New_York
ts,tempAtSiteA id:@a,tempAtSiteB id:@b
2012-10-01T00:15:00-04:00 New_York,72.1°F,71.1°F
2012-10-01T00:30:00-04:00 New_York,74.2°F,73.1°F
2012-10-01T00:45:00-04:00 New_York,N,72.4°F
…

If a user chooses to use v0, v1, v2, … then more power to them, this will still work.

Login or Signup to reply.