23 using System.Collections.Generic;
25 using System.Globalization;
32 namespace Ntp.Analyzer.Graph
39 config = configuration;
41 frequency =
new List<double>();
42 stability =
new List<double>();
50 protected override string YLabel =>
"Milliseconds";
56 string freqDesc = config.Gfrequency.HasValue
57 ?
" x " + config.Gfrequency.Value.ToString(
"0.00", CultureInfo.InvariantCulture)
60 var frequencyPlot = SetupPlot(
"Frequency" + freqDesc, Color.Green, Time, frequency);
61 var stabilityPlot = SetupPlot(
"Stability", Color.Black, Time, stability);
63 if (config.Stability.HasValue)
66 if (config.Gfrequency.HasValue)
74 dataMapper.
FilterTime = DateTime.UtcNow.Subtract(GraphTimeSpan);
76 foreach (var reading
in dataMapper)
78 Time.Add(config.GraphTime == DateTimeKind.Local ? reading.LocalTime : reading.UtcTime);
80 if (config.Offset.HasValue) Offset.Add(reading.Offset*config.Offset.Value);
83 if (config.Jitter.HasValue) Jitter.Add(reading.Jitter*config.Jitter.Value);
86 if (config.Gfrequency.HasValue) frequency.Add(reading.Frequency*config.Gfrequency.Value);
87 else frequency.Add(0.0);
89 if (config.Stability.HasValue) stability.Add(reading.Stability*config.Stability.Value);
90 else stability.Add(0.0);
93 if (config.FilterFactor.HasValue)
102 double totalOffset = 0.0;
103 double totalJitter = 0.0;
104 double totalFrequency = 0.0;
105 double totalStability = 0.0;
108 for (
int i = 0; i < Time.Count; i++)
110 totalOffset += Math.Abs(Offset[i]);
111 totalJitter += Math.Abs(Jitter[i]);
112 totalFrequency += Math.Abs(frequency[i]);
113 totalStability += Math.Abs(stability[i]);
116 double avgOffset = totalOffset/Time.Count;
117 double avgJitter = totalJitter/Time.Count;
118 double avgFrequency = totalFrequency/Time.Count;
119 double avgStability = totalStability/Time.Count;
121 var indexes =
new List<int>();
124 for (
int i = 0; i < Time.Count; i++)
126 if (Math.Abs(Offset[i]) > avgOffset*config.FilterFactor ||
127 Math.Abs(Jitter[i]) > avgJitter*config.FilterFactor ||
128 Math.Abs(frequency[i]) > avgFrequency*config.FilterFactor ||
129 Math.Abs(stability[i]) > avgStability*config.FilterFactor)
136 for (
int i = indexes.Count - 1; i >= 0; i--)
138 Time.RemoveAt(indexes[i]);
139 Offset.RemoveAt(indexes[i]);
140 Jitter.RemoveAt(indexes[i]);
141 frequency.RemoveAt(indexes[i]);
142 stability.RemoveAt(indexes[i]);
A dispersion graph contains an series of offsets and jitter values together with a time coordinate...
HostGraph(IHostGraphConfiguration configuration, Host host)
DateTime FilterTime
Gets or sets the time to use when extracting data. Only readings with a timestamp later than FilterTi...
HostReadingDatabaseMapper HostReadings
Gets the host reading mapper.
readonly List< double > stability
Host FilterHost
Gets or sets the host
Singleton facade class used to access memory persistent data.
void CleanSeries()
Cleans the value series from values out side boundaries.
readonly IHostGraphConfiguration config
static DataFace Instance
Gets the Singleton instance.
readonly List< double > frequency