NTP Analyzer  0.8.2
Analyze the operation of time servers
HostGraphConfiguration.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? gfrequency,
51  double? stability,
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  Gfrequency = gfrequency;
69  Stability = stability;
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 
95  [NtpaIndex(10)]
96  [NtpaSetting(Symbol.KeywordTitle, Layout = Layout.Quoted)]
97  public override string Title { get; }
98 
103  [NtpaIndex(11)]
104  [NtpaSetting(Symbol.KeywordTimespan, 60*12)]
105  public override int Timespan => timespan ?? 60*12;
106 
111  [NtpaIndex(20)]
112  [NtpaSetting(Symbol.KeywordWidth, 1024)]
113  public override int Width => width ?? 1024;
114 
119  [NtpaIndex(21)]
120  [NtpaSetting(Symbol.KeywordHeight, 550)]
121  public override int Height => height ?? 550;
122 
127  [NtpaIndex(22)]
128  public override ImageFormat Format => ImageFormat.Png;
129 
134  [NtpaIndex(40)]
135  [NtpaSetting(Symbol.KeywordFilterFactor)]
136  public double? FilterFactor { get; }
137 
142  [NtpaIndex(30)]
143  [NtpaSetting(Symbol.KeywordJitter)]
144  public double? Jitter { get; }
145 
150  [NtpaIndex(31)]
151  [NtpaSetting(Symbol.KeywordOffset)]
152  public double? Offset { get; }
153 
158  [NtpaIndex(32)]
159  [NtpaSetting(Symbol.KeywordGraphStability)]
160  public double? Stability { get; }
161 
169  [NtpaIndex(33)]
170  [NtpaSetting(Symbol.KeywordGraphFrequency)]
171  public double? Gfrequency { get; }
172 
177  [NtpaIndex(12)]
178  [NtpaSetting(Symbol.KeywordGraphTime, DateTimeKind.Utc)]
179  public override DateTimeKind GraphTime => graphTime ?? DateTimeKind.Utc;
180 
181  [NtpaIndex(1)]
182  [NtpaSetting(Symbol.KeywordFrequency, 5)]
183  public int Frequency => frequency ?? 5;
184 
185  [NtpaIndex(2)]
186  [NtpaSetting(Symbol.KeywordInitialRun, false)]
187  public bool InitialRun => initialRun ?? false;
188 
189  [NtpaIndex(3)]
190  [NtpaSetting(Symbol.KeywordFixedRun, true)]
191  public bool FixedRun => fixedRun ?? true;
192 
199  public override string GetAltName(GraphSetConfiguration owner, string postfix)
200  {
201  int index = owner.LinkIndex;
202  string name = Links.Destinations[index - 1].Link;
203 
204  // remove any path from name
205  int pos = name.LastIndexOf('/');
206  name = pos != -1 ? name.Remove(0, pos + 1) : name;
207 
208  return name;
209  }
210 
217  public override Uri GetLink(GraphSetConfiguration owner, string postfix)
218  {
219  return WebPath.Append(Links.Destinations[owner.LinkIndex - 1].Link);
220  }
221 
222  public override string GetTitle(NamedObject namedObject)
223  {
224  return Title;
225  }
226  }
227 }
override string GetTitle(NamedObject namedObject)
override string GetAltName(GraphSetConfiguration owner, string postfix)
Gets the alternative name when referred to from web pages.
override Uri GetLink(GraphSetConfiguration owner, string postfix)
Gets the link to use when referred to from web pages.
HostGraphConfiguration(string name, int?frequency, bool?initialRun, bool?fixedRun, string title, int?width, int?height, int?timespan, DateTimeKind?graphTime, double?filterFactor, double?gfrequency, double?stability, double?jitter, double?offset, DestinationCollection destinations, WebLinkCollection links)
Host graph configuration used when creating Analyzer.Graph.HostGraph.