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
DataPointsResourceCDF data points resource
timeSeriesExternalId
stringTime series external id
samplingConfiguration
SamplingConfigurationSampling configuration (start and end sampling time)
token
CancellationTokenCancellation token
Returns
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
DataPointsResourceCDF data points resource
timeSeriesExternalId
stringTime series external id
aggregate
DataPointAggregateAggregation method
granularity
intTime granularity in minutes
samplingConfiguration
SamplingConfigurationSampling configuration (start and end sampling time)
token
CancellationTokenCancellation 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
ToDataPointAggregate(string)
Attempts to convert and string to a data point aggregate method
public static DataPointAggregate ToDataPointAggregate(this string aggregate)
Parameters
aggregate
stringAggregate method
Returns
- DataPointAggregate
Aggregate enum value
Exceptions
- ArgumentException
Thrown when the string cannot be converted