From 58a2c7fa01a617e6de69b85905bb645f08fac656 Mon Sep 17 00:00:00 2001
From: 천호석 <hosuk1418@naver.com>
Date: 화, 06 12월 2022 13:51:35 +0900
Subject: [PATCH]  Auto & Manual 상태 일 때 power meter 측정 위치 및 가공 위치에서만 Laser on 할 수 있도록 Interlock 추가

---
 SHARP_CLAS_UI/500.Equipment/Equipment.cs |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 110 insertions(+), 4 deletions(-)

diff --git a/SHARP_CLAS_UI/500.Equipment/Equipment.cs b/SHARP_CLAS_UI/500.Equipment/Equipment.cs
index 7cfea2b..03a63d7 100644
--- a/SHARP_CLAS_UI/500.Equipment/Equipment.cs
+++ b/SHARP_CLAS_UI/500.Equipment/Equipment.cs
@@ -366,7 +366,24 @@
                 sm.Set_Value(Process_Memory_Address.ULD_Tray_Ng_Count, value);
             }
         }
-        
+
+        public int WidthMeasurementCount
+        {
+            get
+            {
+                int count;
+                object value;
+
+                sm.Get_Value(Process_Memory_Address.Width_Measurement_Count, out value);
+                int.TryParse($"{value}", out count);
+                return count;
+            }
+            set
+            {
+                sm.Set_Value(Process_Memory_Address.Width_Measurement_Count, value);
+            }
+        }
+
         public Main_Recipe Cur_Main_Recipe
         {
             get
@@ -547,7 +564,7 @@
         private User_Info _user;
         private SequenceTimer _modeChangeTime = new SequenceTimer();
 
-        private string _programVersion = "001.001.002";
+        private string _programVersion = "001.002.001";
         #endregion
 
         #region Construct
@@ -561,7 +578,7 @@
 
             power_meter = new Power_Meter(this, "COM3");
             power_meter.Open();
-
+            power_meter.HandShakingOn();
             Create_Exception_logger();
             Create_Panel_Info_logger();
             Create_Tact_Time_logger();
@@ -724,6 +741,16 @@
                     {
                         Set_Load_Tray_Buzzer(false);
                         Board_Control.IO_manager.Set_Output(OutputData.Buzzer_1_Relay, false);
+
+                        if(cim_mode == En_Cim_Mode.Online)
+                        {
+                            if (Alarm_Manager.Instance.Alarm_Status == En_Alarm_Status.HEAVY)
+                            {
+                                Set_Equipment_Status_Code(En_Equipment_Status_Code.T3);
+                                Set_Equipment_Status_Code(En_Equipment_Status_Code.W4);
+                            }
+                        }
+
                         Alarm_Manager.Instance.Alarm_Clear();
                     }
                 }
@@ -744,6 +771,16 @@
                             {
 							    Set_Unload_Tray_Buzzer(false);
                                 Board_Control.IO_manager.Set_Output(OutputData.Buzzer_1_Relay, false);
+                                
+                                if (cim_mode == En_Cim_Mode.Online)
+                                {
+                                    if (Alarm_Manager.Instance.Alarm_Status == En_Alarm_Status.HEAVY)
+                                    {
+                                        Set_Equipment_Status_Code(En_Equipment_Status_Code.T3);
+                                        Set_Equipment_Status_Code(En_Equipment_Status_Code.W4);
+                                    }
+                                }
+
                                 Alarm_Manager.Instance.Alarm_Clear();
                                 unloader.LiftNg.Shuttle.Forward();
                             }
@@ -941,7 +978,12 @@
 
                 if (!Align_vision.isConnected) Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0510_ALIGN_VISION_DISCONNECT);
                 if (!Aoi_vision.isConnected) Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0511_AOI_VISION_DISCONNECT);
-                if (!power_meter.isOpen && !Alarm_Manager.Instance.Occured_List.Exists(X => X.Code == En_Alarm_List.AL_0930_POWER_METER_DISCONNECTED)) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0930_POWER_METER_DISCONNECTED); power_meter.Open(); }
+                if (!power_meter.isOpen && !Alarm_Manager.Instance.Occured_List.Exists(X => X.Code == En_Alarm_List.AL_0930_POWER_METER_DISCONNECTED))
+                {
+                    Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0930_POWER_METER_DISCONNECTED);
+                    power_meter.Open();
+                    power_meter.HandShakingOn();
+                }
 
                 if (equip_mode == En_Equipment_Mode.Auto && dt.Second % 10 == 0 && (loader.Panel_Exist && before.Panel_Exist && process.Panel_Exist && after.Panel_Exist && unloader.Panel_Exist) && !units.Exists(x => x.sequenceChangedTime.Minute < 10))
                 {
@@ -955,6 +997,64 @@
                     panel_count_info.CleaningCount = 0;
                     Panel_Count_Info_Manager.Instance.Save_Panel_Count_Info(panel_count_info);
                 }
+
+                if(equip_mode != En_Equipment_Mode.Auto) // Auto mode媛� �븘�땺 �븣 
+                {
+                    if(equip_mode == En_Equipment_Mode.Pause && units.Exists(x => x.UnitMode != equip_mode))
+                    {
+                        // Pause wait �긽�깭 �씪 �븣�뒗 interlock 諛쒖깮 X
+                    }
+                    else
+                    {
+                        
+                    }
+                }
+
+                // Laser On Interlock 
+                // Power meter �쐞移� or 媛�怨� �쐞移섍� �븘�땺 �븣 Laser on�떆 Laser off 吏꾪뻾 �썑 Interlock.
+                if (Cur_Main_Recipe != null && Cur_Main_Recipe.process_info != null && Cur_Main_Recipe.panel_type_info != null)
+                {
+                    double scannerA1Position = Cur_Main_Recipe.process_info.Scanner_X_A1 + Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A1;
+                    double scannerA2Position = Cur_Main_Recipe.process_info.Scanner_X_A2 + Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A2;
+                    double scannerB1Position = Cur_Main_Recipe.process_info.Scanner_X_B1 + Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B1;
+                    double scannerB2Position = Cur_Main_Recipe.process_info.Scanner_X_B2 + Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B2;
+
+                    object value;
+                    sm.Get_Value(Position_Parameter_Address.Scanner_X_Power_Meter_Position, out value);
+                    double scannerPosition = double.Parse($"{value}");
+
+                    bool isInPosition = false;
+
+                    isInPosition |= scannerA1Position - 10 <= scannerPosition && scannerPosition <= scannerA1Position + 10;
+                    isInPosition |= scannerA2Position - 10 <= scannerPosition && scannerPosition <= scannerA2Position + 10;
+                    isInPosition |= scannerB1Position - 10 <= scannerPosition && scannerPosition <= scannerB1Position + 10;
+                    isInPosition |= scannerB2Position - 10 <= scannerPosition && scannerPosition <= scannerB2Position + 10;
+                    isInPosition |= process.ablation.Get_Is_Position_X_Power_Meter() && process.ablation.Get_Is_Position_Z_Power_Meter();
+
+                    if(isInPosition == false)
+                    {
+                        if (sm.Get_Bit(Input_Memory_Address.Laser_Active))
+                        {
+                            scanner.Set_Laser_Off();
+                            Interlock_Manager.Add_Interlock_Msg("Laser can't on.", "Please move power meter position.");
+                        }
+                    }
+                }
+                else
+                {
+                    bool isInPosition = false;
+                    isInPosition |= process.ablation.Get_Is_Position_X_Power_Meter() && process.ablation.Get_Is_Position_Z_Power_Meter();
+
+                    if (isInPosition == false)
+                    {
+                        if (sm.Get_Bit(Input_Memory_Address.Laser_Active))
+                        {
+                            scanner.Set_Laser_Off();
+                            Interlock_Manager.Add_Interlock_Msg("Laser can't on.", "Please move power meter position.");
+                        }
+                    }
+                }
+                
             }
             catch(Exception e)
             {
@@ -1420,6 +1520,12 @@
                         return false;
                     }
                     
+                    if(Door_Opened)
+                    {
+                        Interlock_Manager.Add_Interlock_Msg("Can't Change auto mode.", "Please door close.");
+                        return false;
+                    }
+
                     if(!Is_Home_Complete)
                     {
                         Interlock_Manager.Add_Interlock_Msg("Can't Change auto mode.", "Please Set Home.");

--
Gitblit v1.9.3