ValueStream
in package
implements
ArrayAccess, Countable, Iterator, JsonSerializable
Class ValueStream allows the creation of the PHP Value Steam Object.
This class implements the ArrayAccess interface which will allow user to do things like: $values = $value_stream['values']. This also give us hooks into methods like __toString and jsonSerialize if we choose to implement. This will allow SQL like so: "history.evaluate_expression($stream1 * $stream2)"
Interfaces, Classes and Traits
- ArrayAccess
- Countable
- Iterator
- JsonSerializable
Table of Contents
- $aggregates : array<string|int, mixed>
- $data_type : string|null
- $end_timestamp : DateTimeInterface|string
- $interpolation_method : string|null
- $measurement_unit : MeasurementUnit|null
- $quantity_kind : QuantityKind|null
- $source_id : int|null
- $start_timestamp : DateTimeInterface|string
- $position : int
- $time_series : array<string|int, mixed>
- __construct() : mixed
- ValueStream constructor.
- __toString() : string
- Do not call this method externally, its purpose is to turn a PHP object into a string that Postgres can rehydrate as a value stream object
- count() : int
- Allows calling the count() method on the ValueStream Class.
- current() : array<string|int, mixed>
- part of Iterator interface
- intervalToSeconds() : float|int
- intervalToSeconds
- jsonSerialize() : string
- Do not call this method externally, it is used as part of building a Postgres interpretable object
- key() : int
- part of Iterator interface
- mergeMedia() : mixed
- Called from getTimeSeriesWithMedia, will merge presigned s3 media with time series data
- next() : mixed
- part of Iterator interface
- offsetExists() : bool
- part of ArrayAccess interface
- offsetGet() : mixed
- part of ArrayAccess interface
- offsetSet() : mixed
- part of ArrayAccess interface
- offsetUnset() : mixed
- part of ArrayAccess interface
- processValueStreamTimeLine() : mixed
- processValueStreamTimeLine processes the value stream. Included are: producing of timeline (seconds) and uptime-timeline (secondsUptime) while scanning through the timeline we compute running averages, both, time weighted and sample based we honor expirations, data gaps, and interpolation settings we populate an aggregates object with totalized summary kpi's
- rewind() : mixed
- part of Iterator interface
- setUnit() : void
- valid() : bool
- part of Iterator interface
Properties
$aggregates
public
array<string|int, mixed>
$aggregates
= array()
$data_type
public
string|null
$data_type
float, int, string, etc. see the type model.scalar_type_enum in the database
$end_timestamp
public
DateTimeInterface|string
$end_timestamp
last timestamp in the stream
$interpolation_method
public
string|null
$interpolation_method
'none', 'previous', 'next', 'linear'. see model.interpolation_method_enum
$measurement_unit
public
MeasurementUnit|null
$measurement_unit
= null
$quantity_kind
public
QuantityKind|null
$quantity_kind
= null
$source_id
public
int|null
$source_id
attribute or tag id
$start_timestamp
public
DateTimeInterface|string
$start_timestamp
first timestamp in the stream
$position
private
int
$position
= 0
indicates the Iterator position; used in foreach loops
$time_series
private
array<string|int, mixed>
$time_series
= array()
holds the value, timestamp, and status information
Methods
__construct()
ValueStream constructor.
public
__construct(array<string|int, mixed> $values, array<string|int, mixed> $timestamps[, array<string|int, mixed> $statuses = [] ][, string|null $interpolation_method = 'linear' ]) : mixed
Parameters
- $values : array<string|int, mixed>
- $timestamps : array<string|int, mixed>
- $statuses : array<string|int, mixed> = []
- $interpolation_method : string|null = 'linear'
Tags
Return values
mixed —__toString()
Do not call this method externally, its purpose is to turn a PHP object into a string that Postgres can rehydrate as a value stream object
public
__toString() : string
Return values
string —count()
Allows calling the count() method on the ValueStream Class.
public
count() : int
Useful for writing a control loop like this: for ( $i = 0 ; $i < count($value_stream) ; $i++ ) }
Return values
int —current()
part of Iterator interface
public
current() : array<string|int, mixed>
Return values
array<string|int, mixed> —intervalToSeconds()
intervalToSeconds
public
static intervalToSeconds(DateInterval $interval) : float|int
Parameters
- $interval : DateInterval
Return values
float|int —jsonSerialize()
Do not call this method externally, it is used as part of building a Postgres interpretable object
public
jsonSerialize() : string
Return values
string —key()
part of Iterator interface
public
key() : int
Return values
int —mergeMedia()
Called from getTimeSeriesWithMedia, will merge presigned s3 media with time series data
public
mergeMedia( $result, $imageLinks, $vs) : mixed
Parameters
Return values
mixed —next()
part of Iterator interface
public
next() : mixed
Return values
mixed —offsetExists()
part of ArrayAccess interface
public
offsetExists( $offset) : bool
Parameters
Return values
bool —offsetGet()
part of ArrayAccess interface
public
offsetGet( $offset) : mixed
Parameters
Return values
mixed —offsetSet()
part of ArrayAccess interface
public
offsetSet( $offset, $value) : mixed
Parameters
Return values
mixed —offsetUnset()
part of ArrayAccess interface
public
offsetUnset( $offset) : mixed
Parameters
Return values
mixed —processValueStreamTimeLine()
processValueStreamTimeLine processes the value stream. Included are: producing of timeline (seconds) and uptime-timeline (secondsUptime) while scanning through the timeline we compute running averages, both, time weighted and sample based we honor expirations, data gaps, and interpolation settings we populate an aggregates object with totalized summary kpi's
public
processValueStreamTimeLine() : mixed
NOTE: This processing only works for numeric value streams, you can't interpolate a string, object, etc.
Tags
Return values
mixed —rewind()
part of Iterator interface
public
rewind() : mixed
Return values
mixed —setUnit()
public
setUnit(string|MeasurementUnit $m_u[, string $default_lib = 'thinkiq_base_library' ]) : void
Parameters
- $m_u : string|MeasurementUnit
-
if a string is passed it needs to be the relative_name of a measurement from the base librar
- $default_lib : string = 'thinkiq_base_library'
Tags
Return values
void —valid()
part of Iterator interface
public
valid() : bool