/// <summary> /// 霍尼韦尼扫码返回 例如炉门41 67 69 6E 67 30 30 34 0D (30 30 34为有效数字) /// </summary> /// <param name="NewData"></param> /// <returns></returns> private static void UpdateRecevie(string NewData) { string Value = ""; string ValueAddress = ""; int Address = 0; NewData = NewData.Replace(" ", "");//剔除空格 try { if (NewData.Length == 18)//当前扫码到的值为炉门号41 67 69 6E 67 30 30 34 0D { Value = InterceptStringHelp.ExtractString(NewData, 10, 6); for (int i = 0; i < Value.Length / 2; i++) { Address = PLCSocket.DecimalConversion.HexToTen(NewData.Substring(10 + (i * 2), 2)); // 十六进制转10进制 ValueAddress += ((char)Address).ToString(); // 十进制转acsii码 } delegateAddress fc = new delegateAddress(DoorBarCodeAddress); ControlHelp.ControlHelp.Resource.Invoke(fc, SySetHeip.Prefix.Trim() + ValueAddress); //通过代理调用刷新方法 } if (NewData.Length == 14) //当前扫码到的值为小车号 小车条码号4C31303031320D { Value = InterceptStringHelp.ExtractString(NewData, 6, 6);; for (int i = 0; i < Value.Length / 2; i++) { Address = PLCSocket.DecimalConversion.HexToTen(NewData.Substring(6 + (i * 2), 2)); // 十六进制转10进制 ValueAddress += ((char)Address).ToString(); // 十进制转acsii码 } SedanBarCode = SySetHeip.Prefix.Trim() + ValueAddress; delegateAddress fc = new delegateAddress(Voluation); ControlHelp.ControlHelp.BarCode1.Invoke(fc, SySetHeip.Prefix.Trim() + ValueAddress); //通过代理调用刷新方法 } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 霍尼韦尼扫码返回 例如炉门41 67 69 6E 67 30 30 34 0D (30 30 34为有效数字) /// </summary> /// <param name="NewData"></param> public void UpdateRecevie(string NewData) { string Value = ""; string ValueAddress = ""; int Address = 0; if (this.InvokeRequired)//等待异步 { UpdateString _myInvoke = new UpdateString(UpdateRecevie); this.Invoke(_myInvoke, new object[] { NewData }); } else { NewData = NewData.Replace(" ", ""); //剔除空格 if (NewData.Length == 18) //当前扫码到的值为炉门号41 67 69 6E 67 30 30 34 0D { Value = InterceptStringHelp.ExtractString(NewData, 10, 6); for (int i = 0; i < Value.Length / 2; i++) { Address = DecimalConversion.HexToTen(NewData.Substring(10 + (i * 2), 2)); // 十六进制转10进制 ValueAddress += ((char)Address).ToString(); // 十进制转acsii码 } if (SySetHeip.Prefix.Trim() + ValueAddress == "L10001") //扫到哪一个炉门,自动选择该门 { OperateShow.Text = "当前1号门操作"; DictionaryHelp.Dictionary["Operater1"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10002") { OperateShow.Text = "当前2号门操作"; DictionaryHelp.Dictionary["Operater2"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10003") { OperateShow.Text = "当前3号门操作"; DictionaryHelp.Dictionary["Operater3"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10004") { OperateShow.Text = "当前4号门操作"; DictionaryHelp.Dictionary["Operater4"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10005") { OperateShow.Text = "当前5号门操作"; DictionaryHelp.Dictionary["Operater5"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10006") { OperateShow.Text = "当前6号门操作"; DictionaryHelp.Dictionary["Operater6"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10007") { OperateShow.Text = "当前7号门操作"; DictionaryHelp.Dictionary["Operater7"](); } else if (SySetHeip.Prefix.Trim() + ValueAddress == "L10008") { OperateShow.Text = "当前8号门操作"; DictionaryHelp.Dictionary["Operater8"](); } } if (NewData.Length == 14)//当前扫码到的值为小车号 小车条码号4C31303031320D { Value = InterceptStringHelp.ExtractString(NewData, 6, 6);; for (int i = 0; i < Value.Length / 2; i++) { Address = DecimalConversion.HexToTen(NewData.Substring(6 + (i * 2), 2)); // 十六进制转10进制 ValueAddress += ((char)Address).ToString(); // 十进制转acsii码 } if (!string.IsNullOrEmpty(BarCode1.Text) && !string.IsNullOrEmpty(BarCode2.Text)) { BarCode1.Text = ""; BarCode2.Text = ""; } if (string.IsNullOrEmpty(BarCode1.Text)) { BarCode1.Text = SySetHeip.Prefix.Trim() + ValueAddress; ValueAddress = ""; } else { BarCode2.Text = SySetHeip.Prefix.Trim() + ValueAddress; ValueAddress = ""; } if (BarCode1.Text == BarCode2.Text) { Common.Msg.Warning("不能绑定两个相同的条码"); BarCode2.Text = ""; } } } }