/* * Adds the messages to the output box. This method is invoked in MainWindow process. */ void Process_readerMessageProgress(object sender, ProgressChangedEventArgs e) { ReceiverReport progress = (ReceiverReport)e.ProgressPercentage; switch (progress) { case ReceiverReport.REPORT_RUNNING: LogOutput((string)e.UserState); //Console.WriteLine("{0}", (string)e.UserState); logStrBuilder.Append("\n" + DateTime.Now + " : " + (string)e.UserState); break; case ReceiverReport.ERROR_STOP: CheckStatus("Reading", (Canlib.canStatus)e.UserState); break; case ReceiverReport.FORCED_STOP: CheckStatus((string)e.UserState, Canlib.canStatus.canOK); forceAllBusOff(); break; default: break; } }
public void PrintReport(ReceiverReport report) { lock (_consolePrintLock) { var receivedMessage = $"Packages received: { report.PackagesReceived}"; Console.SetCursorPosition(Console.WindowWidth - receivedMessage.Length, 0); Console.WriteLine(receivedMessage); var lostMessage = $"Packages lost: { report.PackagesLost}"; Console.SetCursorPosition(Console.WindowWidth - lostMessage.Length, 1); Console.WriteLine(lostMessage); } }
/// <summary> /// Serialises a compound RTCP packet to a byte array ready for transmission. /// </summary> /// <returns>A byte array representing a serialised compound RTCP packet.</returns> public byte[] GetBytes() { if (SenderReport == null && ReceiverReport == null) { throw new ApplicationException( "An RTCP compound packet must have either a Sender or Receiver report set."); } else if (SDesReport == null) { throw new ApplicationException("An RTCP compound packet must have an SDES report set."); } List <byte> compoundBuffer = new List <byte>(); compoundBuffer.AddRange((SenderReport != null) ? SenderReport.GetBytes() : ReceiverReport.GetBytes()); compoundBuffer.AddRange(SDesReport.GetBytes()); if (Bye != null) { compoundBuffer.AddRange(Bye.GetBytes()); } return(compoundBuffer.ToArray()); }