using System; using System.Threading; namespace SHARP_CLAS_UI { public class Plasma : PlasmaUnit { #region Enum #endregion #region Property public override bool IsWorkEnd { get { if(Step == PlasmaStpes.S0000_WAIT) { return true; } else { return false; } } } public override bool IsStayPosition { get { return true; } } public PlasmaStpes Step { get { return _step; } set { _step = value; } } #endregion #region Field private PlasmaStpes _step; private PlasmaStpes _oldStep; private PlasmaHomeSteps _homeStep; Time_Checker Home_check = new Time_Checker(); public Time_Checker Tact_Move = new Time_Checker(); public double plasma_postion; Thread Plasma_Run_Th; #endregion #region Construct public Plasma(Equipment equipment) : base(equipment, MotorAxis.Plasma_X) { Step = PlasmaStpes.S0000_WAIT; _oldStep = PlasmaStpes.S0000_WAIT; MotorX.Check_Jog_Interlock = Jog_Interlock; MotorX.Check_Move_Interlock = Move_Interlock; pauseDisableList.Add(PlasmaStpes.S1105_POSITION_CHECK); pauseDisableList.Add(PlasmaStpes.S2105_POSITION_CHECK); pauseDisableList.Add(PlasmaStpes.S3105_POSITION_CHECK); pauseDisableList.Add(PlasmaStpes.S4105_POSITION_CHECK); } #endregion #region Function 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; } public void Init_Seq() { Step = PlasmaStpes.S0000_WAIT; _homeStep = PlasmaHomeSteps.S0000_WAIT; Tact_Move.Reset(); if (equipment.sm.Get_Bit(Output_Memory_Address.Plasma_Remote_On_Relay)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, false); } } public void ExecuteStepAuto() { } public override void MonitoringStatus() { if (equipment.User.Level != En_User_Level.Master && equipment.Door_Opened) { if (MotorX.MotionComplete == false) { MotorX.Move_Stop(); } if (equipment.Board_Control.IO_manager.Get_Output(OutputData.Plasma_Remote_On_Relay)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, false); } } } 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) { 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) { ExecuteStepAuto(); } Seq_PlasmaA1(); Seq_PlasmaA2(); Seq_PlasmaB1(); Seq_PlasmaB2(); } } private void Seq_Home() { switch(_homeStep) { case PlasmaHomeSteps.S0000_WAIT: { _homeStep = PlasmaHomeSteps.S1000_STATUS_CHECK; break; } case PlasmaHomeSteps.S1000_STATUS_CHECK: { if (MotorX.ErrorStop) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0341_PLASMA_X_ERROR_STOP); } else if (!MotorX.PowerOn) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0340_PLASMA_X_POWER_OFF); } else { _homeStep = PlasmaHomeSteps.S2000_X_HOME_START; } break; } case PlasmaHomeSteps.S2000_X_HOME_START: { if (MotorX.Home()) { Home_check.Start(); _homeStep = PlasmaHomeSteps.S2100_X_HOME_CHECK; } break; } case PlasmaHomeSteps.S2100_X_HOME_CHECK: { if (Home_check.Seconds < 1) return; if (!MotorX.IsHomed) { if (MotorX.Homing == false && MotorX.ErrorStop) { Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0341_PLASMA_X_ERROR_STOP); } } else { _homeStep = PlasmaHomeSteps.S9999_END; } break; } case PlasmaHomeSteps.S9999_END: { isHomeComplete = true; _homeStep = PlasmaHomeSteps.S0000_WAIT; break; } } } private void Seq_PlasmaA1() { switch (Step) { case PlasmaStpes.S1000_ABLATION_STAGE_1_1_START: { Step = PlasmaStpes.S1100_MOVE_X_PLASMA_POSITION; break; } case PlasmaStpes.S1100_MOVE_X_PLASMA_POSITION: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_1_1); if (equipment.Mode.Plasma_Skip || (!equipment.Mode.Film_Judge_Skip && !info.Film_Judge_Result) || !info.Ablation_Run) { Step = PlasmaStpes.S1210_PLASMA_PROCESS_WAIT; return; } double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_A1 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = PlasmaStpes.S1105_POSITION_CHECK; } break; } case PlasmaStpes.S1105_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.Plasma_X_A1 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S1100_ABLATION_STAGE_POSITION_CHECK; } else { Step = PlasmaStpes.S1100_MOVE_X_PLASMA_POSITION; } } break; } case PlasmaStpes.S1100_ABLATION_STAGE_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_1_1); double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_Y_A1; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_1.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S1200_PLASMA_PROCESS_START; } break; } case PlasmaStpes.S1200_PLASMA_PROCESS_START: { if (equipment.process.ablation_stage_1.Stage1.IsExist == false) { Step = PlasmaStpes.S1210_PLASMA_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_1.Panel1; info.IsPlasmaWorked = true; equipment.process.ablation_stage_1.Panel1 = info; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_A1 + equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, equipment.Cur_Main_Recipe.process_info.Plasma_Speed)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, true); Plasma_Run_Th = new Thread(() => Plasma_Run(position - 2)); Plasma_Run_Th.Start(); Step = PlasmaStpes.S1210_PLASMA_PROCESS_WAIT; } break; } case PlasmaStpes.S1210_PLASMA_PROCESS_WAIT: { if (Plasma_Run_Th != null && Plasma_Run_Th.ThreadState != ThreadState.Stopped) return; if (MotorX.MotionComplete) { Step = PlasmaStpes.S1999_ABLATION_STAGE_1_1_END; } break; } case PlasmaStpes.S1999_ABLATION_STAGE_1_1_END: { Step = PlasmaStpes.S0000_WAIT; break; } } } private void Seq_PlasmaA2() { switch (Step) { case PlasmaStpes.S2000_ABLATION_STAGE_1_2_START: { Step = PlasmaStpes.S2100_MOVE_X_PLASMA_POSITION; break; } case PlasmaStpes.S2100_MOVE_X_PLASMA_POSITION: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_1_2); if (equipment.Mode.Plasma_Skip || (!equipment.Mode.Film_Judge_Skip && !info.Film_Judge_Result) || !info.Ablation_Run) { Step = PlasmaStpes.S2210_PLASMA_PROCESS_WAIT; return; } double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_A2 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = PlasmaStpes.S2105_POSITION_CHECK; } break; } case PlasmaStpes.S2105_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_1_2); double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_A2 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S2100_ABLATION_STAGE_POSITION_CHECK; } else { Step = PlasmaStpes.S2100_MOVE_X_PLASMA_POSITION; } } break; } case PlasmaStpes.S2100_ABLATION_STAGE_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_1_2); double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_Y_A2; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_1.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S2200_PLASMA_PROCESS_START; } break; } case PlasmaStpes.S2200_PLASMA_PROCESS_START: { if (equipment.process.ablation_stage_1.Stage2.IsExist == false) { Step = PlasmaStpes.S2210_PLASMA_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_1.Panel2; info.IsPlasmaWorked = true; equipment.process.ablation_stage_1.Panel2 = info; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_A2 + equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, equipment.Cur_Main_Recipe.process_info.Plasma_Speed)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, true); Plasma_Run_Th = new Thread(() => Plasma_Run(position - 2)); Plasma_Run_Th.Start(); Step = PlasmaStpes.S2210_PLASMA_PROCESS_WAIT; } break; } case PlasmaStpes.S2210_PLASMA_PROCESS_WAIT: { if (Plasma_Run_Th != null && Plasma_Run_Th.ThreadState != ThreadState.Stopped) return; if (MotorX.MotionComplete) { Tact_Move.Stop(); Step = PlasmaStpes.S2999_ABLATION_STAGE_1_2_END; } break; } case PlasmaStpes.S2999_ABLATION_STAGE_1_2_END: { Step = PlasmaStpes.S0000_WAIT; break; } } } private void Seq_PlasmaB1() { switch (Step) { case PlasmaStpes.S3000_ABLATION_STAGE_2_1_START: { Step = PlasmaStpes.S3100_MOVE_X_PLASMA_POSITION; break; } case PlasmaStpes.S3100_MOVE_X_PLASMA_POSITION: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_2_1); if (equipment.Mode.Plasma_Skip || (!equipment.Mode.Film_Judge_Skip && !info.Film_Judge_Result) || !info.Ablation_Run) { Step = PlasmaStpes.S3210_PLASMA_PROCESS_WAIT; return; } double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_B1 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = PlasmaStpes.S3105_POSITION_CHECK; } break; } case PlasmaStpes.S3105_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_2_1); double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_B1 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S3100_ABLATION_STAGE_POSITION_CHECK; } else { Step = PlasmaStpes.S3100_MOVE_X_PLASMA_POSITION; } } break; } case PlasmaStpes.S3100_ABLATION_STAGE_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_2_1); double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_Y_B1; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_2.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S3200_PLASMA_PROCESS_START; } break; } case PlasmaStpes.S3200_PLASMA_PROCESS_START: { if (equipment.process.ablation_stage_2.Stage1.IsExist == false) { Step = PlasmaStpes.S3210_PLASMA_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_2.Panel1; info.IsPlasmaWorked = true; equipment.process.ablation_stage_2.Panel1 = info; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_B1 + equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, equipment.Cur_Main_Recipe.process_info.Plasma_Speed)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, true); Plasma_Run_Th = new Thread(() => Plasma_Run(position - 2)); Plasma_Run_Th.Start(); Step = PlasmaStpes.S3210_PLASMA_PROCESS_WAIT; } break; } case PlasmaStpes.S3210_PLASMA_PROCESS_WAIT: { if (Plasma_Run_Th != null && Plasma_Run_Th.ThreadState != ThreadState.Stopped) return; if (MotorX.MotionComplete) { Step = PlasmaStpes.S3999_ABLATION_STAGE_2_1_END; } break; } case PlasmaStpes.S3999_ABLATION_STAGE_2_1_END: { Step = PlasmaStpes.S0000_WAIT; break; } } } private void Seq_PlasmaB2() { switch (Step) { case PlasmaStpes.S4000_ABLATION_STAGE_2_2_START: { Step = PlasmaStpes.S4100_MOVE_X_PLASMA_POSITION; break; } case PlasmaStpes.S4100_MOVE_X_PLASMA_POSITION: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_2_2); if (equipment.Mode.Plasma_Skip || (!equipment.Mode.Film_Judge_Skip && !info.Film_Judge_Result) || !info.Ablation_Run) { Step = PlasmaStpes.S4210_PLASMA_PROCESS_WAIT; return; } double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_B2 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, 500)) { Step = PlasmaStpes.S4105_POSITION_CHECK; } break; } case PlasmaStpes.S4105_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_2_2); double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_B2 - equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.MotionComplete) { if (MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S4100_ABLATION_STAGE_POSITION_CHECK; } else { Step = PlasmaStpes.S4100_MOVE_X_PLASMA_POSITION; } } break; } case PlasmaStpes.S4100_ABLATION_STAGE_POSITION_CHECK: { Panel_Info info = Panel_Info_Manager.Instance.Get_Panel_Info(Panel_Info_Names.Ablation_2_2); double position = info.Fine_Align_Y_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_Y_B2; position = double.Parse(position.ToString("F3")); if (equipment.process.ablation_stage_2.MotorY.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { Step = PlasmaStpes.S4200_PLASMA_PROCESS_START; } break; } case PlasmaStpes.S4200_PLASMA_PROCESS_START: { if (equipment.process.ablation_stage_2.Stage2.IsExist == false) { Step = PlasmaStpes.S4210_PLASMA_PROCESS_WAIT; return; } Panel_Info info = equipment.process.ablation_stage_2.Panel2; info.IsPlasmaWorked = true; equipment.process.ablation_stage_2.Panel2 = info; double position = info.Fine_Align_X_Offset + equipment.Cur_Main_Recipe.process_info.Plasma_X_B2 + equipment.Cur_Main_Recipe.process_info.Plasma_Distance / 2; position = double.Parse(position.ToString("F3")); if (MotorX.Move_Absolute_Pos(position, equipment.Cur_Main_Recipe.process_info.Plasma_Speed)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, true); Plasma_Run_Th = new Thread(() => Plasma_Run(position - 2)); Plasma_Run_Th.Start(); Step = PlasmaStpes.S4210_PLASMA_PROCESS_WAIT; } break; } case PlasmaStpes.S4210_PLASMA_PROCESS_WAIT: { if (Plasma_Run_Th != null && Plasma_Run_Th.ThreadState != ThreadState.Stopped) return; if (MotorX.MotionComplete) { Tact_Move.Stop(); Step = PlasmaStpes.S4999_ABLATION_STAGE_2_2_END; } break; } case PlasmaStpes.S4999_ABLATION_STAGE_2_2_END: { Step = PlasmaStpes.S0000_WAIT; break; } } } public void Plasma_Run(double position) { while(true) { if (MotorX.Position >= position || MotorX.Is_Inposition(position, equipment.Setting.Inposition_Offset)) { equipment.Board_Control.IO_manager.Set_Output(OutputData.Plasma_Remote_On_Relay, false); break; } } } public bool Move_Cleaning_Position() { double position = equipment.Cur_Main_Recipe.process_info.Plasma_X_B2; position = double.Parse(position.ToString("F3")); return MotorX.Move_Absolute_Pos(position, 500); } public bool StageA1PlasmaStart() { if (Step != PlasmaStpes.S0000_WAIT) { return false; } else { Step = PlasmaStpes.S1000_ABLATION_STAGE_1_1_START; return true; } } public bool StageA2PlasmaStart() { if (Step != PlasmaStpes.S0000_WAIT) { return false; } else { Step = PlasmaStpes.S2000_ABLATION_STAGE_1_2_START; return true; } } public bool StageB1PlasmaStart() { if (Step != PlasmaStpes.S0000_WAIT) { return false; } else { Step = PlasmaStpes.S3000_ABLATION_STAGE_2_1_START; return true; } } public bool StageB2PlasmaStart() { if (Step != PlasmaStpes.S0000_WAIT) { return false; } else { Step = PlasmaStpes.S4000_ABLATION_STAGE_2_2_START; return true; } } #endregion } }