123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using chutian_parking_terminal.Media;
- using tool;
- using chutian_parking_terminal.data_buffer;
- using chutian_parking_terminal.communication;
- using chutian_parking_terminal.motion_executer;
- using System.Threading;
- namespace chutian_parking_terminal
- {
- //消息提示框的回调(其他模块运行时会有一些提示信息)
- public delegate void Delegate_connect_statu_display(string str, bool flag);
- public partial class action_window : Form
- {
- //显示视频,图片,等
- private MediaPlayer m_mediaPlayer;
- private Thread m_tip_show_thread;
- //是否显示提示框
- private bool m_is_tip_show;
- //是否关闭主程序
- private bool m_is_close_action_window;
-
- public action_window()
- {
- InitializeComponent();
- //初始化日志记录
- Log.Instance.LogInit();
- //初始化json文件操作
- json_file_operation.Instance.json_file_operation_init("../../settings.json");
- //初始化三个数据缓冲区
- Central_control_data_buffer.Instance.central_control_data_buffer_init();
- Ground_radar_data_buffer.Instance.ground_radar_data_buffer_init();
- Singlechip_data_buffer.Instance.Singlechip_data_buffer_init();
- //初始化通信
- Singlechip_communication.Instance.communication_socket_tcp_init();//单片机通信
- Singlechip_communication.Instance.communication_socket_tcp_connect();//默认从settings.json文件读取端口和IP
- Channel_communication.Instance.communication_init();//出入口通信
- //创建显示器
- m_mediaPlayer = new MediaPlayer();
- //初始化显示器
- m_mediaPlayer.MediaPlayerInit(this, ref this.pictureBox1, ref this.axWindowsMediaPlayer1, ref this.timeLab, ref this.dateLab, ref this.dateLab1);
- //初始化提示显示线程
- m_tip_show_thread = new Thread(tip_show_thread);
- //初始化入口执行模块
- Entrance_execute.Instance.entrance_execute_init();
- //初始化出口执行模块
- Exit_execute.Instance.exit_execute_init();
- //是否关闭
- m_is_close_action_window = false;
- }
- //显示提示框
- private void tip_show_thread()
- {
- while (m_is_tip_show)
- {
- if (this.InvokeRequired)
- {
- this.Invoke(new Action(() =>
- {
- tip_label.Text = Tip_data_buffer.Instance.get_tip_str();
- }));
- }
- else
- {
- tip_label.Text = Tip_data_buffer.Instance.get_tip_str();
- }
- Thread.Sleep(1);
- }
- }
- private void parkingBtn_Click(object sender, EventArgs e)
- {
- //检查单片机通信状态
- if (Singlechip_communication.Instance.check_statu())
- {
- //点击停车按钮时 判断入口能否进行停车、
- if (Entrance_execute.Instance.get_process_statu() == Entrance_execute.Entrance_process_statu.ENTRANCE_WAIT_USER)
- {
- //开始停车流程
- Entrance_execute.Instance.entrance_process_run();
- while (!m_is_close_action_window)
- {
- //打印二维码
- if (Entrance_execute.Instance.get_process_statu() == Entrance_execute.Entrance_process_statu.ENTRANCE_MONITOR_PROCESS)
- {
- Entrance_execute.Instance.print_qr_code();
- break;
- }
- Thread.Sleep(1);
- }
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog(Tip_data_buffer.Instance.get_tip_str());
- }
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog("单片机未连接...");
- }
-
- }
- private void fetchingBtn_Click(object sender, EventArgs e)
- {
- //MessageBoxForm messageBoxForm = new MessageBoxForm();
- //messageBoxForm.setText("该终端为停车终端,暂时无法用于取车!");
- //messageBoxForm.ShowDialog();
- //检查单片机通信状态
- if (Singlechip_communication.Instance.check_statu())
- {
- //此窗口只获取车牌号
- FetchingForm fetchingForm = new FetchingForm();
- fetchingForm.StartPosition = FormStartPosition.CenterScreen;
- fetchingForm.BringToFront();
- fetchingForm.ShowDialog();
- if (fetchingForm.m_is_return)
- {
- return;
- }
- //点击停车按钮时 判断入口能否进行停车、
- if (Exit_execute.Instance.get_process_statu() == Exit_execute.Exit_process_statu.EXIT_FREE)
- {
- //开始取车流程
- Exit_execute.Instance.exit_process_run();
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog(Tip_data_buffer.Instance.get_tip_str());
- }
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog("单片机未连接...");
- }
-
- }
- private void action_window_Load(object sender, EventArgs e)
- {
- //启动播放器
- m_mediaPlayer.mediaplayer_run();
- //显示提示
- m_is_tip_show = true;
- m_tip_show_thread.Start();
- }
- private void action_window_FormClosing(object sender, FormClosingEventArgs e)
- {
- //关闭播放器
- m_mediaPlayer.mediaplayer_uninit();
- //关闭单片机通信
- Singlechip_communication.Instance.singlechip_communication_uninit();
- //关闭出入口通信
- Channel_communication.Instance.channel_communication_uninit();
- //关闭入口管理
- Entrance_execute.Instance.entrance_execute_uninit();
- //关闭出口管理
- Exit_execute.Instance.exit_execute_uninit();
- //关闭显示提示
- m_is_tip_show = false;
- m_tip_show_thread.Abort();
- //关闭主程序
- m_is_close_action_window = true;
- }
- private void axWindowsMediaPlayer1_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
- {
- if (this.axWindowsMediaPlayer1.fullScreen == true)
- {
- this.axWindowsMediaPlayer1.fullScreen = false;
- }
- }
- }
- }
-
|