NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Graph.HostGraph Class Reference
Inheritance diagram for Ntp.Analyzer.Graph.HostGraph:
Collaboration diagram for Ntp.Analyzer.Graph.HostGraph:

Public Member Functions

 HostGraph (IHostGraphConfiguration configuration, Host host)
 
- Public Member Functions inherited from Ntp.Analyzer.Graph.GraphBase
Stream Generate ()
 
Stream Render ()
 

Protected Member Functions

override void AddPlots ()
 
override void LoadData ()
 
- Protected Member Functions inherited from Ntp.Analyzer.Graph.DispersionGraph
 DispersionGraph (IDispersionGraphConfiguration configuration)
 
- Protected Member Functions inherited from Ntp.Analyzer.Graph.GraphBase
 GraphBase (IGraphBaseConfiguration baseConfig)
 
virtual void PreRender ()
 
LinePlot SetupPlot (string name, Color color, IList time, IList data)
 

Protected Attributes

override string YLabel => "Milliseconds"
 
- Protected Attributes inherited from Ntp.Analyzer.Graph.DispersionGraph
readonly List< double > Jitter
 
readonly List< double > Offset
 
readonly List< DateTime > Time
 
- Protected Attributes inherited from Ntp.Analyzer.Graph.GraphBase
TimeSpan GraphTimeSpan => new TimeSpan(baseConfig.Timespan, 0, 0, 0)
 

Private Member Functions

void CleanSeries ()
 Cleans the value series from values out side boundaries. More...
 

Private Attributes

readonly IHostGraphConfiguration config
 
readonly List< double > frequency
 
readonly Host host
 
readonly List< double > stability
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Graph.GraphBase
IEnumerable< StreamDestinationDestinations => destinations
 
string ImageFileExtension => "png"
 
- Properties inherited from Ntp.Analyzer.Graph.GraphBase
PlotSurface2D Surface [get, private set]
 
abstract string YLabel [get]
 
- Properties inherited from Ntp.Analyzer.Export.IStreamGenerator
IEnumerable< StreamDestinationDestinations [get]
 

Detailed Description

Definition at line 34 of file HostGraph.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Graph.HostGraph.HostGraph ( IHostGraphConfiguration  configuration,
Host  host 
)
inline

Definition at line 36 of file HostGraph.cs.

37  : base(configuration)
38  {
39  config = configuration;
40  this.host = host;
41  frequency = new List<double>();
42  stability = new List<double>();
43  }
readonly List< double > stability
Definition: HostGraph.cs:48
readonly IHostGraphConfiguration config
Definition: HostGraph.cs:45
readonly List< double > frequency
Definition: HostGraph.cs:46

Member Function Documentation

override void Ntp.Analyzer.Graph.HostGraph.AddPlots ( )
inlineprotectedvirtual

Reimplemented from Ntp.Analyzer.Graph.DispersionGraph.

Definition at line 52 of file HostGraph.cs.

53  {
54  base.AddPlots();
55 
56  string freqDesc = config.Gfrequency.HasValue
57  ? " x " + config.Gfrequency.Value.ToString("0.00", CultureInfo.InvariantCulture)
58  : string.Empty;
59 
60  var frequencyPlot = SetupPlot("Frequency" + freqDesc, Color.Green, Time, frequency);
61  var stabilityPlot = SetupPlot("Stability", Color.Black, Time, stability);
62 
63  if (config.Stability.HasValue)
64  Surface.Add(stabilityPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
65 
66  if (config.Gfrequency.HasValue)
67  Surface.Add(frequencyPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
68  }
readonly List< double > stability
Definition: HostGraph.cs:48
readonly List< DateTime > Time
readonly IHostGraphConfiguration config
Definition: HostGraph.cs:45
LinePlot SetupPlot(string name, Color color, IList time, IList data)
Definition: GraphBase.cs:158
readonly List< double > frequency
Definition: HostGraph.cs:46
void Ntp.Analyzer.Graph.HostGraph.CleanSeries ( )
inlineprivate

Cleans the value series from values out side boundaries.

Definition at line 100 of file HostGraph.cs.

101  {
102  double totalOffset = 0.0;
103  double totalJitter = 0.0;
104  double totalFrequency = 0.0;
105  double totalStability = 0.0;
106 
107  // Calculate mean value
108  for (int i = 0; i < Time.Count; i++)
109  {
110  totalOffset += Math.Abs(Offset[i]);
111  totalJitter += Math.Abs(Jitter[i]);
112  totalFrequency += Math.Abs(frequency[i]);
113  totalStability += Math.Abs(stability[i]);
114  }
115 
116  double avgOffset = totalOffset/Time.Count;
117  double avgJitter = totalJitter/Time.Count;
118  double avgFrequency = totalFrequency/Time.Count;
119  double avgStability = totalStability/Time.Count;
120 
121  var indexes = new List<int>();
122 
123  // Find invalid values
124  for (int i = 0; i < Time.Count; i++)
125  {
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)
130  {
131  indexes.Add(i);
132  }
133  }
134 
135  // Remove invalid values
136  for (int i = indexes.Count - 1; i >= 0; i--)
137  {
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]);
143  }
144  }
readonly List< double > Jitter
readonly List< double > stability
Definition: HostGraph.cs:48
readonly List< DateTime > Time
readonly List< double > Offset
readonly IHostGraphConfiguration config
Definition: HostGraph.cs:45
readonly List< double > frequency
Definition: HostGraph.cs:46
override void Ntp.Analyzer.Graph.HostGraph.LoadData ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Graph.GraphBase.

Definition at line 70 of file HostGraph.cs.

References Ntp.Analyzer.Data.Sql.FilteredSqlDatabaseMapper< T >.FilterHost, Ntp.Analyzer.Data.Sql.FilteredSqlDatabaseMapper< T >.FilterTime, Ntp.Analyzer.Data.DataFace.HostReadings, and Ntp.Analyzer.Data.DataFace.Instance.

71  {
73  dataMapper.FilterHost = host;
74  dataMapper.FilterTime = DateTime.UtcNow.Subtract(GraphTimeSpan);
75 
76  foreach (var reading in dataMapper)
77  {
78  Time.Add(config.GraphTime == DateTimeKind.Local ? reading.LocalTime : reading.UtcTime);
79 
80  if (config.Offset.HasValue) Offset.Add(reading.Offset*config.Offset.Value);
81  else Offset.Add(0.0);
82 
83  if (config.Jitter.HasValue) Jitter.Add(reading.Jitter*config.Jitter.Value);
84  else Jitter.Add(0.0);
85 
86  if (config.Gfrequency.HasValue) frequency.Add(reading.Frequency*config.Gfrequency.Value);
87  else frequency.Add(0.0);
88 
89  if (config.Stability.HasValue) stability.Add(reading.Stability*config.Stability.Value);
90  else stability.Add(0.0);
91  }
92 
93  if (config.FilterFactor.HasValue)
94  CleanSeries();
95  }
readonly List< double > Jitter
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.
Definition: DataFace.cs:75
readonly List< double > stability
Definition: HostGraph.cs:48
readonly List< DateTime > Time
readonly List< double > Offset
Singleton facade class used to access memory persistent data.
Definition: DataFace.cs:30
void CleanSeries()
Cleans the value series from values out side boundaries.
Definition: HostGraph.cs:100
readonly IHostGraphConfiguration config
Definition: HostGraph.cs:45
static DataFace Instance
Gets the Singleton instance.
Definition: DataFace.cs:51
readonly List< double > frequency
Definition: HostGraph.cs:46

Member Data Documentation

readonly IHostGraphConfiguration Ntp.Analyzer.Graph.HostGraph.config
private

Definition at line 45 of file HostGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.HostGraph.frequency
private

Definition at line 46 of file HostGraph.cs.

readonly Host Ntp.Analyzer.Graph.HostGraph.host
private

Definition at line 47 of file HostGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.HostGraph.stability
private

Definition at line 48 of file HostGraph.cs.

override string Ntp.Analyzer.Graph.HostGraph.YLabel => "Milliseconds"
protected

Definition at line 50 of file HostGraph.cs.


The documentation for this class was generated from the following file: