d23004
2023-05-24 fa87a558389d9d425f70afa1c8de54c69875ef2c
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using SA_LTT;
using System;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
 
namespace SA_LTT_UI.Viewer
{
    public partial class PreAlignViwer : Form
    {
        MainFrame _mainFrame;
        Thread t_UIUpdate;
 
        bool updateCheck;
 
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams MyCp = base.CreateParams;
                MyCp.ExStyle |= 0x02000000;
 
                return MyCp;
            }
        }
 
        public PreAlignViwer(MainFrame mainFrame)
        {
            InitializeComponent();
 
            _mainFrame = mainFrame;
            t_UIUpdate = new Thread(UIUpdateTh);
            t_UIUpdate.Start();
        }
 
        private void UIUpdateTh()
        {
            while (_mainFrame.equipment.IsDisposed == false)
            {
                Thread.Sleep(10);
 
                if (updateCheck == false)
                {
                    updateCheck = true;
                    UIUpdate();
                }
            }
        }
 
        private void UIUpdate()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new UIUpdateDelegate(UIUpdate));
                return;
            }
            else
            {
                try
                {
                    lb_PortName.Text = _mainFrame.equipment.preAligner.PortName;
                    lb_PortName.BackColor = _mainFrame.equipment.preAligner.IsOpen ? Color.Lime : Color.Red;
 
                    lb_Version.Text = $"Version - {_mainFrame.equipment.preAligner.Version}";
 
                    lb_RunEnable.BackColor = _mainFrame.equipment.preAligner.IsRunEnable ? Color.Lime : Color.Red;
                    lb_WaferExist.BackColor = _mainFrame.equipment.preAligner.IsWaferExist ? Color.Lime : Color.Red;
                    lb_Vacuum.BackColor = _mainFrame.equipment.preAligner.IsVacuumOn ? Color.Lime : Color.Red;
                    lb_IsHome.BackColor = _mainFrame.equipment.preAligner.IsHome ? Color.Lime : Color.Red;
 
                    tb_PositionX.Text = _mainFrame.equipment.preAligner.PositionX.ToString();
                    tb_PositionY.Text = _mainFrame.equipment.preAligner.PositionY.ToString();
                    tb_PositionT.Text = _mainFrame.equipment.preAligner.PositionT.ToString();
 
                    if (_mainFrame.equipment.preAligner.IsRunEnable && (_mainFrame.equipment.ProcessStatus == ProcessStatus.Idle || _mainFrame.equipment.ProcessStatus == ProcessStatus.Pause))
                    {
                        if (gb_Control.Enabled == false)
                        {
                            gb_Control.Enabled = true;
                        }
                    }
                    else
                    {
                        if (gb_Control.Enabled)
                        {
                            gb_Control.Enabled = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    EquipmentLogManager.Instance.WriteExceptionLog(e.StackTrace);
                }
                finally
                {
                    updateCheck = false;
                }
            }
        }
 
        private void btn_Home_Click(object sender, EventArgs e)
        {
            EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text}");
            _mainFrame.equipment.preAligner.Home();
        }
 
        private void btn_Align_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            double angle = 0;
 
            if(double.TryParse(tb_Angle.Text, out angle))
            {
                EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text} {angle}");
                _mainFrame.equipment.preAligner.Align(angle);
            }
 
            tb_AlignTime.Text = $"{(DateTime.Now - dt).TotalSeconds:F3} s";
        }
 
        private void btn_Again_Click(object sender, EventArgs e)
        {
            double angle = 0;
 
            if (double.TryParse(tb_Angle.Text, out angle))
            {
                EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text} {angle}");
                _mainFrame.equipment.preAligner.Again(angle);
            }
        }
 
        private void btn_VacuumOn_Click(object sender, EventArgs e)
        {
            EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text}");
            _mainFrame.equipment.preAligner.VacuumOn();
        }
 
        private void btn_VacuumOff_Click(object sender, EventArgs e)
        {
            EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text}");
            _mainFrame.equipment.preAligner.VacuumOff();
        }
 
        private void PreAlignViwer_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }
 
        private void btn_Center_Click(object sender, EventArgs e)
        {
            EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text}");
            _mainFrame.equipment.preAligner.Center();
        }
 
        private void btn_PinDown_Click(object sender, EventArgs e)
        {
            EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text}");
            _mainFrame.equipment.preAligner.PinUp();
        }
 
        private void btn_PinUp_Click(object sender, EventArgs e)
        {
            EquipmentLogManager.Instance.WriteButtonLog($"{this.Name} : {((Control)sender).Text}");
            _mainFrame.equipment.preAligner.PinDown();
        }
    }
}