천호석
2022-12-02 7a23f140e04f37ce4c1660ff7a13e1d98c079401
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
using DIT.SharedMemory;
using log4net;
using System;
using System.Threading;
using System.Windows.Forms;
 
namespace SHARP_CLAS_UI
{
    public partial class Form_Sequence_Viewer : Form
    {
        #region Enum
 
        #endregion
 
        #region Logger
        /// <summary>
        /// Exception Log
        /// </summary>
        private ILog ExceptionLog = LogManager.GetLogger("SHARP_CLAS_SEQUENCE_Exception");
 
        /// <summary>
        /// Exception Log Write
        /// </summary>
        /// <param name="Methodname">Method name of exception that occurred</param>
        /// <param name="ex">exception</param>
        public void WriteExceptionLog(string msg)
        {
            if (ExceptionLog != null) ExceptionLog.Debug(msg);
        }
 
        #endregion
 
        #region Field
        private delegate void UI_Update_Delegate();
 
        private Thread UI_Update_Th;
 
        Form_Frame _Parent;
        bool update_check;
 
        #endregion
 
        #region Construct
        public Form_Sequence_Viewer(Form_Frame _Parent)
        {
            InitializeComponent();
 
            this._Parent = _Parent;
            
 
            UI_Update_Th = new Thread(UI_Update_Th_Set);
 
            UI_Update_Th.Start();
        }
        
        #endregion
 
        #region Form Function
        private void button1_Click(object sender, EventArgs e)
        {
            _Parent.sm.Set_Value(Process_Memory_Address.LD_Tray_In_Count, 0);
            _Parent.sm.Set_Value(Process_Memory_Address.LD_Tray_Empty_Count, 0);
            _Parent.sm.Set_Value(Process_Memory_Address.ULD_Tray_Empty_Count, 0);
            _Parent.sm.Set_Value(Process_Memory_Address.ULD_Tray_Ok_Count, 0);
            _Parent.sm.Set_Value(Process_Memory_Address.ULD_Tray_Ng_Count, 0);
 
            //form.Set_Init();
            //form.ShowDialog();
 
        }
 
        private void btn_LD_Conveyor_In_Load_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.loader.ConveyorIn.Step == ConveyorInSteps.S0000_WAIT)
            {
                _Parent._equip.loader.ConveyorIn.Load();
            }
        }
 
        private void btn_LD_Conveyor_In_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.loader.ConveyorIn.Init_Seq();
        }
 
        private void btn_LD_Tray_In_Load_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.loader.LiftIn.Step == LiftInSteps.S0000_WAIT)
                _Parent._equip.loader.LiftIn.Step = LiftInSteps.S1000_LIFT_LOAD_START;
        }
 
        private void btn_LD_Tray_In_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.loader.LiftIn.Init_Seq();
        }
 
        private void btn_LD_Tray_Empty_Start_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.loader.LiftOut.Step == LiftOutSteps.S0000_WAIT)
                _Parent._equip.loader.LiftOut.Step = LiftOutSteps.S1000_LIFT_MOVE_START;
        }
 
        private void btn_LD_Tray_Empty_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.loader.LiftOut.Init_Seq();
        }
 
        private void btn_LD_Tray_TR_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.loader.TrayTransfer.Step == TrayTransferSteps.S0000_WAIT)
                _Parent._equip.loader.TrayTransfer.Step = TrayTransferSteps.S1000_MOVE_STAY_POSITION_START;
        }
 
        private void btn_LD_Tray_TR_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.loader.TrayTransfer.Init_Seq();
        }
 
        private void btn_LD_Handler_1_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.loader.Handler1.Step == LoaderHandler1Steps.S0000_WAIT)
                _Parent._equip.loader.Handler1.Step = LoaderHandler1Steps.S1000_MOVE_STAY_POSITION_START;
        }
 
        private void btn_LD_Handler_1_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.loader.Handler1.Init_Seq();
        }
 
        private void btn_LD_Reverse_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.before.ReverseStage.Step == LoaderReverseStageSteps.S0000_WAIT)
                _Parent._equip.before.ReverseStage.Step = LoaderReverseStageSteps.S1000_PANEL_LOAD_START;
        }
 
        private void btn_LD_Reverse_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.before.ReverseStage.Init_Seq();
        }
 
        private void btn_LD_Handler_2_Init_Click(object sender, EventArgs e)
        {
            //if (_Parent._equip.before.Handler2.Step == LoaderHandler2Steps.S0000_WAIT)
            //    _Parent._equip.before.Handler2.Step = LoaderHandler2Steps.S1000_MOVE_STAY_POSITION_START;
        }
 
        private void btn_LD_Handler_2_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.before.Handler2.Init_Seq();
        }
 
        private void btn_Pre_Align_Init_Click(object sender, EventArgs e)
        {
            _Parent._equip.before.PreAlignStage.Step = PreAlignSteps.S0000_WAIT;
        }
 
        private void btn_Pre_Align_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.before.PreAlignStage.Init_Seq();
        }
 
        private void btn_Ablation_Stage_1_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.process.ablation_stage_1.Step == AblationStageSteps.S0000_WAIT)
                _Parent._equip.process.ablation_stage_1.Step = AblationStageSteps.S1000_PANEL_LOAD_START;
        }
 
        private void btn_Ablation_Stage_1_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.process.ablation_stage_1.Init_Seq();
        }
 
        private void btn_Ablation_Stage_2_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.process.ablation_stage_2.Step == AblationStageSteps.S0000_WAIT)
                _Parent._equip.process.ablation_stage_2.Step = AblationStageSteps.S1000_PANEL_LOAD_START;
        }
 
        private void btn_Ablation_Stage_2_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.process.ablation_stage_2.Init_Seq();
        }
 
        private void btn_ULD_Reverse_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.after.ReverseStage.Step == UnloaderReverseStageSteps.S0000_WAIT)
                _Parent._equip.after.ReverseStage.Step = UnloaderReverseStageSteps.S2000_PANEL_UNLOAD_START;
        }
 
        private void btn_ULD_Reverse_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.after.ReverseStage.Init_Seq();
        }
 
        private void btn_ULD_Handler_2_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.after.Handler2.Step == UnloaderHandler2Steps.S0000_WAIT)
                _Parent._equip.after.Handler2.Step = UnloaderHandler2Steps.S1000_MOVE_STAY_POSITION_START;
        }
 
        private void btn_ULD_Handler_2_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.after.Handler2.Init_Seq();
        }
 
        private void btn_AOI_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.after.AoiStage.Step == AoiStageSteps.S0000_WAIT)
                _Parent._equip.after.AoiStage.Step = AoiStageSteps.S3000_PANEL_UNLOAD_START;
        }
 
        private void btn_AOI_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.after.AoiStage.Init_Seq();
        }
 
        private void btn_ULD_Conveyor_Empty_Load_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.unloader.ConveyorIn.Step == ConveyorInSteps.S0000_WAIT)
            {
                _Parent._equip.unloader.ConveyorIn.Load();
            }
        }
 
        private void btn_ULD_Conveyor_Empty_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.unloader.ConveyorIn.Init_Seq();
        }
 
        private void btn_ULD_Tray_Empty_Load_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.unloader.LiftIn.Step == LiftInSteps.S0000_WAIT)
                _Parent._equip.unloader.LiftIn.Step = LiftInSteps.S1000_LIFT_LOAD_START;
        }
 
        private void btn_ULD_Tray_Empty_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.unloader.LiftIn.Init_Seq();
        }
 
        private void btn_ULD_Tray_Ok_Load_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.unloader.LiftOk.Step == LiftOutSteps.S0000_WAIT)
                _Parent._equip.unloader.LiftOk.Step = LiftOutSteps.S1000_LIFT_MOVE_START;
        }
 
        private void btn_ULD_Tray_Ok_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.unloader.LiftOk.Init_Seq();
        }
 
        private void btn_ULD_Tray_Ng_Load_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.unloader.LiftNg.Step == LiftOutSteps.S0000_WAIT)
                _Parent._equip.unloader.LiftNg.Step = LiftOutSteps.S1000_LIFT_MOVE_START;
        }
 
        private void btn_ULD_Tray_Ng_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.unloader.LiftNg.Init_Seq();
        }
 
        private void btn_ULD_Tray_TR_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.unloader.TrayTransfer.Step == TrayTransferSteps.S0000_WAIT)
                _Parent._equip.unloader.TrayTransfer.Step = TrayTransferSteps.S1000_MOVE_STAY_POSITION_START;
        }
 
        private void btn_ULD_Tray_TR_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.unloader.TrayTransfer.Init_Seq();
        }
 
        private void btn_ULD_Handler_1_Init_Click(object sender, EventArgs e)
        {
            if (_Parent._equip.unloader.Handler1.Step == UnloaderHandler1Steps.S0000_WAIT)
                _Parent._equip.unloader.Handler1.Step = UnloaderHandler1Steps.S1000_MOVE_TO_STAY_START;
        }
 
        private void btn_ULD_Handler_1_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.unloader.Handler1.Init_Seq();
        }
 
        private void btn_Vision_Click(object sender, EventArgs e)
        {
 
        }
 
        private void btn_Fine_Align_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.process.fine_align.Step = FineAlignSteps.S0000_WAIT;
        }
 
        private void btn_Scanner_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.process.ablation.Step = AblationSteps.S0000_WAIT;
        }
 
        private void btn_Plasma_Stop_Click(object sender, EventArgs e)
        {
            _Parent._equip.process.plasma.Step = PlasmaStpes.S0000_WAIT;
        }
 
        #endregion
 
        #region Function
        public void MessageBoxShow(string msg)
        {
            MessageBox.Show(msg);
        }
 
        private void UI_Update_Th_Set()
        {
            while (!_Parent.IsDisposed)
            {
                Thread.Sleep(100);
                if (!update_check)
                {
                    update_check = true;
                    UI_Update();
                }
            }
        }
 
        private void UI_Update()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new UI_Update_Delegate(UI_Update));
                return;
            }
            else
            {
                try
                {
                    tb_Board_Status.Text = _Parent._equip.Board_Control.BoardMode.ToString();
 
                    tb_Ld_Tray_Id.Text = _Parent._equip.loader.LiftIn.TrayID;
 
                    object value;
                    if (_Parent.sm.Get_Value(Process_Memory_Address.ULD_Tray_Ok_ID, out value))
                        tb_Uld_Tray_Ok_Id.Text = value.ToString();
 
                    tb_Uld_Tray_Ng_Id.Text = _Parent._equip.unloader.LiftNg.TrayID;
 
                    Update_Load_Sequence_UI();
                    Update_Befor_Sequence_UI();
                    Update_After_Sequence_UI();
                }
                catch (Exception ex)
                {
 
                }
                finally
                {
                    update_check = false;
                }
            }
        }
 
        private void Update_Load_Sequence_UI()
        {
            if (_Parent._equip.Cur_Main_Recipe == null || _Parent._equip.Cur_Main_Recipe.tray_info == null)
                tb_Tray_Info_Name.Text = "";
            else
                tb_Tray_Info_Name.Text = _Parent._equip.Cur_Main_Recipe.tray_info.Name;
            
            if (_Parent._equip.Cur_Main_Recipe == null || _Parent._equip.Cur_Main_Recipe.vision_info == null)
                tb_Vision_Info_Name.Text = "";
            else
                tb_Vision_Info_Name.Text = _Parent._equip.Cur_Main_Recipe.vision_info.Name;
 
            if (_Parent._equip.Cur_Main_Recipe == null || _Parent._equip.Cur_Main_Recipe.process_info == null)
                tb_Process_Info_Name.Text = "";
            else
                tb_Process_Info_Name.Text = _Parent._equip.Cur_Main_Recipe.process_info.Name;
 
            tb_LD_Tray_In_Tray_Cur_Count.Text = _Parent._equip.LoaderInTrayCount.ToString();
 
            tb_LD_Tray_Empty_Tray_Cur_Count.Text = _Parent._equip.LoaderOutTrayCount.ToString();
 
            tb_ULD_Tray_Ok_Tray_Cur_Count.Text = _Parent._equip.UnloaderOkTrayCount.ToString();
            tb_ULD_Tray_Ng_Tray_Cur_Count.Text = _Parent._equip.UnloaderNgTrayCount.ToString();
            tb_ULD_Tray_Empty_Tray_Cur_Count.Text = _Parent._equip.UnloaderInTrayCount.ToString();
            if (_Parent._equip.Cur_Main_Recipe != null && _Parent._equip.Cur_Main_Recipe.tray_info != null)
            {
                tb_LD_Tray_In_Tray_Count.Text = _Parent._equip.Cur_Main_Recipe.tray_info.LD_Tray_In_Tray_Count.ToString();
 
                tb_LD_Tray_Empty_Tray_Count.Text = _Parent._equip.Cur_Main_Recipe.tray_info.LD_Tray_Empty_Tray_Count.ToString();
 
                tb_ULD_Tray_Ok_Tray_Count.Text = _Parent._equip.Cur_Main_Recipe.tray_info.ULD_Tray_Ok_Tray_Count.ToString();
 
                tb_ULD_Tray_Ng_Tray_Count.Text = _Parent._equip.Cur_Main_Recipe.tray_info.ULD_Tray_Ng_Tray_Count.ToString();
 
                tb_ULD_Tray_Empty_Tray_Count.Text = _Parent._equip.Cur_Main_Recipe.tray_info.ULD_Tray_Empty_Tray_Count.ToString();
            }
 
            tb_LD_Tray_In_Conveyor_Seq.Text = _Parent._equip.loader.ConveyorIn.Step.ToString();
            tb_LD_Tray_In_Lift_Up_Seq.Text = _Parent._equip.loader.LiftIn.Step.ToString();
            tb_LD_Tray_Empty_Seq.Text = _Parent._equip.loader.LiftOut.Step.ToString();
            tb_LD_Tray_TR_Seq.Text = _Parent._equip.loader.TrayTransfer.Step.ToString();
            tb_LD_Handler_1_Seq.Text = _Parent._equip.loader.Handler1.Step.ToString();
 
            tb_LD_Reverse_Stage_Seq.Text = _Parent._equip.before.ReverseStage.Step.ToString();
            tb_Pre_Align_Stage_Seq.Text = _Parent._equip.before.PreAlignStage.Step.ToString();
            tb_LD_Handler_2_Seq.Text = _Parent._equip.before.Handler2.Step.ToString();
 
            tb_Ablation_Stage_1_Seq.Text = _Parent._equip.process.ablation_stage_1.Step.ToString();
            tb_Ablation_Stage_2_Seq.Text = _Parent._equip.process.ablation_stage_2.Step.ToString();
            tb_Fine_Align_Seq.Text = _Parent._equip.process.fine_align.Step.ToString();
            tb_Scanner_Seq.Text = _Parent._equip.process.ablation.Step.ToString();
            tb_Plasma_Seq.Text = _Parent._equip.process.plasma.Step.ToString();
 
            tb_ULD_Reverse_Stage_Seq.Text = _Parent._equip.after.ReverseStage.Step.ToString();
            tb_AOI_Stage_Seq.Text = _Parent._equip.after.AoiStage.Step.ToString();
            tb_ULD_Handler_2_Seq.Text = _Parent._equip.after.Handler2.Step.ToString();
 
            tb_ULD_Tray_Empty_Conveyor_Seq.Text = _Parent._equip.unloader.ConveyorIn.Step.ToString();
            tb_ULD_Tray_Empty_Seq .Text = _Parent._equip.unloader.LiftIn.Step.ToString();
            tb_ULD_Tray_Ok_Seq.Text = _Parent._equip.unloader.LiftOk.Step.ToString();
            tb_ULD_Tray_Ng_Seq.Text = _Parent._equip.unloader.LiftNg.Step.ToString();
            tb_ULD_Tray_TR_Seq.Text = _Parent._equip.unloader.TrayTransfer.Step.ToString();
            tb_ULD_Handler_1_Seq.Text = _Parent._equip.unloader.Handler1.Step.ToString();
        }
 
        private void Update_Befor_Sequence_UI()
        {
 
        }
 
        private void Update_After_Sequence_UI()
        {
 
        }
 
        #endregion
 
        private void Form_Sequence_Viewer_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!_Parent.IsDisposed)
            {
                e.Cancel = true;
 
                this.Hide();
            }
        }
    }
}