123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 |
- 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 PunkHPX8_Core;
- using PunkHPX8_MainPages.Unity;
- using PunkHPX8_MainPages.Views;
- using PunkHPX8_Themes.CustomControls;
- using PunkHPX8_Themes.Unity;
- using PunkHPX8_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.Beckhoff.AxisProvider;
- using QiHe.CodeLib;
- using MECF.Framework.Common.Jobs;
- using ExcelLibrary.BinaryFileFormat;
- namespace PunkHPX8_MainPages.ViewModels
- {
- public class OperationOverNewViewModel : 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;
- #endregion
- #region 私有字段
- private bool _isLp1Unable;
- private bool _isLp2Unable;
- private ModuleInfo _LP1ModuleInfo;
- private ModuleInfo _LP2ModuleInfo;
- private ModuleInfo _EFEMModuleInfo;
- private ModuleInfo _srd1ModuleInfo;
- private ModuleInfo _srd2ModuleInfo;
- private ModuleInfo _dummy1ModuleInfo;
- private ModuleInfo _dummy2ModuleInfo;
- private WaferRobotTAction m_Robot1TAction;
- private WaferRobotXAction m_Robot1XAction;
- private WaferRobotTAction m_Robot2TAction;
- private WaferRobotXAction m_Robot2XAction;
- private WaferRobotFAction m_Robot2FAction;
-
- private RobotMoveInfo m_robotMoveInfo;
- private WaferInfo m_srd1Wafer;
- private WaferInfo m_srd2Wafer;
- private List<string> m_RtDataKeys = new List<string>();
- private Dictionary<string, object> m_RtDataValues;
- private bool m_EFEMIsInstalled;
- private WaferInfo m_EFEMBladeAWafer;
- private WaferInfo m_EFEMBladeBWafer;
- private WaferInfo m_Aligner1Wafer;
- private WaferInfo m_vpw1Wafer;
- private WaferInfo m_vpw2Wafer;
- private WaferInfo m_platingCell1Wafer;
- private WaferInfo m_platingCell2Wafer;
- private WaferInfo m_platingCell3Wafer;
- private WaferInfo m_platingCell4Wafer;
- private int m_LP1WaferCount;
- private int m_LP2WaferCount;
- private int m_dummy1WaferCount;
- private int m_dummy2WaferCount;
- private int m_CycledWafer;
- private int m_CycleCountDisplay;
- private EFEM.RobotPosition m_CurrentRobotPosition;
- private WaferInfo m_BladeAWafer;
- private WaferInfo m_BladeBWafer;
- private string m_RouteState;
- /// <summary>
- /// 定时器
- /// </summary>
- private DispatcherTimer _timer;
- /// <summary>
- /// 是否存在Job
- /// </summary>
- private bool _isLp1HasNoJob;
- private bool _isLp2HasNoJob;
- #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 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 SRD1ModuleInfo
- {
- get { return _srd1ModuleInfo; }
- set { SetProperty(ref _srd1ModuleInfo, value); }
- }
- public ModuleInfo SRD2ModuleInfo
- {
- get { return _srd2ModuleInfo; }
- set { SetProperty(ref _srd2ModuleInfo, value); }
- }
-
- public ModuleInfo Dummy1ModuleInfo
- {
- get { return _dummy1ModuleInfo; }
- set { SetProperty(ref _dummy1ModuleInfo, value); }
- }
- public ModuleInfo Dummy2ModuleInfo
- {
- get { return _dummy2ModuleInfo; }
- set { SetProperty(ref _dummy2ModuleInfo, 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 WaferRobotFAction Robot2FAction
- {
- get { return m_Robot2FAction; }
- set { SetProperty(ref m_Robot2FAction, value); }
- }
- public RobotMoveInfo RobotMoveInfo
- {
- get { return m_robotMoveInfo; }
- set
- {
- RobotMoveInfoChanged(m_robotMoveInfo, value);
- //m_robotMoveInfo = value;
- SetProperty(ref m_robotMoveInfo, value);
- }
- }
- public Dictionary<string, object> 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 WaferInfo Aligner1Wafer
- {
- get { return m_Aligner1Wafer; }
- set { SetProperty(ref m_Aligner1Wafer, value); }
- }
- public WaferInfo VPW1Wafer
- {
- get { return m_vpw1Wafer; }
- set { SetProperty(ref m_vpw1Wafer, value); }
- }
- public WaferInfo VPW2Wafer
- {
- get { return m_vpw2Wafer; }
- set { SetProperty(ref m_vpw2Wafer, value); }
- }
- public WaferInfo PlatingCell1Wafer
- {
- get { return m_platingCell1Wafer; }
- set { SetProperty(ref m_platingCell1Wafer, value); }
- }
- public WaferInfo PlatingCell2Wafer
- {
- get { return m_platingCell2Wafer; }
- set { SetProperty(ref m_platingCell2Wafer, value); }
- }
- public WaferInfo PlatingCell3Wafer
- {
- get { return m_platingCell3Wafer; }
- set { SetProperty(ref m_platingCell3Wafer, value); }
- }
- public WaferInfo PlatingCell4Wafer
- {
- get { return m_platingCell4Wafer; }
- set { SetProperty(ref m_platingCell4Wafer, 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 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 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 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 RouteState
- {
- get { return m_RouteState; }
- set { SetProperty(ref m_RouteState, value); }
- }
- public bool IsLP1HasNoJob
- {
- get { return _isLp1HasNoJob; }
- set { SetProperty(ref _isLp1HasNoJob, value); }
- }
- public bool IsLP2HasNoJob
- {
- get { return _isLp2HasNoJob; }
- set { SetProperty(ref _isLp2HasNoJob, value); }
- }
- #endregion
- #region 命令
- private DelegateCommand<object> _MapCommand;
- public DelegateCommand<object> MapCommand =>
- _MapCommand ?? (_MapCommand = new DelegateCommand<object>(OnMap));
- private DelegateCommand<object> _StartCommand;
- public DelegateCommand<object> StartCommand =>
- _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
- private DelegateCommand<object> _StopCommand;
- public DelegateCommand<object> StopCommand =>
- _StopCommand ?? (_StopCommand = new DelegateCommand<object>(OnStop));
- private DelegateCommand<object> _AbortCommand;
- public DelegateCommand<object> AbortCommand =>
- _AbortCommand ?? (_AbortCommand = new DelegateCommand<object>(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<object> _SetSequenceCommand;
- public DelegateCommand<object> SetSequenceCommand =>
- _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(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<object> _GotoSrdViewCommond;
- public DelegateCommand<object> GotoSrdViewCommond =>
- _GotoSrdViewCommond ?? (_GotoSrdViewCommond = new DelegateCommand<object>(GotoSrdViewAction));
- public bool SwitchFlag;
-
- #endregion
- #region 构造函数
- public OperationOverNewViewModel()
- {
- addDataKeys();
- }
- #endregion
- #region 命令方法
- /// <summary>
- /// 加载数据
- /// </summary>
- public void LoadData(string systemName)
- {
- Dictionary<string, object> allModulesDictionary = QueryDataClient.Instance.Service.PollData(new List<string>() { "System.InstalledModules" });
- if (allModulesDictionary != null)
- {
- List<string> allModules = CommonFunction.GetValue<List<string>>(allModulesDictionary, "System.InstalledModules");
- EFEMIsInstalled = allModules.Contains("EFEM");
- }
- if (_timer == null)
- {
- _timer = new DispatcherTimer();
- _timer.Interval = TimeSpan.FromMilliseconds(100);
- _timer.Tick += Timer_Tick;
- }
- _timer.Start();
- RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
- }
-
- /// <summary>
- /// 隐藏
- /// </summary>
- public void Hide()
- {
- if (_timer != null)
- {
- _timer.Stop();
- }
- }
-
- private void OnMap(object obj)
- {
- InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Map");
- }
- 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<int>(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)
- {
- PunkHPX8_Core.GlobalEvents.OnSwitchFixedTabItem("HardWare", "SRD", $"{obj.ToString()}");
- }
-
- #endregion
- #region 私有方法
- /// <summary>
- /// 定时器
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Timer_Tick(object sender, EventArgs e)
- {
- LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
- LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
- EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
- SRD1ModuleInfo = ModuleManager.ModuleInfos["SRD1"];
- SRD2ModuleInfo = ModuleManager.ModuleInfos["SRD2"];
- Dummy1ModuleInfo = ModuleManager.ModuleInfos["Dummy1"];
- Dummy2ModuleInfo = ModuleManager.ModuleInfos["Dummy2"];
- if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
- {
- BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
- BladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
- }
- if (EFEMIsInstalled == true)
- {
- if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
- {
- EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
- EFEMBladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
- }
- if (ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers.Count != 0)
- {
- Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
- }
- }
- if (ModuleManager.ModuleInfos["VPW1"].WaferManager.Wafers.Count != 0)
- {
- VPW1Wafer = ModuleManager.ModuleInfos["VPW1"].WaferManager.Wafers[0];
- }
- if (ModuleManager.ModuleInfos["VPW2"].WaferManager.Wafers.Count != 0)
- {
- VPW2Wafer = ModuleManager.ModuleInfos["VPW2"].WaferManager.Wafers[0];
- }
- if (ModuleManager.ModuleInfos["PlatingCell1"].WaferManager.Wafers.Count!=0)
- {
- PlatingCell1Wafer = ModuleManager.ModuleInfos["PlatingCell1"].WaferManager.Wafers[0];
- }
- if (ModuleManager.ModuleInfos["PlatingCell2"].WaferManager.Wafers.Count != 0)
- {
- PlatingCell2Wafer = ModuleManager.ModuleInfos["PlatingCell2"].WaferManager.Wafers[0];
- }
- if (ModuleManager.ModuleInfos["PlatingCell3"].WaferManager.Wafers.Count != 0)
- {
- PlatingCell3Wafer = ModuleManager.ModuleInfos["PlatingCell3"].WaferManager.Wafers[0];
- }
- if (ModuleManager.ModuleInfos["PlatingCell4"].WaferManager.Wafers.Count != 0)
- {
- PlatingCell4Wafer = ModuleManager.ModuleInfos["PlatingCell4"].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];
- }
- 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();
- //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");
- if (RtDataValues != null)
- {
- if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
- {
- RouteState = "Resume";
- }
- else
- {
- RouteState = "Pause";
- }
- ControlJobInfo lp1Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP1.CurrentControlJob");
- IsLP1HasNoJob = lp1Cj == null ? true : false;
- ControlJobInfo lp2Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP2.CurrentControlJob");
- IsLP2HasNoJob = lp2Cj == null ? true : false;
- }
- }
- int count = 0;
-
- 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;
- }
- 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 robot1Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
- //Robot整体平移动画
- await ChangePosition(robot1Robot1TAction, newValue.Action);
- if (Robot1TAction != robot1Robot1TAction)
- {
- Robot1TAction = robot1Robot1TAction;
- await Task.Delay(600);
- }
- //await Task.Delay(1500);
- Robot1XAction = 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);
- }
- Robot1XAction = WaferRobotXAction.Retract;
- if (newValue.Action == RobotAction.Placing)
- {
- await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
- }
- }
- else //使用上手臂
- {
- //实现翻转动画
- if (newValue.BladeTarget.Split('.')[2] == "Down")
- {
- Robot2FAction = WaferRobotFAction.UpperToDown;
- }
- else if (newValue.BladeTarget.Split('.')[2] == "Upper")
- {
- Robot2FAction = WaferRobotFAction.DownToUpper;
- }
- var robot1Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
- //Robot整体平移动画
- await ChangePosition(robot1Robot1TAction, newValue.Action);
- if (Robot1TAction != robot1Robot1TAction)
- {
- Robot1TAction = robot1Robot1TAction;
- await Task.Delay(600);
- }
- //await Task.Delay(1500);
- Robot1XAction = WaferRobotXAction.Extend2;
- while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1].WaferStatus == 0))
- {
- await Task.Delay(100);
- }
- Robot1XAction = WaferRobotXAction.Retract2;
- if (newValue.Action == RobotAction.Placing)
- {
- await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
- }
- }
- }
- #region Home
- else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
- {
- if (Robot1XAction == WaferRobotXAction.Extend || Robot2XAction == WaferRobotXAction.Extend2)
- {
- Robot1XAction = WaferRobotXAction.Retract2;
- }
- if (Robot2XAction == WaferRobotXAction.Extend || Robot2XAction == WaferRobotXAction.Extend2)
- {
- Robot2XAction = WaferRobotXAction.Retract2;
- }
- await Task.Delay(2000);
- if (Robot1TAction != WaferRobotTAction.T_Origin)
- {
- Robot1TAction = WaferRobotTAction.T_Origin;
- }
- if (Robot2TAction != WaferRobotTAction.T_Origin)
- {
- Robot2TAction = WaferRobotTAction.T_Origin;
- }
- if (CurrentRobotPosition != EFEM.RobotPosition.Origin)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Origin;
- }
- await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
- }
- #endregion
- }
- private void addDataKeys()
- {
- m_RtDataKeys.Add("LP1.IsLoaded");
- m_RtDataKeys.Add("LP2.IsLoaded");
- m_RtDataKeys.Add("LP1.CassettePlaced");
- m_RtDataKeys.Add("LP2.CassettePlaced");
- m_RtDataKeys.Add("LP1.CurrentControlJob");
- m_RtDataKeys.Add("LP2.CurrentControlJob");
- m_RtDataKeys.Add("LP1.WaferSize");
- m_RtDataKeys.Add("LP2.WaferSize");
- m_RtDataKeys.Add("Dummy1.CassettePlaced");
- m_RtDataKeys.Add("Dummy2.CassettePlaced");
- m_RtDataKeys.Add("Dummy1.WaferSize");
- m_RtDataKeys.Add("Dummy2.WaferSize");
- 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("Scheduler.CjNameList");
- }
-
- private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
- {
- if (wafers[index].WaferStatus == 0)
- return false;
- return true;
- }
- private async Task ChangePosition(WaferRobotTAction waferRobotTAction, RobotAction robotAction)
- {
- //CurrentRobotPosition = RobotPosition.Origin;
- //await Task.Delay(1000);
- if (robotAction == RobotAction.Placing)
- {
- if (waferRobotTAction == WaferRobotTAction.LP1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Left_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.LP2)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Middle_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.Aligner1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Aligner_Place;
- }
- 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 if (waferRobotTAction == WaferRobotTAction.VPW1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.VPW1_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.VPW2)
- {
- CurrentRobotPosition = EFEM.RobotPosition.VPW2_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell1_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell2)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell2_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell3)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell3_Place;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell4)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell4_Place;
- }
- else
- {
- CurrentRobotPosition = EFEM.RobotPosition.Origin;
- }
- }
- else
- {
- if (waferRobotTAction == WaferRobotTAction.LP1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Left;
- }
- else if (waferRobotTAction == WaferRobotTAction.LP2)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Middle;
- }
- else if (waferRobotTAction == WaferRobotTAction.Aligner1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.Aligner;
- }
- 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 if (waferRobotTAction == WaferRobotTAction.VPW1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.VPW1;
- }
- else if (waferRobotTAction == WaferRobotTAction.VPW2)
- {
- CurrentRobotPosition = EFEM.RobotPosition.VPW2;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell1)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell1;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell2)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell2;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell3)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell3;
- }
- else if (waferRobotTAction == WaferRobotTAction.PlatingCell4)
- {
- CurrentRobotPosition = EFEM.RobotPosition.PlatingCell4;
- }
- else
- {
- CurrentRobotPosition = EFEM.RobotPosition.Origin;
- }
- }
- await Task.Delay(600);
- }
- /// <summary>
- /// 计算最大值最小值
- /// </summary>
- /// <param name="Puf1RotationAxis"></param>
- /// <returns></returns>
- private (double right, double left) CalculatePufMaxMin(BeckhoffStationAxis pufAxis)
- {
- if (pufAxis == null || pufAxis.Stations.Count == 0) return (-1,-1);
- double max = double.Parse(pufAxis.Stations[0].Position);
- double min = double.Parse(pufAxis.Stations[0].Position);
- double home = 0;
- double pickup = 0;
- foreach (Station item in pufAxis.Stations)
- {
- if (item.Name.ToLower().Contains("home")) home = double.Parse(item.Position);
- if (item.Name.ToLower().Contains("pickup")) pickup = double.Parse(item.Position);
- double position = double.Parse(item.Position);
- if (position > max)
- {
- max = position;
- }
- if (position < min)
- {
- min = position;
- }
- }
-
- return pickup < home ? (min, max):(max, min);
- }
- /// <summary>
- /// 计算PufFlip差值
- /// </summary>
- /// <param name="pufAxis"></param>
- /// <returns></returns>
- private double CalculatePufFlipDiff(BeckhoffStationAxis pufAxis)
- {
- double sideAangle = 0;
- double sideBangle = 0; ;
- return sideAangle > sideBangle ? 180 : 0;
- }
- /// <summary>
- /// 判定是否在station位置
- /// </summary>
- private bool JudgeAtStation(double targetPosition, double currentPosition, double tolerance)
- {
-
- if (Math.Abs(currentPosition - targetPosition) <= tolerance)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- #endregion
- }
- }
|