123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- 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 string m_search_response_commedkey;
- //子进程
- private Process m_process;
-
- public action_window()
- {
- InitializeComponent();
- m_parking_license = "";
- m_pickup_license = "";
- m_search_response_commedkey = "";
- // 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);
- }
- //显示提示框
- private void tip_show_thread()
- {
- while (m_tip_show_condition)
- {
- //检查各个节点连接状态
- Message.Error_manager error = Channel_communication.Instance.check_statu();
- if (error.ErrorCode == 0 )
- {
- 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.parkingBtn.Enabled = true;
- this.fetchingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "fetchingBtn.BackgroundImage.png"); ;
- this.fetchingBtn.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;
- }));
- 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)
- {
- //取车终端
- ////检查各个节点连接状态
- //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();
- // //单片机检测门内有车,门内车未超界,雷达扫描未超界,号牌机拍摄到的号牌不为空。满足以上需求才可停车
- // if (t_singlechip_msg.InsideExistenceFlag == 1 &&
- // t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Normal &&
- // t_ground_status_msg.ErrorManager.ErrorCode == 0 &&
- // unNormalized_Module.StatuCode.ErrorCode == 0 &&
- // unNormalized_Module.CarLicense != "")
- // {
- // 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();
- // 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 < 300)
- // {
- // 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;
- // car_Info.License = unNormalized_Module.CarLicense + ":" + GetUniqueIdentifier(8);
- // 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;
- // store_Command_Request_Msg.IdStruct.TerminalId = m_ternimalID;
- // 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) < 500)
- // {
- // if (m_store_command_response_msg != null)
- // {
- // break;
- // }
- // }
- // if (m_store_command_response_msg != null)
- // {
- // //查看反馈结果
- // if (m_store_command_response_msg.Code.ErrorCode == 0)
- // {
- // //通知打印机打印
- // PrintManual.Instance.PrintTicket(car_Info.License);
- // //通知单片机关门
- // 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 + " 停车成功,请取走小票!");
- // }
- // else
- // {
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(" 停车请求有误!" + m_store_command_response_msg.Code.ErrorDescription);
- // Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 停车请求有误!" + m_store_command_response_msg.Code.ErrorDescription);
- // }
- // m_parking_license = "";
- // m_store_command_response_msg = null;
- // }
- // else
- // {
- // Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, store_Command_Request_Msg.ToString() + " 停车反馈超时!发送时间:" + t_start_time.ToString() + " 当前时间:" + DateTime.Now.ToString());
- // MessageBoxForm messageBoxForm = new MessageBoxForm();
- // messageBoxForm.ShowDialog(m_parking_license + " 停车反馈超时!");
- // }
- // }
- // }
- // else
- // {
- // string str = "";
- // if (t_singlechip_msg.InsideExistenceFlag == 0)
- // {
- // str = str + "无车!";
- // }
- // else
- // {
- // if (unNormalized_Module.CarLicense == "")
- // {
- // str = str + "号牌机未拍摄到号牌,请尝试重新进入!";
- // }
- // else
- // {
- // if (t_singlechip_msg.OverBorderStatus != Message.Over_border_status.Normal)
- // {
- // if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Front)
- // {
- // str = str + "前超界!";
- // }
- // else if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Back)
- // {
- // str = str + "后超界!";
- // }
- // else if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Left)
- // {
- // str = str + "左超界!";
- // }
- // else if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Right)
- // {
- // str = str + "右超界!";
- // }
- // else
- // {
- // str = str + "单片机超界信息错误!";
- // }
- // }
- // if (t_ground_status_msg.ErrorManager.ErrorCode != 0)
- // {
- // str = str + t_ground_status_msg.ErrorManager.ErrorDescription;
- // }
- // }
- // if (unNormalized_Module.StatuCode.ErrorCode != 0)
- // {
- // str = str + unNormalized_Module.StatuCode.ErrorDescription;
- // }
- // }
- // MessageBoxForm message = new MessageBoxForm();
- // message.ShowDialog(str);
- // }
- //}
- //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 + "单片机未连接!");
- // }
- //}
- }
- 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;
- }
- //处理车牌号
- string tip_pickup_license = "";
- m_pickup_license = fetchingForm?.m_license;
- //MessageBox.Show("车牌号:" + tip_pickup_license + "\n" + "车牌号+唯一码:" + m_pickup_license);
- //检查唯一码是否是16位
- if (m_pickup_license.Length == 16 )
- {
- //查询请求
- 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;
- //填充唯一码 反馈判断凭证
- m_search_response_commedkey = GetUniqueIdentifier(10);
- //填充信息
- t_msg.BaseInfo = baseInfo;
- t_msg.CommandKey = m_search_response_commedkey;
- t_msg.CarInfo = car_Info;
- //发送查询车辆请求
- Channel_communication.Instance.encapsulate_msg(t_msg.ToByteString());
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 查询请求:" + t_msg.ToString());
- DateTime t_start_time = DateTime.Now;
- while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 1000)
- {
- if (m_search_response_msg != null)
- {
- break;
- }
- }
- if (m_search_response_msg != null)
- {
- //查看反馈结果
- if (m_search_response_msg?.ErrorManager?.ErrorCode == 0)
- {
- tip_pickup_license = m_search_response_msg.QueryParkspaceInfoEx[0].CarInfo.CarNumberPlate;
- //取车请求
- 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.ToByteString());
- //MessageBox.Show("发送查询请求:" + t_pickup_command_request_msg.ToString());
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 取车请求:" + t_pickup_command_request_msg.ToString());
- //记录发送时间
- t_start_time = DateTime.Now;
- while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 3000)
- {
- 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.ToString());
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, tip_pickup_license + "取车反馈失败!" + m_pickup_command_response_msg.ToString());
- }
- break;
- }
- }
- if (m_pickup_command_response_msg == null)
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog(tip_pickup_license + "取车反馈超时!");
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, tip_pickup_license + "取车反馈超时!");
- }
- m_pickup_command_response_msg = null;
- m_search_response_commedkey = "";
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog("车位查询反馈错误!"+ m_search_response_msg.ErrorManager.ErrorDescription);
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "车位查询反馈错误!" + m_search_response_msg.ToString());
- }
- m_search_response_msg = null;
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog("车位查询反馈超时!");
- }
- }
- else
- {
- MessageBoxForm messageBoxForm = new MessageBoxForm();
- messageBoxForm.ShowDialog("凭证码:"+m_pickup_license +" 长度:"+m_pickup_license.Length.ToString() + " 长度有误!",true,10);
- Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "凭证码:" + m_pickup_license + " 长度:" + m_pickup_license.Length.ToString() + " 长度有误!");
- }
- }
- else
- {
- MessageBoxForm message = new MessageBoxForm();
- message.ShowDialog(error.ErrorDescription);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message+ 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.parkingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "parkingBtn_gray.BackgroundImage.png");
- //this.parkingBtn.Enabled = true;
- 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();
- }
- 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)
- {
- //只处理本终端的消息
- //if (t_store_command_response_msg.TerminalId == m_terminal_id)
- //{
- 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.CommandKey == m_search_response_commedkey)
- {
- 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)
- {
- //反馈是否与自己查询的车辆一致
- if (t_pickup_command_response_msg.License == m_pickup_license )
- {
- 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();
- }
- }
- }
-
|