/// <summary> /// Logs the pingManipulatorResult. Creates the Message with latency and depending on the status information text. /// </summary> public void Log(PingManipulatorResult pingManipulatorResult) { // local variable for detailed information if there is any string detailedInformation = null; // get message string message = String.Empty; // depending on status ... if (pingManipulatorResult.PingerData.PingStatus == PingStatus.Success) { // generate normal message message = String.Format("{0} ms", Math.Round(pingManipulatorResult.Ping, 2)); } else if (pingManipulatorResult.PingerData.PingStatus == PingStatus.Timeout) { // generate timeout message message = "Timeout"; detailedInformation = "Timeout just happend."; } else { // generate unknown error message message = "Unknown error!"; detailedInformation = "Unknown error happend. Dunno what happend."; } // get status MessageStatus status = MessageStatus.Normal; if (pingManipulatorResult.PingerData.PingStatus == PingStatus.Success) { if (pingManipulatorResult.Ping > pingManipulatorResult.Average) { if (pingManipulatorResult.Ping > (pingManipulatorResult.Average * 2)) { status = MessageStatus.Critical; detailedInformation = "Latency is more than twice the average."; } else { status = MessageStatus.Warning; detailedInformation = "Latency is higher than average."; } } } else { status = MessageStatus.Critical; } // make previous not current if (LogHistory.Count > 0) { LogHistory.First().MarkNotCurrent(); } // log it LogHistory.Insert(0, new Message(message, status, detailedInformation)); }
/// <summary> /// Updates the display values with new ping result /// </summary> public void Update(PingManipulatorResult pingManipulatorResult) { Loger.Log(pingManipulatorResult); string averageText = String.Format("{0} ms", Math.Round(pingManipulatorResult.Average, 2)); Average = averageText; }
/// <summary> /// When new ping is calculated notifies other components /// </summary> private void Pinger_NewPing(object sender, PingerData e) { try { _dispatcher.Invoke(new Action(() => { PingManipulatorResult pingManipulatorResult = PingManipulator.Calculate(e); Graph.Draw(pingManipulatorResult); Display.Update(pingManipulatorResult); //_scrollViewerTrainer.ScrollCenter(); })); } catch { } }
/// <summary> /// Draws the points with the pingManipulatorResult data. /// </summary> public void Draw(PingManipulatorResult pingManipulatorResult) { AveragePing.DrawPoint(pingManipulatorResult.Time, Height - pingManipulatorResult.Ping); CurrentPing.DrawPoint(pingManipulatorResult.Time, Height - pingManipulatorResult.Average); Expand(pingManipulatorResult.Time); }