Table of Contents

Class DataPointsExtensions

Namespace
Cognite.Simulator.Extensions
Assembly
Cognite.Simulator.Extensions.dll

Class containing extensions to the CDF Data points resource with utility methods for simulator integrations

public static class DataPointsExtensions
Inheritance
DataPointsExtensions
Inherited Members

Methods

GetLatestValue(DataPointsResource, string, SamplingConfiguration, CancellationToken)

Get the latest value of a time series before a given time

public static Task<(long Timestamp, double Value)> GetLatestValue(this DataPointsResource dataPoints, string timeSeriesExternalId, SamplingConfiguration samplingConfiguration, CancellationToken token)

Parameters

dataPoints DataPointsResource

CDF data points resource

timeSeriesExternalId string

Time series external id

samplingConfiguration SamplingConfiguration

Sampling configuration (start and end sampling time)

token CancellationToken

Cancellation token

Returns

Task<(long Timestamp, double Value)>

An array with the timestamps and one with the values

Exceptions

ArgumentNullException

Thrown when the time samplingConfiguration is null

DataPointSampleNotFoundException

Thrown when no data points where found based on samplingConfiguration

GetSample(DataPointsResource, string, DataPointAggregate, int, SamplingConfiguration, CancellationToken)

Sample a time series data points with the given time samplingConfiguration, granularity and aggregation method

public static Task<(long[] Timestamps, double[] Values)> GetSample(this DataPointsResource dataPoints, string timeSeriesExternalId, DataPointAggregate aggregate, int granularity, SamplingConfiguration samplingConfiguration, CancellationToken token)

Parameters

dataPoints DataPointsResource

CDF data points resource

timeSeriesExternalId string

Time series external id

aggregate DataPointAggregate

Aggregation method

granularity int

Time granularity in minutes

samplingConfiguration SamplingConfiguration

Sampling configuration (start and end sampling time)

token CancellationToken

Cancellation token

Returns

Task<(long[] Timestamps, double[] Values)>

An array with the timestamps and one with the values

Exceptions

ArgumentNullException

Thrown when the time samplingConfiguration is null

DataPointSampleNotFoundException

Thrown when no data points where found based on samplingConfiguration

MinutesToGranularity(int)

Convert data sampling granularity specified in minutes to a string format accepted by CDF, and conforming to its limits. Fractional granularity is not allowed, and the values are cast to int

public static string MinutesToGranularity(int minutes)

Parameters

minutes int

Returns

string

ToDataPointAggregate(string)

Attempts to convert and string to a data point aggregate method

public static DataPointAggregate ToDataPointAggregate(this string aggregate)

Parameters

aggregate string

Aggregate method

Returns

DataPointAggregate

Aggregate enum value

Exceptions

ArgumentException

Thrown when the string cannot be converted