// // Copyright (c) 2013-2016 Carsten Sonne Larsen // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. namespace Ntp.Analyzer.Objects { public sealed class AssociationEntry : PersistentObject { public AssociationEntry( int id, int hostId, char tallyChar, string remote, string refid, int stratus, char peerType, int lastPoll, int poll, int reach, double delay, double offset, double jitter) : base(id) { HostId = hostId; TallyChar = tallyChar; Remote = remote; this.refid = refid; Stratus = stratus; PeerType = peerType; LastPoll = lastPoll; Poll = poll; Reach = reach; Delay = delay; Offset = offset; Jitter = jitter; } public AssociationEntry( int hostId, char tallyChar, string remote, string refid, int stratus, char peerType, int lastPoll, int poll, int reach, double delay, double offset, double jitter) { HostId = hostId; TallyChar = tallyChar; Remote = remote; this.refid = refid; Stratus = stratus; PeerType = peerType; LastPoll = lastPoll; Poll = poll; Reach = reach; Delay = delay; Offset = offset; Jitter = jitter; } private readonly string refid; /// /// Gets the tally code. /// /// The tally code. public TallyCode TallyCode { get { switch (TallyChar) { case ' ': return TallyCode.Reject; case 'x': return TallyCode.FalseTick; case '.': return TallyCode.Excess; case '-': return TallyCode.Outlyer; case '+': return TallyCode.Candidat; case '#': return TallyCode.Selected; case '*': return TallyCode.SysPeer; case 'o': return TallyCode.PpsPeer; default: return TallyCode.Undefined; } } } /// /// Gets the tally char. /// /// The tally char. public char TallyChar { get; } /// /// Gets the host ID of this association entry. /// /// The host ID. public int HostId { get; } /// /// Gets the address of the remote peer. /// /// The address. public string Remote { get; } /// /// Gets the reference ID (0.0.0.0 if this is unknown) /// /// The reference ID. public string Refid => refid ?? "0.0.0.0"; /// /// Gets the stratum of the remote peer. /// /// The stratus. public int Stratus { get; } /// /// Gets the type of the peer (local, unicast, multicast or broadcast) /// /// l, u, m or b public char PeerType { get; } /// /// Gets when the last packet was received, the polling interval, in seconds. /// /// The last poll in seconds. public int LastPoll { get; } /// /// Gets the the polling interval in seconds. /// /// The polling interval. public int Poll { get; } /// /// Gets the reachability register in octal. /// /// The reachability register. public int Reach { get; } /// /// Gets the current estimated delay. /// /// The estimated delay. public double Delay { get; } /// /// Gets the offset of the peer in milliseconds. /// /// The offset. public double Offset { get; } /// /// Gets the dispersion of the peer in milliseconds. /// /// The dispersion. public double Jitter { get; } } }