action_window.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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.front_terminal_manager;
  15. using System.Threading;
  16. using Kitware.VTK;
  17. using Google.Protobuf;
  18. using System.Security.Cryptography;
  19. using System.Diagnostics;
  20. using System.Speech.Synthesis;
  21. using System.Globalization;
  22. namespace chutian_parking_terminal
  23. {
  24. public partial class action_window : Form
  25. {
  26. //自适应窗口大小
  27. AutoResizeForm m_auto_resize_form = new AutoResizeForm();
  28. //显示视频,图片,等
  29. private MediaPlayer m_mediaPlayer;
  30. //显示提示框
  31. private Thread m_tip_show_thread;
  32. private bool m_tip_show_condition;
  33. //本终端终端号
  34. private int m_ternimalID;
  35. //存车反馈
  36. private Message.Store_command_response_msg m_store_command_response_msg;
  37. //查询反馈
  38. private Message.Parkspace_search_response_msg m_search_response_msg;
  39. //取车反馈
  40. private Message.Pickup_command_response_msg m_pickup_command_response_msg;
  41. //存车车牌号
  42. private string m_parking_license;
  43. //取车车牌号
  44. private string m_pickup_license;
  45. //查询反馈唯一码
  46. private string m_search_response_commedkey;
  47. //子进程
  48. private Process m_process;
  49. public action_window()
  50. {
  51. InitializeComponent();
  52. m_parking_license = "";
  53. m_pickup_license = "";
  54. m_search_response_commedkey = "";
  55. // parkingBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
  56. fetchingBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
  57. //初始化日志记录
  58. Log.Instance.LogInit();
  59. //初始化json文件操作
  60. json_file_operation.Instance.json_file_operation_init("./settings.json");
  61. m_ternimalID = int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber"));
  62. //初始化数据缓冲区
  63. Front_terminal_manager.Instance.front_terminal_manager_init(int.Parse(json_file_operation.Instance.read_json_string("pickup_singleChip_connect_count")));
  64. //初始化通信
  65. Channel_communication.Instance.channel_communication_init();
  66. //Singlechip_communication.Instance.singlechip_communication_init();//单片机通信
  67. //Singlechip_communication.Instance.singlechip_communication_connect();//默认从settings.json文件读取端口和IP
  68. //初始化打印机
  69. //PrintManual.Instance.PrintManualInit();
  70. //创建显示器
  71. m_mediaPlayer = new MediaPlayer();
  72. //初始化显示器
  73. 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);
  74. //初始化提示显示线程
  75. m_tip_show_thread = new Thread(tip_show_thread);
  76. //初始化反馈
  77. m_store_command_response_msg = null;
  78. m_search_response_msg = null;
  79. m_pickup_command_response_msg = null;
  80. //设置回调函数
  81. Channel_communication.Instance.SetStoreResponseMsgDelegate(set_store_response_msg);
  82. Channel_communication.Instance.SetPickupResponseMsgDelegate(set_pickup_response_msg);
  83. Channel_communication.Instance.SetParkspaceSearchMsgDelegate(set_search_response_msg);
  84. }
  85. //显示提示框
  86. private void tip_show_thread()
  87. {
  88. while (m_tip_show_condition)
  89. {
  90. //检查各个节点连接状态
  91. Message.Error_manager error = Channel_communication.Instance.check_statu();
  92. if (error.ErrorCode == 0 )
  93. {
  94. Front_terminal_manager.Instance.get_tip_data_buffer().set_tip_str("系统正常!");
  95. this.Invoke(new Action(() =>
  96. {
  97. //this.parkingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "parkingBtn.BackgroundImage.png");
  98. //this.parkingBtn.Enabled = true;
  99. this.fetchingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "fetchingBtn.BackgroundImage.png"); ;
  100. this.fetchingBtn.Enabled = true;
  101. }));
  102. }
  103. else
  104. {
  105. this.Invoke(new Action(() =>
  106. {
  107. //this.parkingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "parkingBtn_gray.BackgroundImage.png");
  108. //this.parkingBtn.Enabled = false;
  109. this.fetchingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "fetchingBtn_gray.BackgroundImage.png");
  110. this.fetchingBtn.Enabled = false;
  111. }));
  112. Front_terminal_manager.Instance.get_tip_data_buffer().set_tip_str(error.ErrorDescription);
  113. }
  114. if (this.InvokeRequired)
  115. {
  116. this.Invoke(new Action(() =>
  117. {
  118. tip_label.Text = Front_terminal_manager.Instance.get_tip_data_buffer().get_tip_str();
  119. }));
  120. }
  121. else
  122. {
  123. tip_label.Text = Front_terminal_manager.Instance.get_tip_data_buffer().get_tip_str();
  124. }
  125. Thread.Sleep(100);
  126. }
  127. }
  128. private void parkingBtn_Click(object sender, EventArgs e)
  129. {
  130. //取车终端
  131. ////检查各个节点连接状态
  132. //Message.Error_manager error = Channel_communication.Instance.check_statu();
  133. //if (error.ErrorCode == 0 && Singlechip_communication.Instance.check_entrance_statu())
  134. //{
  135. // //判断能否发送停车请求。
  136. // Message.UnNormalized_module_statu_msg unNormalized_Module = Front_terminal_manager.Instance.get_unnormalized_module_data_bufferr().get_unnormalized_module_status_msg();
  137. // Message.Singlechip_data t_singlechip_msg = Front_terminal_manager.Instance.get_singlechip_data_bufferr().get_entrance_singlechip_msg();
  138. // Message.Ground_status_msg t_ground_status_msg = Front_terminal_manager.Instance.get_ground_radar_data_buffer().get_ground_status_msg();
  139. // //单片机检测门内有车,门内车未超界,雷达扫描未超界,号牌机拍摄到的号牌不为空。满足以上需求才可停车
  140. // if (t_singlechip_msg.InsideExistenceFlag == 1 &&
  141. // t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Normal &&
  142. // t_ground_status_msg.ErrorManager.ErrorCode == 0 &&
  143. // unNormalized_Module.StatuCode.ErrorCode == 0 &&
  144. // unNormalized_Module.CarLicense != "")
  145. // {
  146. // Message.Store_command_request_msg store_Command_Request_Msg = new Message.Store_command_request_msg();
  147. // Message.Base_info t_base_info = new Message.Base_info();
  148. // t_base_info.MsgType = Message.Message_type.EStoreCommandRequestMsg;
  149. // t_base_info.Sender = Message.Communicator.ETerminor;
  150. // t_base_info.Receiver = Message.Communicator.EMain;
  151. // //地面雷达的 实时定位信息
  152. // Message.Locate_information locateInformation = new Message.Locate_information();
  153. // //获取雷达的测量数据 雷达不稳定有可能状态正常但是测量失败 所以测量500毫秒
  154. // DateTime t_start_time = DateTime.Now;
  155. // while (DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000 < 300)
  156. // {
  157. // locateInformation = Front_terminal_manager.Instance.get_ground_radar_data_buffer().get_ground_status_msg().LocateInformationRealtime;
  158. // if (locateInformation.LocateCorrect)
  159. // {
  160. // break;
  161. // }
  162. // }
  163. // if (!locateInformation.LocateCorrect)
  164. // {
  165. // MessageBoxForm message = new MessageBoxForm();
  166. // message.ShowDialog("雷达测量失败!");
  167. // }
  168. // else
  169. // {
  170. // /*用单片机的数据填充车辆信息*/
  171. // Message.Car_info car_Info = new Message.Car_info();
  172. // car_Info.CarNumberPlate = unNormalized_Module.CarLicense;
  173. // car_Info.License = unNormalized_Module.CarLicense + ":" + GetUniqueIdentifier(8);
  174. // m_parking_license = unNormalized_Module.CarLicense;
  175. // if (t_singlechip_msg.CarHeightStatusCurrent == Message.Car_height_status.Small)
  176. // {
  177. // car_Info.CarHeight = 1.5f;
  178. // }
  179. // else if (t_singlechip_msg.CarHeightStatusCurrent == Message.Car_height_status.Medium)
  180. // {
  181. // car_Info.CarHeight = 1.7f;
  182. // }
  183. // else if (t_singlechip_msg.CarHeightStatusCurrent == Message.Car_height_status.Large)
  184. // {
  185. // car_Info.CarHeight = 1.9f;
  186. // }
  187. // else
  188. // {
  189. // car_Info.CarHeight = 2.2f;
  190. // }
  191. // car_Info.CarWheelBase = locateInformation.LocateWheelBase;
  192. // car_Info.CarWheelWidth = locateInformation.LocateWheelWidth;
  193. // store_Command_Request_Msg.BaseInfo = t_base_info;
  194. // store_Command_Request_Msg.IdStruct.TerminalId = m_ternimalID;
  195. // store_Command_Request_Msg.LocateInformation = locateInformation;
  196. // store_Command_Request_Msg.CarInfo = car_Info;
  197. // //发送停车请求
  198. // Channel_communication.Instance.encapsulate_msg(store_Command_Request_Msg.ToByteArray());
  199. // t_start_time = DateTime.Now;
  200. // while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 500)
  201. // {
  202. // if (m_store_command_response_msg != null)
  203. // {
  204. // break;
  205. // }
  206. // }
  207. // if (m_store_command_response_msg != null)
  208. // {
  209. // //查看反馈结果
  210. // if (m_store_command_response_msg.Code.ErrorCode == 0)
  211. // {
  212. // //通知打印机打印
  213. // PrintManual.Instance.PrintTicket(car_Info.License);
  214. // //通知单片机关门
  215. // Message.terminal_msg terminal_Msg = new Message.terminal_msg();
  216. // terminal_Msg.TerminalID = m_ternimalID;
  217. // terminal_Msg.DispatchDirection = 1;
  218. // terminal_Msg.ProcessControl = Message.Process_control.AutoClose;
  219. // terminal_Msg.OutPutDo = new Message.OutputDo();
  220. // //给单片机发送关门
  221. // Singlechip_communication.Instance.encapsulate_msg(Singlechip_communication.Instance.m_stop_singlechip_index, Newtonsoft.Json.JsonConvert.SerializeObject(terminal_Msg));
  222. // MessageBoxForm messageBoxForm = new MessageBoxForm();
  223. // messageBoxForm.ShowDialog(m_parking_license + " 停车成功,请取走小票!");
  224. // }
  225. // else
  226. // {
  227. // MessageBoxForm messageBoxForm = new MessageBoxForm();
  228. // messageBoxForm.ShowDialog(" 停车请求有误!" + m_store_command_response_msg.Code.ErrorDescription);
  229. // Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 停车请求有误!" + m_store_command_response_msg.Code.ErrorDescription);
  230. // }
  231. // m_parking_license = "";
  232. // m_store_command_response_msg = null;
  233. // }
  234. // else
  235. // {
  236. // Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, store_Command_Request_Msg.ToString() + " 停车反馈超时!发送时间:" + t_start_time.ToString() + " 当前时间:" + DateTime.Now.ToString());
  237. // MessageBoxForm messageBoxForm = new MessageBoxForm();
  238. // messageBoxForm.ShowDialog(m_parking_license + " 停车反馈超时!");
  239. // }
  240. // }
  241. // }
  242. // else
  243. // {
  244. // string str = "";
  245. // if (t_singlechip_msg.InsideExistenceFlag == 0)
  246. // {
  247. // str = str + "无车!";
  248. // }
  249. // else
  250. // {
  251. // if (unNormalized_Module.CarLicense == "")
  252. // {
  253. // str = str + "号牌机未拍摄到号牌,请尝试重新进入!";
  254. // }
  255. // else
  256. // {
  257. // if (t_singlechip_msg.OverBorderStatus != Message.Over_border_status.Normal)
  258. // {
  259. // if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Front)
  260. // {
  261. // str = str + "前超界!";
  262. // }
  263. // else if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Back)
  264. // {
  265. // str = str + "后超界!";
  266. // }
  267. // else if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Left)
  268. // {
  269. // str = str + "左超界!";
  270. // }
  271. // else if (t_singlechip_msg.OverBorderStatus == Message.Over_border_status.Right)
  272. // {
  273. // str = str + "右超界!";
  274. // }
  275. // else
  276. // {
  277. // str = str + "单片机超界信息错误!";
  278. // }
  279. // }
  280. // if (t_ground_status_msg.ErrorManager.ErrorCode != 0)
  281. // {
  282. // str = str + t_ground_status_msg.ErrorManager.ErrorDescription;
  283. // }
  284. // }
  285. // if (unNormalized_Module.StatuCode.ErrorCode != 0)
  286. // {
  287. // str = str + unNormalized_Module.StatuCode.ErrorDescription;
  288. // }
  289. // }
  290. // MessageBoxForm message = new MessageBoxForm();
  291. // message.ShowDialog(str);
  292. // }
  293. //}
  294. //else
  295. //{
  296. // if (error.ErrorCode == 0 && !Singlechip_communication.Instance.check_entrance_statu())
  297. // {
  298. // MessageBoxForm message = new MessageBoxForm();
  299. // message.ShowDialog("单片机未连接!");
  300. // }
  301. // else if (error.ErrorCode != 0 && Singlechip_communication.Instance.check_entrance_statu())
  302. // {
  303. // MessageBoxForm message = new MessageBoxForm();
  304. // message.ShowDialog(error.ErrorDescription);
  305. // }
  306. // else if (error.ErrorCode != 0 && !Singlechip_communication.Instance.check_entrance_statu())
  307. // {
  308. // MessageBoxForm message = new MessageBoxForm();
  309. // message.ShowDialog(error.ErrorDescription + "单片机未连接!");
  310. // }
  311. //}
  312. }
  313. private void fetchingBtn_Click(object sender, EventArgs e)
  314. {
  315. try
  316. {
  317. //检查各个节点连接状态
  318. Message.Error_manager error = Channel_communication.Instance.check_statu();
  319. if (error.ErrorCode == 0)
  320. {
  321. //此窗口只获取车牌号
  322. FetchingForm fetchingForm = new FetchingForm();
  323. fetchingForm.StartPosition = FormStartPosition.CenterScreen;
  324. fetchingForm.BringToFront();
  325. fetchingForm.ShowDialog();
  326. if (fetchingForm.m_is_return)
  327. {
  328. return;
  329. }
  330. //处理车牌号
  331. string tip_pickup_license = "";
  332. m_pickup_license = fetchingForm?.m_license;
  333. //MessageBox.Show("车牌号:" + tip_pickup_license + "\n" + "车牌号+唯一码:" + m_pickup_license);
  334. //检查唯一码是否是16位
  335. if (m_pickup_license.Length == 16 )
  336. {
  337. //查询请求
  338. Message.Parkspace_search_request_msg t_msg = new Message.Parkspace_search_request_msg();
  339. //消息头
  340. Message.Base_info baseInfo = new Message.Base_info();
  341. baseInfo.MsgType = Message.Message_type.EParkspaceSearchRequestMsg;
  342. baseInfo.Sender = Message.Communicator.ETerminor;
  343. baseInfo.Receiver = Message.Communicator.EParkspace;
  344. baseInfo.TimeoutMs = 1000;
  345. //车辆信息--只需填充车牌号
  346. Message.Car_info car_Info = new Message.Car_info();
  347. car_Info.License = m_pickup_license;
  348. //填充唯一码 反馈判断凭证
  349. m_search_response_commedkey = GetUniqueIdentifier(10);
  350. //填充信息
  351. t_msg.BaseInfo = baseInfo;
  352. t_msg.CommandKey = m_search_response_commedkey;
  353. t_msg.CarInfo = car_Info;
  354. //发送查询车辆请求
  355. Channel_communication.Instance.encapsulate_msg(t_msg.ToByteString());
  356. Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 查询请求:" + t_msg.ToString());
  357. DateTime t_start_time = DateTime.Now;
  358. while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 1000)
  359. {
  360. if (m_search_response_msg != null)
  361. {
  362. break;
  363. }
  364. }
  365. if (m_search_response_msg != null)
  366. {
  367. //查看反馈结果
  368. if (m_search_response_msg?.ErrorManager?.ErrorCode == 0)
  369. {
  370. tip_pickup_license = m_search_response_msg.QueryParkspaceInfoEx[0].CarInfo.CarNumberPlate;
  371. //取车请求
  372. Message.Pickup_command_request_msg t_pickup_command_request_msg = new Message.Pickup_command_request_msg();
  373. //消息头
  374. Message.Base_info t_baseInfo = new Message.Base_info();
  375. baseInfo.MsgType = Message.Message_type.EPickupCommandRequestMsg;
  376. baseInfo.Sender = Message.Communicator.ETerminor;
  377. baseInfo.Receiver = Message.Communicator.EMain;
  378. //车辆信息--只需填充车牌号
  379. Message.Car_info t_car_Info = new Message.Car_info();
  380. car_Info.License = m_pickup_license;
  381. car_Info.CarNumberPlate = tip_pickup_license;
  382. Message.Id_struct t_id_struct = new Message.Id_struct();
  383. //填充信息
  384. t_pickup_command_request_msg.BaseInfo = baseInfo;
  385. t_id_struct.UnitId = m_search_response_msg.QueryParkspaceInfoEx[0].ParkingspaceUnitId;
  386. t_pickup_command_request_msg.IdStruct = t_id_struct;
  387. t_pickup_command_request_msg.CarInfo = car_Info;
  388. //发送取车请求
  389. Channel_communication.Instance.encapsulate_msg(t_pickup_command_request_msg.ToByteString());
  390. //MessageBox.Show("发送查询请求:" + t_pickup_command_request_msg.ToString());
  391. Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, " 取车请求:" + t_pickup_command_request_msg.ToString());
  392. //记录发送时间
  393. t_start_time = DateTime.Now;
  394. while ((DateTime.Now.Ticks / 10000 - t_start_time.Ticks / 10000) < 3000)
  395. {
  396. if (m_pickup_command_response_msg != null)
  397. {
  398. if (m_pickup_command_response_msg.Code?.ErrorCode == 0)
  399. {
  400. MessageBoxForm messageBoxForm = new MessageBoxForm();
  401. messageBoxForm.ShowDialog(tip_pickup_license + "取车成功!请观察LED屏幕提示取车!");
  402. }
  403. else
  404. {
  405. MessageBoxForm messageBoxForm = new MessageBoxForm();
  406. messageBoxForm.ShowDialog(tip_pickup_license + "取车反馈失败!" + m_pickup_command_response_msg.Code.ToString());
  407. Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, tip_pickup_license + "取车反馈失败!" + m_pickup_command_response_msg.ToString());
  408. }
  409. break;
  410. }
  411. }
  412. if (m_pickup_command_response_msg == null)
  413. {
  414. MessageBoxForm messageBoxForm = new MessageBoxForm();
  415. messageBoxForm.ShowDialog(tip_pickup_license + "取车反馈超时!");
  416. Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, tip_pickup_license + "取车反馈超时!");
  417. }
  418. m_pickup_command_response_msg = null;
  419. m_search_response_commedkey = "";
  420. }
  421. else
  422. {
  423. MessageBoxForm messageBoxForm = new MessageBoxForm();
  424. messageBoxForm.ShowDialog("车位查询反馈错误!"+ m_search_response_msg.ErrorManager.ErrorDescription);
  425. Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "车位查询反馈错误!" + m_search_response_msg.ToString());
  426. }
  427. m_search_response_msg = null;
  428. }
  429. else
  430. {
  431. MessageBoxForm messageBoxForm = new MessageBoxForm();
  432. messageBoxForm.ShowDialog("车位查询反馈超时!");
  433. }
  434. }
  435. else
  436. {
  437. MessageBoxForm messageBoxForm = new MessageBoxForm();
  438. messageBoxForm.ShowDialog("凭证码:"+m_pickup_license +" 长度:"+m_pickup_license.Length.ToString() + " 长度有误!",true,10);
  439. Log.Instance.WriteLog(LogType.PROCESS, LogFile.LOG, "凭证码:" + m_pickup_license + " 长度:" + m_pickup_license.Length.ToString() + " 长度有误!");
  440. }
  441. }
  442. else
  443. {
  444. MessageBoxForm message = new MessageBoxForm();
  445. message.ShowDialog(error.ErrorDescription);
  446. }
  447. }
  448. catch (Exception ex)
  449. {
  450. MessageBox.Show(ex.Message+ ex.StackTrace);
  451. }
  452. }
  453. private void action_window_Load(object sender, EventArgs e)
  454. {
  455. this.terminal_number_label.Text = "智象泊车终端" + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber")) + 1).ToString() + "号机";
  456. this.terminal_number_english_label.Text = this.terminal_number_english_label.Text + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber")) + 1);
  457. //this.parkingBtn.BackgroundImage = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "./Resource/" + "parkingBtn_gray.BackgroundImage.png");
  458. //this.parkingBtn.Enabled = true;
  459. if (MessageBox.Show("是否最大化?", "tip", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
  460. {
  461. //设置最大化
  462. this.WindowState = FormWindowState.Maximized;
  463. }
  464. //启动播放器
  465. m_mediaPlayer.mediaplayer_run();
  466. //显示提示
  467. m_tip_show_condition = true;
  468. m_tip_show_thread.Start();
  469. //启动打印机
  470. //PrintManual.Instance.Start();
  471. m_auto_resize_form.controllInitializeSize(this);
  472. ////启动子程序
  473. //Process[] myprocess = Process.GetProcessesByName("UnNomalized_node");
  474. //if (myprocess.Count() == 0 )
  475. //{
  476. // try
  477. // {
  478. // m_process = new Process();//创建一个新的进程
  479. // ProcessStartInfo startInfo = new ProcessStartInfo();//启动进程时使用的集合
  480. // startInfo.FileName = @".\UnNomalized_node\UnNomalized_node.exe"; ;//要启动的应用程序
  481. // startInfo.WindowStyle = ProcessWindowStyle.Normal;//启动应用程序时使用的窗口状态
  482. // m_process.StartInfo = startInfo;//把启动进程的信息赋值给新建的进程
  483. // m_process.StartInfo.UseShellExecute = true;//是否使用操作系统shell执行该程序
  484. // m_process.Start();
  485. // }
  486. // catch (Exception)
  487. // {
  488. // }
  489. //}
  490. }
  491. private void action_window_FormClosing(object sender, FormClosingEventArgs e)
  492. {
  493. //关闭播放器
  494. m_mediaPlayer.mediaplayer_uninit();
  495. //关闭单片机通信
  496. //Singlechip_communication.Instance.singlechip_communication_uninit();
  497. //关闭出入口通信
  498. Channel_communication.Instance.channel_communication_uninit();
  499. //关闭显示提示
  500. m_tip_show_condition = false;
  501. m_tip_show_thread.Abort();
  502. //关闭数据管理的线程
  503. Front_terminal_manager.Instance.front_terminal_manager_uninit();
  504. //关闭打印机
  505. //PrintManual.Instance.Close();
  506. }
  507. private void axWindowsMediaPlayer1_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
  508. {
  509. if (this.axWindowsMediaPlayer.fullScreen == true)
  510. {
  511. this.axWindowsMediaPlayer.fullScreen = false;
  512. }
  513. }
  514. private void action_window_SizeChanged(object sender, EventArgs e)
  515. {
  516. m_auto_resize_form.controlAutoSize(this);
  517. }
  518. //设置存车的反馈--由上层调用
  519. public void set_store_response_msg(Message.Store_command_response_msg t_store_command_response_msg)
  520. {
  521. //只处理本终端的消息
  522. //if (t_store_command_response_msg.TerminalId == m_terminal_id)
  523. //{
  524. m_store_command_response_msg = new Message.Store_command_response_msg();
  525. m_store_command_response_msg = t_store_command_response_msg;
  526. //}
  527. }
  528. //设置查询的反馈--由上层调用
  529. public void set_search_response_msg(Message.Parkspace_search_response_msg t_search_response_msg)
  530. {
  531. //反馈是否与自己查询的车辆一致
  532. if (t_search_response_msg.CommandKey == m_search_response_commedkey)
  533. {
  534. m_search_response_msg = new Message.Parkspace_search_response_msg();
  535. m_search_response_msg = t_search_response_msg;
  536. }
  537. }
  538. //设置取车的反馈--由上层调用
  539. public void set_pickup_response_msg(Message.Pickup_command_response_msg t_pickup_command_response_msg)
  540. {
  541. //反馈是否与自己查询的车辆一致
  542. if (t_pickup_command_response_msg.License == m_pickup_license )
  543. {
  544. m_pickup_command_response_msg = new Message.Pickup_command_response_msg();
  545. m_pickup_command_response_msg = t_pickup_command_response_msg;
  546. }
  547. }
  548. //生成指定长度唯一码
  549. public static string GetUniqueIdentifier(int length)
  550. {
  551. int maxSize = length;
  552. char[] chars = new char[62];
  553. string a;
  554. a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  555. chars = a.ToCharArray();
  556. int size = maxSize;
  557. byte[] data = new byte[1];
  558. var crypto = new RNGCryptoServiceProvider();
  559. crypto.GetNonZeroBytes(data);
  560. size = maxSize;
  561. data = new byte[size];
  562. crypto.GetNonZeroBytes(data);
  563. var result = new StringBuilder(size);
  564. foreach (byte b in data)
  565. {
  566. result.Append(chars[b % (chars.Length - 1)]);
  567. }
  568. if (result[0] >= '0' && result[0] <= '9')
  569. {
  570. return GetUniqueIdentifier(length);
  571. }
  572. return result.ToString();
  573. }
  574. //设置天气
  575. public void set_weatherLab_text(string str)
  576. {
  577. this.weather_label.Text = str;
  578. }
  579. //设置气温
  580. public void set_temperatureLab_text(string str)
  581. {
  582. this.temperature_label.Text = str;
  583. }
  584. public static void Speaking(string saying)
  585. {
  586. string say = saying;
  587. Task task = new Task(() =>
  588. {
  589. SpeechSynthesizer speech = new SpeechSynthesizer();
  590. speech.Volume = 100; //音量
  591. speech.Rate = -1;
  592. CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
  593. InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault();
  594. if (neededVoice == null)
  595. {
  596. say = "未知的操作";
  597. }
  598. else
  599. {
  600. speech.SelectVoice(neededVoice.VoiceInfo.Name);
  601. }
  602. speech.Speak(say);
  603. });
  604. task.Start();
  605. }
  606. }
  607. }