[关闭]
@Pigmon 2021-06-04T13:23:58.000000Z 字数 1979 阅读 580

铁建错误编码发送到遥控端的接收说明

遥控


1. 简述

错误代码在遥控驾驶系统最基本的车辆上行报文中,具体字段如下图所示:
1.png-92.2kB

2. 遥控端接收方法示例

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace TestCSharp
  7. {
  8. class Program
  9. {
  10. static ushort ERRDET_GPS_LOSS = 0x0004;
  11. static ushort ERRDET_IMU_LOSS = 0x0008;
  12. static ushort ERRDET_LIDAR_LOSS = 0x0010;
  13. static ushort ERRDET_POSTYPE = 0X0080;
  14. static ushort ERRDET_OUTOFPATH = 0X0100;
  15. static void Main(string[] args)
  16. {
  17. ushort err_msg = (ushort)(ERRDET_GPS_LOSS | ERRDET_LIDAR_LOSS | ERRDET_OUTOFPATH);
  18. string msg1 = ErrorToString(err_msg);
  19. string msg2 = ErrorToString_Single(err_msg);
  20. Console.WriteLine("多个错误一起显示的方式:" + msg1);
  21. Console.WriteLine("只显示一个错误的方式:" + msg2);
  22. }
  23. /// <summary>
  24. /// 如果有多个错误,全部显示的函数;
  25. /// </summary>
  26. /// <param name="_err_msg">车辆上行报文中m_ctrl_info 的数值</param>
  27. /// <returns>代表错误的字符串</returns>
  28. static string ErrorToString(ushort _err_msg)
  29. {
  30. string ret = "";
  31. bool location_error = (_err_msg & ERRDET_GPS_LOSS) == ERRDET_GPS_LOSS ||
  32. (_err_msg & ERRDET_IMU_LOSS) == ERRDET_IMU_LOSS ||
  33. (_err_msg & ERRDET_POSTYPE) == ERRDET_POSTYPE;
  34. bool lidar_error = (_err_msg & ERRDET_LIDAR_LOSS) == ERRDET_LIDAR_LOSS;
  35. bool path_error = (_err_msg & ERRDET_OUTOFPATH) == ERRDET_OUTOFPATH;
  36. bool is_error = location_error || lidar_error || path_error;
  37. if (is_error)
  38. {
  39. if (location_error)
  40. ret += "定位系统故障;";
  41. if (lidar_error)
  42. ret += "激光雷达故障;";
  43. if (path_error)
  44. ret += "行驶异常;";
  45. }
  46. else
  47. ret += "正常";
  48. return ret;
  49. }
  50. /// <summary>
  51. /// 同时发生多个错误,但只显示其中一个错误的函数
  52. /// </summary>
  53. /// <param name="_err_msg">车辆上行报文中m_ctrl_info 的数值</param>
  54. /// <returns>代表错误的字符串</returns>
  55. static string ErrorToString_Single(ushort _err_msg)
  56. {
  57. string ret = "";
  58. bool location_error = (_err_msg & ERRDET_GPS_LOSS) == ERRDET_GPS_LOSS ||
  59. (_err_msg & ERRDET_IMU_LOSS) == ERRDET_IMU_LOSS ||
  60. (_err_msg & ERRDET_POSTYPE) == ERRDET_POSTYPE;
  61. bool lidar_error = (_err_msg & ERRDET_LIDAR_LOSS) == ERRDET_LIDAR_LOSS;
  62. bool path_error = (_err_msg & ERRDET_OUTOFPATH) == ERRDET_OUTOFPATH;
  63. bool is_error = location_error || lidar_error || path_error;
  64. // 假设错误显示优先级从高到低依次为:
  65. // 1. 定位问题;
  66. // 2. 行驶异常;
  67. // 3. 激光雷达故障;
  68. if (location_error)
  69. ret += "定位系统故障;";
  70. else if (path_error)
  71. ret += "行驶异常;";
  72. else if (lidar_error)
  73. ret += "激光雷达故障;";
  74. else
  75. ret += "正常";
  76. return ret;
  77. }
  78. }
  79. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注