| @@ -378,6 +378,17 @@ namespace GrafanaAdapters · 377 unmodified lines |
| 378 | 378 | /// </remarks> |
| 379 | 379 | ExcludeRange, |
| 380 | 380 | /// <summary> |
| 381 | + /// Returns a series of values that represent a filtered set of the values in the source series where each value is a real number, i.e., value is not NaN. |
| 382 | + /// First parameter, optional, is a boolean flag that determines if infinite values should also be excluded - defaults to true. |
| 383 | + /// </summary> |
| 384 | + /// <remarks> |
| 385 | + /// Signature: <c>FilterNaN([alsoFilterInfinity], expression)</c><br/> |
| 386 | + /// Example: <c>FilterNaN(FILTER ActiveMeasurements WHERE SignalType='VPHM')</c><br/> |
| 387 | + /// Variants: FilterNaN<br/> |
| 388 | + /// Execution: Deferred enumeration. |
| 389 | + /// </remarks> |
| 390 | + FilterNaN, |
| 391 | + /// <summary> |
| 381 | 392 | /// Returns a series of values that represent an adjusted set of angles that are unwrapped, per specified angle units, so that a comparable mathematical |
| 382 | 393 | /// operation can be executed. For example, for angles that wrap between -180 and +180 degrees, this algorithm unwraps the values to make the values |
| 383 | 394 | /// mathematically comparable. The units parameter, optional, specifies the type of angle units and must be one of the following: Degrees, Radians, Grads, |
| @@ -876,6 +887,7 @@ namespace GrafanaAdapters · 492 unmodified lines |
| 876 | 887 | private static readonly Regex s_intervalExpression; |
| 877 | 888 | private static readonly Regex s_includeRangeExpression; |
| 878 | 889 | private static readonly Regex s_excludeRangeExpression; |
| 890 | + private static readonly Regex s_filterNaNExpression; |
| 879 | 891 | private static readonly Regex s_unwrapAngleExpression; |
| 880 | 892 | private static readonly Regex s_wrapAngleExpression; |
| 881 | 893 | private static readonly Regex s_labelExpression; |
| @@ -923,6 +935,7 @@ namespace GrafanaAdapters · 41 unmodified lines |
| 923 | 935 | s_intervalExpression = new Regex(string.Format(GetExpression, "Interval"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| 924 | 936 | s_includeRangeExpression = new Regex(string.Format(GetExpression, "(IncludeRange|Include)"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| 925 | 937 | s_excludeRangeExpression = new Regex(string.Format(GetExpression, "(ExcludeRange|Exclude)"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| 938 | + s_filterNaNExpression = new Regex(string.Format(GetExpression, "FilterNaN"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| 926 | 939 | s_unwrapAngleExpression = new Regex(string.Format(GetExpression, "(UnwrapAngle|Unwrap)"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| 927 | 940 | s_wrapAngleExpression = new Regex(string.Format(GetExpression, "(WrapAngle|Wrap)"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| 928 | 941 | s_labelExpression = new Regex(string.Format(GetExpression, "(Label|Name)"), RegexOptions.Compiled | RegexOptions.IgnoreCase); |
| @@ -960,6 +973,7 @@ namespace GrafanaAdapters · 31 unmodified lines |
| 960 | 973 | [SeriesFunction.Interval] = 1, |
| 961 | 974 | [SeriesFunction.IncludeRange] = 2, |
| 962 | 975 | [SeriesFunction.ExcludeRange] = 2, |
| 976 | + [SeriesFunction.FilterNaN] = 0, |
| 963 | 977 | [SeriesFunction.UnwrapAngle] = 0, |
| 964 | 978 | [SeriesFunction.WrapAngle] = 0, |
| 965 | 979 | [SeriesFunction.Label] = 1 |
| @@ -998,6 +1012,7 @@ namespace GrafanaAdapters · 32 unmodified lines |
| 998 | 1012 | [SeriesFunction.Interval] = 0, |
| 999 | 1013 | [SeriesFunction.IncludeRange] = 2, |
| 1000 | 1014 | [SeriesFunction.ExcludeRange] = 2, |
| 1015 | + [SeriesFunction.FilterNaN] = 1, |
| 1001 | 1016 | [SeriesFunction.UnwrapAngle] = 1, |
| 1002 | 1017 | [SeriesFunction.WrapAngle] = 1, |
| 1003 | 1018 | [SeriesFunction.Label] = 0 |
| @@ -1235,6 +1250,13 @@ namespace GrafanaAdapters · 231 unmodified lines |
| 1235 | 1250 | if (filterMatch.Success) |
| 1236 | 1251 | return new Tuple<SeriesFunction, string, GroupOperation>(SeriesFunction.ExcludeRange, filterMatch.Result("${Expression}").Trim(), groupOperation); |
| 1237 | 1252 | |
| 1253 | + // Look for filter NaN function |
| 1254 | + lock (s_filterNaNExpression) |
| 1255 | + filterMatch = s_filterNaNExpression.Match(expression); |
| 1256 | + |
| 1257 | + if (filterMatch.Success) |
| 1258 | + return new Tuple<SeriesFunction, string, GroupOperation>(SeriesFunction.FilterNaN, filterMatch.Result("${Expression}").Trim(), groupOperation); |
| 1259 | + |
| 1238 | 1260 | // Look for unwrap angle function |
| 1239 | 1261 | lock (s_unwrapAngleExpression) |
| 1240 | 1262 | filterMatch = s_unwrapAngleExpression.Match(expression); |
| @@ -1644,6 +1666,13 @@ namespace GrafanaAdapters · 403 unmodified lines |
| 1644 | 1666 | foreach (DataSourceValue dataValue in source.Where(dataValue => (lowInclusive ? dataValue.Value <= low : dataValue.Value < low) || (highInclusive ? dataValue.Value >= high : dataValue.Value > high))) |
| 1645 | 1667 | yield return dataValue; |
| 1646 | 1668 | |
| 1669 | + break; |
| 1670 | + case SeriesFunction.FilterNaN: |
| 1671 | + bool alsoFilterInifinity = parameters.Length == 0 || parameters[0].Trim().ParseBoolean(); |
| 1672 | + |
| 1673 | + foreach (DataSourceValue dataValue in source.Where(dataValue => !(double.IsNaN(dataValue.Value) || (alsoFilterInifinity && double.IsInfinity(dataValue.Value))))) |
| 1674 | + yield return dataValue; |
| 1675 | + |
| 1647 | 1676 | break; |
| 1648 | 1677 | case SeriesFunction.UnwrapAngle: |
| 1649 | 1678 | if (parameters.Length == 0 || !Enum.TryParse(parameters[0], true, out angleUnits)) |