new StreamDatum(streamId, ts [, iProps] [, aProps] [, sProps] [, tags])
Constructor.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
streamId |
string | the datum stream ID |
|
ts |
Date | number | string | the datum timestamp, either as a |
|
iProps |
Array.<Number> |
<optional> |
the instantaneous property values |
aProps |
Array.<Number> |
<optional> |
the accumulating property values |
sProps |
Array.<String> |
<optional> |
the status property values |
tags |
Set.<String> | Array.<String> |
<optional> |
the tag values |
Methods
-
<static> fromJsonEncoding(json, meta)
-
Parse a JSON string into a StreamDatum instance.
The JSON must be encoded the same way StreamDatum#toJsonEncoding() does.
Parameters:
Name Type Description json
string the JSON to parse
meta
module:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry a metadata instance or metadata registry to decode with
Returns:
the stream datum instance
-
<static> fromJsonObject(data, meta)
-
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:
Name Type Description data
Array the array parsed from JSON
meta
module:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry a metadata instance or metadata registry to decode with
Returns:
the stream datum instance
-
propertyValuesForType(samplesType)
-
Get the property values for a given samples type.
Parameters:
Name Type Description samplesType
module: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( [registry])
-
Get this object as a standard JSON encoded string value.
This method returns the JSON form of the result of StreamDatum#toJsonObject().
Parameters:
Name Type Argument Description registry
module:util~DatumStreamMetadataRegistry <optional>
a stream metadata registry to encode as a registry-indexed stream datum
Returns:
the JSON encoded string
- Type
- string
-
toJsonObject( [registry])
-
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:
Name Type Argument Description registry
module: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)
-
Get this instance as a simple object.
The following basic properties will be set on the returned object:
streamId
- the stream IDdate
- the timestampsourceId
- the metadata source IDnodeId
orlocationId
- either the node ID or location ID from the metadatatags
- 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:
Name Type Description meta
module:domain~DatumStreamMetadata a metadata instance to encode the property names with
Returns:
an object populated with all available properties
- Type
- Object