domain~ StreamDatum

A stream datum entity.

A stream datum is a datum without any metadata describing the datum property names. The instantantaneous, accumulating, and status property values are stored as the array fields iProps, aProps, and sProps. A DatumStreamMetadata object is required to associate names with these arrays.

Constructor

new StreamDatum(streamId, ts, iPropsopt, aPropsopt, sPropsopt, tagsopt)

Constructor.

Parameters:
NameTypeAttributesDescription
streamIdstring

the datum stream ID

tsDate | number | string

the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

iPropsArray.<Number><optional>

the instantaneous property values

aPropsArray.<Number><optional>

the accumulating property values

sPropsArray.<String><optional>

the status property values

tagsSet.<String> | Array.<String><optional>

the tag values

Methods

propertyValuesForType(samplesType) → {Array}

Get the property values for a given samples type.

Parameters:
NameTypeDescription
samplesTypemodule:domain~DatumSamplesType

the type of property values to return

Returns:

the property values for the given type, or undefined if none available

Type: 
Array

toJsonEncoding(registryopt) → {string}

Get this object as a standard JSON encoded string value.

This method returns the JSON form of the result of StreamDatum#toJsonObject().

Parameters:
NameTypeAttributesDescription
registrymodule:util~DatumStreamMetadataRegistry<optional>

a stream metadata registry to encode as a registry-indexed stream datum

Returns:

the JSON encoded string

Type: 
string

toJsonObject(registryopt) → {Array}

Get this object as an array suitable for encoding into a standard stream datum JSON string.

This method can encode the datum into an array using one of two ways, depending on whether the registry argument is provided. When provided, the first array element will be the stream metadata index based on calling DatumStreamMetadataRegistry#indexOfMetadataStreamId(). Otherwise the first array element will be the stream ID itself.

For example if a registry is used, the resulting array might look like this:

[0, 1650667326308, 12326, null, 230.19719, 50.19501, 6472722]

while without a registry the array might look like this:

["7714f762-2361-4ec2-98ab-7e96807b32a6", 1650667326308, 12326, null, 230.19719, 50.19501, 6472722]
Parameters:
NameTypeAttributesDescription
registrymodule:util~DatumStreamMetadataRegistry<optional>

a stream metadata registry to encode as a registry-indexed stream datum

Returns:

the datum stream array object

Type: 
Array

toObject(meta) → {Object}

Get this instance as a simple object.

The following basic properties will be set on the returned object:

  • streamId - the stream ID
  • date - the timestamp
  • sourceId - the metadata source ID
  • nodeId or locationId - either the node ID or location ID from the metadata
  • tags - any tags (as an Array)

Beyond that, all instantaneous, accumulating, and status properties will be included. If duplicate property names exist between the different classifications, the first-available value will be used.

Parameters:
NameTypeDescription
metamodule:domain~DatumStreamMetadata

a metadata instance to encode the property names with

Returns:

an object populated with all available properties

Type: 
Object

(static) fromJsonEncoding(json, meta) → {module:domain~StreamDatum}

Parse a JSON string into a StreamDatum instance.

The JSON must be encoded the same way StreamDatum#toJsonEncoding() does.

Parameters:
NameTypeDescription
jsonstring

the JSON to parse

metamodule:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry

a metadata instance or metadata registry to decode with

Returns:

the stream datum instance

Type: 
module:domain~StreamDatum

(static) fromJsonObject(data, meta) → {module:domain~StreamDatum}

Create a new StreamDatum instance from an array parsed from a stream datum JSON string.

The array must have been parsed from JSON that was encoded the same way StreamDatum#toJsonEncoding() does.

Parameters:
NameTypeDescription
dataArray

the array parsed from JSON

metamodule:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry

a metadata instance or metadata registry to decode with

Returns:

the stream datum instance

Type: 
module:domain~StreamDatum