patrick.xu
2021-12-29 c39b6196509ee07d5799cd2a6611700995948f5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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
}