using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; namespace M423project { #region add by Patrick 2018-07-12 public partial class CarrierBarcodeCtrl : UserControl { private static OPC OPCInstance { get; set; } private static string globalCarrierBarcode = ""; public static string GlobalCarrierBarcode { get { return globalCarrierBarcode; } set { globalCarrierBarcode = value; try { if (string.IsNullOrWhiteSpace(globalCarrierBarcode)) { OPCInstance.Write(OPCOutputTag.TrayBarcodeReady, false); } else { OPCInstance.Write(OPCOutputTag.TrayBarcodeReady, true); } } catch (Exception ex) { } } } private string carrierBarcode = ""; public string CarrierBarcode { get { return carrierBarcode; } set { if (carrierBarcode != value) { GlobalCarrierBarcode = carrierBarcode = value; SetCarrierBarcodeDisplay(value); } } } private void SetCarrierBarcodeDisplay(string barcode) { if (this.InvokeRequired) { this.Invoke(new Action(() => SetCarrierBarcodeDisplay(barcode))); } else { txtCarrierBarcode.Text = barcode; } } public CarrierBarcodeCtrl() { InitializeComponent(); } public CarrierBarcodeCtrl(OPC _opc) { InitializeComponent(); OPCInstance = _opc; } string temp = ""; public void AddChar(char inputChar) { if (inputChar != (char)13) { temp += inputChar; } else { Trace.TraceInformation($"扫码输入:{temp}"); if (temp.Length == 13) { CarrierBarcode = temp; Trace.TraceInformation($"条码输入信息:{temp}"); temp = ""; } } } } #endregion }