コード例 #1
0
            public LinkDetailReply(ILinkDetail linkDetail)
            {
                if (linkDetail == null)
                {
                    throw new ArgumentNullException(nameof(linkDetail), "The link detail to construct from is null");
                }

                this.MacString1       = linkDetail.MacString1;
                this.MacString2       = linkDetail.MacString2;
                this.Address1         = linkDetail.Address1.ToString();
                this.Address2         = linkDetail.Address2.ToString();
                this.ModelAndVersion1 = linkDetail.ModelAndVersion1;
                this.ModelAndVersion2 = linkDetail.ModelAndVersion2;

                try
                {
                    this.RxLevel1at2 = linkDetail.RxLevel1at2;
                }
                catch (HamnetSnmpException)
                {
                    this.RxLevel1at2 = double.NaN;
                }

                try
                {
                    this.RxLevel2at1 = linkDetail.RxLevel2at1;
                }
                catch (HamnetSnmpException)
                {
                    this.RxLevel2at1 = double.NaN;
                }

                try
                {
                    this.LinkUptime = linkDetail.LinkUptime;
                }
                catch (HamnetSnmpException)
                {
                    this.LinkUptime = TimeSpan.Zero;
                }

                try
                {
                    this.SideOfAccessPoint = linkDetail.SideOfAccessPoint;
                }
                catch (HamnetSnmpException)
                {
                    this.SideOfAccessPoint = null;
                }
            }
コード例 #2
0
        /// <summary>
        /// Formats as block-formatted string of an <see cref="ILinkDetail" />.
        /// </summary>
        /// <param name="linkDetail">The data to format.</param>
        /// <returns>The formatted string.</returns>
        public string Format(ILinkDetail linkDetail)
        {
            if (linkDetail == null)
            {
                return("<null>");
            }

            StringBuilder returnBuilder = new StringBuilder(256);

            returnBuilder.Append("Link between side #1 (").Append(linkDetail.Address1).Append(", ").Append(linkDetail.ModelAndVersion1).Append(") and side #2 (").Append(linkDetail.Address2).Append(", ").Append(linkDetail.ModelAndVersion2).AppendLine("):");
            returnBuilder.Append("Side #1 MAC: ").AppendLine(linkDetail.MacString1);
            returnBuilder.Append("Side #2 MAC: ").AppendLine(linkDetail.MacString2);
            returnBuilder.Append("Side of AP : ").AppendLine(linkDetail.SideOfAccessPoint?.ToString("0") ?? "not available");
            returnBuilder.Append("Rx level of side #1 at side #2: ").AppendLine(linkDetail.RxLevel1at2.ToString("0.0 dBm"));
            returnBuilder.Append("Rx level of side #2 at side #1: ").AppendLine(linkDetail.RxLevel2at1.ToString("0.0 dBm"));
            returnBuilder.Append("Link Uptime: ").Append(linkDetail.LinkUptime.ToString());

            return(returnBuilder.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Construct by copying another <see cref="ILinkDetail" />
        /// </summary>
        /// <param name="linkDetail">The link detail to copy and store.</param>
        public LinkDetailStoreOnlyContainer(ILinkDetail linkDetail)
        {
            // NOTE: These assignment might look really dumb.
            //       But remember: The rhs might be a lazy container for which exactly this access triggers the evaluation!
            this.MacString1        = linkDetail.MacString1;
            this.MacString2        = linkDetail.MacString2;
            this.Address1          = linkDetail.Address1;
            this.Address2          = linkDetail.Address2;
            this.ModelAndVersion1  = linkDetail.ModelAndVersion1;
            this.ModelAndVersion2  = linkDetail.ModelAndVersion2;
            this.RxLevel1at2       = linkDetail.RxLevel1at2;
            this.RxLevel2at1       = linkDetail.RxLevel2at1;
            this.LinkUptime        = linkDetail.LinkUptime;
            this.SideOfAccessPoint = linkDetail.SideOfAccessPoint;
            this.DeviceAddress     = linkDetail.DeviceAddress;
            this.DeviceModel       = linkDetail.DeviceModel;
            this.Ccq1 = linkDetail.Ccq1;
            this.Ccq2 = linkDetail.Ccq2;
            this.Ccq  = linkDetail.Ccq;

            // assign this last so it contains the sum of the possibly lazy evaluations triggered by above assignments
            this.QueryDuration = linkDetail.QueryDuration;
        }
コード例 #4
0
        /// <summary>
        /// Adds or modifies an RSSI entry for the given link detail.
        /// </summary>
        /// <param name="databaseContext">The database context to work with.</param>
        /// <param name="subnet">The subnet that is being recorded.</param>
        /// <param name="queryTime">The time of the data aquisition (recorded with the data).</param>
        /// <param name="linkDetail">The link details to record.</param>
        /// <param name="adressToSearch">The host address to search for (and modify if found).</param>
        /// <param name="rssiToSet">The RSSI value to record.</param>
        /// <param name="hostCall">The call of the foreign host.</param>
        /// <param name="description">The description for this value.</param>
        private void SetNewRssiForLink(QueryResultDatabaseContext databaseContext, IHamnetDbSubnet subnet, DateTime queryTime, ILinkDetail linkDetail, string adressToSearch, double rssiToSet, string hostCall, string description)
        {
            var adressEntry = databaseContext.RssiValues.Find(adressToSearch);

            if (adressEntry == null)
            {
                adressEntry = new Rssi
                {
                    ForeignId    = adressToSearch,
                    Metric       = RssiMetricName,
                    MetricId     = RssiMetricId,
                    ParentSubnet = subnet.Subnet?.ToString(),
                    Description  = description,
                    ForeignCall  = hostCall
                };

                databaseContext.RssiValues.Add(adressEntry);
            }

            adressEntry.RssiValue = rssiToSet.ToString("0.0");

            // we're setting a couple of values here again so that migrated database will get the value added
            adressEntry.ParentSubnet = subnet.Subnet?.ToString();
            adressEntry.Description  = description;
            adressEntry.ForeignCall  = hostCall;

            adressEntry.TimeStampString = queryTime.ToUniversalTime().ToString("yyyy-MM-ddTHH\\:mm\\:sszzz");
            adressEntry.UnixTimeStamp   = (ulong)queryTime.ToUniversalTime().Subtract(Program.UnixTimeStampBase).TotalSeconds;
        }