<commit_before>﻿//******************************************************************************************************
//  GrafanaDataSourceBase.cs - Gbtc
//
//  Copyright © 2016, Grid Protection Alliance.  All Rights Reserved.
//
//  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
//  the NOTICE file distributed with this work for additional information regarding copyright ownership.
//  The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
//  not use this file except in compliance with the License. You may obtain a copy of the License at:
//
//      http://opensource.org/licenses/MIT
//
//  Unless agreed to in writing, the subject software distributed under the License is distributed on an
//  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
//  License for the specific language governing permissions and limitations.
//
//  Code Modification History:
//  ----------------------------------------------------------------------------------------------------
//  09/22/2016 - <NAME>
//       Generated original version of source code.
//
//******************************************************************************************************

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using GSF;
using GSF.Collections;
using GSF.NumericalAnalysis;
using GSF.TimeSeries;
using GSF.TimeSeries.Adapters;
using GSF.Units;
using GSF.Web;

// ReSharper disable PossibleMultipleEnumeration
namespace GrafanaAdapters
{
    #region [ Enumerations ]

    /// <summary>
    /// Defines available functions that can operate on <see cref="TimeSeriesValues"/>.
    /// </summary>
    public enum SeriesFunction
    {
        /// <summary>
        /// Returns a single value that represents the mean of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Average(expression)</c><br/>
        /// Example: <c>Average(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Average, Avg, Mean<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Average,
        /// <summary>
        /// Returns a single value that is the minimum of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Minimum(expression)</c><br/>
        /// Example: <c>Minimum(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Minimum, Min<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Minimum,
        /// <summary>
        /// Returns a single value that is the maximum of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Maximum(expression)</c><br/>
        /// Example: <c>Maximum(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Maximum, Max<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Maximum,
        /// <summary>
        /// Returns a single value that represents the sum of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Total(expression)</c><br/>
        /// Example: <c>Total(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Total, Sum<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Total,
        /// <summary>
        /// Returns a single value that represents the range, i.e., <c>maximum - minimum</c>, of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Range(expression)</c><br/>
        /// Example: <c>Range(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Range<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Range,
        /// <summary>
        /// Returns a single value that is the count of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Count(expression)</c><br/>
        /// Example: <c>Count(PPA:1; PPA:2; PPA:3)</c><br/>
        /// Variants: Count<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Count,
        /// <summary>
        /// Returns a series of values that represent the unique set of values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Distinct(expression)</c><br/>
        /// Example: <c>Distinct(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Distinct, Unique<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Distinct,
        /// <summary>
        /// Returns a series of values that represent the absolute value each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>AbsoluteValue(expression)</c><br/>
        /// Example: <c>AbsoluteValue(FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
        /// Variants: AbsoluteValue, Abs<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        AbsoluteValue,
        /// <summary>
        /// Returns a series of values that represent each of the values in the source series added with N.
        /// N is a floating point value representing an additive offset to be applied to each value the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Add(N, expression)</c><br/>
        /// Example: <c>Add(-1.5, FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
        /// Variants: Add<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Add,
        /// <summary>
        /// Returns a series of values that represent each of the values in the source series multiplied by N.
        /// N is a floating point value representing a multiplicative factor to be applied to each value the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Multiply(N, expression)</c><br/>
        /// Example: <c>Multiply(0.5, FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
        /// Variants: Multiply<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Multiply,
        /// <summary>
        /// Returns a series of values that represent the rounded value, with N fractional digits, of each of the values in the source series.
        /// N, optional, is a positive integer value representing the number of decimal places in the return value - defaults to 0.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Round([N], expression)</c><br/>
        /// Example: <c>Round(3, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Round<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Round,
        /// <summary>
        /// Returns a series of values that represent the smallest integral value that is less than or equal to each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Floor(expression)</c><br/>
        /// Example: <c>Floor(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Floor<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Floor,
        /// <summary>
        /// Returns a series of values that represent the smallest integral value that is greater than or equal to each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Ceiling(expression)</c><br/>
        /// Example: <c>Ceiling(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Ceiling, Ceil<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Ceiling,
        /// <summary>
        /// Returns a series of values that represent the integral part of each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Truncate(expression)</c><br/>
        /// Example: <c>Truncate(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Truncate, Trunc<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Truncate,
        /// <summary>
        /// Returns a single value that represents the standard deviation of the values in the source series. First parameter,
        /// optional, is a boolean flag representing if the sample based calculation should be used - defaults to false, which
        /// means the population based calculation should be used.
        /// </summary>
        /// <remarks>
        /// Signature: <c>StandardDeviation([samplecalc], expression)</c><br/>
        /// Example: <c>StandardDeviation(FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/>
        /// Variants: StandardDeviation, StdDev<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        StandardDeviation,
        /// <summary>
        /// Returns a single value that represents the median of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Median(expression)</c><br/>
        /// Example: <c>Median(FILTER ActiveMeasurements WHERE SignalType='ALOG')</c><br/>
        /// Variants: Median, Med, Mid<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Median,
        /// <summary>
        /// Returns a single value that represents the mode of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Mode(expression)</c><br/>
        /// Example: <c>Mode(FILTER TOP 5 ActiveMeasurements WHERE SignalType='DIGI')</c><br/>
        /// Variants: Mode<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Mode,
        /// <summary>
        /// Returns a series of N, or N% of total, values that are the largest in the source series.
        /// N is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100.
        /// Second parameter, optional, is a boolean flag representing if time in dataset should be normalized - defaults to true.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Top(N|N%, [normalizeTime], expression)</c><br/>
        /// Example: <c>Top(50%, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Top, Largest<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Top,
        /// <summary>
        /// Returns a series of N, or N% of total, values that are the smallest in the source series.
        /// N is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100.
        /// Second parameter, optional, is a boolean flag representing if time in dataset should be normalized - defaults to true.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Bottom(N|N%, [normalizeTime], expression)</c><br/>
        /// Example: <c>Bottom(100, false, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Bottom, Bot, Smallest<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Bottom,
        /// <summary>
        /// Returns a series of N, or N% of total, values that are a random sample of the values in the source series.
        /// N is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100.
        /// Second parameter, optional, is a boolean flag representing if time in dataset should be normalized - defaults to true.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Random(N|N%, [normalizeTime], expression)</c><br/>
        /// Example: <c>Random(25%, FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/>
        /// Variants: Random, Rand, Sample<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Random,
        /// <summary>
        /// Returns a series of N, or N% of total, values from the start of the source series.
        /// N, optional, is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100 - defaults to 1.
        /// </summary>
        /// <remarks>
        /// Signature: <c>First([N|N%], expression)</c><br/>
        /// Example: <c>First(5%, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: First<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        First,
        /// <summary>
        /// Returns a series of N, or N% of total, values from the end of the source series.
        /// N, optional, is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100 - defaults to 1.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Last([N|N%], expression)</c><br/>
        /// Example: <c>Last(150, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Last<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Last,
        /// <summary>
        /// Returns a single value that represents the Nth order percentile for the sorted values in the source series.
        /// N is a floating point value, representing a percentage, that must range from 0 to 100.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Percentile(N[%], expression)</c><br/>
        /// Example: <c>Percentile(10%, FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/>
        /// Variants: Percentile, Pctl<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Percentile,
        /// <summary>
        /// Returns a series of values that represent the difference between consecutive values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Difference(expression)</c><br/>
        /// Example: <c>Difference(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Difference, Diff<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Difference,
        /// <summary>
        /// Returns a series of values that represent the time difference, in seconds, between consecutive values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>TimeDifference(expression)</c><br/>
        /// Example: <c>TimeDifference(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: TimeDifference, TimeDiff, Elapsed<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        TimeDifference,
        /// <summary>
        /// Returns a series of values that represent the rate of change, per second, for the difference between consecutive values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Derivative(expression)</c><br/>
        /// Example: <c>Derivative(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Derivative, Der<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Derivative,
        /// <summary>
        /// Returns a single value that represents the time-based integration, i.e., the sum of <c>V(n) * (T(n) - T(n-1))</c> where time difference is
        /// calculated in hours, of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>TimeIntegration(expression)</c><br/>
        /// Example: <c>TimeIntegration(FILTER ActiveMeasurements WHERE SignalType='CALC' AND PointTag LIKE '%-MW:%')</c><br/>
        /// Variants: TimeIntegration, TimeInt<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        TimeIntegration,
        /// <summary>
        /// Returns a series of values that represent a decimated set of the values in the source series based on the specified interval N, in seconds.
        /// N is a floating-point value that must be greater than or equal to zero that represents the desired time interval, in seconds, for the returned data.
        /// Setting N value to zero will request non-decimated, full resolution data from the data source. A zero value will always produce the most accurate
        /// aggregation calculation results but will increase query burden for large time ranges.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Interval(N, expression)</c><br/>
        /// Example: <c>Sum(Interval(0, FILTER ActiveMeasurements WHERE SignalType LIKE '%PHM'))</c><br/>
        /// Variants: Interval<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Interval,
        /// <summary>
        /// Returns a series of values that represent a filtered set of the values in the source series where each value falls between the specified low and high.
        /// The low and high parameter values are floating-point numbers that represent the range of values allowed in the return series. Third parameter, optional,
        /// is a boolean flag that determines if range values are inclusive, i.e., allowed values are &gt;= low and &lt;= high - defaults to false, which means
        /// values are exclusive, i.e., allowed values are &gt; low and &lt; high. Function allows a fourth optional parameter that is a boolean flag - when four
        /// parameters are provided, third parameter determines if low value is inclusive and forth parameter determines if high value is inclusive
        /// </summary>
        /// <remarks>
        /// Signature: <c>IncludeRange(low, high, [inclusive], expression)</c> -or- <c>IncludeRange(low, high, [lowinclusive], [highinclusive], expression)</c><br/>
        /// Example: <c>IncludeRange(59.90, 60.10, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: IncludeRange, Include<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        IncludeRange,
        /// <summary>
        /// Returns a series of values that represent a filtered set of the values in the source series where each value falls outside the specified low and high.
        /// The low and high parameter values are floating-point numbers that represent the range of values excluded in the return series. Third parameter, optional,
        /// is a boolean flag that determines if range values are inclusive, i.e., excluded values are &gt;= low and &lt;= high - defaults to false, which means
        /// values are exclusive, i.e., excluded values are &gt; low and &lt; high. Function allows a fourth optional parameter that is a boolean flag - when four
        /// parameters are provided, third parameter determines if low value is inclusive and forth parameter determines if high value is inclusive
        /// </summary>
        /// <remarks>
        /// Signature: <c>ExcludeRange(low, high, [inclusive], expression)</c> -or- <c>ExcludeRange(low, high, [lowinclusive], [highinclusive], expression)</c><br/>
        /// Example: <c>ExcludeRange(-180.0, 180.0, true, false, FILTER ActiveMeasurements WHERE SignalType LIKE '%PHA')</c><br/>
        /// Variants: ExcludeRange, Exclude<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        ExcludeRange,
        /// <summary>
        /// Returns a series of values that represent an adjusted set of angles that are unwrapped, per specified angle units, so that a comparable mathematical
        /// operation can be executed. For example, for angles that wrap between -180 and +180 degrees, this algorithm unwraps the values to make the values
        /// mathematically comparable. The units parameter, optional, specifies the type of angle units and must be one of the following: Degrees, Radians, Grads,
        /// ArcMinutes, ArcSeconds or AngularMil - defaults to Degrees.
        /// </summary>
        /// <remarks>
        /// Signature: <c>UnwrapAngle(units, expression)</c><br/>
        /// Example: <c>UnwrapAngle(Degrees, FSX_PMU2-PA1:VH; REA_PMU3-PA2:VH)</c><br/>
        /// Variants: UnwrapAngle, Unwrap<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        UnwrapAngle,
        /// <summary>
        /// Returns a series of values that represent an adjusted set of angles that are wrapped, per specified angle units, so that angle values are consistently
        /// between -180 and +180 degrees. The units parameter, optional, specifies the type of angle units and must be one of the following: Degrees, Radians,
        /// Grads, ArcMinutes, ArcSeconds or AngularMil - defaults to Degrees.<commit_msg>GrafanaAdapters: Updated documentation of new functions.<commit_after>﻿//******************************************************************************************************
//  GrafanaDataSourceBase.cs - Gbtc
//
//  Copyright © 2016, Grid Protection Alliance.  All Rights Reserved.
//
//  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
//  the NOTICE file distributed with this work for additional information regarding copyright ownership.
//  The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
//  not use this file except in compliance with the License. You may obtain a copy of the License at:
//
//      http://opensource.org/licenses/MIT
//
//  Unless agreed to in writing, the subject software distributed under the License is distributed on an
//  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
//  License for the specific language governing permissions and limitations.
//
//  Code Modification History:
//  ----------------------------------------------------------------------------------------------------
//  09/22/2016 - <NAME>
//       Generated original version of source code.
//
//******************************************************************************************************

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using GSF;
using GSF.Collections;
using GSF.NumericalAnalysis;
using GSF.TimeSeries;
using GSF.TimeSeries.Adapters;
using GSF.Units;
using GSF.Web;

// ReSharper disable PossibleMultipleEnumeration
namespace GrafanaAdapters
{
    #region [ Enumerations ]

    /// <summary>
    /// Defines available functions that can operate on <see cref="TimeSeriesValues"/>.
    /// </summary>
    public enum SeriesFunction
    {
        /// <summary>
        /// Returns a single value that represents the mean of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Average(expression)</c><br/>
        /// Example: <c>Average(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Average, Avg, Mean<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Average,
        /// <summary>
        /// Returns a single value that is the minimum of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Minimum(expression)</c><br/>
        /// Example: <c>Minimum(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Minimum, Min<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Minimum,
        /// <summary>
        /// Returns a single value that is the maximum of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Maximum(expression)</c><br/>
        /// Example: <c>Maximum(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Maximum, Max<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Maximum,
        /// <summary>
        /// Returns a single value that represents the sum of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Total(expression)</c><br/>
        /// Example: <c>Total(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Total, Sum<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Total,
        /// <summary>
        /// Returns a single value that represents the range, i.e., <c>maximum - minimum</c>, of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Range(expression)</c><br/>
        /// Example: <c>Range(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Range<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Range,
        /// <summary>
        /// Returns a single value that is the count of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Count(expression)</c><br/>
        /// Example: <c>Count(PPA:1; PPA:2; PPA:3)</c><br/>
        /// Variants: Count<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        Count,
        /// <summary>
        /// Returns a series of values that represent the unique set of values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Distinct(expression)</c><br/>
        /// Example: <c>Distinct(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Distinct, Unique<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Distinct,
        /// <summary>
        /// Returns a series of values that represent the absolute value each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>AbsoluteValue(expression)</c><br/>
        /// Example: <c>AbsoluteValue(FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
        /// Variants: AbsoluteValue, Abs<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        AbsoluteValue,
        /// <summary>
        /// Returns a series of values that represent each of the values in the source series added with N.
        /// N is a floating point value representing an additive offset to be applied to each value the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Add(N, expression)</c><br/>
        /// Example: <c>Add(-1.5, FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
        /// Variants: Add<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Add,
        /// <summary>
        /// Returns a series of values that represent each of the values in the source series multiplied by N.
        /// N is a floating point value representing a multiplicative factor to be applied to each value the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Multiply(N, expression)</c><br/>
        /// Example: <c>Multiply(0.5, FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
        /// Variants: Multiply<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Multiply,
        /// <summary>
        /// Returns a series of values that represent the rounded value, with N fractional digits, of each of the values in the source series.
        /// N, optional, is a positive integer value representing the number of decimal places in the return value - defaults to 0.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Round([N], expression)</c><br/>
        /// Example: <c>Round(3, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Round<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Round,
        /// <summary>
        /// Returns a series of values that represent the smallest integral value that is less than or equal to each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Floor(expression)</c><br/>
        /// Example: <c>Floor(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Floor<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Floor,
        /// <summary>
        /// Returns a series of values that represent the smallest integral value that is greater than or equal to each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Ceiling(expression)</c><br/>
        /// Example: <c>Ceiling(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Ceiling, Ceil<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Ceiling,
        /// <summary>
        /// Returns a series of values that represent the integral part of each of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Truncate(expression)</c><br/>
        /// Example: <c>Truncate(FILTER ActiveMeasurements WHERE SignalType='IPHM')</c><br/>
        /// Variants: Truncate, Trunc<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Truncate,
        /// <summary>
        /// Returns a single value that represents the standard deviation of the values in the source series. First parameter,
        /// optional, is a boolean flag representing if the sample based calculation should be used - defaults to false, which
        /// means the population based calculation should be used.
        /// </summary>
        /// <remarks>
        /// Signature: <c>StandardDeviation([samplecalc], expression)</c><br/>
        /// Example: <c>StandardDeviation(FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/>
        /// Variants: StandardDeviation, StdDev<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        StandardDeviation,
        /// <summary>
        /// Returns a single value that represents the median of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Median(expression)</c><br/>
        /// Example: <c>Median(FILTER ActiveMeasurements WHERE SignalType='ALOG')</c><br/>
        /// Variants: Median, Med, Mid<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Median,
        /// <summary>
        /// Returns a single value that represents the mode of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Mode(expression)</c><br/>
        /// Example: <c>Mode(FILTER TOP 5 ActiveMeasurements WHERE SignalType='DIGI')</c><br/>
        /// Variants: Mode<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Mode,
        /// <summary>
        /// Returns a series of N, or N% of total, values that are the largest in the source series.
        /// N is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100.
        /// Second parameter, optional, is a boolean flag representing if time in dataset should be normalized - defaults to true.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Top(N|N%, [normalizeTime], expression)</c><br/>
        /// Example: <c>Top(50%, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Top, Largest<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Top,
        /// <summary>
        /// Returns a series of N, or N% of total, values that are the smallest in the source series.
        /// N is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100.
        /// Second parameter, optional, is a boolean flag representing if time in dataset should be normalized - defaults to true.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Bottom(N|N%, [normalizeTime], expression)</c><br/>
        /// Example: <c>Bottom(100, false, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Bottom, Bot, Smallest<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Bottom,
        /// <summary>
        /// Returns a series of N, or N% of total, values that are a random sample of the values in the source series.
        /// N is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100.
        /// Second parameter, optional, is a boolean flag representing if time in dataset should be normalized - defaults to true.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Random(N|N%, [normalizeTime], expression)</c><br/>
        /// Example: <c>Random(25%, FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/>
        /// Variants: Random, Rand, Sample<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Random,
        /// <summary>
        /// Returns a series of N, or N% of total, values from the start of the source series.
        /// N, optional, is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100 - defaults to 1.
        /// </summary>
        /// <remarks>
        /// Signature: <c>First([N|N%], expression)</c><br/>
        /// Example: <c>First(5%, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: First<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        First,
        /// <summary>
        /// Returns a series of N, or N% of total, values from the end of the source series.
        /// N, optional, is either a positive integer value, representing a total, that is greater than zero - or - a floating point value,
        /// suffixed with '%' representing a percentage, that must range from greater than 0 to less than or equal to 100 - defaults to 1.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Last([N|N%], expression)</c><br/>
        /// Example: <c>Last(150, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Last<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Last,
        /// <summary>
        /// Returns a single value that represents the Nth order percentile for the sorted values in the source series.
        /// N is a floating point value, representing a percentage, that must range from 0 to 100.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Percentile(N[%], expression)</c><br/>
        /// Example: <c>Percentile(10%, FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/>
        /// Variants: Percentile, Pctl<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        Percentile,
        /// <summary>
        /// Returns a series of values that represent the difference between consecutive values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Difference(expression)</c><br/>
        /// Example: <c>Difference(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Difference, Diff<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Difference,
        /// <summary>
        /// Returns a series of values that represent the time difference, in seconds, between consecutive values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>TimeDifference(expression)</c><br/>
        /// Example: <c>TimeDifference(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: TimeDifference, TimeDiff, Elapsed<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        TimeDifference,
        /// <summary>
        /// Returns a series of values that represent the rate of change, per second, for the difference between consecutive values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Derivative(expression)</c><br/>
        /// Example: <c>Derivative(FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: Derivative, Der<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Derivative,
        /// <summary>
        /// Returns a single value that represents the time-based integration, i.e., the sum of <c>V(n) * (T(n) - T(n-1))</c> where time difference is
        /// calculated in hours, of the values in the source series.
        /// </summary>
        /// <remarks>
        /// Signature: <c>TimeIntegration(expression)</c><br/>
        /// Example: <c>TimeIntegration(FILTER ActiveMeasurements WHERE SignalType='CALC' AND PointTag LIKE '%-MW:%')</c><br/>
        /// Variants: TimeIntegration, TimeInt<br/>
        /// Execution: Immediate enumeration.
        /// </remarks>
        TimeIntegration,
        /// <summary>
        /// Returns a series of values that represent a decimated set of the values in the source series based on the specified interval N, in seconds.
        /// N is a floating-point value that must be greater than or equal to zero that represents the desired time interval, in seconds, for the returned data.
        /// Setting N value to zero will request non-decimated, full resolution data from the data source. A zero value will always produce the most accurate
        /// aggregation calculation results but will increase query burden for large time ranges.
        /// </summary>
        /// <remarks>
        /// Signature: <c>Interval(N, expression)</c><br/>
        /// Example: <c>Sum(Interval(0, FILTER ActiveMeasurements WHERE SignalType LIKE '%PHM'))</c><br/>
        /// Variants: Interval<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        Interval,
        /// <summary>
        /// Returns a series of values that represent a filtered set of the values in the source series where each value falls between the specified low and high.
        /// The low and high parameter values are floating-point numbers that represent the range of values allowed in the return series. Third parameter, optional,
        /// is a boolean flag that determines if range values are inclusive, i.e., allowed values are &gt;= low and &lt;= high - defaults to false, which means
        /// values are exclusive, i.e., allowed values are &gt; low and &lt; high. Function allows a fourth optional parameter that is a boolean flag - when four
        /// parameters are provided, third parameter determines if low value is inclusive and forth parameter determines if high value is inclusive.
        /// </summary>
        /// <remarks>
        /// Signature: <c>IncludeRange(low, high, [inclusive], expression)</c> -or- <c>IncludeRange(low, high, [lowinclusive], [highinclusive], expression)</c><br/>
        /// Example: <c>IncludeRange(59.90, 60.10, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
        /// Variants: IncludeRange, Include<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        IncludeRange,
        /// <summary>
        /// Returns a series of values that represent a filtered set of the values in the source series where each value falls outside the specified low and high.
        /// The low and high parameter values are floating-point numbers that represent the range of values excluded in the return series. Third parameter, optional,
        /// is a boolean flag that determines if range values are inclusive, i.e., excluded values are &gt;= low and &lt;= high - defaults to false, which means
        /// values are exclusive, i.e., excluded values are &gt; low and &lt; high. Function allows a fourth optional parameter that is a boolean flag - when four
        /// parameters are provided, third parameter determines if low value is inclusive and forth parameter determines if high value is inclusive.
        /// </summary>
        /// <remarks>
        /// Signature: <c>ExcludeRange(low, high, [inclusive], expression)</c> -or- <c>ExcludeRange(low, high, [lowinclusive], [highinclusive], expression)</c><br/>
        /// Example: <c>ExcludeRange(-180.0, 180.0, true, false, FILTER ActiveMeasurements WHERE SignalType LIKE '%PHA')</c><br/>
        /// Variants: ExcludeRange, Exclude<br/>
        /// Execution: Deferred enumeration.
        /// </remarks>
        ExcludeRange,
        /// <summary>
        /// Returns a series of values that represent an adjusted set of angles that are unwrapped, per specified angle units, so that a comparable mathematical
        /// operation can be executed. For example, for angles that wrap between -180 and +180 degrees, this algorithm unwraps the values to make the values
        /// mathematically comparable. The units parameter, optional, specifies the type of angle units and must be one of the following: Degrees, Radians, Grads,
        /// ArcMinutes, ArcSeconds or AngularMil - defaults to Degrees.
        /// </summary>
        /// <remarks>
        /// Signature: <c>UnwrapAngle(units, expression)</c><br/>
        /// Example: <c>UnwrapAngle(FSX_PMU2-PA1:VH; REA_PMU3-PA2:VH)</c><br/>
        /// Variants: UnwrapAngle, Unwrap<br/>
        /// Execution: Immediate in-memory array load.
        /// </remarks>
        UnwrapAngle,
        /// <summary>
        /// Returns a series of values that represent an adjusted set of angles that are wrapped, per specified angle units, so that angle values are consistently
        /// between -180 and +180 degrees. The units parameter, optional, specifies the type of angle units and must be one of the following: Degrees, Radians,
        /// Grads, ArcMinutes, ArcSeconds or AngularMil - defaults to Degrees.
{'fraction_non_alphanumeric': 0.14348922512608894, 'fraction_numerical': 0.004355800091701055, 'mean_word_length': 2.1752074537778423, 'pattern_counts': {'":': 0, '<': 711, '<?xml version=': 0, '>': 711, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5451654', 'n_tokens_mistral': 11370, 'n_tokens_neox': 11052, 'n_words': 4263}