/// <summary> /// 串口初始化,打开了串口 /// </summary> private void CallCOMInit() { int callcombaudrate = int.Parse(ConfigurationManager.AppSettings["CallCOMBaudrate"]); int callcomdatabits = int.Parse(ConfigurationManager.AppSettings["CallCOMDataBits"]); string callcomstopbits = ConfigurationManager.AppSettings["CallCOMStopBits"]; string callcomparity = ConfigurationManager.AppSettings["CallCOMParity"]; try { SPComCall = new COM.SerialPortWrapper(GlobalPara.Gcallcomname, callcombaudrate, callcomparity, callcomdatabits, callcomstopbits); SPComCall.OnDataReceived += new SerialDataReceivedEventHandler(SPComCall_OnDataReceived); SPComCall.Open(); btn_Set.IsEnabled = true; } catch (System.UnauthorizedAccessException ex) { if (MessageBoxResult.OK == MessageBox.Show(ex.Message + "请先暂停此系统或其他系统使用当前串口!", "错误", MessageBoxButton.OK, MessageBoxImage.Error)) { this.Close(); } } catch (System.Exception ex) { if (MessageBoxResult.OK == MessageBox.Show(ex.Message + "请在<通信设置>中设置新的串口!", "错误", MessageBoxButton.OK, MessageBoxImage.Error)) { this.Close(); } } }
/// <summary> /// AGV叫料串口初始化 /// </summary> private void CallCOMInit() { int callcombaudrate = int.Parse(ConfigurationManager.AppSettings["CallCOMBaudrate"]); int callcomdatabits = int.Parse(ConfigurationManager.AppSettings["CallCOMDataBits"]); string callcomstopbits = ConfigurationManager.AppSettings["CallCOMStopBits"]; string callcomparity = ConfigurationManager.AppSettings["CallCOMParity"]; try { SPComCall = new COM.SerialPortWrapper(GlobalPara.GCallcomname, callcombaudrate, callcomparity, callcomdatabits, callcomstopbits); SPComCall.OnDataReceived += new SerialDataReceivedEventHandler(SPComCall_OnDataReceived); } catch (System.Exception ex) { MessageBox.Show(ex.Message); return; } }
/// <summary> /// AGV叫料串口初始化 /// </summary> private void CallCOMInit() { int callcombaudrate = int.Parse(ConfigurationManager.AppSettings["CallCOMBaudrate"]); int callcomdatabits = int.Parse(ConfigurationManager.AppSettings["CallCOMDataBits"]); string callcomstopbits = ConfigurationManager.AppSettings["CallCOMStopBits"]; string callcomparity = ConfigurationManager.AppSettings["CallCOMParity"]; try { SPComCall = new COM.SerialPortWrapper(GlobalPara.Gcallcomname, callcombaudrate, callcomparity, callcomdatabits, callcomstopbits); SPComCall.OnDataReceived += new SerialDataReceivedEventHandler(SPComCall_OnDataReceived); SPComCall.ReceivedBytesThreshold = buf_callret.Length; } catch (System.Exception ex) { MessageBox.Show(ex.Message); return; } }