using MECF.Framework.Common.CommonData; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.OperationCenter; using OpenSEMI.ClientBase; using Prism.Commands; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; using CyberX8_Core; using CyberX8_MainPages.Unity; using CyberX8_MainPages.Views; using CyberX8_Themes.CustomControls; using CyberX8_Themes.Unity; using CyberX8_Themes.UserControls; using Aitex.Core.RT.Log; using MECF.Framework.Common.Reservior; using MECF.Framework.Common.ProcessCell; using MECF.Framework.Common.Utilities; using Aitex.Sorter.Common; using MECF.Framework.Common.Schedulers; using MECF.Framework.Common.Beckhoff.Station; using MECF.Framework.Common.Layout; using Aitex.Core.RT.Routine; using Aitex.Core.RT.Device; using System.Reflection; using MECF.Framework.Common.Beckhoff.IOAxis; using MECF.Framework.Common.TwinCat; using LiveCharts.Wpf; using MECF.Framework.Common.CommonData.PUF; using MECF.Framework.Common.Beckhoff.AxisProvider; using QiHe.CodeLib; using MECF.Framework.Common.Jobs; namespace CyberX8_MainPages.ViewModels { public class OperationOverViewModel : BindableBase { #region 常量 private const string CURRENT_STATION = "CurrentStation"; private const string MOTOR_POSITION = "MotorPosition"; private const string MOTION_DATA = "MotionData"; private const double LOADER_ROTATION_DIFFER = 90; private const double PUF_FLIP_DIFFER = 180; #endregion #region 私有字段 private bool _isLp1Unable; private bool _isLp2Unable; private bool _isLp3Unable; private ModuleInfo _LP1ModuleInfo; private ModuleInfo _LP2ModuleInfo; private ModuleInfo _LP3ModuleInfo; private ModuleInfo _EFEMModuleInfo; private ModuleInfo _srd1ModuleInfo; private ModuleInfo _srd2ModuleInfo; private ModuleInfo _puf1ModuleInfo; private ModuleInfo _dummy1ModuleInfo; private ModuleInfo _dummy2ModuleInfo; private ModuleInfo _loaderModuleInfo; private WaferRobotTAction m_Robot1TAction; private WaferRobotXAction m_Robot1XAction; private WaferRobotTAction m_Robot2TAction; private WaferRobotXAction m_Robot2XAction; private WaferRobotTAction m_Robot3TAction; private WaferRobotXAction m_Robot3XAction; private WaferRobotTAction m_Robot4TAction; private WaferRobotXAction m_Robot4XAction; private RobotMoveInfo m_robotMoveInfo; private WaferInfo m_srd1Wafer; private WaferInfo m_srd2Wafer; private WaferInfo m_puf1WaferA; private WaferInfo m_puf1WaferB; private WaferInfo m_loaderWaferA; private WaferInfo m_loaderWaferB; private List m_RtDataKeys = new List(); private Dictionary m_RtDataValues; private bool m_EFEMIsInstalled; private bool m_loaderInstalled; private bool m_puf1IsInRobotStation; //private bool m_IsPUFChange; private WaferInfo m_EFEMBladeAWafer; private WaferInfo m_EFEMBladeBWafer; private WaferInfo m_Aligner1Wafer; private int m_LP1WaferCount; private int m_LP2WaferCount; private int m_LP3WaferCount; private int m_dummy1WaferCount; private int m_dummy2WaferCount; private int m_CycledWafer; private int m_CycleCountDisplay; private EFEM.RobotPosition m_CurrentRobotPosition; private PufControl.LoaderXLocation m_loaderAXLoaction = PufControl.LoaderXLocation.Parker; private PufControl.LoaderXLocation m_loaderBXLoaction = PufControl.LoaderXLocation.Parker; /// /// Loader的sideA开启状态 /// private bool m_loaderWaferVisibleA = false; /// /// Loader的sideB开启状态 /// private bool m_loaderWaferVisibleB = false; private WaferInfo m_BladeAWafer; private WaferInfo m_BladeBWafer; private string m_ATMModeIsOn; private string m_RouteState; /// /// puf1 Rotation ui 水平比例 /// private double _puf1RotationRatio; /// /// 定时器 /// private DispatcherTimer _timer; /// /// 定时器1 /// private DispatcherTimer _timer1; /// /// puf Rotation UI水平距离 /// private int _pufLayoutRotationDistance; /// /// Efem robot UI位置 /// private int _robotLayoutPosition; /// /// Puf1 Rotation实际位置数据 /// private double _puf1RotationMotorPosition; /// /// Puf1 Flip实际位置数据 /// private double _puf1FlipMotorPosition; /// /// Puf1 Flip UI位置 /// private double _puf1FlipPosition; /// /// Puf1 Rotation最左侧的位置 /// private double _puf1RotationMotorPositionMax; /// /// Puf1 Rotation UI对应位置 /// private double _puf1RotationPosition; /// /// Loader1 Rotation UI对应位置 /// private double _loader1RotationPosition; /// /// Puf1 Rotation Axis /// private BeckhoffStationAxis _puf1RotationAxis; /// /// Puf1 Flip Axis /// private BeckhoffStationAxis _puf1FlipAxis; /// /// Loader1 Rotation Axis /// private BeckhoffStationAxis _loader1RotationAxis; /// /// Loader1 TlitA Axis /// private BeckhoffStationAxis _loader1TiltAAxis; /// /// Loader1 TlitB Axis /// private BeckhoffStationAxis _loader1TiltBAxis; /// /// Loader1 Rotation实际位置数据 /// private double _loader1RotationMotorPosition; /// /// Loader1 TiltA实际位置数据 /// private double _loader1TiltAMotorPosition; /// /// Loader1 TiltB实际位置数据 /// private double _loader1TiltBMotorPosition; /// /// Loader Rotation位置 /// private LoaderControl.LoaderRotation m_currentLoaderRotation = LoaderControl.LoaderRotation.Load; /// /// Puf1 Flip当前station /// private string _puf1FlipCurrentStation; /// /// Loader1 TiltA当前station /// private string _loaderTiltACurrentStation; /// /// Loader1 TiltB当前station /// private string _loaderTiltBCurrentStation; /// /// 是否存在Job /// private bool _isLp1HasNoJob; private bool _isLp2HasNoJob; private bool _isLp3HasNoJob; #endregion #region 属性 public bool IsLP1Unable { get { return _isLp1Unable; } set { SetProperty(ref _isLp1Unable, value); } } public bool IsLP2Unable { get { return _isLp2Unable; } set { SetProperty(ref _isLp2Unable, value); } } public bool IsLP3Unable { get { return _isLp3Unable; } set { SetProperty(ref _isLp3Unable, value); } } public ModuleInfo LP1ModuleInfo { get { return _LP1ModuleInfo; } set { SetProperty(ref _LP1ModuleInfo, value); } } public ModuleInfo EFEMModuleInfo { get { return _EFEMModuleInfo; } set { SetProperty(ref _EFEMModuleInfo, value); } } public ModuleInfo LP2ModuleInfo { get { return _LP2ModuleInfo; } set { SetProperty(ref _LP2ModuleInfo, value); } } public ModuleInfo LP3ModuleInfo { get { return _LP3ModuleInfo; } set { SetProperty(ref _LP3ModuleInfo, value); } } public ModuleInfo SRD1ModuleInfo { get { return _srd1ModuleInfo; } set { SetProperty(ref _srd1ModuleInfo, value); } } public ModuleInfo SRD2ModuleInfo { get { return _srd2ModuleInfo; } set { SetProperty(ref _srd2ModuleInfo, value); } } public ModuleInfo PUF1ModuleInfo { get { return _puf1ModuleInfo; } set { SetProperty(ref _puf1ModuleInfo, value); } } public ModuleInfo Dummy1ModuleInfo { get { return _dummy1ModuleInfo; } set { SetProperty(ref _dummy1ModuleInfo, value); } } public ModuleInfo Dummy2ModuleInfo { get { return _dummy2ModuleInfo; } set { SetProperty(ref _dummy2ModuleInfo, value); } } public ModuleInfo LoaderModuleInfo { get { return _loaderModuleInfo; } set { SetProperty(ref _loaderModuleInfo, value); } } public WaferRobotTAction Robot1TAction { get { return m_Robot1TAction; } set { SetProperty(ref m_Robot1TAction, value); } } public WaferRobotXAction Robot1XAction { get { return m_Robot1XAction; } set { SetProperty(ref m_Robot1XAction, value); } } public WaferRobotTAction Robot2TAction { get { return m_Robot2TAction; } set { SetProperty(ref m_Robot2TAction, value); } } public WaferRobotXAction Robot2XAction { get { return m_Robot2XAction; } set { SetProperty(ref m_Robot2XAction, value); } } public WaferRobotTAction Robot3TAction { get { return m_Robot3TAction; } set { SetProperty(ref m_Robot3TAction, value); } } public WaferRobotXAction Robot3XAction { get { return m_Robot3XAction; } set { SetProperty(ref m_Robot3XAction, value); } } public WaferRobotTAction Robot4TAction { get { return m_Robot4TAction; } set { SetProperty(ref m_Robot4TAction, value); } } public WaferRobotXAction Robot4XAction { get { return m_Robot4XAction; } set { SetProperty(ref m_Robot4XAction, value); } } public RobotMoveInfo RobotMoveInfo { get { return m_robotMoveInfo; } set { RobotMoveInfoChanged(m_robotMoveInfo, value); //m_robotMoveInfo = value; SetProperty(ref m_robotMoveInfo, value); } } public Dictionary RtDataValues { get { return m_RtDataValues; } set { SetProperty(ref m_RtDataValues, value); } } public bool EFEMIsInstalled { get { return m_EFEMIsInstalled; } set { SetProperty(ref m_EFEMIsInstalled, value); } } public WaferInfo EFEMBladeAWafer { get { return m_EFEMBladeAWafer; } set { SetProperty(ref m_EFEMBladeAWafer, value); } } public WaferInfo EFEMBladeBWafer { get { return m_EFEMBladeBWafer; } set { SetProperty(ref m_EFEMBladeBWafer, value); } } public bool LoaderIsInstalled { get { return m_loaderInstalled; } set { SetProperty(ref m_loaderInstalled, value); } } public WaferInfo Aligner1Wafer { get { return m_Aligner1Wafer; } set { SetProperty(ref m_Aligner1Wafer, value); } } public WaferInfo SRD1Wafer { get { return m_srd1Wafer; } set { SetProperty(ref m_srd1Wafer, value); } } public WaferInfo SRD2Wafer { get { return m_srd2Wafer; } set { SetProperty(ref m_srd2Wafer, value); } } public WaferInfo PUF1WaferA { get { return m_puf1WaferA; } set { SetProperty(ref m_puf1WaferA, value); } } public WaferInfo PUF1WaferB { get { return m_puf1WaferB; } set { SetProperty(ref m_puf1WaferB, value); } } public WaferInfo LoaderWaferA { get { return m_loaderWaferA; } set { SetProperty(ref m_loaderWaferA, value); } } public WaferInfo LoaderWaferB { get { return m_loaderWaferB; } set { SetProperty(ref m_loaderWaferB, value); } } public int LP1WaferCount { get { return m_LP1WaferCount; } set { SetProperty(ref m_LP1WaferCount, value); } } public int LP2WaferCount { get { return m_LP2WaferCount; } set { SetProperty(ref m_LP2WaferCount, value); } } public int LP3WaferCount { get { return m_LP3WaferCount; } set { SetProperty(ref m_LP3WaferCount, value); } } public int Dummy1WaferCount { get { return m_dummy1WaferCount; } set { SetProperty(ref m_dummy1WaferCount, value); } } public int Dummy2WaferCount { get { return m_dummy2WaferCount; } set { SetProperty(ref m_dummy2WaferCount, value); } } public int CycledWafer { get { return m_CycledWafer; } set { SetProperty(ref m_CycledWafer, value); } } public int CycleCountDisplay { get { return m_CycleCountDisplay; } set { SetProperty(ref m_CycleCountDisplay, value); } } public RobotMoveInfo m_EfemRobotMoveInfo; public RobotMoveInfo EfemRobotMoveInfo { get { return m_EfemRobotMoveInfo; } set { EFEMRobotMoveInfoChanged(m_EfemRobotMoveInfo, value); //m_EfemRobotMoveInfo = value; SetProperty(ref m_EfemRobotMoveInfo, value); } } public EFEM.RobotPosition CurrentRobotPosition { get { return m_CurrentRobotPosition; } set { SetProperty(ref m_CurrentRobotPosition, value); } } public PufControl.LoaderXLocation LoaderAXLocation { get { return m_loaderAXLoaction; } set { SetProperty(ref m_loaderAXLoaction, value); } } public PufControl.LoaderXLocation LoaderBXLocation { get { return m_loaderBXLoaction; } set { SetProperty(ref m_loaderBXLoaction, value); } } public WaferInfo BladeAWafer { get { return m_BladeAWafer; } set { SetProperty(ref m_BladeAWafer, value); } } public WaferInfo BladeBWafer { get { return m_BladeBWafer; } set { SetProperty(ref m_BladeBWafer, value); } } public string ATMModeIsOn { get { return m_ATMModeIsOn; } set { SetProperty(ref m_ATMModeIsOn, value); } } public string RouteState { get { return m_RouteState; } set { SetProperty(ref m_RouteState, value); } } /// /// Loader的sideA开启状态 /// public bool LoaderWaferVisibleA { get { return m_loaderWaferVisibleA; } set { SetProperty(ref m_loaderWaferVisibleA, value); } } /// /// Loader的sideB开启状态 /// public bool LoaderWaferVisibleB { get { return m_loaderWaferVisibleB; } set { SetProperty(ref m_loaderWaferVisibleB, value); } } public bool Puf1IsInRobotStation { get { return m_puf1IsInRobotStation; } set { SetProperty(ref m_puf1IsInRobotStation, value); } } /// /// Puf1 Rotation实际位置数据 /// public double Puf1RotationMotorPosition { get { return _puf1RotationMotorPosition; } set { SetProperty(ref _puf1RotationMotorPosition, value); } } /// /// Puf1 Flip实际位置数据 /// public double Puf1FlipMotorPosition { get { return _puf1FlipMotorPosition; } set { SetProperty(ref _puf1FlipMotorPosition, value); } } /// /// Puf1 Flip UI位置 /// public double Puf1FlipPosition { get { return _puf1FlipPosition; } set { SetProperty(ref _puf1FlipPosition, value); } } /// /// Puf1 Rotation UI对应位置 /// public double Puf1RotationPosition { get { return _puf1RotationPosition; } set { SetProperty(ref _puf1RotationPosition, value); } } /// /// Loader1 Rotation UI对应位置 /// public double Loader1RotationPosition { get { return _loader1RotationPosition; } set { SetProperty(ref _loader1RotationPosition, value); } } /// /// Puf1 Rotation Axis /// public BeckhoffStationAxis Puf1RotationAxis { get { return _puf1RotationAxis; } set { SetProperty(ref _puf1RotationAxis, value); } } /// /// Puf1 Flip Axis /// public BeckhoffStationAxis Puf1FlipAxis { get { return _puf1FlipAxis; } set { SetProperty(ref _puf1FlipAxis, value); } } /// /// Loader1 Rotation Axis /// public BeckhoffStationAxis Loader1RotationAxis { get { return _loader1RotationAxis; } set { SetProperty(ref _loader1RotationAxis, value); } } /// /// Loader1 TiltA Axis /// public BeckhoffStationAxis Loader1TiltAAxis { get { return _loader1TiltAAxis; } set { SetProperty(ref _loader1TiltAAxis, value); } } /// /// Loader1 TiltB Axis /// public BeckhoffStationAxis Loader1TiltBAxis { get { return _loader1TiltBAxis; } set { SetProperty(ref _loader1TiltBAxis, value); } } /// /// Loader1 Rotation实际位置数据 /// public double Loader1RotationMotorPosition { get { return _loader1RotationMotorPosition; } set { SetProperty(ref _loader1RotationMotorPosition, value); } } /// /// Loader1 TiltA实际位置数据 /// public double Loader1TiltAMotorPosition { get { return _loader1TiltAMotorPosition; } set { SetProperty(ref _loader1TiltAMotorPosition, value); } } /// /// Loader1 TiltB实际位置数据 /// public double Loader1TiltBMotorPosition { get { return _loader1TiltBMotorPosition; } set { SetProperty(ref _loader1TiltBMotorPosition, value); } } /// /// Loader Rotation位置 /// public LoaderControl.LoaderRotation CurrentLoaderRotation { get { return m_currentLoaderRotation; } set { SetProperty(ref m_currentLoaderRotation, value); } } public string LoaderTiltACurrentStation { get { return _loaderTiltACurrentStation; } set { SetProperty(ref _loaderTiltACurrentStation, value); } } /// /// Loader TiltB当前station /// public string LoaderTiltBCurrentStation { get { return _loaderTiltBCurrentStation; } set { SetProperty(ref _loaderTiltBCurrentStation, value); } } public bool IsLP1HasNoJob { get { return _isLp1HasNoJob; } set { SetProperty(ref _isLp1HasNoJob, value); } } public bool IsLP2HasNoJob { get { return _isLp2HasNoJob; } set { SetProperty(ref _isLp2HasNoJob, value); } } public bool IsLP3HasNoJob { get { return _isLp3HasNoJob; } set { SetProperty(ref _isLp3HasNoJob, value); } } #endregion #region 命令 private DelegateCommand _LoadWaferCommand; public DelegateCommand LoadWaferCommand => _LoadWaferCommand ?? (_LoadWaferCommand = new DelegateCommand(OnLoadWafer)); private DelegateCommand _UnLoadWaferCommand; public DelegateCommand UnLoadWaferCommand => _UnLoadWaferCommand ?? (_UnLoadWaferCommand = new DelegateCommand(OnUnLoadWafer)); private DelegateCommand _StartCommand; public DelegateCommand StartCommand => _StartCommand ?? (_StartCommand = new DelegateCommand(OnStart)); private DelegateCommand _StopCommand; public DelegateCommand StopCommand => _StopCommand ?? (_StopCommand = new DelegateCommand(OnStop)); private DelegateCommand _AbortCommand; public DelegateCommand AbortCommand => _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort)); private DelegateCommand _HomeAllCommand; public DelegateCommand HomeAllCommand => _HomeAllCommand ?? (_HomeAllCommand = new DelegateCommand(OnHomeAll)); private DelegateCommand _ResumeAllJobCommand; public DelegateCommand ResumeAllJobCommand => _ResumeAllJobCommand ?? (_ResumeAllJobCommand = new DelegateCommand(OnResumeAllJob)); private DelegateCommand _AbortAllCommand; public DelegateCommand AbortAllCommand => _AbortAllCommand ?? (_AbortAllCommand = new DelegateCommand(OnAbortAll)); private DelegateCommand _ReturnAllWaferCommand; public DelegateCommand ReturnAllWaferCommand => _ReturnAllWaferCommand ?? (_ReturnAllWaferCommand = new DelegateCommand(OnReturnAllWafer)); private DelegateCommand _SetSequenceCommand; public DelegateCommand SetSequenceCommand => _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand(OnSetSequence)); private DelegateCommand _EnableAutoCommand; public DelegateCommand EnableAutoCommand => _EnableAutoCommand ?? (_EnableAutoCommand = new DelegateCommand(OnEnableAuto)); private DelegateCommand _EnableManualCommand; public DelegateCommand EnableManualCommand => _EnableManualCommand ?? (_EnableManualCommand = new DelegateCommand(OnEnableManual)); private DelegateCommand _GotoSrdViewCommond; public DelegateCommand GotoSrdViewCommond => _GotoSrdViewCommond ?? (_GotoSrdViewCommond = new DelegateCommand(GotoSrdViewAction)); public bool SwitchFlag; #endregion #region 构造函数 public OperationOverViewModel() { addDataKeys(); ATMModeIsOn = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig("System.IsATMMode")) == true ? "ATM Mode On" : "ATM Mode Off"; } #endregion #region 命令方法 /// /// 加载数据 /// public void LoadData(string systemName) { Dictionary allModulesDictionary = QueryDataClient.Instance.Service.PollData(new List() { "System.InstalledModules" }); if (allModulesDictionary != null) { List allModules = CommonFunction.GetValue>(allModulesDictionary, "System.InstalledModules"); EFEMIsInstalled = allModules.Contains("EFEM"); LoaderIsInstalled = allModules.Contains(ModuleName.Loader1.ToString()); } if (_timer == null) { _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromMilliseconds(100); _timer.Tick += Timer_Tick; } _timer.Start(); if (_timer1 == null) { _timer1 = new DispatcherTimer(); _timer1.Interval = TimeSpan.FromMilliseconds(50); _timer1.Tick += Timer1_Tick; } _timer1.Start(); _pufLayoutRotationDistance = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.PufLayoutRotationDistance"); _robotLayoutPosition = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.RobotLayoutPosition"); if (!m_RtDataKeys.Contains($"Station.PUF1.Roation")) { addStationDataKeys(); } RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys); if (RtDataValues != null) { //目标位置数据获取 Puf1RotationAxis = CommonFunction.GetValue(RtDataValues, $"Station.PUF1.Rotation"); //Puf1Rotation比例尺计算 var resultRotation = Puf1RotationAxis != null ? CalculateMaxMin(Puf1RotationAxis) : (0, 0); double distance = resultRotation.max - resultRotation.min; _puf1RotationRatio = distance / _pufLayoutRotationDistance; _puf1RotationMotorPositionMax = resultRotation.max; } } /// /// 隐藏 /// public void Hide() { if (_timer != null) { _timer.Stop(); } if (_timer1 != null) { _timer1.Stop(); } } private void OnLoadWafer(object obj) { InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Load", ModuleManager.ModuleInfos[obj.ToString()].ModuleID); } private void OnUnLoadWafer(object obj) { InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Unload", ModuleManager.ModuleInfos[obj.ToString()].ModuleID); } private void OnStart(object obj) { var info = obj as WaferAssociationInfo; InvokeClient.Instance.Service.DoOperation("System.StartJob", info.LotId); } private void OnStop(object obj) { var info = obj as WaferAssociationInfo; InvokeClient.Instance.Service.DoOperation("System.PauseJob", info.JobID); } private void OnAbort(object obj) { var info = obj as WaferAssociationInfo; InvokeClient.Instance.Service.DoOperation("System.ResumeJob", info.JobID); } private void OnHomeAll() { InvokeClient.Instance.Service.DoOperation("System.HomeAll"); } private void OnResumeAllJob() { if (CommonFunction.GetValue(RtDataValues, "EquipmentStatus") == 4) { InvokeClient.Instance.Service.DoOperation("System.ResumeAllJob"); } else { InvokeClient.Instance.Service.DoOperation("System.PauseAllJob"); } } private void OnAbortAll() { InvokeClient.Instance.Service.DoOperation("System.Abort"); } private void OnReturnAllWafer() { //Dialog WaferDialogView dialog = new WaferDialogView() { Owner = Application.Current.MainWindow, }; dialog.Height = 300; dialog.Width = 400; double angel = 0; double coolingtime = 0; string message = "Please Confirm Return Wafer"; WaferDialogViewModel vm = new WaferDialogViewModel(); vm.ConfirmText = message; dialog.DataContext = vm; if (dialog.ShowDialog() == true) { if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle)) { angel = Convert.ToDouble(dialog.Angle); } if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime)) { coolingtime = Convert.ToDouble(dialog.CoolingTime); } InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag, coolingtime, dialog.AlignFlag, angel); } } private void OnSetSequence(object obj) { var info = obj as WaferInfo; bool flag = info.SequenceName != "" ? false : true; } private void OnEnableAuto() { InvokeClient.Instance.Service.DoOperation("System.SetAutoMode"); } private void OnEnableManual() { InvokeClient.Instance.Service.DoOperation("System.SetManualMode"); } private void GotoSrdViewAction(object obj) { CyberX8_Core.GlobalEvents.OnSwitchFixedTabItem("HardWare", "SRD", $"{obj.ToString()}"); } #endregion #region 私有方法 /// /// 定时器 /// /// /// private void Timer_Tick(object sender, EventArgs e) { LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"]; LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"]; LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"]; EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"]; SRD1ModuleInfo = ModuleManager.ModuleInfos["SRD1"]; SRD2ModuleInfo = ModuleManager.ModuleInfos["SRD2"]; PUF1ModuleInfo = ModuleManager.ModuleInfos["PUF1"]; Dummy1ModuleInfo = ModuleManager.ModuleInfos["Dummy1"]; Dummy2ModuleInfo = ModuleManager.ModuleInfos["Dummy2"]; LoaderModuleInfo = ModuleManager.ModuleInfos["Loader1"]; if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0) { BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0]; } if (EFEMIsInstalled == true) { if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0) { EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0]; } if (ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers.Count != 0) { Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0]; } } if (SRD1ModuleInfo != null&& SRD1ModuleInfo.WaferManager.Wafers.Count!=0) { SRD1Wafer = SRD1ModuleInfo.WaferManager.Wafers[0]; } if (SRD2ModuleInfo != null&& SRD2ModuleInfo.WaferManager.Wafers.Count!=0) { SRD2Wafer = SRD2ModuleInfo.WaferManager.Wafers[0]; } if(PUF1ModuleInfo!=null) { if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0) { PUF1WaferA = PUF1ModuleInfo.WaferManager.Wafers[0]; } if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0) { PUF1WaferB = PUF1ModuleInfo.WaferManager.Wafers[1]; } } if(LoaderIsInstalled&&LoaderModuleInfo!=null) { if (LoaderModuleInfo.WaferManager.Wafers.Count != 0) { LoaderWaferA = LoaderModuleInfo.WaferManager.Wafers[0]; } if (LoaderModuleInfo.WaferManager.Wafers.Count != 0) { LoaderWaferB = LoaderModuleInfo.WaferManager.Wafers[1]; } } RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction"); EfemRobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction"); LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count(); LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count(); LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count(); //Dummy1WaferCount = 15; Dummy1WaferCount = Dummy1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count(); Dummy2WaferCount = Dummy2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count(); RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys); IsLP1Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable"); IsLP2Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable"); IsLP3Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort3Unable"); if (RtDataValues != null) { Puf1IsInRobotStation = CommonFunction.GetValue(RtDataValues, "PUF1.IsInRobotStation"); if (CommonFunction.GetValue(RtDataValues, "EquipmentStatus") == 4) { RouteState = "Resume"; } else { RouteState = "Pause"; } ControlJobInfo lp1Cj = CommonFunction.GetValue(RtDataValues, "LP1.CurrentControlJob"); IsLP1HasNoJob = lp1Cj == null ? true : false; ControlJobInfo lp2Cj = CommonFunction.GetValue(RtDataValues, "LP2.CurrentControlJob"); IsLP2HasNoJob = lp2Cj == null ? true : false; ControlJobInfo lp3Cj = CommonFunction.GetValue(RtDataValues, "LP3.CurrentControlJob"); IsLP3HasNoJob = lp3Cj == null ? true : false; } } int count = 0; /// /// 定时器1 /// /// /// private void Timer1_Tick(object sender, EventArgs e) { if (m_RtDataKeys.Count != 0) { RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys); if (RtDataValues != null) { Puf1RotationMotorPosition = CommonFunction.GetValue(RtDataValues, $"PUF1.Rotation.{MOTOR_POSITION}"); Loader1TiltAMotorPosition = CommonFunction.GetValue(RtDataValues, $"Loader1.TiltA.{MOTOR_POSITION}"); Loader1TiltBMotorPosition = CommonFunction.GetValue(RtDataValues, $"Loader1.TiltB.{MOTOR_POSITION}"); Loader1RotationMotorPosition = CommonFunction.GetValue(RtDataValues, $"Loader1.Rotation.{MOTOR_POSITION}"); Puf1FlipMotorPosition = CommonFunction.GetValue(RtDataValues, $"PUF1.Flip.{MOTOR_POSITION}"); //计算Puf1 Rotation UI位置 Puf1RotationPosition = _robotLayoutPosition + (_puf1RotationMotorPositionMax - Puf1RotationMotorPosition) / _puf1RotationRatio; //计Loader Rotation UI位置 Loader1RotationPosition = -Loader1RotationMotorPosition - LOADER_ROTATION_DIFFER; //计算Puf1 Flip UI位置 Puf1FlipPosition = Puf1FlipMotorPosition - PUF_FLIP_DIFFER; //判断Loader1的TiltA水平状态 LoaderTiltACurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue(RtDataValues, $"Loader1.TiltA.{CURRENT_STATION}"), "Loader1.TiltA"); if (LoaderTiltACurrentStation == "HORI") { LoaderWaferVisibleA = true; } else if(LoaderTiltACurrentStation == "VERT") { LoaderWaferVisibleA = false; } //判断Loader1的TiltB水平状态 LoaderTiltBCurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue(RtDataValues, $"Loader1.TiltB.{CURRENT_STATION}"), "Loader1.TiltB"); if (LoaderTiltBCurrentStation == "HORI") { LoaderWaferVisibleB = true; } else if (LoaderTiltBCurrentStation == "VERT") { LoaderWaferVisibleB = false; } } } } private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue) { string RobotTarget; if (oldValue == null || newValue == null) { return; } #region Rotating if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating)) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); } else if (arm == "ArmB") { Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); } } #endregion #region pick 和 place LL else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking)) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); if (waferRobotTAction != Robot1TAction) { Robot1TAction = waferRobotTAction; } else { //await Task.Delay(100); } await Task.Delay(600); //Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); //await Task.Delay(600); Robot1XAction = WaferRobotXAction.Extend; while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0)) { await Task.Delay(100); } Robot1XAction = WaferRobotXAction.Retract; } else if (arm == "ArmB") { var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); if (waferRobotTAction != Robot2TAction) { Robot2TAction = waferRobotTAction; } else { //await Task.Delay(100); } await Task.Delay(600); //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); //await Task.Delay(600); Robot2XAction = WaferRobotXAction.Extend; while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0)) { await Task.Delay(100); } Robot2XAction = WaferRobotXAction.Retract; } } #endregion #region pick 和 place pm else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); if (waferRobotTAction != Robot1TAction) { Robot1TAction = waferRobotTAction; } else { // await Task.Delay(100); } await Task.Delay(600); Robot1XAction = WaferRobotXAction.Extend; } else if (arm == "ArmB") { var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); if (waferRobotTAction != Robot2TAction) { Robot2TAction = waferRobotTAction; } else { // await Task.Delay(100); } await Task.Delay(600); Robot2XAction = WaferRobotXAction.Extend; } } else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; if (arm == "ArmA") { Robot1XAction = WaferRobotXAction.Retract; } else if (arm == "ArmB") { Robot2XAction = WaferRobotXAction.Retract; } } #endregion #region Home else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing) { if (Robot1XAction == WaferRobotXAction.Extend) { Robot1XAction = WaferRobotXAction.Retract; } if (Robot2XAction == WaferRobotXAction.Extend) { Robot2XAction = WaferRobotXAction.Retract; } await Task.Delay(2000); if (Robot1TAction != WaferRobotTAction.T_Origin) { Robot1TAction = WaferRobotTAction.T_Origin; } if (Robot2TAction != WaferRobotTAction.T_Origin) { Robot2TAction = WaferRobotTAction.T_Origin; } } #endregion } private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue) { string RobotTarget; if (oldValue == null || newValue == null) { return; } #region pick 和 place LL if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking)) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); //await Task.Delay(1000); await ChangePosition(robot3Robot3TAction, newValue.Action); if (Robot3TAction != robot3Robot3TAction) { Robot3TAction = robot3Robot3TAction; await Task.Delay(600); } Robot3XAction = WaferRobotXAction.Extend; while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0].WaferStatus == 0)) { await Task.Delay(100); } Robot3XAction = WaferRobotXAction.Retract; if(newValue.Action == RobotAction.Placing) { await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action); } } } #endregion #region pick 和 place pm if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); await Task.Delay(1500); //ChangePosition(Robot3TAction); //await Task.Delay(2000); Robot3XAction = WaferRobotXAction.Extend; } else if (arm == "ArmB") { Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); await Task.Delay(1500); //ChangePosition(Robot4TAction); //await Task.Delay(2000); Robot4XAction = WaferRobotXAction.Extend; } } if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; if (arm == "ArmA") { Robot3XAction = WaferRobotXAction.Retract; await Task.Delay(3000); //ChangePosition(Robot3TAction); //await Task.Delay(2000); } else if (arm == "ArmB") { Robot4XAction = WaferRobotXAction.Retract; await Task.Delay(3000); //ChangePosition(Robot3TAction); //await Task.Delay(2000); } } #endregion #region Home else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing) { if (Robot3XAction == WaferRobotXAction.Extend) { Robot3XAction = WaferRobotXAction.Retract; } if (Robot4XAction == WaferRobotXAction.Extend) { Robot4XAction = WaferRobotXAction.Retract; } if (Robot3TAction != WaferRobotTAction.T_Origin) { Robot3TAction = WaferRobotTAction.T_Origin; } if (Robot4TAction != WaferRobotTAction.T_Origin) { Robot4TAction = WaferRobotTAction.T_Origin; } await Task.Delay(1000); await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action); } #endregion } private void addDataKeys() { m_RtDataKeys.Add("LP1.IsLoaded"); m_RtDataKeys.Add("LP2.IsLoaded"); m_RtDataKeys.Add("LP3.IsLoaded"); m_RtDataKeys.Add("LP1.CassettePlaced"); m_RtDataKeys.Add("LP2.CassettePlaced"); m_RtDataKeys.Add("LP3.CassettePlaced"); m_RtDataKeys.Add("LP1.CurrentControlJob"); m_RtDataKeys.Add("LP2.CurrentControlJob"); m_RtDataKeys.Add("LP3.CurrentControlJob"); m_RtDataKeys.Add("System.IsAutoMode"); m_RtDataKeys.Add("System.IsBusy"); m_RtDataKeys.Add("Scheduler.CycledCount"); m_RtDataKeys.Add("Scheduler.CycledWafer"); m_RtDataKeys.Add("Scheduler.CycleSetPoint"); m_RtDataKeys.Add("Scheduler.Throughput"); m_RtDataKeys.Add("EquipmentStatus"); m_RtDataKeys.Add("Scheduler.PjNameList"); m_RtDataKeys.Add("PUF1.IsInRobotStation"); m_RtDataKeys.Add("Scheduler.CjNameList"); } private void addStationDataKeys() { m_RtDataKeys.Add($"Station.PUF1.Rotation"); m_RtDataKeys.Add($"Station.PUF1.Flip"); m_RtDataKeys.Add($"Station.PUF1.Vertical"); m_RtDataKeys.Add($"Station.Loader1.Rotation"); m_RtDataKeys.Add($"Station.Loader1.TiltA"); m_RtDataKeys.Add($"Station.Loader1.TiltB"); m_RtDataKeys.Add($"PUF1.Rotation.{MOTOR_POSITION}"); m_RtDataKeys.Add($"PUF1.Flip.{MOTOR_POSITION}"); m_RtDataKeys.Add($"Loader1.Rotation.{MOTOR_POSITION}"); m_RtDataKeys.Add($"Loader1.TiltA.{MOTOR_POSITION}"); m_RtDataKeys.Add($"Loader1.TiltB.{MOTOR_POSITION}"); m_RtDataKeys.Add($"PUF1.Flip.{CURRENT_STATION}"); m_RtDataKeys.Add($"Loader1.TiltA.{CURRENT_STATION}"); m_RtDataKeys.Add($"Loader1.TiltB.{CURRENT_STATION}"); m_RtDataKeys.Add($"PUF1.Rotation.{MOTION_DATA}"); } private bool HasWaferOnSlot(List wafers, int index) { if (wafers[index].WaferStatus == 0) return false; return true; } private async Task ChangePosition(WaferRobotTAction waferRobotTAction, RobotAction robotAction) { await Task.Delay(500); int delay = 500; if (robotAction == RobotAction.Placing) { if (waferRobotTAction == WaferRobotTAction.LP1 || waferRobotTAction == WaferRobotTAction.PUF1) { CurrentRobotPosition = EFEM.RobotPosition.Left_Place; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.LP3) { CurrentRobotPosition = EFEM.RobotPosition.Right_Place; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.LP2 ) { CurrentRobotPosition = EFEM.RobotPosition.Middle_Place; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.Aligner1) { CurrentRobotPosition = EFEM.RobotPosition.Aligner_Place; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2) { CurrentRobotPosition = EFEM.RobotPosition.SRD_Place; } else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2) { CurrentRobotPosition = EFEM.RobotPosition.Dummy_Place; } else { CurrentRobotPosition = EFEM.RobotPosition.Origin; await Task.Delay(delay); } } else { if (waferRobotTAction == WaferRobotTAction.LP1 || waferRobotTAction == WaferRobotTAction.PUF1) { CurrentRobotPosition = EFEM.RobotPosition.Left; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.LP3) { CurrentRobotPosition = EFEM.RobotPosition.Right; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.LP2) { CurrentRobotPosition = EFEM.RobotPosition.Middle; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.Aligner1) { CurrentRobotPosition = EFEM.RobotPosition.Aligner; await Task.Delay(delay); } else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2) { CurrentRobotPosition = EFEM.RobotPosition.SRD; } else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2) { CurrentRobotPosition = EFEM.RobotPosition.Dummy; } else { CurrentRobotPosition = EFEM.RobotPosition.Origin; await Task.Delay(delay); } } } /// /// 计算最大值最小值 /// /// /// private (double max, double min) CalculateMaxMin(BeckhoffStationAxis pufAxis) { double max = 0; double min = 0; foreach (Station item in pufAxis.Stations) { double position = double.Parse(item.Position); if (position > max) { max = position; } if (position < min) { min = position; } } foreach (Station item in pufAxis.Stations) { double position = double.Parse(item.Position); if (position > max) { max = position; } if (position < min) { min = position; } } return (max, min); } /// /// 判定是否在station位置 /// private bool JudgeAtStation(double targetPosition, double currentPosition, double tolerance) { if (Math.Abs(currentPosition - targetPosition) <= tolerance) { return true; } else { return false; } } #endregion } }