NTP Analyzer  0.8.2
Analyze the operation of time servers
PeerGraphConfiguration.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using System.Drawing.Imaging;
26 using Ntp.Analyzer.Config.Table;
27 using Ntp.Analyzer.Interface;
28 using Ntp.Analyzer.Objects;
29 using Ntp.Common.Process;
30 using Ntp.Common.Web;
31 
32 namespace Ntp.Analyzer.Config.Node.Graph
33 {
38  {
40  string name,
41  int? frequency,
42  bool? initialRun,
43  bool? fixedRun,
44  string title,
45  int? width,
46  int? height,
47  int? timespan,
48  DateTimeKind? graphTime,
49  double? filterFactor,
50  double? balance,
51  double? delay,
52  double? jitter,
53  double? offset,
54  DestinationCollection destinations,
55  WebLinkCollection links)
56  : base(name)
57  {
58  this.frequency = frequency;
59  this.initialRun = initialRun;
60  this.fixedRun = fixedRun;
61  this.timespan = timespan;
62  this.height = height;
63  this.width = width;
64  this.graphTime = graphTime;
65  FilterFactor = filterFactor;
66  Jitter = jitter;
67  Offset = offset;
68  Balance = balance;
69  Delay = delay;
70  Title = title;
71  Destinations = destinations;
72  ConfigLinks = links;
73  }
74 
75  private readonly bool? fixedRun;
76  private readonly int? frequency;
77  private readonly DateTimeKind? graphTime;
78  private readonly int? height;
79  private readonly bool? initialRun;
80  private readonly int? timespan;
81  private readonly int? width;
82 
83  [NtpaIndex(50)]
84  [NtpaSetting(Symbol.KeywordDestinations)]
85  public override DestinationCollection Destinations { get; }
86 
87  [NtpaIndex(51)]
88  [NtpaSetting(Symbol.KeywordWebLinks)]
89  public override WebLinkCollection ConfigLinks { get; }
90 
91  [NtpaIndex(1)]
92  [NtpaSetting(Symbol.KeywordFrequency, 5)]
93  public int Frequency => frequency ?? 5;
94 
95  [NtpaIndex(2)]
96  [NtpaSetting(Symbol.KeywordInitialRun, false)]
97  public bool InitialRun => initialRun ?? false;
98 
99  [NtpaIndex(3)]
100  [NtpaSetting(Symbol.KeywordFixedRun, true)]
101  public bool FixedRun => fixedRun ?? true;
102 
107  [NtpaIndex(12)]
108  [NtpaSetting(Symbol.KeywordGraphTime, DateTimeKind.Utc)]
109  public override DateTimeKind GraphTime => graphTime ?? DateTimeKind.Utc;
110 
115  [NtpaIndex(10)]
116  [NtpaSetting(Symbol.KeywordTitle, Layout = Layout.Quoted)]
117  public override string Title { get; }
118 
123  [NtpaIndex(11)]
124  [NtpaSetting(Symbol.KeywordTimespan, 60*12)]
125  public override int Timespan => timespan ?? 60*12;
126 
131  [NtpaIndex(20)]
132  [NtpaSetting(Symbol.KeywordWidth, 1024)]
133  public override int Width => width ?? 1024;
134 
139  [NtpaIndex(21)]
140  [NtpaSetting(Symbol.KeywordHeight, 550)]
141  public override int Height => height ?? 550;
142 
147  [NtpaIndex(22)]
148  public override ImageFormat Format => ImageFormat.Png;
149 
154  [NtpaIndex(40)]
155  [NtpaSetting(Symbol.KeywordFilterFactor)]
156  public double? FilterFactor { get; }
157 
162  [NtpaIndex(31)]
163  [NtpaSetting(Symbol.KeywordJitter)]
164  public double? Jitter { get; }
165 
170  [NtpaIndex(30)]
171  [NtpaSetting(Symbol.KeywordOffset)]
172  public double? Offset { get; }
173 
178  [NtpaIndex(32)]
179  [NtpaSetting(Symbol.KeywordGraphBalance)]
180  public double? Balance { get; }
181 
186  [NtpaIndex(33)]
187  [NtpaSetting(Symbol.KeywordGraphDelay)]
188  public double? Delay { get; }
189 
190  public override string GetTitle(NamedObject namedObject)
191  {
192  return string.Concat(namedObject.DisplayName, " ", Title);
193  }
194 
195  public override string GetAltName(GraphSetConfiguration owner, string postfix)
196  {
197  string peerName = postfix;
198  return GraphName + "-" + peerName.Replace('.', '-') + ".png";
199  }
200 
201  public override Uri GetLink(GraphSetConfiguration owner, string postfix)
202  {
203  return WebPath.
204  Append(Links.Destinations[owner.LinkIndex - 1].Link).
205  AppendExtension(postfix.Replace('.', '-')).
206  AppendExtension(".png");
207  }
208  }
209 }
override string GetAltName(GraphSetConfiguration owner, string postfix)
PeerGraphConfiguration(string name, int?frequency, bool?initialRun, bool?fixedRun, string title, int?width, int?height, int?timespan, DateTimeKind?graphTime, double?filterFactor, double?balance, double?delay, double?jitter, double?offset, DestinationCollection destinations, WebLinkCollection links)
override string GetTitle(NamedObject namedObject)
override Uri GetLink(GraphSetConfiguration owner, string postfix)
Peer graph configuration used when creating Ntp.Analyzer.Graph.PeerGraph.