Learn AXON

Axon doc: 


hisWrite(data, hisRec, opts)

Asynchronously write the specified timestamp/value pairs to the history. The timestamps must match tz of history. If the history has a unit tag, then the items have either a null or matching unit.

The data may be one of the following:

  • Dict with ts and val tags; writes one pair to the history
  • List of Dicts with ts and val tags; writes the list of items to the history
  • Grid where first column is ts and second column (may be named anything) is the values

The hisRec parameter may be:

  • Ref of history to write to
  • Rec of history to write to


Side effects:

  • updates his rec tags hisSize, hisStart, etc
  • writes new history data into hisYear
  • clears context read cache

Be sure hisRec has tags: point, his, tz, kind (tz and kind should be as history's tz and kind)


() => do
//find point we want to set history
  point: readById(@p:demo:r:21d637b5-5b6dc525)

//make history list (also maybe Dict or Grid, can be read from csv or another format)
  history: [{"ts": dateTime(date(2017,01,01),time(00,00),"New_York"),"val": 1},
  {"ts": dateTime(date(2017,01,02),time(00,00),"New_York"),"val": 2}, 
  {"ts": dateTime(date(2017,01,03),time(00,00),"New_York"),"val": 3}, 
  {"ts": dateTime(date(2017,01,04),time(00,00),"New_York"),"val": 4}, 
  {"ts": dateTime(date(2017,01,05),time(00,00),"New_York"),"val": 5}]

//write history and return result ("write {{number of values}}")
  return history.hisWrite(point)

Result will be:

Point after running this function will looks like:

hisEnd, hisSize, hisStart appears within hisWrite

  • No labels