RTProvider_TLV.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. namespace MinicsConsole.Hubs.RT;
  2. public class RTProvider_TLV(ConfigFileOperator configFileOperator, ILog log) : ITlvProvider
  3. {
  4. void ITlvProvider.Connected(UniversalNetFrame451.IO.TcpConnection connection)
  5. {
  6. log.Info($"RT TLV Client Connected {connection.RemoteEndPoint.Address}:{connection.RemoteEndPoint.Port}");
  7. }
  8. void ITlvProvider.Disconnected(UniversalNetFrame451.IO.TcpConnection connection)
  9. {
  10. log.Info($"RT TLV Client DisConnected {connection.RemoteEndPoint.Address}:{connection.RemoteEndPoint.Port}");
  11. }
  12. void ITlvProvider.Received(TlvData data)
  13. {
  14. if (data.RawData is null || data.RawData.Length == 0)
  15. {
  16. //Log
  17. return;
  18. }
  19. switch (data.Tag)
  20. {
  21. case 1:
  22. string fileName = Encoding.UTF8.GetString(data.RawData);
  23. _ = configFileOperator.SetConfigFile(fileName) switch
  24. {
  25. true => log.Info($"RT Select TempConfig File:{fileName}"),
  26. false => log.Error($"RT Select TempConfig Failed! File:{fileName} "),
  27. };
  28. break;
  29. default:
  30. break;
  31. }
  32. }
  33. TlvData ITlvProvider.RequestReply(TlvData tlvData)
  34. {
  35. return tlvData;
  36. }
  37. }