using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Windows.Forms; namespace SHARP_CLAS_UI { public class Ablation : AblationUnit { #region Enum #endregion #region Property public bool Is_Power_Measure { get { return (AblationSteps.S5000_AUTO_POWER_START <= Step && Step <= AblationSteps.S5999_AUTO_POWER_END); } } public AblationSteps Step { get { return _step; } set { _step = value; } } public override bool IsWorkEnd { get { if(Step == AblationSteps.S0000_WAIT) { return true; } else { return false; } } } public override bool IsStayPosition { get { double position = Get_Scanner_Z_A1_Stay_Position(); return MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset); } } #endregion #region Field private AblationSteps _step; private AblationSteps _oldStep; public AblationHomeSteps _homeStep; public Time_Checker Tact_Move = new Time_Checker(); public Time_Checker Power_Time_Check = new Time_Checker(); private Thread Ablation_Run_Th; List lst_power = new List(); Form_Auto_Power_Viewer auto_power_view; System.Windows.Forms.Timer tmrUi = new System.Windows.Forms.Timer(); int retry_cnt; #endregion #region Construct public Ablation(Equipment equipment) : base (equipment, MotorAxis.Ablation_X, MotorAxis.Ablation_Z) { Step = AblationSteps.S0000_WAIT; _oldStep = AblationSteps.S0000_WAIT; auto_power_view = new Form_Auto_Power_Viewer(equipment); pauseDisableList.Add(AblationSteps.S1105_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S1115_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S1135_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S1215_ABLATION_PROCESS_WAIT); pauseDisableList.Add(AblationSteps.S1225_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S2105_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S2115_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S2135_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S2215_ABLATION_PROCESS_WAIT); pauseDisableList.Add(AblationSteps.S2225_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S3105_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S3115_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S3135_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S3215_ABLATION_PROCESS_WAIT); pauseDisableList.Add(AblationSteps.S3225_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S4105_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S4115_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S4135_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S4215_ABLATION_PROCESS_WAIT); pauseDisableList.Add(AblationSteps.S4225_POSITION_CHECK); pauseDisableList.Add(AblationSteps.S5220_SCANNER_MOVE_WAIT); pauseDisableList.Add(AblationSteps.S5320_LASER_ON); pauseDisableList.Add(AblationSteps.S5330_LASER_ON_CHECK); pauseDisableList.Add(AblationSteps.S5340_POWER_MEASUREMENT_START); pauseDisableList.Add(AblationSteps.S5350_POWER_MEASUREMENT); pauseDisableList.Add(AblationSteps.S5360_POWER_MEASUREMENT_END); pauseDisableList.Add(AblationSteps.S5370_LASER_OFF); pauseDisableList.Add(AblationSteps.S5380_LASER_OFF_CHECK); pauseDisableList.Add(AblationSteps.S5420_LASER_ON); pauseDisableList.Add(AblationSteps.S5430_LASER_ON_CHECK); pauseDisableList.Add(AblationSteps.S5440_POWER_MEASUREMENT_START); pauseDisableList.Add(AblationSteps.S5450_POWER_MEASUREMENT); pauseDisableList.Add(AblationSteps.S5460_POWER_MEASUREMENT_END); pauseDisableList.Add(AblationSteps.S5470_LASER_OFF); pauseDisableList.Add(AblationSteps.S5480_LASER_OFF_CHECK); MotorX.Check_Jog_Interlock = Jog_Interlock_MotorX; MotorX.Check_Move_Interlock = Move_Interlock_MotorX; MotorZ.Check_Jog_Interlock = Jog_Interlock; MotorZ.Check_Move_Interlock = Move_Interlock; tmrUi.Tick += TmrUi_Tick; tmrUi.Interval = 5000; tmrUi.Start(); } #endregion #region Function private bool Move_Interlock_MotorX() { if (equipment.User.Level != En_User_Level.Master && equipment.Door_Opened) { return true; } double position = Get_Scanner_Z_A1_Stay_Position(); if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset) == false) { return true; } return false; } private bool Jog_Interlock_MotorX(bool positive) { if (equipment.User.Level != En_User_Level.Master && equipment.Door_Opened) { return true; } double position = Get_Scanner_Z_A1_Stay_Position(); if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset) == false) { return true; } return false; } private bool Move_Interlock() { if (equipment.User.Level != En_User_Level.Master && equipment.Door_Opened) { return true; } return false; } private bool Jog_Interlock(bool positive) { if (equipment.User.Level != En_User_Level.Master && equipment.Door_Opened) { return true; } return false; } private void TmrUi_Tick(object sender, EventArgs e) { if (Is_Power_Measure && !auto_power_view.shown) { auto_power_view.shown = true; auto_power_view.Show(); auto_power_view.BringToFront(); } else if(Is_Power_Measure) { auto_power_view.BringToFront(); } } public void Auto_Power_View_Show() { auto_power_view.Show(); auto_power_view.BringToFront(); } public void Init_Seq() { Step = AblationSteps.S0000_WAIT; _homeStep = AblationHomeSteps.S0000_WAIT; Tact_Move.Reset(); } public void Seq_Auto() { } public override void MonitoringStatus() { if (equipment.User.Level != En_User_Level.Master && equipment.Door_Opened) { if (MotorX.MotionComplete == false) { MotorX.Move_Stop(); } if (MotorZ.MotionComplete == false) { MotorZ.Move_Stop(); } bool on = false; equipment.scanner.Get_Laser_On(out on); if (on) { equipment.scanner.Set_Stop(); equipment.scanner.Set_Laser_Off(); } } } public override void ExecuteStep() { if (_oldStep != Step) { sequenceChangedTime.Restart(); _oldStep = Step; WriteSequenceLog(Step.ToString()); } if (UnitMode == En_Equipment_Mode.Stop) { Init_Seq(); isHomeComplete = false; return; } else if (UnitMode == En_Equipment_Mode.Pause) { if ((AblationSteps.S5320_LASER_ON <= Step && Step <= AblationSteps.S5380_LASER_OFF_CHECK) || (AblationSteps.S5420_LASER_ON <= Step && Step <= AblationSteps.S5480_LASER_OFF_CHECK)) { Seq_Power_Measure(); } return; } else if (UnitMode == En_Equipment_Mode.Home) { if (!IsHomeComplete) { Seq_Home(); } return; } else if (UnitMode == En_Equipment_Mode.Auto || UnitMode == En_Equipment_Mode.Manual) { sequenceChangedTime.Start(); if (equipment.equip_mode == En_Equipment_Mode.Pause) { if (pauseDisableList.Contains(Step) != false) { UnitMode = En_Equipment_Mode.Pause; return; } } if (UnitMode == En_Equipment_Mode.Auto) { Seq_Auto(); } //인터락 위치. Seq_AblationA1(); Seq_AblationA2(); Seq_AblationB1(); Seq_AblationB2(); Seq_Power_Measure(); } } private void Seq_Home() { switch(_homeStep) { case AblationHomeSteps.S0000_WAIT: { _homeStep = AblationHomeSteps.S1000_STATUS_CHECK; break; } case AblationHomeSteps.S1000_STATUS_CHECK: { if (MotorX.ErrorStop) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0321_ABLATION_X_ERROR_STOP); } else if (MotorZ.ErrorStop) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0331_ABLATION_Z_ERROR_STOP); } else if (!MotorX.PowerOn) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0320_ABLATION_X_POWER_OFF); } else if (!MotorZ.PowerOn) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0330_ABLATION_Z_POWER_OFF); } else { _homeStep = AblationHomeSteps.S2000_X_HOME_START; } break; } case AblationHomeSteps.S2000_X_HOME_START: { if (MotorX.Home()) { homeCheckedTime.Restart(); _homeStep = AblationHomeSteps.S2100_X_HOME_CHECK; } break; } case AblationHomeSteps.S2100_X_HOME_CHECK: { if (homeCheckedTime.Seconds < 1) return; if (!MotorX.IsHomed) { if (MotorX.Homing == false && MotorX.ErrorStop) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0321_ABLATION_X_ERROR_STOP); } } else { _homeStep = AblationHomeSteps.S2200_Z_HOME_START; } break; } case AblationHomeSteps.S2200_Z_HOME_START: { if (MotorZ.Home()) { _homeStep = AblationHomeSteps.S2300_Z_HOME_CHECK; } break; } case AblationHomeSteps.S2300_Z_HOME_CHECK: { if (!MotorZ.IsHomed) { if (MotorZ.ErrorStop) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0331_ABLATION_Z_ERROR_STOP); } } else { _homeStep = AblationHomeSteps.S9999_END; } break; } case AblationHomeSteps.S9999_END: { isHomeComplete = true; _homeStep = AblationHomeSteps.S0000_WAIT; break; } } } private void Seq_AblationA1() { switch (Step) { case AblationSteps.S1000_ABLATION_STAGE_1_1_START: { Panel_Info info = equipment.process.ablation_stage_1.Panel1; if (equipment.process.ablation_stage_1.Stage1.IsExist == false || info.IsAblationWorked || info.Ablation_Run == false) { Step = AblationSteps.S1999_ABLATION_STAGE_1_1_END; } else { Tact_Move.Start(); Step = AblationSteps.S1100_MOVE_Z_STAY_POSITION; } break; } case AblationSteps.S1100_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_A1_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S1105_POSITION_CHECK; } break; } case AblationSteps.S1105_POSITION_CHECK: { double position = Get_Scanner_Z_A1_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S1110_MOVE_X_ABLATION_POSITION; } else { Step = AblationSteps.S1100_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S1110_MOVE_X_ABLATION_POSITION: { Panel_Info info = equipment.process.ablation_stage_1.Panel1; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_A1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A1; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S1115_POSITION_CHECK; } break; } case AblationSteps.S1115_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_1_1); double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_A1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A1; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S1120_ABLATION_STAGE_1_CHECK; } else { Step = AblationSteps.S1110_MOVE_X_ABLATION_POSITION; } } break; } case AblationSteps.S1120_ABLATION_STAGE_1_CHECK: { Panel_Info info = equipment.process.ablation_stage_1.Panel1; double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_Y_A1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_Y_A1; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_1.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S1130_MOVE_Z_ABLATION_POSITION; } break; } case AblationSteps.S1130_MOVE_Z_ABLATION_POSITION: { if (MotorZ.Move_Absolute_Pos(equipment.Cur_Main_Recipe.process_info.Scanner_Z_A1, 500)) { Step = AblationSteps.S1135_POSITION_CHECK; } break; } case AblationSteps.S1135_POSITION_CHECK: { if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(equipment.Cur_Main_Recipe.process_info.Scanner_Z_A1, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S1200_LASER_SETTING; } else { Step = AblationSteps.S1130_MOVE_Z_ABLATION_POSITION; } } break; } case AblationSteps.S1200_LASER_SETTING: { if (sequenceChangedTime.Seconds < 1) return; double jump_speed = 0, mark_speed = 0; short laseron_delay = 0, laseroff_delay = 0; ushort jump_delay = 0, mark_delay = 0, polygon_delay = 0; jump_speed = equipment.Cur_Main_Recipe.process_info.Jump_Speed; mark_speed = equipment.Cur_Main_Recipe.process_info.Mark_Speed; laseron_delay = equipment.Cur_Main_Recipe.process_info.Laser_On_Delay; laseroff_delay = equipment.Cur_Main_Recipe.process_info.Laser_Off_Delay; jump_delay = equipment.Cur_Main_Recipe.process_info.Jump_Delay; mark_delay = equipment.Cur_Main_Recipe.process_info.Mark_Delay; polygon_delay = 0; if (!equipment.scanner.Set_Process_Datas(jump_speed, mark_speed, laseron_delay, laseroff_delay, jump_delay, mark_delay, polygon_delay)) return; int frequency = equipment.Cur_Main_Recipe.process_info.Frequency; double power = equipment.Cur_Main_Recipe.process_info.Power + equipment.Setting.Stage_1_1_Power_Offset; Panel_Info info = equipment.process.ablation_stage_1.Panel1; info.AblationPower = power; info.AblationTargetPower = equipment.Cur_Main_Recipe.process_info.Target_Power_W; equipment.process.ablation_stage_1.Panel1 = info; if (!equipment.scanner.Set_Power(frequency, power)) return; Step = AblationSteps.S1210_ABLATION_PROCESS_START; break; } case AblationSteps.S1210_ABLATION_PROCESS_START: { if (sequenceChangedTime.Seconds < 0.5) return; if(equipment.Mode.Ablation_Skip || equipment.process.ablation_stage_1.Stage1.IsExist == false) { Step = AblationSteps.S1215_ABLATION_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_1.Panel1; info.IsAblationWorked = true; equipment.process.ablation_stage_1.Panel1 = info; equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, true); Ablation_Run_Th = new Thread(() => Ablation_Run(info.Fine_Align_T_Offset + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_T_A1)); Ablation_Run_Th.Start(); Step = AblationSteps.S1215_ABLATION_PROCESS_WAIT; break; } case AblationSteps.S1215_ABLATION_PROCESS_WAIT: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (moving == false) { equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Step = AblationSteps.S1220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S1220_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_A1_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S1225_POSITION_CHECK; } break; } case AblationSteps.S1225_POSITION_CHECK: { double position = Get_Scanner_Z_A1_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S1999_ABLATION_STAGE_1_1_END; } else { Step = AblationSteps.S1220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S1999_ABLATION_STAGE_1_1_END: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (moving == false) { equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Tact_Move.Stop(); Step = AblationSteps.S0000_WAIT; } } break; } } } private void Seq_AblationA2() { switch (Step) { case AblationSteps.S2000_ABLATION_STAGE_1_2_START: { Panel_Info info = equipment.process.ablation_stage_1.Panel2; if (equipment.process.ablation_stage_1.Stage2.IsExist == false || info.IsAblationWorked || info.Ablation_Run == false) { Step = AblationSteps.S2999_ABLATION_STAGE_1_2_END; } else { Tact_Move.Start(); Step = AblationSteps.S2100_MOVE_Z_STAY_POSITION; } break; } case AblationSteps.S2100_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_A2_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S2105_POSITION_CHECK; } break; } case AblationSteps.S2105_POSITION_CHECK: { double position = Get_Scanner_Z_A2_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S2110_MOVE_X_ABLATION_POSITION; } else { Step = AblationSteps.S2100_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S2110_MOVE_X_ABLATION_POSITION: { Panel_Info info = equipment.process.ablation_stage_1.Panel2; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_A2 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S2115_POSITION_CHECK; } break; } case AblationSteps.S2115_POSITION_CHECK: { Panel_Info info = equipment.process.ablation_stage_1.Panel2; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_A2 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A2; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S2120_ABLATION_STAGE_1_CHECK; } else { Step = AblationSteps.S2110_MOVE_X_ABLATION_POSITION; } } break; } case AblationSteps.S2120_ABLATION_STAGE_1_CHECK: { Panel_Info info = equipment.process.ablation_stage_1.Panel2; double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_Y_A2 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_Y_A2; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_1.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S2130_MOVE_Z_ABLATION_POSITION; } break; } case AblationSteps.S2130_MOVE_Z_ABLATION_POSITION: { if (MotorZ.Move_Absolute_Pos(equipment.Cur_Main_Recipe.process_info.Scanner_Z_A2, 500)) { Step = AblationSteps.S2135_POSITION_CHECK; } break; } case AblationSteps.S2135_POSITION_CHECK: { if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(equipment.Cur_Main_Recipe.process_info.Scanner_Z_A2, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S2200_LASER_SETTING; } else { Step = AblationSteps.S2130_MOVE_Z_ABLATION_POSITION; } } break; } case AblationSteps.S2200_LASER_SETTING: { if (sequenceChangedTime.Seconds < 1) return; double jump_speed = 0, mark_speed = 0; short laseron_delay = 0, laseroff_delay = 0; ushort jump_delay = 0, mark_delay = 0, polygon_delay = 0; jump_speed = equipment.Cur_Main_Recipe.process_info.Jump_Speed; mark_speed = equipment.Cur_Main_Recipe.process_info.Mark_Speed; laseron_delay = equipment.Cur_Main_Recipe.process_info.Laser_On_Delay; laseroff_delay = equipment.Cur_Main_Recipe.process_info.Laser_Off_Delay; jump_delay = equipment.Cur_Main_Recipe.process_info.Jump_Delay; mark_delay = equipment.Cur_Main_Recipe.process_info.Mark_Delay; polygon_delay = 0; if (!equipment.scanner.Set_Process_Datas(jump_speed, mark_speed, laseron_delay, laseroff_delay, jump_delay, mark_delay, polygon_delay)) return; int frequency = equipment.Cur_Main_Recipe.process_info.Frequency; double power = equipment.Cur_Main_Recipe.process_info.Power + equipment.Setting.Stage_1_2_Power_Offset; Panel_Info info = equipment.process.ablation_stage_1.Panel2; info.AblationPower = power; info.AblationTargetPower = equipment.Cur_Main_Recipe.process_info.Target_Power_W; equipment.process.ablation_stage_1.Panel2 = info; if (!equipment.scanner.Set_Power(frequency, power)) return; Step = AblationSteps.S2210_ABLATION_PROCESS_START; break; } case AblationSteps.S2210_ABLATION_PROCESS_START: { if (sequenceChangedTime.Seconds < 0.5) return; if (equipment.Mode.Ablation_Skip || equipment.process.ablation_stage_1.Stage2.IsExist == false) { Step = AblationSteps.S2215_ABLATION_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_1.Panel2; info.IsAblationWorked = true; equipment.process.ablation_stage_1.Panel2 = info; equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, true); Ablation_Run_Th = new Thread(() => Ablation_Run(info.Fine_Align_T_Offset + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_T_A2)); Ablation_Run_Th.Start(); Step = AblationSteps.S2215_ABLATION_PROCESS_WAIT; break; } case AblationSteps.S2215_ABLATION_PROCESS_WAIT: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if(sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (moving == false) { equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Step = AblationSteps.S2220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S2220_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_A2_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S2225_POSITION_CHECK; } break; } case AblationSteps.S2225_POSITION_CHECK: { double position = Get_Scanner_Z_A2_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S2999_ABLATION_STAGE_1_2_END; } else { Step = AblationSteps.S2220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S2999_ABLATION_STAGE_1_2_END: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (!moving) { Tact_Move.Stop(); equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Step = AblationSteps.S0000_WAIT; } } break; } } } private void Seq_AblationB1() { switch (Step) { case AblationSteps.S3000_ABLATION_STAGE_2_1_START: { Panel_Info info = equipment.process.ablation_stage_2.Panel1; if (equipment.process.ablation_stage_2.Stage1.IsExist == false || info.IsAblationWorked || info.Ablation_Run == false) { Step = AblationSteps.S1999_ABLATION_STAGE_1_1_END; } else { Tact_Move.Start(); Step = AblationSteps.S3100_MOVE_Z_STAY_POSITION; } break; } case AblationSteps.S3100_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_B2_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S3105_POSITION_CHECK; } break; } case AblationSteps.S3105_POSITION_CHECK: { double position = Get_Scanner_Z_B2_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S3110_MOVE_X_ABLATION_POSITION; } else { Step = AblationSteps.S3100_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S3110_MOVE_X_ABLATION_POSITION: { Panel_Info info = equipment.process.ablation_stage_2.Panel1; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_B1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B1; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S3115_POSITION_CHECK; } break; } case AblationSteps.S3115_POSITION_CHECK: { Panel_Info info = equipment.process.ablation_stage_2.Panel1; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_B1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B1; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S3120_ABLATION_STAGE_2_CHECK; } else { Step = AblationSteps.S3110_MOVE_X_ABLATION_POSITION; } } break; } case AblationSteps.S3120_ABLATION_STAGE_2_CHECK: { Panel_Info info = equipment.process.ablation_stage_2.Panel1; double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_Y_B1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_Y_B1; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_2.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S3130_MOVE_Z_ABLATION_POSITION; } break; } case AblationSteps.S3130_MOVE_Z_ABLATION_POSITION: { if (MotorZ.Move_Absolute_Pos(equipment.Cur_Main_Recipe.process_info.Scanner_Z_B1, 500)) { Step = AblationSteps.S3135_POSITION_CHECK; } break; } case AblationSteps.S3135_POSITION_CHECK: { if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(equipment.Cur_Main_Recipe.process_info.Scanner_Z_B1, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S3200_LASER_SETTING; } else { Step = AblationSteps.S3130_MOVE_Z_ABLATION_POSITION; } } break; } case AblationSteps.S3200_LASER_SETTING: { if (MotorZ.MotionComplete && MotorX.MotionComplete && sequenceChangedTime.Seconds< 1) return; double jump_speed = 0, mark_speed = 0; short laseron_delay = 0, laseroff_delay = 0; ushort jump_delay = 0, mark_delay = 0, polygon_delay = 0; jump_speed = equipment.Cur_Main_Recipe.process_info.Jump_Speed; mark_speed = equipment.Cur_Main_Recipe.process_info.Mark_Speed; laseron_delay = equipment.Cur_Main_Recipe.process_info.Laser_On_Delay; laseroff_delay = equipment.Cur_Main_Recipe.process_info.Laser_Off_Delay; jump_delay = equipment.Cur_Main_Recipe.process_info.Jump_Delay; mark_delay = equipment.Cur_Main_Recipe.process_info.Mark_Delay; polygon_delay = 0; if (!equipment.scanner.Set_Process_Datas(jump_speed, mark_speed, laseron_delay, laseroff_delay, jump_delay, mark_delay, polygon_delay)) return; int frequency = equipment.Cur_Main_Recipe.process_info.Frequency; double power = equipment.Cur_Main_Recipe.process_info.Power + equipment.Setting.Stage_2_1_Power_Offset; Panel_Info info = equipment.process.ablation_stage_2.Panel1; info.AblationPower = power; info.AblationTargetPower = equipment.Cur_Main_Recipe.process_info.Target_Power_W; equipment.process.ablation_stage_2.Panel1 = info; if (!equipment.scanner.Set_Power(frequency, power)) return; Step = AblationSteps.S3210_ABLATION_PROCESS_START; break; } case AblationSteps.S3210_ABLATION_PROCESS_START: { if (sequenceChangedTime.Seconds < 0.5) return; if (equipment.Mode.Ablation_Skip || equipment.process.ablation_stage_2.Stage1.IsExist == false) { Step = AblationSteps.S3215_ABLATION_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_2.Panel1; info.IsAblationWorked = true; equipment.process.ablation_stage_2.Panel1 = info; equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, true); Ablation_Run_Th = new Thread(() => Ablation_Run(info.Fine_Align_T_Offset + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_T_B1)); Ablation_Run_Th.Start(); Step = AblationSteps.S3215_ABLATION_PROCESS_WAIT; break; } case AblationSteps.S3215_ABLATION_PROCESS_WAIT: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (!moving) { equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Step = AblationSteps.S3220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S3220_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_B1_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S3225_POSITION_CHECK; } break; } case AblationSteps.S3225_POSITION_CHECK: { double position = Get_Scanner_Z_B1_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S3999_ABLATION_STAGE_2_1_END; } else { Step = AblationSteps.S3220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S3999_ABLATION_STAGE_2_1_END: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (!moving) { equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Tact_Move.Stop(); Step = AblationSteps.S0000_WAIT; } } break; } } } private void Seq_AblationB2() { switch (Step) { case AblationSteps.S4000_ABLATION_STAGE_2_2_START: { Panel_Info info = equipment.process.ablation_stage_2.Panel2; if (equipment.process.ablation_stage_2.Stage2.IsExist == false || info.IsAblationWorked || info.Ablation_Run == false) { Step = AblationSteps.S4999_ABLATION_STAGE_2_2_END; } else { Tact_Move.Start(); Step = AblationSteps.S4100_MOVE_Z_STAY_POSITION; } break; } case AblationSteps.S4100_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_B2_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S4105_POSITION_CHECK; } break; } case AblationSteps.S4105_POSITION_CHECK: { double position = Get_Scanner_Z_B2_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S4110_MOVE_X_ABLATION_POSITION; } else { Step = AblationSteps.S4100_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S4110_MOVE_X_ABLATION_POSITION: { Panel_Info info = equipment.process.ablation_stage_2.Panel2; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_B2 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S4115_POSITION_CHECK; } break; } case AblationSteps.S4115_POSITION_CHECK: { Panel_Info info = equipment.process.ablation_stage_2.Panel2; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_X_B2 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B2; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S4120_ABLATION_STAGE_2_CHECK; } else { Step = AblationSteps.S4110_MOVE_X_ABLATION_POSITION; } } break; } case AblationSteps.S4120_ABLATION_STAGE_2_CHECK: { Panel_Info info = equipment.process.ablation_stage_2.Panel2; double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Scanner_Y_B2 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_Y_B2; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_2.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S4130_MOVE_Z_ABLATION_POSITION; } break; } case AblationSteps.S4130_MOVE_Z_ABLATION_POSITION: { if (MotorZ.Move_Absolute_Pos(equipment.Cur_Main_Recipe.process_info.Scanner_Z_B2, 500)) { Step = AblationSteps.S4135_POSITION_CHECK; } break; } case AblationSteps.S4135_POSITION_CHECK: { if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(equipment.Cur_Main_Recipe.process_info.Scanner_Z_B2, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S4200_LASER_SETTING; } else { Step = AblationSteps.S4130_MOVE_Z_ABLATION_POSITION; } } break; } case AblationSteps.S4200_LASER_SETTING: { if (sequenceChangedTime.Seconds < 1) return; double jump_speed = 0, mark_speed = 0; short laseron_delay = 0, laseroff_delay = 0; ushort jump_delay = 0, mark_delay = 0, polygon_delay = 0; jump_speed = equipment.Cur_Main_Recipe.process_info.Jump_Speed; mark_speed = equipment.Cur_Main_Recipe.process_info.Mark_Speed; laseron_delay = equipment.Cur_Main_Recipe.process_info.Laser_On_Delay; laseroff_delay = equipment.Cur_Main_Recipe.process_info.Laser_Off_Delay; jump_delay = equipment.Cur_Main_Recipe.process_info.Jump_Delay; mark_delay = equipment.Cur_Main_Recipe.process_info.Mark_Delay; polygon_delay = 0; if (!equipment.scanner.Set_Process_Datas(jump_speed, mark_speed, laseron_delay, laseroff_delay, jump_delay, mark_delay, polygon_delay)) return; int frequency = equipment.Cur_Main_Recipe.process_info.Frequency; double power = equipment.Cur_Main_Recipe.process_info.Power + equipment.Setting.Stage_2_2_Power_Offset; Panel_Info info = equipment.process.ablation_stage_2.Panel2; info.AblationPower = power; info.AblationTargetPower = equipment.Cur_Main_Recipe.process_info.Target_Power_W; equipment.process.ablation_stage_2.Panel2 = info; if (!equipment.scanner.Set_Power(frequency, power)) return; Step = AblationSteps.S4210_ABLATION_PROCESS_START; break; } case AblationSteps.S4210_ABLATION_PROCESS_START: { if (sequenceChangedTime.Seconds < 0.5) return; if (equipment.Mode.Ablation_Skip || equipment.process.ablation_stage_2.Stage2.IsExist == false) { Step = AblationSteps.S4215_ABLATION_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_2.Panel2; info.IsAblationWorked = true; equipment.process.ablation_stage_2.Panel2 = info; equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, true); Ablation_Run_Th = new Thread(() => Ablation_Run(info.Fine_Align_T_Offset + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_T_B2)); Ablation_Run_Th.Start(); Step = AblationSteps.S4215_ABLATION_PROCESS_WAIT; break; } case AblationSteps.S4215_ABLATION_PROCESS_WAIT: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (!moving) { equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Step = AblationSteps.S4220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S4220_MOVE_Z_STAY_POSITION: { double position = Get_Scanner_Z_B2_Stay_Position(); if (MotorZ.Move_Absolute_Pos(position, 500)) { Step = AblationSteps.S4225_POSITION_CHECK; } break; } case AblationSteps.S4225_POSITION_CHECK: { double position = Get_Scanner_Z_B2_Stay_Position(); if (MotorZ.MotionComplete) { if (MotorZ.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = AblationSteps.S4999_ABLATION_STAGE_2_2_END; } else { Step = AblationSteps.S4220_MOVE_Z_STAY_POSITION; } } break; } case AblationSteps.S4999_ABLATION_STAGE_2_2_END: { if (Ablation_Run_Th != null && Ablation_Run_Th.ThreadState != ThreadState.Stopped) { return; } else if (sequenceChangedTime.Seconds > 1) { bool moving; equipment.scanner.Get_Busy(out moving); if (!moving) { Tact_Move.Stop(); equipment.Board_Control.IO_manager.Set_Output(OutputData.LASER_LED_Electronic_Board, false); Step = AblationSteps.S0000_WAIT; } } break; } } } private void Seq_Power_Measure() { //Laser 출사 위치에서 Power Meter위치가 아닐 때 Laser off 후 첫 Step으로 이동. if((AblationSteps.S5320_LASER_ON <= Step && Step <= AblationSteps.S5360_POWER_MEASUREMENT_END) || (AblationSteps.S5420_LASER_ON <= Step && Step <= AblationSteps.S5460_POWER_MEASUREMENT_END)) { if (equipment.process.ablation.Get_Is_Position_X_Power_Meter() == false || equipment.process.ablation.Get_Is_Position_Z_Power_Meter() == false) { if (equipment.scanner.Set_Laser_Off()) { Step = AblationSteps.S0000_WAIT; } } } switch (Step) { case AblationSteps.S5000_AUTO_POWER_START: { if (!auto_power_view.shown) return; retry_cnt = 0; auto_power_view.Clear_Info(); auto_power_view.Add_Info($"{DateTime.Now} Auto Power Start"); Step = AblationSteps.S5100_POWER_METER_STATUS_CHECK; break; } case AblationSteps.S5100_POWER_METER_STATUS_CHECK: { if (equipment.power_meter.Check_Power_Meter_Status()) { Step = AblationSteps.S5110_MEASURE_MODE_SET_W; } else { auto_power_view.Add_Info($"Power Meter Status Fail"); Step = AblationSteps.S5999_AUTO_POWER_END; } break; } case AblationSteps.S5110_MEASURE_MODE_SET_W: { equipment.power_meter.Set_Measurement_Mode_W(); Step = AblationSteps.S5120_MEASURE_MODE_SET_CHECK; break; } case AblationSteps.S5120_MEASURE_MODE_SET_CHECK: { if (equipment.power_meter.Check_Measurement_Mode_W()) { Step = AblationSteps.S5130_ZERO_SET; } break; } case AblationSteps.S5130_ZERO_SET: { equipment.power_meter.Set_Zero(); Step = AblationSteps.S5210_SCANNER_POSITION_MOVE; break; } case AblationSteps.S5210_SCANNER_POSITION_MOVE: { if (equipment.process.ablation.Move_X_Power_Meter_Position()) { if (equipment.process.ablation.Move_Z_Power_Meter_Position()) { Step = AblationSteps.S5220_SCANNER_MOVE_WAIT; } } break; } case AblationSteps.S5220_SCANNER_MOVE_WAIT: { if (equipment.process.ablation.MotorX.MotionComplete && equipment.process.ablation.MotorZ.MotionComplete) { if (equipment.process.ablation.Get_Is_Position_X_Power_Meter() && equipment.process.ablation.Get_Is_Position_Z_Power_Meter()) { auto_power_view.Add_Info($"Scanner Position Move"); Step = AblationSteps.S5300_SCANNER_INIT; } else { Step = AblationSteps.S5210_SCANNER_POSITION_MOVE; } } break; } case AblationSteps.S5300_SCANNER_INIT: { if (equipment.Cur_Main_Recipe.process_info == null) return; if (equipment.scanner.Initialize(equipment.Cur_Main_Recipe.process_info.CTB_File_Path)) { Step = AblationSteps.S5310_TARGET_POWER_SET; } else { //Interlock. } break; } case AblationSteps.S5310_TARGET_POWER_SET: { int frequency = equipment.Power_Parameter.Target_Setting_Frequency; double power = equipment.Power_Parameter.Target_Setting_Power; if (equipment.scanner.Set_Power(frequency, power)) { auto_power_view.Add_Info($"Target Power Set."); auto_power_view.Add_Info($"Frequency : {frequency}"); auto_power_view.Add_Info($"Power : {power}"); Step = AblationSteps.S5320_LASER_ON; } break; } case AblationSteps.S5320_LASER_ON: { if (equipment.process.ablation.MotorX.MotionComplete && equipment.process.ablation.MotorZ.MotionComplete) { if (equipment.process.ablation.Get_Is_Position_X_Power_Meter() && equipment.process.ablation.Get_Is_Position_Z_Power_Meter()) { if (equipment.scanner.Set_Laser_On()) { auto_power_view.Add_Info($"Laser On."); Step = AblationSteps.S5330_LASER_ON_CHECK; } } else { Step = AblationSteps.S0000_WAIT; } } break; } case AblationSteps.S5330_LASER_ON_CHECK: { if (equipment.sm.Get_Bit(Input_Memory_Address.Laser_Active)) { Step = AblationSteps.S5340_POWER_MEASUREMENT_START; } break; } case AblationSteps.S5340_POWER_MEASUREMENT_START: { if (sequenceChangedTime.Seconds < 5) return; auto_power_view.Add_Info($"Target Measrue Start."); lst_power.Clear(); Power_Time_Check.Start(); Step = AblationSteps.S5350_POWER_MEASUREMENT; break; } case AblationSteps.S5350_POWER_MEASUREMENT: { if (Power_Time_Check.Seconds < equipment.Power_Parameter.Measurement_Time_Sec) { double power = equipment.power_meter.Read_Power(); lst_power.Add(power); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Energy, power); if (lst_power.Count != 0) { equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Average, lst_power.Average()); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Max, lst_power.Max()); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Min, lst_power.Min()); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Count, lst_power.Count); } else { equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Average, 0); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Max, 0); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Min, 0); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Count, 0); } } else { Step = AblationSteps.S5360_POWER_MEASUREMENT_END; } break; } case AblationSteps.S5360_POWER_MEASUREMENT_END: { Step = AblationSteps.S5370_LASER_OFF; break; } case AblationSteps.S5370_LASER_OFF: { if (equipment.scanner.Set_Laser_Off()) { Step = AblationSteps.S5380_LASER_OFF_CHECK; } break; } case AblationSteps.S5380_LASER_OFF_CHECK: { if (!equipment.sm.Get_Bit(Input_Memory_Address.Laser_Active)) { auto_power_view.Add_Info($"Laser Off."); Step = AblationSteps.S5390_ENERGY_CHECK; } break; } case AblationSteps.S5390_ENERGY_CHECK: { if(lst_power.Count == 0) { //alarm. Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0942_POWER_COUNT_IS_EMPTY); Step = AblationSteps.S5999_AUTO_POWER_END; } double averager = lst_power.Average(); double min = equipment.Power_Parameter.Target_Power - equipment.Power_Parameter.Target_Margin_of_Error; double max = equipment.Power_Parameter.Target_Power + equipment.Power_Parameter.Target_Margin_of_Error; if (min <= averager && averager <= max) { auto_power_view.Add_Info($"Target Measure Success"); auto_power_view.Add_Info($"Target : {equipment.Power_Parameter.Target_Power}"); auto_power_view.Add_Info($"Averager : {averager}"); auto_power_view.Add_Info($"Max : {lst_power.Max()}"); auto_power_view.Add_Info($"Min : {lst_power.Min()}"); Step = AblationSteps.S5400_SCANNER_INIT; } else { //Target Alarm auto_power_view.Add_Info($"Target Measure Fail"); auto_power_view.Add_Info($"Target : {equipment.Power_Parameter.Target_Power}"); auto_power_view.Add_Info($"Averager : {averager}"); auto_power_view.Add_Info($"Max : {lst_power.Max()}"); auto_power_view.Add_Info($"Min : {lst_power.Min()}"); Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0940_TARGET_POWER_ERROR); Step = AblationSteps.S5999_AUTO_POWER_END; } break; } case AblationSteps.S5400_SCANNER_INIT: { if (equipment.Cur_Main_Recipe.process_info == null) return; if (equipment.scanner.Initialize(equipment.Cur_Main_Recipe.process_info.CTB_File_Path)) { Step = AblationSteps.S5410_RECIPE_POWER_SET; } else { //Interlock. } break; } case AblationSteps.S5410_RECIPE_POWER_SET: { if (sequenceChangedTime.Seconds < 5) return; int frequency = equipment.Cur_Main_Recipe.process_info.Frequency; double power = equipment.Cur_Main_Recipe.process_info.Power; if (equipment.scanner.Set_Power(frequency, power)) { Step = AblationSteps.S5420_LASER_ON; } break; } case AblationSteps.S5420_LASER_ON: { if (equipment.process.ablation.MotorX.MotionComplete && equipment.process.ablation.MotorZ.MotionComplete) { if (equipment.process.ablation.Get_Is_Position_X_Power_Meter() && equipment.process.ablation.Get_Is_Position_Z_Power_Meter()) { if (equipment.scanner.Set_Laser_On()) { auto_power_view.Add_Info($"Laser On."); Step = AblationSteps.S5430_LASER_ON_CHECK; } } else { Step = AblationSteps.S0000_WAIT; } } break; } case AblationSteps.S5430_LASER_ON_CHECK: { if (equipment.sm.Get_Bit(Input_Memory_Address.Laser_Active)) { auto_power_view.Add_Info($"Laser On"); Step = AblationSteps.S5440_POWER_MEASUREMENT_START; } break; } case AblationSteps.S5440_POWER_MEASUREMENT_START: { if (sequenceChangedTime.Seconds < 5) return; auto_power_view.Add_Info($"Recipe Measrue Start."); lst_power.Clear(); Power_Time_Check.Start(); Step = AblationSteps.S5450_POWER_MEASUREMENT; break; } case AblationSteps.S5450_POWER_MEASUREMENT: { if (Power_Time_Check.Seconds < equipment.Power_Parameter.Measurement_Time_Sec) { double power = equipment.power_meter.Read_Power(); lst_power.Add(power); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Energy, power); if (lst_power.Count != 0) { equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Average, lst_power.Average()); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Max, lst_power.Max()); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Min, lst_power.Min()); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Count, lst_power.Count); } else { equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Average, 0); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Max, 0); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Min, 0); equipment.sm.Set_Value(Process_Memory_Address.Power_Meter_Count, 0); } } else { Step = AblationSteps.S5460_POWER_MEASUREMENT_END; } break; } case AblationSteps.S5460_POWER_MEASUREMENT_END: { Step = AblationSteps.S5470_LASER_OFF; break; } case AblationSteps.S5470_LASER_OFF: { if (equipment.scanner.Set_Laser_Off()) { Step = AblationSteps.S5480_LASER_OFF_CHECK; } break; } case AblationSteps.S5480_LASER_OFF_CHECK: { if (!equipment.sm.Get_Bit(Input_Memory_Address.Laser_Active)) { auto_power_view.Add_Info($"Lsaer Off"); Step = AblationSteps.S5490_ENERGEY_CHECK; } break; } case AblationSteps.S5490_ENERGEY_CHECK: { if (lst_power.Count == 0) { //alarm. Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0942_POWER_COUNT_IS_EMPTY); Step = AblationSteps.S5999_AUTO_POWER_END; } double averager = lst_power.Average(); double min = equipment.Cur_Main_Recipe.process_info.Target_Power_W - equipment.Power_Parameter.Recipe_Margin_of_Error; double max = equipment.Cur_Main_Recipe.process_info.Target_Power_W + equipment.Power_Parameter.Recipe_Margin_of_Error; if (min <= averager && averager <= max) { auto_power_view.Add_Info($"Recipe Measure Succeess"); auto_power_view.Add_Info($"Target : {equipment.Cur_Main_Recipe.process_info.Target_Power_W}"); auto_power_view.Add_Info($"Averager : {averager}"); auto_power_view.Add_Info($"Max : {lst_power.Max()}"); auto_power_view.Add_Info($"Min : {lst_power.Min()}"); Step = AblationSteps.S5999_AUTO_POWER_END; } else { if (retry_cnt < equipment.Power_Parameter.Power_Revision_Count) { auto_power_view.Add_Info($"Recipe Measure Fail"); auto_power_view.Add_Info($"Target : {equipment.Cur_Main_Recipe.process_info.Target_Power_W}"); auto_power_view.Add_Info($"Averager : {averager}"); auto_power_view.Add_Info($"Max : {lst_power.Max()}"); auto_power_view.Add_Info($"Min : {lst_power.Min()}"); auto_power_view.Add_Info($"Recipe Measure Retry"); retry_cnt++; Step = AblationSteps.S5510_RECIPE_POWER_CHANGE; } else { //Target Alarm auto_power_view.Add_Info($"Recipe Measure Fail"); auto_power_view.Add_Info($"Target : {equipment.Cur_Main_Recipe.process_info.Target_Power_W}"); auto_power_view.Add_Info($"Averager : {averager}"); auto_power_view.Add_Info($"Max : {lst_power.Max()}"); auto_power_view.Add_Info($"Min : {lst_power.Min()}"); Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0941_RECIPE_POWER_ERROR); Step = AblationSteps.S5999_AUTO_POWER_END; } } break; } case AblationSteps.S5510_RECIPE_POWER_CHANGE: { double com_power = equipment.Cur_Main_Recipe.process_info.Target_Power_W - lst_power.Average(); int frequency = equipment.Cur_Main_Recipe.process_info.Frequency; double power = equipment.Cur_Main_Recipe.process_info.Power + com_power; Main_Recipe recipe = equipment.Cur_Main_Recipe.Clone(); auto_power_view.Add_Info($"Recipe Name : {recipe.process_info.Name}"); auto_power_view.Add_Info($"Current Power : {recipe.process_info.Power}"); auto_power_view.Add_Info($"Change Power : {power.ToString("F1")}"); recipe.process_info.Power = double.Parse(power.ToString("F1")); Process_Info_Manager.Instance.Save_Recipe(recipe.process_info.Name, recipe.process_info); Main_Recipe_Manager.Instance.Save_Recipe(recipe.Name, recipe); Step = AblationSteps.S5410_RECIPE_POWER_SET; break; } case AblationSteps.S5999_AUTO_POWER_END: { Parameter_Power parameter = equipment.Power_Parameter.Clone(); parameter.Measure_Date = DateTime.Now; Parameter_Power_Manager.Instance.Save_Parameter_Power(parameter); auto_power_view.Add_Info($"Auto Power Check End."); Step = AblationSteps.S0000_WAIT; break; } } } public bool Auto_Power_Start() { if (Step == AblationSteps.S0000_WAIT) { Step = AblationSteps.S5000_AUTO_POWER_START; return true; } else { return false; } } private void Ablation_Run(double degree) { bool moving; do { equipment.scanner.Get_Busy(out moving); } while (moving); Thread th; if (equipment.Cur_Main_Recipe.process_info.Draw_Info_1.Draw) { th = new Thread(() => Ablation_Run(equipment.Cur_Main_Recipe.process_info.Draw_Info_1, degree)); th.Start(); while (th.ThreadState != ThreadState.Stopped) { } } if (equipment.Cur_Main_Recipe.process_info.Draw_Info_2.Draw) { th = new Thread(() => Ablation_Run(equipment.Cur_Main_Recipe.process_info.Draw_Info_2, degree)); th.Start(); while (th.ThreadState != ThreadState.Stopped) { } } if (equipment.Cur_Main_Recipe.process_info.Draw_Info_3.Draw) { th = new Thread(() => Ablation_Run(equipment.Cur_Main_Recipe.process_info.Draw_Info_3, degree)); th.Start(); while (th.ThreadState != ThreadState.Stopped) { } } if (equipment.Cur_Main_Recipe.process_info.Draw_Info_4.Draw) { th = new Thread(() => Ablation_Run(equipment.Cur_Main_Recipe.process_info.Draw_Info_4, degree)); th.Start(); while (th.ThreadState != ThreadState.Stopped) { } } } private void Ablation_Run(Process_Draw_Info draw_info, double degree) { Scanner_Recipe rec; bool moving; float work_area_x, work_area_y; float start_x, end_x, start_y, end_y, distance, draw_distance; int repeat, range, draw_repeat; Scanner_Recipe.Ablation_Style waveform; work_area_x = equipment.Cur_Main_Recipe.process_info.Work_Area_X; work_area_y = equipment.Cur_Main_Recipe.process_info.Work_Area_Y; start_x = draw_info.Start_X; end_x = draw_info.End_X; start_y = draw_info.Start_Y; end_y = draw_info.End_Y; distance = equipment.Cur_Main_Recipe.process_info.Hatch_Distance; repeat = equipment.Cur_Main_Recipe.process_info.Jump_Repeat; range = equipment.Cur_Main_Recipe.process_info.Jump_Range; draw_distance = draw_info.Distance; draw_repeat = draw_info.Repeat; waveform = (Scanner_Recipe.Ablation_Style)equipment.Cur_Main_Recipe.process_info.Waveform; if (draw_info.Reverse) rec = new Scanner_Recipe(work_area_x, work_area_y, start_x, start_y, end_x, end_y, distance, repeat, range, 0, draw_distance, 0, draw_repeat, waveform, degree, draw_info.Reverse); else rec = new Scanner_Recipe(work_area_x, work_area_y, start_x, start_y, end_x, end_y, distance, repeat, range, draw_distance, 0, draw_repeat, 0, waveform, degree, draw_info.Reverse); do { equipment.scanner.Get_Busy(out moving); } while (moving); equipment.scanner.Set_Start_List(1); equipment.Write_Scanner_Log($"degree : {degree}, reverse : {draw_info.Reverse}"); foreach (Scanner_Position_Info info in rec.Recipe_Pos_Info) { if (info.mark) { equipment.scanner.Set_Mark_Abs(info.x, info.y); } else { equipment.scanner.Set_Jump_Abs(info.x, info.y); } } equipment.scanner.Set_End_Of_List(); equipment.scanner.Set_Excute_List(1); do { equipment.scanner.Get_Busy(out moving); } while (moving); } public bool Move_X_Power_Meter_Position() { object value; double position; double velocity; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_X_Power_Meter_Position, out value); position = double.Parse($"{value}"); equipment.sm.Get_Value(Position_Parameter_Address.Scanner_X_Power_Meter_Velocity, out value); velocity = double.Parse($"{value}"); return MotorX.Move_Absolute_Pos(position, velocity); } public bool Move_Z_Power_Meter_Position() { object value; double position; double velocity; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_Power_Meter_Position, out value); position = double.Parse($"{value}"); equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_Power_Meter_Velocity, out value); velocity = double.Parse($"{value}"); return MotorZ.Move_Absolute_Pos(position, velocity); } public bool Get_Is_Position_X_Power_Meter() { object value; double get_position; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_X_Power_Meter_Position, out value); get_position = double.Parse($"{value}"); return MotorX.Is_Inposition(get_position, equipment.Setting.Inposition_Offset); } public bool Get_Is_Position_Z_Power_Meter() { object value; double get_position; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_Power_Meter_Position, out value); get_position = double.Parse($"{value}"); return MotorZ.Is_Inposition(get_position, equipment.Setting.Inposition_Offset); } public double Get_Scanner_Z_A1_Stay_Position() { object value; double get_position; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_A1_Position, out value); get_position = double.Parse($"{value}"); return get_position; } public double Get_Scanner_Z_A2_Stay_Position() { object value; double get_position; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_A2_Position, out value); get_position = double.Parse($"{value}"); return get_position; } public double Get_Scanner_Z_B1_Stay_Position() { object value; double get_position; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_B1_Position, out value); get_position = double.Parse($"{value}"); return get_position; } public double Get_Scanner_Z_B2_Stay_Position() { object value; double get_position; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_B2_Position, out value); get_position = double.Parse($"{value}"); return get_position; } public bool StageA1AblationStart() { if (Step != AblationSteps.S0000_WAIT) { return false; } else { Step = AblationSteps.S1000_ABLATION_STAGE_1_1_START; return true; } } public bool StageA2AblationStart() { if (Step != AblationSteps.S0000_WAIT) { return false; } else { Step = AblationSteps.S2000_ABLATION_STAGE_1_2_START; return true; } } public bool StageB1AblationStart() { if (Step != AblationSteps.S0000_WAIT) { return false; } else { Step = AblationSteps.S3000_ABLATION_STAGE_2_1_START; return true; } } public bool StageB2AblationStart() { if (Step != AblationSteps.S0000_WAIT) { return false; } else { Step = AblationSteps.S4000_ABLATION_STAGE_2_2_START; return true; } } public bool Move_Cleaning_Position() { object value; equipment.sm.Get_Value(Position_Parameter_Address.Scanner_Z_A1_Position, out value); double position = double.Parse($"{value}"); return MotorX.Move_Absolute_Pos(0, 500) && MotorZ.Move_Absolute_Pos(position, 500); } public void Stage1WaitPositionMove() { double position = equipment.Cur_Main_Recipe.process_info.Scanner_X_A1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_A1; position = double.Parse(position.ToString("F3")); MotorX.Move_Absolute_Pos(position, 500); } public void Stage2WaitPositionMove() { double position = equipment.Cur_Main_Recipe.process_info.Scanner_X_B1 + equipment.Cur_Main_Recipe.panel_type_info.Scanner_Offset_X_B1; position = double.Parse(position.ToString("F3")); MotorX.Move_Absolute_Pos(position, 500); } #endregion } }