Class ConstantParameterDataAccess
PDA for accessing constants on the session or lap. See ParameterDataAccessBase documentation for more information.
Inherited Members
Namespace: MESL.SqlRace.Domain
Assembly: MESL.SqlRace.Domain.dll
Syntax
public class ConstantParameterDataAccess : ParameterDataAccessBase, IParameterDataAccess, IDisposable
Properties
CoverageCursor
Gets the coverage cursor for the PDA.
Declaration
public override long CoverageCursor { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
DataChangedCounter
Gets a count of changes made to the data of the channel i.e. it's incremented each time data is added.
Declaration
public override int DataChangedCounter { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Overrides
Methods
CancelSearch()
Cancel Search
Declaration
public override void CancelSearch()
Overrides
Exceptions
Type | Condition |
---|---|
System.NotImplementedException |
Contains(Int64, Int64, MatchingRule, Double, Nullable<Double>, Nullable<Int32>)
Does this PDA's data contain a value
Declaration
public override bool Contains(long startAt, long endAt, MatchingRule rule, double value, Nullable<double> upperValue, Nullable<int> timespan)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startAt | Seach Start Position |
System.Int64 | endAt | Search End Position |
MatchingRule | rule | Comparison operator |
System.Double | value | Value to Search For |
System.Nullable<System.Double> | upperValue | Upper Value - used when using the Between Operator |
System.Nullable<System.Int32> | timespan |
Returns
Type | Description |
---|---|
System.Boolean | Was the ValueFound |
Overrides
Contains(Int64, Int64, MatchingRule, String, Nullable<Int32>)
Does this PDA's data contain a value
Declaration
public override bool Contains(long startAt, long endAt, MatchingRule rule, string value, Nullable<int> timespan)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startAt | Seach Start Position |
System.Int64 | endAt | Search End Position |
MatchingRule | rule | Comparison operator |
System.String | value | Value to Search For |
System.Nullable<System.Int32> | timespan | Period of time the condition must be met for |
Returns
Type | Description |
---|---|
System.Boolean | Was the ValueFound |
Overrides
GetData(Int64[], SampleModeType, Boolean, ParameterValuesTemplate)
Gets the sampled data values and DataStatusType from the requested timestamps and sample types.
Declaration
public override ParameterValues GetData(long[] sampleTimestamps, SampleModeType withSampleMode, bool linearInterpolation = false, ParameterValuesTemplate template = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int64[] | sampleTimestamps | The timestamps requested |
SampleModeType | withSampleMode | The SampleModeType which can be used. These are Minimum, Maximum, Mean and First. This is defaulted to Mean. These can be specified as flags to get more than one type |
System.Boolean | linearInterpolation | This option only really matters when you are requesting data at a higher frequency than it was collected. |
ParameterValuesTemplate | template | Optional template to be populated with samples. This can be used if the client wants to manage the memory to perform it's own memory management/buffering. The use of this is discouraged as the SQL Race memory pooling means it is more efficient in the large object heap and reduces fragmentation. When specifing a template you should follow these rules:
|
Returns
Type | Description |
---|---|
ParameterValues | Returns a ParameterValues object containing the resulting data |
Overrides
Remarks
On completion of this call, the CurrentTime will be set to the end of the returned data
Examples
The most simple call to this method, provides just the timestamps. This call will return the mean samples for the given timestamps
pda.GetData(timestamps)
This call will return the first samples for the given timestamps
pda.GetData(timestamps, SampleModeType.First)
This call will return the linearly interpolated mean values for the given timestamps
pda.GetData(timestamps, linearInterpolation: true)
Get minimum and maximum values and populate the given template
pda.GetData(timestamps, SampleModeType.Minimum | SampleModeType.Maximum, interpolate, new ParameterValuesTemplate { DataMin = minimumValues, DataMax = maximumValues, DataStatus = status });
Exceptions
Type | Condition |
---|---|
System.ArgumentException | This is thrown if the timestamps is an empty array or if the length of the arrays in the template are less than the number of timestamps requested |
System.ArgumentNullException | This is thrown if timestamps is set to null or if a template is provided, but it does not contain the array definitions it need for the given SampleModeType(s). You need to follow the template definition rules documented. |
GetDataStatistics(Int64, Int64, Boolean, StatisticOption, IParameterDataStatistics)
Returns the statistical values requested with statistic option flag(s) for a time range of data.
It takes a show you workings
approach. For example when you specify StandardDeviation it will include the sum of values and mean in the result.
Any samples that have a NaN value are skipped.
Declaration
public override IParameterDataStatistics GetDataStatistics(long startTimeStamp, long duration, bool weightStatistics = false, StatisticOption statisticOption, IParameterDataStatistics statisticsResult = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startTimeStamp | Start time of data range in nanoseconds. This number is inclusive so will include the sample at this given timestamp |
System.Int64 | duration | Length of data range in nanoseconds. This duration is exclusive, it will ignore any sample at the end of the sample range (startTimeStamp + duration) |
System.Boolean | weightStatistics | Weight statistics flag, this is defaulted to false. If this is set to true then the mean, absolute mean and standard deviation calculations are weighted against the sample interval |
StatisticOption | statisticOption | The statistic to be retrieved. This is defaulted to None which will only return start/end values. This is a flag field so mutiple types of statistics can be requested in one call. |
IParameterDataStatistics | statisticsResult | Optional base statistics result |
Returns
Type | Description |
---|---|
IParameterDataStatistics | Returns a IParameterDataStatistics object containing the results for the requested statistic options. Depending on the statistic options depends which fields will be populated:
|
Overrides
Remarks
If data is requested data is either before or after samples are available then a zero numberOfSamples will be returned.
Examples
Get the minimum value for the given time range
var result = this.pda.GetDataStatistics(
startTime,
duration,
false,
StatisticOption.Min);
Get the Max, Min and Mean for a given time range
pda.GetDataStatistics(
startTime,
duration,
false,
StatisticOption.Max | StatisticOption.Min | StatisticOption.Mean,
compositeStatistics);
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if the |
GetEndTime()
Returns the end time of the parameter's data.
Declaration
public override Nullable<long> GetEndTime()
Returns
Type | Description |
---|---|
System.Nullable<System.Int64> | The end time |
Overrides
GetLapStatistics(Lap, Boolean, StatisticOption, IParameterDataStatistics)
Returns the statistical values for the requested lap with statistic option flag(s) for lap time range of data. The calculated statistics will be cached for improved performance.
It takes a show you workings
approach. For example when you specify StandardDeviation it will include the sum of values and mean in the result.
Any samples that have a NaN value are skipped.
Declaration
public override IParameterDataStatistics GetLapStatistics(Lap lap, bool weightStatistics = false, StatisticOption statisticOption, IParameterDataStatistics statisticsResult = null)
Parameters
Type | Name | Description |
---|---|---|
Lap | lap | The Lap to get statistics for. |
System.Boolean | weightStatistics | Weight statistics flag, this is defaulted to false. If this is set to true then the mean, absolute mean and standard deviation calculations are weighted |
StatisticOption | statisticOption | The statistic to be retrieved. This is defaulted to None which will only return start/end values. This is a flag field so mutiple types of statistics can be requested in one call. |
IParameterDataStatistics | statisticsResult | Optional base statistics result |
Returns
Type | Description |
---|---|
IParameterDataStatistics | Returns a IParameterDataStatistics object containing the results for the requested statistic options. Depending on the statistic options depends which fields will be populated:
|
Overrides
Remarks
If data is requested data is either before or after samples are available then a zero numberOfSamples will be returned.
Examples
Get the minimum value for the given lap
var result = this.pda.GetLapStatistics(
lap,
false,
StatisticOption.Min);
Get the Max, Min and Mean for a given lap
pda.GetLapStatistics(
lap
false,
StatisticOption.Max | StatisticOption.Min | StatisticOption.Mean,
compositeStatistics);
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if the laps start is less than zero or if the start time is after the end time |
System.ArgumentNullException | Thrown if the lap is null or if the lap does not have an end time |
GetMaximumFrequency()
Returns the maximum frequency in Hz.
Declaration
public override double GetMaximumFrequency()
Returns
Type | Description |
---|---|
System.Double | The maximum frequency. |
Overrides
Remarks
If zero, then the frequency could not be determined.
GetMaximumSampleRate()
Returns the maximum sample rate available from the channels within the underlying Parameter associated with the PDA.
Declaration
public override Nullable<long> GetMaximumSampleRate()
Returns
Type | Description |
---|---|
System.Nullable<System.Int64> | The maximum sample rate |
Overrides
Remarks
This time returned is in nanoseconds.
GetMinimumFrequency()
Returns the minimum frequency in Hz.
Declaration
public override double GetMinimumFrequency()
Returns
Type | Description |
---|---|
System.Double | The minimum frequency. |
Overrides
Remarks
If zero, then the frequency could not be determined.
GetMinimumSampleInterval(Int64, Boolean)
Declaration
public override long GetMinimumSampleInterval(long sampleTime, bool useSubSampledChannels)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | sampleTime | |
System.Boolean | useSubSampledChannels |
Returns
Type | Description |
---|---|
System.Int64 |
Overrides
GetNextData(Int32, SampleModeType, Boolean, ParameterValuesTemplate)
Gets the next sampled data values and DataStatusType based on the number of samples requested and the PDA's current position.
Declaration
public override ParameterValues GetNextData(int numberOfSamples, SampleModeType withSampleMode, bool linearInterpolation = false, ParameterValuesTemplate template = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberOfSamples | Number of samples to retrieve. |
SampleModeType | withSampleMode | The SampleModeType which can be used. These are Minimum, Maximum, Mean and First. This is defaulted to Mean. These can be specified as flags to get more than one type |
System.Boolean | linearInterpolation | This option only really matters when you are requesting data at a higher frequency than it was collected. |
ParameterValuesTemplate | template | Optional template to be populated with samples. This can be used if the client wants to manage the memory to perform it's own memory management/buffering. The use of this is discouraged as the SQL Race memory pooling means it is more efficient in the large object heap and reduces fragmentation. When specifing a template you should follow these rules:
|
Returns
Type | Description |
---|---|
ParameterValues | Returns a ParameterValues object containing the resulting data |
Overrides
Remarks
On completion of this call, the CurrentTime will be set to the end of the returned data
Examples
This example is the most simple call to the method. It fetches the mean samples which are not linearly interpolated.
var parameterValues = this.sourcePda.GetNextData(numberOfSamples);
This example gets the next mean, minimum and maximum samples which are linearly interpolated
var parameterValues = this.sourcePda.GetNextData(numberOfSamples, SampleModeType.Minimum | SampleModeType.Maximum | SampleModeType.Mean, true);
Using the template to populate arrays in the client. This is particularly useful if you want to reuse the same array for multiple calls to perform buffering or object reuse.
var data = new double[numberOfSamples];
var status = new DataStatusType[numberOfSamples];
parameterDataAccess.GetNextData(numberOfSamples, template: new ParameterValuesTemplate { Data = data, DataStatus = status});
If using the template and specifing different sample types, you need to ensure that you have defined the correct arrays in the template to be populated
parameterDataAccess.GetNextData(numberOfSamples, SampleModeType.Minimum | SampleModeType.Maximum,
template: new ParameterValuesTemplate { DataMin = minimumValues, DataMax = maximumValues, DataStatus = dataStatusTypes});
Exceptions
Type | Condition |
---|---|
System.ArgumentException | This is thrown if number of samples requested is less than 1 or if the length of the arrays in the template are less than the number of samples requested |
System.ArgumentNullException | This is thrown if a template is provided, but it does not contain the array definitions it need for the given SampleModeType(s). You need to follow the template definition rules documented. |
GetNextSamples(Int32, StepDirection, ParameterValuesTemplate)
Returns the next raw data samples, their DataStatusType and time based on the number of samples requested.
Declaration
public override ParameterValues GetNextSamples(int numberOfSamples, StepDirection direction, ParameterValuesTemplate template = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberOfSamples | Number of samples to retrieve. This has to be larger than 0. |
StepDirection | direction | Set this to Reverse if you want to read the previous samples (read backwards) |
ParameterValuesTemplate | template | Optional template to be populated with samples. This can be used if the client wants to manage the memory to perform it's own memory management/buffering. The use of this is discouraged as the SQL Race memory pooling means it is more efficient in the large object heap and reduces fragmentation. When specifing a template you should follow these rules:
|
Returns
Type | Description |
---|---|
ParameterValues | Returns a ParameterValues object with the Data, Timestamp and DataStatus arrays populated with the results.
Use the ParameterValues.SampleCount field to determine how much data to read out of the array. If there are no samples then SampleCount will be 0. |
Overrides
Remarks
On completion of this call, the CurrentTime will be set to the end of the returned data
Examples
Example of usage and then iterating over the results using the SampleCount field not the array size.
this.pda.GoTo(startTime);
var pdaSamples = this.pda.GetNextSamples(noOfSamples);
for (var i = 0; i < pdaSamples.SampleCount; i++)
{
if(pdaSamples.DataStatus[i] != DataStatusType.Missing)
{
var data = pdaSamples.Data[i];
var timestamp = pdaSamples.Timestamp[i]
//Do something with data
}
}
This is the same code example, but called using a template.
this.pda.GoTo(startTime);
var pdaSamples = this.pda.GetNextSamples(noOfSamples, template: new ParameterValuesTemplate
{
Data = this.data,
DataStatus = this.dataStatus,
Timestamp = this.timeStamps
});
for (var i = 0; i < pdaSamples.SampleCount; i++)
{
if(this.dataStatus[i] != DataStatusType.Missing)
{
var data = this.data[i];
var timestamp = this.timeStamps[i]
//Do something with data
}
}
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if a template is provided without Data, DataStatus or Timestamp arrays |
System.ArgumentException | Thrown if; template arrays are too short, the smallest array is less than the number of samples in length or the number of samples is less than 1 |
GetSamplesBetween(Int64, Int64, Int32)
Gets a number of raw data samples, timestamps and DataStatusType based on the time range between the current position to the end sample time and sample size cap requested.
If the start time is after the end time it will read the data backwards in reverse. The CurrentTime is not updated by this call.
Declaration
public override ParameterValues GetSamplesBetween(long startTimeStamp, long endTimeStamp, int sampleSizeCap = 10000)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startTimeStamp | The start time stamp for the range to be read. If this is larger than the end time then the data will be read in reverse. |
System.Int64 | endTimeStamp | The end time stamp for the range to be read. If this is smaller than the start time then the data will be read in reverse. |
System.Int32 | sampleSizeCap | The maximum number of samples to return, this is defaulted to 10000. If the cap is exceeded it will return the first X number of samples. This is a useful protection in case you query for high resolution data over an extended time. |
Returns
Type | Description |
---|---|
ParameterValues | Returns a ParameterValues object with the Data, Timestamp and DataStatus arrays populated with the results.
Use the ParameterValues.SampleCount field to determine how much data to read out of the array. If there are no samples then SampleCount will be 0. |
Overrides
Remarks
If start and end time are equal then the sample for that timestamp is returned
Examples
Example of usage and then iterating over the results using the SampleCount field not the array size.
var pdaSamples = this.pda.GetSamplesBetween(startTime, endTime, maxSampleCountForPdaCall);
for (var i = 0; i < pdaSamples.SampleCount; i++)
{
if(pdaSamples.DataStatus[i] != DataStatusType.Missing)
{
var data = pdaSamples.Data[i];
var timestamp = pdaSamples.Timestamp[i]
//Do something with data
}
}
Exceptions
Type | Condition |
---|---|
System.ArgumentException | This is thrown if start or end time are minus numbers |
System.ArgumentOutOfRangeException | This is thrown if the sampleSizeCap is less than 1 |
GetSamplesCount(Int64, Int64)
Returns the numbers of samples between a specified start and end time.
Declaration
public override long GetSamplesCount(long startTimeStamp, long endTimeStamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startTimeStamp | Start time stamp of the data. |
System.Int64 | endTimeStamp | End time stamp of the data. |
Returns
Type | Description |
---|---|
System.Int64 | Number of samples between the start and end time, or zero if not samples found. |
Overrides
GetSamplesCountEstimate(Int64, Int64)
Get the maximum number of samples expected for the provided interval. If the parameter has no periodic channel, it returns 0
Declaration
public override long GetSamplesCountEstimate(long startTimeStamp, long endTimeStamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startTimeStamp | The start time range. |
System.Int64 | endTimeStamp | The end time range. |
Returns
Type | Description |
---|---|
System.Int64 | The maximum number of samples expected for the provided request. Zero if is impossible to foresee |
Overrides
GetSamplesUntil(Int64, Int32)
Returns a number of raw data samples between the current position to the end sample time. If the endtime is after the CurrentTime then the position will be updated to be the last timestamp + 1.
If the endtime is before the CurrentTime then the position will be updated to be the last timestamp - 1 and the data will be read in reverse. If there are no samples then the PDA position is not updated.
Declaration
public override ParameterValues GetSamplesUntil(long endTimeStamp, int sampleSizeCap = 10000)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | endTimeStamp | The end time stamp. If this is before the PDA current time then it will read backwards to that point. |
System.Int32 | sampleSizeCap | This is a cap on the amount of samples which will be returned. This is defaulted to 10,000. This is a useful protection in case you query for high resolution data over and extended time. If the cap is exceeded it will return the first X number of samples.. This can be overriden if required |
Returns
Type | Description |
---|---|
ParameterValues | Returns a ParameterValues object with the Data, Timestamp and DataStatus arrays populated with the results.
Use the ParameterValues.SampleCount field to determine how much data to read out of the array. If there are no samples then SampleCount will be 0. |
Overrides
Remarks
If current time and end time are equal then the sample for that timestamp is returned
Examples
Example of usage and then iterating over the results using the SampleCount field not the array size.
this.pda.GoTo(startTime);
var pdaSamples = this.pda.GetSamplesUntil(endTime);
for (var i = 0; i < pdaSamples.SampleCount; i++)
{
if(pdaSamples.DataStatus[i] != DataStatusType.Missing)
{
var data = pdaSamples.Data[i];
var timestamp = pdaSamples.Timestamp[i]
//Do something with data
}
}
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if sampleSizeCap is less than 1 |
System.ArgumentException | Is thrown if endtime equals the PDa current position or in less than 0 |
GetStartTime()
Returns the start time for the parameter's data.
Declaration
public override Nullable<long> GetStartTime()
Returns
Type | Description |
---|---|
System.Nullable<System.Int64> | The start time |
Overrides
GetTextAtTimestamp(Int64)
Gets the text at timestamp.
Declaration
public string GetTextAtTimestamp(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The timestamp. |
Returns
Type | Description |
---|---|
System.String | Returns string value for the constant |
GetTimeRange()
Gets the time range for the PDA.
Declaration
public override Nullable<TimeRange> GetTimeRange()
Returns
Type | Description |
---|---|
System.Nullable<TimeRange> | Returns timerange or null if there is no data. |
Overrides
Search(Int64, Int64, MatchingRule, Double, Nullable<Double>, Nullable<Int32>)
Search PDA for data value
Declaration
public override IList<QuerySample> Search(long startAt, long endAt, MatchingRule rule, double value, Nullable<double> upperValue, Nullable<int> timespan)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startAt | Seach Start Position |
System.Int64 | endAt | Search End Position |
MatchingRule | rule | Comparison operator |
System.Double | value | Value to Search For |
System.Nullable<System.Double> | upperValue | Upper Value - used when using the Between Operator |
System.Nullable<System.Int32> | timespan |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<QuerySample> | Matching samples |
Overrides
Search(Int64, Int64, MatchingRule, String, Nullable<Int32>)
Search PDA for all occurances of a data value
Declaration
public override IList<QuerySample> Search(long startAt, long endAt, MatchingRule rule, string value, Nullable<int> timespan)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startAt | Seach Start Position |
System.Int64 | endAt | Search End Position |
MatchingRule | rule | Comparison operator |
System.String | value | Value to Search For |
System.Nullable<System.Int32> | timespan | Period of time the condition must be met for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<QuerySample> | Matching samples |
Overrides
SetMapper(String)
Sets the mapper for the PDA.
Declaration
public override void SetMapper(string mapper)
Parameters
Type | Name | Description |
---|---|---|
System.String | mapper | The name of the mapper. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotImplementedException | Not implemented for this PDA |
Events
Invalidated
Occurs when [invalidated].
Declaration
public override event EventHandler Invalidated
Event Type
Type | Description |
---|---|
System.EventHandler |
Overrides
UnderlyingDataSourceChanged
Occurs when [underlying data source changed].
Declaration
public override event EventHandler UnderlyingDataSourceChanged
Event Type
Type | Description |
---|---|
System.EventHandler |