action_window.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using chutian_parking_terminal.Media;
  11. using tool;
  12. using chutian_parking_terminal.data_buffer;
  13. using chutian_parking_terminal.communication;
  14. using chutian_parking_terminal.motion_executer;
  15. using System.Threading;
  16. namespace chutian_parking_terminal
  17. {
  18. //消息提示框的回调(其他模块运行时会有一些提示信息)
  19. public delegate void Delegate_connect_statu_display(string str, bool flag);
  20. public partial class action_window : Form
  21. {
  22. //显示视频,图片,等
  23. private MediaPlayer m_mediaPlayer;
  24. private Thread m_tip_show_thread;
  25. //是否显示提示框
  26. private bool m_is_tip_show;
  27. //是否关闭主程序
  28. private bool m_is_close_action_window;
  29. public action_window()
  30. {
  31. InitializeComponent();
  32. //初始化日志记录
  33. Log.Instance.LogInit();
  34. //初始化json文件操作
  35. json_file_operation.Instance.json_file_operation_init("../../settings.json");
  36. //初始化三个数据缓冲区
  37. Central_control_data_buffer.Instance.central_control_data_buffer_init();
  38. Ground_radar_data_buffer.Instance.ground_radar_data_buffer_init();
  39. Singlechip_data_buffer.Instance.Singlechip_data_buffer_init();
  40. //初始化通信
  41. Singlechip_communication.Instance.communication_socket_tcp_init();//单片机通信
  42. Singlechip_communication.Instance.communication_socket_tcp_connect();//默认从settings.json文件读取端口和IP
  43. Channel_communication.Instance.communication_init();//出入口通信
  44. //创建显示器
  45. m_mediaPlayer = new MediaPlayer();
  46. //初始化显示器
  47. m_mediaPlayer.MediaPlayerInit(this, ref this.pictureBox1, ref this.axWindowsMediaPlayer1, ref this.timeLab, ref this.dateLab, ref this.dateLab1);
  48. //初始化提示显示线程
  49. m_tip_show_thread = new Thread(tip_show_thread);
  50. //初始化入口执行模块
  51. Entrance_execute.Instance.entrance_execute_init();
  52. //初始化出口执行模块
  53. Exit_execute.Instance.exit_execute_init();
  54. //是否关闭
  55. m_is_close_action_window = false;
  56. }
  57. //显示提示框
  58. private void tip_show_thread()
  59. {
  60. while (m_is_tip_show)
  61. {
  62. if (this.InvokeRequired)
  63. {
  64. this.Invoke(new Action(() =>
  65. {
  66. tip_label.Text = Tip_data_buffer.Instance.get_tip_str();
  67. }));
  68. }
  69. else
  70. {
  71. tip_label.Text = Tip_data_buffer.Instance.get_tip_str();
  72. }
  73. Thread.Sleep(1);
  74. }
  75. }
  76. private void parkingBtn_Click(object sender, EventArgs e)
  77. {
  78. //检查单片机通信状态
  79. if (Singlechip_communication.Instance.check_statu())
  80. {
  81. //点击停车按钮时 判断入口能否进行停车、
  82. if (Entrance_execute.Instance.get_process_statu() == Entrance_execute.Entrance_process_statu.ENTRANCE_WAIT_USER)
  83. {
  84. //开始停车流程
  85. Entrance_execute.Instance.entrance_process_run();
  86. while (!m_is_close_action_window)
  87. {
  88. //打印二维码
  89. if (Entrance_execute.Instance.get_process_statu() == Entrance_execute.Entrance_process_statu.ENTRANCE_MONITOR_PROCESS)
  90. {
  91. Entrance_execute.Instance.print_qr_code();
  92. break;
  93. }
  94. Thread.Sleep(1);
  95. }
  96. }
  97. else
  98. {
  99. MessageBoxForm messageBoxForm = new MessageBoxForm();
  100. messageBoxForm.ShowDialog(Tip_data_buffer.Instance.get_tip_str());
  101. }
  102. }
  103. else
  104. {
  105. MessageBoxForm messageBoxForm = new MessageBoxForm();
  106. messageBoxForm.ShowDialog("单片机未连接...");
  107. }
  108. }
  109. private void fetchingBtn_Click(object sender, EventArgs e)
  110. {
  111. //MessageBoxForm messageBoxForm = new MessageBoxForm();
  112. //messageBoxForm.setText("该终端为停车终端,暂时无法用于取车!");
  113. //messageBoxForm.ShowDialog();
  114. //检查单片机通信状态
  115. if (Singlechip_communication.Instance.check_statu())
  116. {
  117. //此窗口只获取车牌号
  118. FetchingForm fetchingForm = new FetchingForm();
  119. fetchingForm.StartPosition = FormStartPosition.CenterScreen;
  120. fetchingForm.BringToFront();
  121. fetchingForm.ShowDialog();
  122. if (fetchingForm.m_is_return)
  123. {
  124. return;
  125. }
  126. //点击停车按钮时 判断入口能否进行停车、
  127. if (Exit_execute.Instance.get_process_statu() == Exit_execute.Exit_process_statu.EXIT_FREE)
  128. {
  129. //开始取车流程
  130. Exit_execute.Instance.exit_process_run();
  131. }
  132. else
  133. {
  134. MessageBoxForm messageBoxForm = new MessageBoxForm();
  135. messageBoxForm.ShowDialog(Tip_data_buffer.Instance.get_tip_str());
  136. }
  137. }
  138. else
  139. {
  140. MessageBoxForm messageBoxForm = new MessageBoxForm();
  141. messageBoxForm.ShowDialog("单片机未连接...");
  142. }
  143. }
  144. private void action_window_Load(object sender, EventArgs e)
  145. {
  146. //启动播放器
  147. m_mediaPlayer.mediaplayer_run();
  148. //显示提示
  149. m_is_tip_show = true;
  150. m_tip_show_thread.Start();
  151. }
  152. private void action_window_FormClosing(object sender, FormClosingEventArgs e)
  153. {
  154. //关闭播放器
  155. m_mediaPlayer.mediaplayer_uninit();
  156. //关闭单片机通信
  157. Singlechip_communication.Instance.singlechip_communication_uninit();
  158. //关闭出入口通信
  159. Channel_communication.Instance.channel_communication_uninit();
  160. //关闭入口管理
  161. Entrance_execute.Instance.entrance_execute_uninit();
  162. //关闭出口管理
  163. Exit_execute.Instance.exit_execute_uninit();
  164. //关闭显示提示
  165. m_is_tip_show = false;
  166. m_tip_show_thread.Abort();
  167. //关闭主程序
  168. m_is_close_action_window = true;
  169. }
  170. private void axWindowsMediaPlayer1_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
  171. {
  172. if (this.axWindowsMediaPlayer1.fullScreen == true)
  173. {
  174. this.axWindowsMediaPlayer1.fullScreen = false;
  175. }
  176. }
  177. }
  178. }