ground_radar_data_buffer.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using tool;
  7. namespace chutian_parking_terminal.data_buffer
  8. {
  9. class Ground_radar_data_buffer
  10. {
  11. public Ground_radar_data_buffer()
  12. {
  13. }
  14. public void ground_radar_data_buffer_init()
  15. {
  16. m_ground_status_msg = new Message.Ground_status_msg();
  17. m_has_ground_statu_msg = false;
  18. }
  19. public bool has_ground_statu_msg()
  20. {
  21. return m_has_ground_statu_msg;
  22. }
  23. //设置消息
  24. public void set_ground_status_msg(Message.Ground_status_msg msg)
  25. {
  26. lock (m_data_lock)
  27. {
  28. m_ground_status_msg = msg;
  29. }
  30. m_has_ground_statu_msg = true;
  31. }
  32. //获取消息
  33. public Message.Ground_status_msg get_ground_status_msg()
  34. {
  35. return m_ground_status_msg;
  36. }
  37. //数据锁
  38. //作用:将会锁住代码块的内容,并阻止其他线程进入该代码块,直到该代码块运行完成,释放该锁。
  39. //注意:定义的锁对象应该是 私有的,静态的,只读的,引用类型的对象,这样可以防止外部改变锁对象
  40. private static readonly object m_data_lock = new object();
  41. //地面雷达状态消息
  42. private Message.Ground_status_msg m_ground_status_msg;
  43. //是否被赋值过(是否是有效数据)
  44. private bool m_has_ground_statu_msg;
  45. }
  46. }