123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724 |
- 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.front_terminal_manager;
- using System.Threading;
- using Kitware.VTK;
- using Google.Protobuf;
- using System.Security.Cryptography;
- using System.Diagnostics;
- using System.Speech.Synthesis;
- using System.Globalization;
- namespace chutian_parking_terminal
- {
- public partial class action_window : Form
- {
- //自适应窗口大小
- AutoResizeForm m_auto_resize_form = new AutoResizeForm();
- //显示视频,图片,等
- private MediaPlayer m_mediaPlayer;
- //显示提示框
- private Thread m_tip_show_thread;
- private bool m_tip_show_condition;
- //本终端终端号
- private int m_ternimalID;
- //存车反馈
- private Message.Store_command_response_msg m_store_command_response_msg;
- //查询反馈
- private Message.Parkspace_search_response_msg m_search_response_msg;
- //取车反馈
- private Message.Pickup_command_response_msg m_pickup_command_response_msg;
- //存车车牌号
- private string m_parking_license;
- //取车车牌号
- private string m_pickup_license;
- //子进程
- private Process m_process;
- private bool m_process_is_start;
- public action_window()
- {
- InitializeComponent();
- m_parking_license = "";
- m_pickup_license = "";
- parkingBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- // fetchingBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- //初始化日志记录
- Log.Instance.LogInit();
- //初始化json文件操作
- json_file_operation.Instance.json_file_operation_init("./settings.json");
- m_ternimalID = int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber"));
- //初始化数据缓冲区
- Front_terminal_manager.Instance.front_terminal_manager_init(int.Parse(json_file_operation.Instance.read_json_string("pickup_singleChip_connect_count")));
- //初始化通信
- Channel_communication.Instance.channel_communication_init();
- Singlechip_communication.Instance.singlechip_communication_init();//单片机通信
- Singlechip_communication.Instance.singlechip_communication_connect();//默认从settings.json文件读取端口和IP
- //初始化打印机
- PrintManual.Instance.PrintManualInit();
- //创建显示器
- m_mediaPlayer = new MediaPlayer();
- //初始化显示器
- m_mediaPlayer.MediaPlayerInit(this, ref this.image_pictureBox, ref this.axWindowsMediaPlayer, ref this.time_label, ref this.date_label_1, ref this.date_label_2);
- //初始化提示显示线程
- m_tip_show_thread = new Thread(tip_show_thread);
- //初始化反馈
- m_store_command_response_msg = null;
- m_search_response_msg = null;
- m_pickup_command_response_msg = null;
- //设置回调函数
- Channel_communication.Instance.SetStoreResponseMsgDelegate(set_store_response_msg);
- Channel_communication.Instance.SetPickupResponseMsgDelegate(set_pickup_response_msg);
- Channel_communication.Instance.SetParkspaceSearchMsgDelegate(set_search_response_msg);
- //设置状态发送间隔
- Channel_communication.Instance.set_encapsulate_cycle_time(50);
- m_process_is_start = false;
- }
- //显示提示框
- private void tip_show_thread()
- {
- while (m_tip_show_condition)
- {
- //检查各个节点连接状态
- Message.Error_manager error = Channel_communication.Instance.check_statu();
- if (error.ErrorCode == 0 && Singlechip_communication.Instance.check_entrance_statu())
- {
- Front_terminal_manager.Instance.get_tip_data_buffer().set_tip_str("系统正常!");
- this.Invoke(new Action(() =>
- {
- this.parkingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "parkingBtn.BackgroundImage.png");
- //this.fetchingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "fetchingBtn.BackgroundImage.png"); ;
- //this.fetchingBtn.Enabled = true;
- this.parkingBtn.Enabled = true;
- }));
- }
- else
- {
- this.Invoke(new Action(() =>
- {
- this.parkingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "parkingBtn_gray.BackgroundImage.png");
- this.parkingBtn.Enabled = false;
- //this.fetchingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "fetchingBtn_gray.BackgroundImage.png");
- //this.fetchingBtn.Enabled = false;
- }));
- if (error.ErrorCode == 0 && !Singlechip_communication.Instance.check_entrance_statu())
- {
- Front_terminal_manager.Instance.get_tip_data_buffer().set_tip_str("单片机未连接!");
- }
- else if (error.ErrorCode != 0 && Singlechip_communication.Instance.check_entrance_statu())
- {
- Front_terminal_manager.Instance.get_tip_data_buffer().set_tip_str(error.ErrorDescription);
- }
- else if (error.ErrorCode != 0 && !Singlechip_communication.Instance.check_entrance_statu())
- {
- Front_terminal_manager.Instance.get_tip_data_buffer().set_tip_str("单片机未连接!"+error.ErrorDescription);
- }
- }
- if (this.InvokeRequired)
- {
- this.Invoke(new Action(() =>
- {
- tip_label.Text = Front_terminal_manager.Instance.get_tip_data_buffer().get_tip_str();
- }));
- }
- else
- {
- tip_label.Text = Front_terminal_manager.Instance.get_tip_data_buffer().get_tip_str();
- }
- Thread.Sleep(100);
- }
- }
- private void parkingBtn_Click(object sender, EventArgs e)
- {
- //PrintManual.Instance.PrintTicket("鄂A3BO6X:lkjhgfds");
- //return;
- try
- {
- //检查各个节点连接状态
- Message.Error_manager error = Channel_communication.Instance.check_statu();
- if (error.ErrorCode == 0 && Singlechip_communication.Instance.check_entrance_statu())
- {
- //判断能否发送停车请求。
- Message.UnNormalized_module_statu_msg unNormalized_Module = Front_terminal_manager.Instance.get_unnormalized_module_data_bufferr().get_unnormalized_module_status_msg();
- Message.Singlechip_data t_singlechip_msg = Front_terminal_manager.Instance.get_singlechip_data_bufferr().get_entrance_singlechip_msg();
- Message.Ground_status_msg t_ground_status_msg = Front_terminal_manager.Instance.get_ground_radar_data_buffer().get_ground_status_msg();
- string check_results = check_status(unNormalized_Module, t_singlechip_msg, t_ground_status_msg);
- //单片机检测门内有车,门内车未超界,雷达扫描未超界,号牌机拍摄到的号牌不为空。满足以上需求才可停车
- if (check_results == "")
- {
- Message.Store_command_request_msg store_Command_Request_Msg = new Message.Store_command_request_msg();
- Message.Base_info t_base_info = new Message.Base_info();
- Message.Id_struct t_id_Struct = new Message.Id_struct();
- t_base_info.MsgType = Message.Message_type.EStoreCommandRequestMsg;
- t_base_info.Sender = Message.Communicator.ETerminor;
- t_base_info.Receiver = Message.Communicator.EMain;
- //地面雷达的 实时定位信息
- Message.Locate_information locateInformation = new Message.Locate_information();
- //获取雷达的测量数据 雷达不稳定有可能状态正常但是测量失败 所以测量500毫秒
- DateTime t_start_time = DateTime.Now;
- while (DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000 < 500)
- {
- locateInformation = Front_terminal_manager.Instance.get_ground_radar_data_buffer().get_ground_status_msg().LocateInformationRealtime;
- if (locateInformation.LocateCorrect)
- {
- break;
- }
- }
- if (!locateInformation.LocateCorrect)
- {
- MessageBoxForm message = new MessageBoxForm();
- message.ShowDialog("雷达测量失败!");
- }
- else
- {
- /*用单片机的数据填充车辆信息*/
- Message.Car_info car_Info = new Message.Car_info();
- car_Info.CarNumberPlate = unNormalized_Module.CarLicense;
- //Encoding FromEcoding = Encoding.GetEncoding("UTF-8");
- //Encoding ToEcoding = Encoding.GetEncoding("GB2312");
- //byte[] FromBytes = FromEcoding.GetBytes(unNormalized_Module.CarLicense);
- //byte[] ToBytes = Encoding.Convert(FromEcoding, ToEcoding, FromBytes);
- //car_Info.CarNumberPlate = ToEcoding.GetString(ToBytes);
- //char[] vs = car_Info.CarNumberPlate.ToCharArray();
- car_Info.License = GetUniqueIdentifier(16);
- m_parking_license = unNormalized_Module.CarLicense;
- if (t_singlechip_msg.CarHeightStatusCurrent == Message.Car_height_status.Small)
- {
- car_Info.CarHeight = 1.5f;
- }
- else if (t_singlechip_msg.CarHeightStatusCurrent == Message.Car_height_status.Medium)
- {
- car_Info.CarHeight = 1.7f;
- }
- else if (t_singlechip_msg.CarHeightStatusCurrent == Message.Car_height_status.Large)
- {
- car_Info.CarHeight = 1.9f;
- }
- else
- {
- car_Info.CarHeight = 2.2f;
- }
- car_Info.CarWheelBase = locateInformation.LocateWheelBase;
- car_Info.CarWheelWidth = locateInformation.LocateWheelWidth;
- store_Command_Request_Msg.BaseInfo = t_base_info;
- t_id_Struct.TerminalId = m_ternimalID;
- store_Command_Request_Msg.IdStruct = t_id_Struct;
- store_Command_Request_Msg.LocateInformation = locateInformation;
- store_Command_Request_Msg.CarInfo = car_Info;
- //发送停车请求
- Channel_communication.Instance.encapsulate_msg(store_Command_Request_Msg.ToByteArray());
- t_start_time = DateTime.Now;
- while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 3000)
- {
- if (m_store_command_response_msg != null)
- {
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "@@@ 接收到停车请求反馈:" + m_store_command_response_msg.ToString());
- if(m_store_command_response_msg.Code == null)
- {
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "@@@ 接收到停车请求反馈 code null" );
- }
- else
- {
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "@@@ 接收到停车请求反馈 code: "+ m_store_command_response_msg.ToString());
- }
- //查看反馈结果
- if (m_store_command_response_msg.Code?.ErrorCode == 0)
- {
- //通知打印机打印
- PrintManual.Instance.PrintTicket(car_Info.License, car_Info.CarNumberPlate);
- //通知单片机关门
- Message.terminal_msg terminal_Msg = new Message.terminal_msg();
- terminal_Msg.TerminalID = m_ternimalID;
- terminal_Msg.DispatchDirection = 1;
- terminal_Msg.ProcessControl = Message.Process_control.AutoClose;
- terminal_Msg.OutPutDo = new Message.OutputDo();
- //给单片机发送关门
- Singlechip_communication.Instance.encapsulate_msg(Singlechip_communication.Instance.m_stop_singlechip_index, Newtonsoft.Json.JsonConvert.SerializeObject(terminal_Msg));
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog(m_parking_license + " 停车成功,请取走小票!");
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "@@@ 停车请求反馈正常!" + m_store_command_response_msg.ToString() + "$$$" + m_store_command_response_msg.Code?.ErrorCode.ToString());
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog(" 停车请求反馈失败!" + m_store_command_response_msg.Code.ErrorDescription.ToString()+"号牌:"+ car_Info.CarNumberPlate + "车高等级:" + t_singlechip_msg.CarHeightStatusCurrent);
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 停车请求反馈失败!" + m_store_command_response_msg.ToString() + "$$$" + m_store_command_response_msg.Code?.ErrorCode.ToString());
- }
- break;
- }
- }
- if (m_store_command_response_msg == null)
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog(m_parking_license + " 停车反馈超时!");
- m_parking_license = "";
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, store_Command_Request_Msg.ToString() + " 停车反馈超时!发送时间:" + t_start_time.ToString() + " 当前时间:" + DateTime.Now.ToString());
- }
- m_parking_license = "";
- m_store_command_response_msg = null;
- }
- }
- else
- {
-
- MessageBoxForm message = new MessageBoxForm();
- message.ShowDialog(check_results);
- }
- }
- else
- {
- if (error.ErrorCode == 0 && !Singlechip_communication.Instance.check_entrance_statu())
- {
- MessageBoxForm message = new MessageBoxForm();
- message.ShowDialog("单片机未连接!");
- }
- else if (error.ErrorCode != 0 && Singlechip_communication.Instance.check_entrance_statu())
- {
- MessageBoxForm message = new MessageBoxForm();
- message.ShowDialog(error.ErrorDescription);
- }
- else if (error.ErrorCode != 0 && !Singlechip_communication.Instance.check_entrance_statu())
- {
- MessageBoxForm message = new MessageBoxForm();
- message.ShowDialog(error.ErrorDescription + "单片机未连接!");
- }
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.StackTrace);
- }
- }
- private void fetchingBtn_Click(object sender, EventArgs e)
- {
- ///停车终端
- //try
- //{
- // //检查各个节点连接状态
- // Message.Error_manager error = Channel_communication.Instance.check_statu();
- // if (error.ErrorCode == 0)
- // {
- // //此窗口只获取车牌号
- // FetchingForm fetchingForm = new FetchingForm();
- // fetchingForm.StartPosition = FormStartPosition.CenterScreen;
- // fetchingForm.BringToFront();
- // fetchingForm.ShowDialog();
- // if (fetchingForm.m_is_return)
- // {
- // return;
- // }
- // m_pickup_license = fetchingForm.m_license;
- // string tip_pickup_license = "";
- // if (m_pickup_license.Length == 16 || m_pickup_license.Length == 17)
- // {
- // tip_pickup_license = m_pickup_license.Substring(0, m_pickup_license.Length - 9);
- // }
- // else
- // {
- // tip_pickup_license = m_pickup_license;
- // }
- // //检查车牌号是否合法
- // if (tip_pickup_license.Length == 7 || tip_pickup_license.Length == 8)
- // {
- // //查询请求
- // Message.Parkspace_search_request_msg t_msg = new Message.Parkspace_search_request_msg();
- // //消息头
- // Message.Base_info baseInfo = new Message.Base_info();
- // baseInfo.MsgType = Message.Message_type.EParkspaceSearchRequestMsg;
- // baseInfo.Sender = Message.Communicator.ETerminor;
- // baseInfo.Receiver = Message.Communicator.EParkspace;
- // baseInfo.TimeoutMs = 1000;
- // //车辆信息--只需填充车牌号
- // Message.Car_info car_Info = new Message.Car_info();
- // car_Info.License = m_pickup_license;
- // //填充信息
- // t_msg.BaseInfo = baseInfo;
- // t_msg.CommandKey = GetUniqueIdentifier(8);
- // t_msg.CarInfo = car_Info;
- // //发送查询车辆请求
- // Channel_communication.Instance.encapsulate_msg(t_msg.ToByteArray());
- // DateTime t_start_time = DateTime.Now;
- // while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 500)
- // {
- // if (m_search_response_msg != null)
- // {
- // break;
- // }
- // }
- // if (m_search_response_msg != null)
- // {
- // //查看反馈结果
- // if (m_search_response_msg.ErrorManager.ErrorCode == 0)
- // {
- // //取车请求
- // Message.Pickup_command_request_msg t_pickup_command_request_msg = new Message.Pickup_command_request_msg();
- // //消息头
- // Message.Base_info t_baseInfo = new Message.Base_info();
- // baseInfo.MsgType = Message.Message_type.EPickupCommandRequestMsg;
- // baseInfo.Sender = Message.Communicator.ETerminor;
- // baseInfo.Receiver = Message.Communicator.EMain;
- // //车辆信息--只需填充车牌号
- // Message.Car_info t_car_Info = new Message.Car_info();
- // car_Info.License = m_pickup_license;
- // car_Info.CarNumberPlate = tip_pickup_license;
- // Message.Id_struct t_id_Struct = new Message.Id_struct();
- // //填充信息
- // t_pickup_command_request_msg.BaseInfo = baseInfo;
- // t_id_Struct.UnitId = m_search_response_msg.QueryParkspaceInfoEx[0].ParkingspaceUnitId; ;
- // t_pickup_command_request_msg.IdStruct = t_id_Struct;
- // t_pickup_command_request_msg.CarInfo = car_Info;
- // //发送取车请求
- // Channel_communication.Instance.encapsulate_msg(t_pickup_command_request_msg.ToByteArray());
- // //记录发送时间
- // t_start_time = DateTime.Now;
- // while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 500)
- // {
- // if (m_pickup_command_response_msg != null)
- // {
- // break;
- // }
- // }
- // if (m_pickup_command_response_msg != null)
- // {
- // if (m_pickup_command_response_msg.Code.ErrorCode == 0)
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(tip_pickup_license + "取车成功!请观察LED屏幕提示取车!");
- // }
- // else
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(tip_pickup_license + "取车反馈失败!" + m_pickup_command_response_msg.Code.ErrorDescription);
- // }
- // t_pickup_command_request_msg = null;
- // }
- // else
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(tip_pickup_license + "取车反馈超时!");
- // }
- // m_search_response_msg = null;
- // }
- // else
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(tip_pickup_license + "车位查询反馈错误!"+ m_search_response_msg.ErrorManager.ErrorDescription);
- // m_search_response_msg = null;
- // }
- // }
- // else
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(tip_pickup_license + "车位查询反馈超时!");
- // }
- // }
- // else
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(tip_pickup_license + "非正常车牌号!");
- // }
- // }
- // else
- // {
- // MessageBoxForm message = new MessageBoxForm();
- // message.ShowDialog(error.ErrorDescription);
- // }
- //}
- //catch(Exception ex)
- //{
- // MessageBox.Show(ex.StackTrace);
- //}
-
- }
- private void action_window_Load(object sender, EventArgs e)
- {
- this.terminal_number_label.Text = "智象泊车终端" + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber")) + 1).ToString() + "号机";
- this.terminal_number_english_label.Text = this.terminal_number_english_label.Text + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber")) + 1);
- //this.fetchingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "fetchingBtn_gray.BackgroundImage.png");
- //this.fetchingBtn.Enabled = false;
- if (MessageBox.Show("是否最大化?", "tip", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
- {
- //设置最大化
- this.WindowState = FormWindowState.Maximized;
- }
- //启动播放器
- m_mediaPlayer.mediaplayer_run();
- //显示提示
- m_tip_show_condition = true;
- m_tip_show_thread.Start();
- //启动打印机
- PrintManual.Instance.Start();
- m_auto_resize_form.controllInitializeSize(this);
- //启动子程序
- Process[] myprocess = Process.GetProcessesByName("UnNomalized_node");
- if (myprocess.Count() == 0 )
- {
- try
- {
- m_process = new Process();//创建一个新的进程
- ProcessStartInfo startInfo = new ProcessStartInfo();//启动进程时使用的集合
- startInfo.FileName = @".\UnNomalized_node\UnNomalized_node.exe"; ;//要启动的应用程序
- startInfo.WindowStyle = ProcessWindowStyle.Normal;//启动应用程序时使用的窗口状态
- m_process.StartInfo = startInfo;//把启动进程的信息赋值给新建的进程
- m_process.StartInfo.UseShellExecute = true;//是否使用操作系统shell执行该程序
- m_process.Start();
- }
- catch (Exception)
- {
- }
- }
- }
- 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();
- //关闭显示提示
- m_tip_show_condition = false;
- m_tip_show_thread.Abort();
- //关闭数据管理的线程
- Front_terminal_manager.Instance.front_terminal_manager_uninit();
- //关闭打印机
- PrintManual.Instance.Close();
- //关闭子程序
- if (m_process != null && !m_process.HasExited)
- {
- m_process.Kill();
- }
- }
- private void axWindowsMediaPlayer1_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
- {
- if (this.axWindowsMediaPlayer.fullScreen == true)
- {
- this.axWindowsMediaPlayer.fullScreen = false;
- }
- }
- private void action_window_SizeChanged(object sender, EventArgs e)
- {
- m_auto_resize_form.controlAutoSize(this);
- }
- //设置存车的反馈--由上层调用
- public void set_store_response_msg(Message.Store_command_response_msg t_store_command_response_msg)
- {
- m_store_command_response_msg = new Message.Store_command_response_msg();
- m_store_command_response_msg = t_store_command_response_msg;
- }
- //设置查询的反馈--由上层调用
- public void set_search_response_msg(Message.Parkspace_search_response_msg t_search_response_msg)
- {
- //反馈是否与自己查询的车辆
- if (t_search_response_msg.QueryParkspaceInfoEx[0].CarInfo.License == m_pickup_license)
- {
- m_search_response_msg = new Message.Parkspace_search_response_msg();
- m_search_response_msg = t_search_response_msg;
- }
- }
- //设置取车的反馈--由上层调用
- public void set_pickup_response_msg(Message.Pickup_command_response_msg t_pickup_command_response_msg)
- {
- m_pickup_command_response_msg = new Message.Pickup_command_response_msg();
- m_pickup_command_response_msg = t_pickup_command_response_msg;
- }
- //生成指定长度唯一码
- public static string GetUniqueIdentifier(int length)
- {
- int maxSize = length;
- char[] chars = new char[62];
- string a;
- a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- chars = a.ToCharArray();
- int size = maxSize;
- byte[] data = new byte[1];
- var crypto = new RNGCryptoServiceProvider();
- crypto.GetNonZeroBytes(data);
- size = maxSize;
- data = new byte[size];
- crypto.GetNonZeroBytes(data);
- var result = new StringBuilder(size);
- foreach (byte b in data)
- {
- result.Append(chars[b % (chars.Length - 1)]);
- }
- if (result[0] >= '0' && result[0] <= '9')
- {
- return GetUniqueIdentifier(length);
- }
- return result.ToString();
- }
- //设置天气
- public void set_weatherLab_text(string str)
- {
- this.weather_label.Text = str;
- }
- //设置气温
- public void set_temperatureLab_text(string str)
- {
- this.temperature_label.Text = str;
- }
- public static void Speaking(string saying)
- {
- string say = saying;
- Task task = new Task(() =>
- {
- SpeechSynthesizer speech = new SpeechSynthesizer();
- speech.Volume = 100; //音量
- speech.Rate = -1;
- CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
- InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault();
- if (neededVoice == null)
- {
- say = "未知的操作";
- }
- else
- {
- speech.SelectVoice(neededVoice.VoiceInfo.Name);
- }
- speech.Speak(say);
- });
- task.Start();
- }
- //检查各模块状态 看能否发送消息
- public string check_status(Message.UnNormalized_module_statu_msg unNormalized_Module,Message.Singlechip_data t_singlechip_msg,Message.Ground_status_msg t_ground_status_msg)
- {
- int border_statu = t_ground_status_msg.BorderStatus;
- string results = "";
- //检车门内光电
- if (t_singlechip_msg.InsideExistenceFlag != 1)
- {
- results = "无车!";
- return results;
- }
- //检测号牌
- if (unNormalized_Module.CarLicense == "" )
- {
- results = "号牌机未拍摄到号牌,请尝试重新进入!";
- return results;
- }
- //检测光电超界信息
- switch (t_singlechip_msg.OverBorderStatus)
- {
- case Message.Over_border_status.Normal:
- {
- } break;
- case Message.Over_border_status.Front:
- {
- results = results + "前超界!";
- }
- break;
- case Message.Over_border_status.Left:
- {
- results = results + "左超界!";
- }
- break;
- case Message.Over_border_status.Right:
- {
- results = results + "右超界!";
- }
- break;
- case Message.Over_border_status.Back:
- {
- results = results + "后超界!";
- }
- break;
- default:
- {
- results = results + "单片机超界信息错误!";
- }
- break;
- }
- //检测雷达状态
- if (t_ground_status_msg.ErrorManager.ErrorCode != 0)
- {
- results = results + t_ground_status_msg.ErrorManager.ErrorDescription;
- }
- //检测非标状态
- if (unNormalized_Module.StatuCode.ErrorCode != 0)
- {
- results = results + unNormalized_Module.StatuCode.ErrorDescription;
- }
- //检测雷达超界信息
- if (((border_statu >> 0) & 0x01) > 0)
- {
- results = results + "前超界!";
- }
- if (((border_statu >> 1) & 0x01) > 0)
- {
- results = results + "后超界!";
- }
- if (((border_statu >> 2) & 0x01) > 0)
- {
- results = results + "左超界!";
- }
- if (((border_statu >> 3) & 0x01) > 0)
- {
- results = results + "右超界!";
- }
- if (((border_statu >> 6) & 0x01) > 0)
- {
- results = results + "车辆超宽!";
- }
- if (((border_statu >> 7) & 0x01) > 0)
- {
- results = results + "轴距超差!";
- }
- if (((border_statu >> 8) & 0x01) > 0 || ((border_statu >> 9) & 0x01) > 0)
- {
- results = results + "车辆倾斜严重!";
- }
- if (((border_statu >> 10) & 0x01) > 0)
- {
- results = results + "方向盘未回正!";
- }
- return results;
- }
- }
- }
-
|