new _DataArchive()

Data archive.
May not be directly instanced. An instance of the class is created by the method HomeServerConnector._Connection#getDataArchive.

Example

var da = conn.getDataArchive("DA@MyDataArchive", function(err, data) {});

Methods

destroy()

Enables the object and cancels any existing subscription.

Example

da.destroy(); 

getData(startDate, blockCount, blockSize, columnList, callback)

Retrieves a selection of data from the archive. The selection is specified via the parameters.

Examples

Retrieval of the archive columns 1, 3 and 4 from 01.01.2016, from 14:00 for a time period of 60 minutes: 30 entries of which each summarises the values from 2 minutes.

var startDate = new Date(2016, 0, 1, 14, 0);  // 01.01.2016 14:00
da.getData(startDate, 30, 2, ['#1', '#3', '#4'], function(err, data) {});

Retrieval of the archive columns with the column headers "TARGET" and "ACTUAL" for a time period which began 12 hours ago and lasts 6 hours: 24 entries of which each summarises the values from 15 minutes.

var startDate = da.getStartDateFromHours(12);  // NOW - 12 hours
da.getData(startDate, 24, 15, ['TARGET', 'ACTUAL'], function(err, data) {});

Parameters

Name Type Optional Description

startDate

Date

 

Date object. Start time from which the data is to be supplied.

blockCount

Number

 

Number of data blocks to be supplied.

blockSize

Number

 

Size of a data block (in minutes).

columnList

Array

 

List of columns to be displayed. Either keys or indices are listed here. If an index is involved, a '#' must be placed in front of the value. The indices correspond to the from left to right consecutively numbered columns of the archive, beginning with '1'.

callback

function()

 

HomeServerConnector._DataArchive~getDataCallback

getKey() → String

Returns the key of the object.

Example

var object_key = da.getKey(); 
Returns

String 

getMeta(callback)

Retrieves the metadata.

Example

Retrieval of metadata

da.getMeta(function(err, data) {});

Parameter

Name Type Optional Description

callback

function()

 

HomeServerConnector._DataArchive~getMetaCallback

getStartDateFromDays(hours) → Date

Returns a correctly formatted "start date" string for the getData() archive. A number of days is transferred. The date created is NOW - Number of days

Parameter

Name Type Optional Description

hours

Number

 

Number of days deducted from the current time.

Returns

Date Date.

getStartDateFromHours(hours) → Date

Returns a correctly formatted "start date" string for the getData() archive. A number of hours is transferred. The date created is NOW - Number of hours

Parameter

Name Type Optional Description

hours

Number

 

Number of hours deducted from the current time.

Returns

Date Date.

getStartDateFromWeeks(hours) → Date

Returns a correctly formatted "start date" string for the getData() archive. A number of weeks is transferred. The date created is NOW - Number of weeks

Parameter

Name Type Optional Description

hours

Number

 

Number of weeks deducted from the current time.

Returns

Date Date.

Abstract types

inner

getDataCallback(err, data)

Examples

Retrieval of the archive columns 1, 3 and 4 from 01.01.2016, from 14:00 for a time period of 60 minutes: 30 entries of which each summarises the values from 2 minutes.

var startDate = new Date(2016, 0, 1, 14, 0);  // 01.01.2016 14:00
da.getData(startDate, 30, 2, ['#1', '#3', '#4'], function(err, data) {});

Retrieval of the archive columns with the column headers "TARGET" and "ACTUAL" for a time period which began 12 hours ago and lasts 6 hours: 24 entries of which each summarises the values from 15 minutes.

var startDate = da.getStartDateFromHours(12);  // NOW - 12 hours
da.getData(startDate, 24, 15, ['TARGET', 'ACTUAL'], function(err, data) {});

# Structure of the returned 'data' object with example values for the above call in the 2nd example
    {
      "columns": {
        "ACTUAL": {
          "sum": [31, 32, 31, 33],
          "cnt": [2, 2, 2, 2],
          "min": [15, 16, 15, 16],
          "max": [16, 16, 16, 17]
        },
        "TARGET": {
          "sum": [34, 34, 34, 34],
          "cnt": [2, 2, 2, 2],
          "min": [17, 15, 17, 17],
          "max": [17, 19, 17, 17]
        },
      }
    }

Parameters

Name Type Optional Description

err

(Object or undefined)

 

Error object

data

Object

 

Archive information

Structure

{
  "columns": {
    "COLUMN_KEY": {
      "sum": Array of Number,
      "cnt": Array of Number,
      "min": Array of Number,
      "max": Array of Number,
    }
  }
}

Explanation

  • columns - Object, contains all the requested columns as a key.
    • COLUMN_KEY - Object, contains information on the requested column. Is returned exactly once for every requested column. The placeholder COLUMN_KEY is replaced by the column header assigned in Expert.
      The number of list entries is the same as for the following 4 lists and corresponds to the requested number of block entries (blockCount)
      • sum - List with totals. Each list entry corresponds to the totals of all values which were recorded within a block (block period).
      • cnt - List with quantities. Each list entry corresponds to the number of values which were recorded within a block (block period).
      • min - List with minimum values. Each list entry contains the lowest of all values which were recorded within a block (block period).
      • max - List with maximum values. Each list entry contains the highest of all values which were recorded within a block (block period).
inner

getMetaCallback(err, data)

Example

Retrieval of metadata

da.getMeta(function(err, data) {}); 

Parameters

Name Type Optional Description

err

(Object or undefined)

 

Error object

data

Object

 

Meta information

Structure

{
  "keys":        Array of String,
  "caption":     String,
  "description": String,
  "tags":        Array of String,
  "size":        Number,

  "stat": {
      "first":   Number,
      "last":    Number,
      "count":   Number
  },

  "cols": [
    {
      "idx":     Number,
      "key":     String,
      "caption": String
    }
  ]
}

Explanation

  • keys - List with keys (e.g.: ["DA:2", "DA@MyDataArchive"]). Contains at least one number.
  • caption - Designation of the object.
  • description - Description of the object.
  • tags - List of tags (e.g.: ["BM", "Light"]).
  • size - Maximum size of ring buffer.
  • stat - Object, contains information about the content of the archive.
    • first - Unix time stamp (in seconds, milliseconds as a decimal value) of the oldest entry in the archive.
    • last - Unix time stamp (in seconds, milliseconds as a decimal value) of the youngest entry in the archive.
    • count - Number of entries in the archive.
  • cols - List of column objects.
    • idx - Index of column.
    • key - Key of column.
    • caption - Designation of the column.