private void OnTxtCommandResultReady(FwCommandMessageResult cmdResult) { FlTxtMessageCommand command = (FlTxtMessageCommand)cmdResult.Command; int i; TimeSpan spanTime; DateTime now = DateTime.UtcNow; TxtCommandResult txtCmdResult = new TxtCommandResult() { Command = command, Response = (FlTxtMessageResponse)cmdResult.Response, CreatedDate = cmdResult.CreatedDate, LogName = $"{now.Year}{now.Month.ToString("00")}{now.Day.ToString("00")} {now.Hour.ToString("00")}:{now.Minute.ToString("00")}:{now.Second.ToString("00")}.{now.Millisecond.ToString("000")}" }; col.Insert(txtCmdResult); Console.WriteLine($"Command : {command.MessageId}"); Console.WriteLine($"Try count : {command.TryCount}"); if (command.TryCount > 1) { for (i = 0; i < command.TryCount; i++) { if ((i + 1) < command.TryCount) { spanTime = command.SendTimeHistory[i + 1] - command.SendTimeHistory[i]; Console.WriteLine($"Try interval : {spanTime.TotalMilliseconds}"); } } } if (command.TryCount > 0) { spanTime = cmdResult.CreatedDate - command.SendTimeHistory[0]; Console.WriteLine($"Total processing time : {spanTime.TotalMilliseconds}"); } if (cmdResult.Response != null) { if (cmdResult.Response.Arguments?.Count > 0) { foreach (var item in cmdResult.Response.Arguments) { Console.WriteLine($"{item}"); } } } else { Console.WriteLine("No response"); } }
private void OnCommandResultReady(FwCommandMessageResult cmdResult) { switch (cmdResult.Command.MessageType) { case FlMessageType.Text: OnTxtCommandResultReady(cmdResult); break; case FlMessageType.Binary: OnBinCommandResultReady(cmdResult); break; default: Log.Error("MessageType should be specified"); break; } }
private void OnBinCommandResultReady(FwCommandMessageResult cmdResult) { FlBinMessageCommand command = (FlBinMessageCommand)cmdResult.Command; int i; TimeSpan spanTime; Console.WriteLine($"Command : {command.MessageId}"); Console.WriteLine($"Try count : {command.TryCount}"); if (command.TryCount > 1) { for (i = 0; i < command.TryCount; i++) { if ((i + 1) < command.TryCount) { spanTime = command.SendTimeHistory[i + 1] - command.SendTimeHistory[i]; Console.WriteLine($"Try interval : {spanTime.TotalMilliseconds}"); } } } if (command.TryCount > 0) { spanTime = cmdResult.CreatedDate - command.SendTimeHistory[0]; Console.WriteLine($"Total processing time : {spanTime.TotalMilliseconds}"); } if (cmdResult.Response != null) { if (cmdResult.Response.Arguments?.Count > 0) { foreach (var item in cmdResult.Response.Arguments) { Console.WriteLine($"{item}"); } } } else { Console.WriteLine("No response"); } }