using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using Aitex.Core.UI.MVVM; using Aitex.Core.Util; using Aitex.Core.Utilities; using Aitex.Sorter.Common; using Aitex.Sorter.UI.ViewModel; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using MECF.Framework.UI.Core.View.Common; namespace EfemUI.Controls { public partial class NewE84Info : UserControl { public static readonly DependencyProperty LoadPortNameProperty = DependencyProperty.Register( "LoadPortName", typeof(string), typeof(NewE84Info), new PropertyMetadata("")); public static readonly DependencyProperty E84DataProperty = DependencyProperty.Register( "E84Data", typeof(NewE84InfoData), typeof(NewE84Info), new PropertyMetadata(null)); private readonly NewE84InfoViewModel _e84InfoViewModel; public NewE84Info() { InitializeComponent(); root.DataContext = this; _e84InfoViewModel = new NewE84InfoViewModel(); ConfigBorder.DataContext = _e84InfoViewModel; ConfigBorder1.DataContext = _e84InfoViewModel; Inputs.DataContext = this; Outputs.DataContext = this; //BindingErrorTraceListener.SetTrace(); E84Command = new DelegateCommand(DoLoadPortCmd); FALoadPortCommand = new DelegateCommand(DoFALoadPortCommand); DeviceOperationCommand = new DelegateCommand(DoLoadPortOperationCmd); DeviceExecuteMoveCommand = new DelegateCommand(DoDeviceExecuteMoveCmd); DeviceExecuteSetCommand = new DelegateCommand(DoDeviceExecuteSetCmd); DeviceExecuteGetCommand = new DelegateCommand(DoDeviceExecuteGetCmd); IsVisibleChanged += E84Info_IsVisibleChanged; LPCommandList = new List() { "Lock(Clamp)", "Unlock(Unclamp)", "Clamp close(PODCL)", "Dock(YDOOR)", "Vacuum ON(VACON)", "Door clamp Open(DOROP)", "Door open(DORBK)", "Move to mapping start position(ZMPST)", "Move to mapping measurement position(MAPOP)", "Move to mapping end position(ZDRMP)", "Move to mapping wait position(MAPCL)", "Move to loading position(ZDRDW)", "Move to door openn/close position(ZDRUP)", "Door close(DORFW)", "Door clamp close(DORCL)", "Vacuum OFF(VACOF)", "Undock operation(YWAIT)", "Clamp open(PODOP)", "Load without map(CLOAD)", "Load with map(CLDMP)", "Load with door close(CLDDK)", "Door open and move to load(CLDOP)", "Door open and map(CLMPO)", "Clamp and dock(CLDYD)", "Unload without map(CULOD)", "Unload with map(CUDMP)", "Door up and close(CULDK)", "Map and door up and close(CUMDK)", "Door clamp close,Vac off undock and unclamp(CUDNC)", "Door clamp close,Vac off and undock(CUDCL)", "Door up,clost,clamp close,vac off and undock(CULFC)", "Mapping and unload with clamped(CUMFC)", "Door up,clost,clamp close,vac off(CULYD)", "Mapping(MAPDO)", "Re-Mapping(REMAP)" }; } public ICommand E84Command { get; set; } public ICommand FALoadPortCommand { get; set; } public ICommand DeviceOperationCommand { get; set; } public ICommand DeviceExecuteMoveCommand { get; set; } public ICommand DeviceExecuteSetCommand { get; set; } public ICommand DeviceExecuteGetCommand { get; set; } public string LoadPortName { get => (string)GetValue(LoadPortNameProperty); set => SetValue(LoadPortNameProperty, value); } public NewE84InfoData E84Data { get => (NewE84InfoData)GetValue(E84DataProperty); set => SetValue(E84DataProperty, value); } public List LPCommandList { get; set; } private void DoLoadPortCmd(string cmd) { var deviceName = LoadPortName; var param = new object[] { deviceName }; InvokeClient.Instance.Service.DoOperation($"{param[0]}.{cmd}"); } private void DoFALoadPortCommand(string cmd) { var deviceName = LoadPortName; var param = new object[] { cmd, deviceName }; InvokeClient.Instance.Service.DoOperation($"FALoadPortCommand", param); } private void DoLoadPortOperationCmd(string cmd) { var deviceName = LoadPortName; object[] param = new object[] { deviceName, cmd }; if (cmd == "ReadCarrierIDByIndex" || cmd == "WriteCarrierIDByIndex") { if (cmd == "ReadCarrierIDByIndex") { param = new object[] { cboCarrierIDOption.Text == "" ? "0" : cboCarrierIDOption.Text }; } if (cmd == "WriteCarrierIDByIndex") { param = new object[] { cboCarrierIDOption.Text == "" ? "0": cboCarrierIDOption.Text, txtWriteCarrierID.Text }; } var efemnum = QueryDataClient.Instance.Service.GetConfig("System.EFEMNUM"); if (efemnum.ToString() == "002") { if ((cmd == "ReadCarrierIDByIndex")) { cmd = "ReadCarrierID"; param = new object[] { (cboCarrierIDOption.Text == "" || cboCarrierIDOption.Text == "0") ? "LCDFILE.TXT" : "CARRIER.TXT" }; } } InvokeClient.Instance.Service.DoOperation($"{deviceName}.{cmd}", param); } else { InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), param); } } private void DoDeviceExecuteMoveCmd(string obj) { Regex rgx = new Regex(@"(?i)(?<=\()(.*)(?=\))"); string tmp = rgx.Match(obj).Value; if (string.IsNullOrEmpty(tmp)) return; var deviceName = LoadPortName; //object[] param = new object[] { "Move", tmp }; object[] param = new object[] { deviceName, $"Loadport{tmp}" }; InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), param); //InvokeClient.Instance.Service.DoOperation($"{deviceName}.LoadportExecuteCommand", param); } private void DoDeviceExecuteGetCmd(string obj) { Regex rgx = new Regex(@"(?i)(?<=\()(.*)(?=\))"); string tmp = rgx.Match(obj).Value; if (string.IsNullOrEmpty(tmp)) return; var deviceName = LoadPortName; object[] param = new object[] { "Get", tmp }; InvokeClient.Instance.Service.DoOperation($"{deviceName}.LoadportExecuteCommand", param); } private void DoDeviceExecuteSetCmd(string obj) { Regex rgx = new Regex(@"(?i)(?<=\()(.*)(?=\))"); string tmp = rgx.Match(obj).Value; if (string.IsNullOrEmpty(tmp)) return; var deviceName = LoadPortName; object[] param = new object[] { "Set", tmp }; InvokeClient.Instance.Service.DoOperation($"{deviceName}.LoadportExecuteCommand", param); } private void E84Info_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { (DataContext as NewE84InfoViewModel)?.EnableTimer(IsVisible); } } internal class NewE84InfoViewModel : UIViewModelBase { public NewE84InfoViewModel() : base("NewE84InfoViewModel") { SetConfigCommand = new DelegateCommand(SetConfig); ConfigFeedback = new NewE84SCs(); ConfigSetPoint = new NewE84SCs(); ConfigFeedback.UpdateKeys(typeof(NewE84SCs).GetProperties()); ConfigSetPoint.UpdateKeys(typeof(NewE84SCs).GetProperties()); UpdateConfig(); } //定义委托 public delegate void ConfigChangedHandle(object sender); //定义事件 public event ConfigChangedHandle ConfigChanged; private void ConfigChangedCmd(object sender) { if (ConfigChanged != null) ConfigChanged(sender);//把按钮自身作为参数传递 } [IgnorePropertyChange] public ICommand SetConfigCommand { get; } [IgnorePropertyChange] public NewE84SCs ConfigFeedback { get; set; } [IgnorePropertyChange] public NewE84SCs ConfigSetPoint { get; set; } public bool AutomaticMode { get; set; } public bool KeepClampedAfterRun { get; set; } public bool KeepDockAfterRun { get; set; } public bool CloseDoorAfterMap { get; set; } [Subscription("E84State")] public string E84Status { get; set; } private void SetConfig(object param) { var sc = (object[])param; InvokeClient.Instance.Service.DoOperation("System.SetConfig", sc[0].ToString(), sc[1].ToString()); UpdateConfig(); } public void UpdateConfig() { ConfigFeedback.Update(QueryDataClient.Instance.Service.PollConfig(ConfigFeedback.GetKeys())); ConfigSetPoint.Update(QueryDataClient.Instance.Service.PollConfig(ConfigSetPoint.GetKeys())); ConfigChangedCmd(this); InvokeAllPropertyChanged(); } } public class NewE84SCs : PageSCValue { public int Fa_E84_TP1 { get; set; } public int Fa_E84_TP2 { get; set; } public int Fa_E84_TP3 { get; set; } public int Fa_E84_TP4 { get; set; } public int Fa_E84_TP5 { get; set; } public int Fa_E84_TP6 { get; set; } public bool LoadPort_LP1_PLInService { get; set; } public bool LoadPort_LP1_EnableAutoCarrierIdRead { get; set; } public int LoadPort_LP1_DataReadSize { get; set; } public int LoadPort_LP1_StartPage { get; set; } public int LoadPort_LP1_DefaultPage { get; set; } public bool LoadPort_LP2_PLInService { get; set; } public bool LoadPort_LP2_EnableAutoCarrierIdRead { get; set; } public int LoadPort_LP2_DataReadSize { get; set; } public int LoadPort_LP2_StartPage { get; set; } public int LoadPort_LP2_DefaultPage { get; set; } public bool LoadPort_LP3_PLInService { get; set; } public bool LoadPort_LP3_EnableAutoCarrierIdRead { get; set; } public int LoadPort_LP3_DataReadSize { get; set; } public int LoadPort_LP3_StartPage { get; set; } public int LoadPort_LP3_DefaultPage { get; set; } public bool LoadPort_LP4_PLInService { get; set; } public bool LoadPort_LP4_EnableAutoCarrierIdRead { get; set; } public int LoadPort_LP4_DataReadSize { get; set; } public int LoadPort_LP4_StartPage { get; set; } public int LoadPort_LP4_DefaultPage { get; set; } //public bool LoadPort_LP5_PLInService { get; set; } //public bool LoadPort_LP5_EnableAutoCarrierIdRead { get; set; } //public int LoadPort_LP5_DataReadSize { get; set; } //public int LoadPort_LP5_StartPage { get; set; } //public int LoadPort_LP5_DefaultPage { get; set; } //public bool LoadPort_LP6_PLInService { get; set; } //public bool LoadPort_LP6_EnableAutoCarrierIdRead { get; set; } //public int LoadPort_LP6_DataReadSize { get; set; } //public int LoadPort_LP6_StartPage { get; set; } //public int LoadPort_LP6_DefaultPage { get; set; } //public bool LoadPort_LP7_PLInService { get; set; } //public bool LoadPort_LP7_EnableAutoCarrierIdRead { get; set; } //public int LoadPort_LP7_DataReadSize { get; set; } //public int LoadPort_LP7_StartPage { get; set; } //public int LoadPort_LP7_DefaultPage { get; set; } //public bool LoadPort_LP8_PLInService { get; set; } //public bool LoadPort_LP8_EnableAutoCarrierIdRead { get; set; } //public int LoadPort_LP8_DataReadSize { get; set; } //public int LoadPort_LP8_StartPage { get; set; } //public int LoadPort_LP8_DefaultPage { get; set; } } public class NewE84InfoData : NotifyPropertyChangedBase { private bool _busy; private string _carrierId; private bool _continuousTransfer; private bool _cs0; private bool _cs1; private string _e84State; private bool _emergencyOk; private bool _errorOnPlacementTimeout; private bool _handoffAvailable; private string _loadPortState; private string _AccessMode; //Factory Outputs private bool _loadRequest; private bool _podDocked; private bool _podLatched; private bool _podOpen; private bool _podPlaced; private bool _podReserved; private string _portState; private bool _potPresent; private bool _readyToTransfer; private string _slotMap; private bool _transferComplete; private bool _transferRequest; private bool _unloadRequest; //Factory Inputs private bool _valid; private bool _virtualMode; private bool _inService; private string _carrierIDStatus; public string CarrierIDStatus { get => _carrierIDStatus; set { _carrierIDStatus = value; OnPropertyChanged("CarrierIDStatus"); } } private string _slotmapStatus; public string SlotMapStatus { get => _slotmapStatus; set { _slotmapStatus = value; OnPropertyChanged("SlotMapStatus"); } } private string _accessStatus; public string AccessStatus { get => _accessStatus; set { _accessStatus = value; OnPropertyChanged("AccessStatus"); } } public bool PodPresent { get => _potPresent; set { _potPresent = value; OnPropertyChanged("PodPresent"); } } public bool PodPlaced { get => _podPlaced; set { _podPlaced = value; OnPropertyChanged("PodPlaced"); } } public bool PodLatched { get => _podLatched; set { _podLatched = value; OnPropertyChanged("PodLatched"); } } public bool PodDocked { get => _podDocked; set { _podDocked = value; OnPropertyChanged("PodDocked"); } } public bool PodOpen { get => _podOpen; set { _podOpen = value; OnPropertyChanged("PodOpen"); } } public string LoadPortState { get => $"_{_loadPortState}"; set { _loadPortState = value; OnPropertyChanged("LoadPortState"); } } public string AccessMode { get => $"_{_AccessMode}"; set { _AccessMode = value; OnPropertyChanged("AccessMode"); } } public bool VirtualMode { get => _virtualMode; set { _virtualMode = value; OnPropertyChanged("VirtualMode"); } } public bool PodReserved { get => _podReserved; set { _podReserved = value; OnPropertyChanged("PodReserved"); } } public string PortState { get => $"_{_portState}"; set { _portState = value; OnPropertyChanged("PortState"); } } public string CarrierID { get => _carrierId; set { _carrierId = value; OnPropertyChanged("CarrierID"); } } public string SlotMap { get => _slotMap; set { _slotMap = value; OnPropertyChanged("SlotMap"); } } public bool Valid { get => _valid; set { _valid = value; OnPropertyChanged("Valid"); } } public bool InService { get => _inService; set { _inService = value; OnPropertyChanged("InService"); } } public bool TransferRequest { get => _transferRequest; set { _transferRequest = value; OnPropertyChanged("TransferRequest"); } } public bool Busy { get => _busy; set { _busy = value; OnPropertyChanged("Busy"); } } public bool TransferComplete { get => _transferComplete; set { _transferComplete = value; OnPropertyChanged("TransferComplete"); } } public bool CS0 { get => _cs0; set { _cs0 = value; OnPropertyChanged("CS0"); } } public bool CS1 { get => _cs1; set { _cs1 = value; OnPropertyChanged("CS1"); } } public bool ContinuousTransfer { get => _continuousTransfer; set { _continuousTransfer = value; OnPropertyChanged("ContinuousTransfer"); } } public bool LoadRequest { get => _loadRequest; set { _loadRequest = value; OnPropertyChanged("LoadRequest"); } } public bool UnloadRequest { get => _unloadRequest; set { _unloadRequest = value; OnPropertyChanged("UnloadRequest"); } } public bool ReadyToTransfer { get => _readyToTransfer; set { _readyToTransfer = value; OnPropertyChanged("ReadyToTransfer"); } } public bool HandoffAvailable { get => _handoffAvailable; set { _handoffAvailable = value; OnPropertyChanged("HandoffAvailable"); } } public bool EmergencyOk { get => _emergencyOk; set { _emergencyOk = value; OnPropertyChanged("EmergencyOk"); } } public bool ErrorOnPlacementTimeout { get => _errorOnPlacementTimeout; set { _errorOnPlacementTimeout = value; OnPropertyChanged("ErrorOnPlacementTimeout"); } } public string E84State { get => _e84State; set { _e84State = value; OnPropertyChanged("E84State"); } } //DATA.Subscribe($"{Name}.IndicatiorLoad", () => IndicatiorLoad); // DATA.Subscribe($"{Name}.IndicatiorUnload", () => IndicatiorUnload); // DATA.Subscribe($"{Name}.IndicatiorPresence", () => IndicatiorPresence); // DATA.Subscribe($"{Name}.IndicatiorPlacement", () => IndicatiorPlacement); // DATA.Subscribe($"{Name}.IndicatiorAlarm", () => IndicatorAlarm); // DATA.Subscribe($"{Name}.IndicatiorAccessAuto", () => IndicatiorAccessAuto); // DATA.Subscribe($"{Name}.IndicatiorAccessManual", () => IndicatiorAccessManual); // DATA.Subscribe($"{Name}.IndicatiorOpAccess", () => IndicatiorOpAccess); // DATA.Subscribe($"{Name}.IndicatiorStatus1", () => IndicatiorStatus1); // DATA.Subscribe($"{Name}.IndicatiorStatus2", () => IndicatiorStatus2); private IndicatorState _indicatiorLoad; public IndicatorState IndicatiorLoad { get => _indicatiorLoad; set { _indicatiorLoad = value; OnPropertyChanged("IndicatiorLoad"); } } private IndicatorState _indicatiorUnload; public IndicatorState IndicatiorUnload { get => _indicatiorUnload; set { _indicatiorUnload = value; OnPropertyChanged("IndicatiorUnload"); } } private IndicatorState _indicatiorPresence; public IndicatorState IndicatiorPresence { get => _indicatiorPresence; set { _indicatiorPresence = value; OnPropertyChanged("IndicatiorPresence"); } } private IndicatorState _indicatiorPlacement; public IndicatorState IndicatiorPlacement { get => _indicatiorPlacement; set { _indicatiorPlacement = value; OnPropertyChanged("IndicatiorPlacement"); } } private IndicatorState _indicatiorAlarm; public IndicatorState IndicatiorAlarm { get => _indicatiorAlarm; set { _indicatiorAlarm = value; OnPropertyChanged("IndicatiorAlarm"); } } private IndicatorState _indicatiorAccessAuto; public IndicatorState IndicatiorAccessAuto { get => _indicatiorAccessAuto; set { _indicatiorAccessAuto = value; OnPropertyChanged("IndicatiorAccessAuto"); } } private IndicatorState _indicatiorAccessManual; public IndicatorState IndicatiorAccessManual { get => _indicatiorAccessManual; set { _indicatiorAccessManual = value; OnPropertyChanged("IndicatiorAccessManual"); } } private IndicatorState _indicatiorOpAccess; public IndicatorState IndicatiorOpAccess { get => _indicatiorOpAccess; set { _indicatiorOpAccess = value; OnPropertyChanged("IndicatiorOpAccess"); } } private IndicatorState _indicatiorStatus1; public IndicatorState IndicatiorStatus1 { get => _indicatiorStatus1; set { _indicatiorStatus1 = value; OnPropertyChanged("IndicatiorStatus1"); } } private IndicatorState _indicatiorStatus2; public IndicatorState IndicatiorStatus2 { get => _indicatiorStatus2; set { _indicatiorStatus2 = value; OnPropertyChanged("IndicatiorStatus2"); } } private string _systemStatus; public string SystemStatus { get => _systemStatus; set { _systemStatus = value; OnPropertyChanged("SystemStatus"); } } private string _mode; public string Mode { get => _mode; set { _mode = value; OnPropertyChanged("Mode"); } } private string _initPosMovement; public string InitPosMovement { get => _initPosMovement; set { _initPosMovement = value; OnPropertyChanged("InitPosMovement"); } } private string _operationStatus; public string OperationStatus { get => _operationStatus; set { _operationStatus = value; OnPropertyChanged("OperationStatus"); } } private string _errorCode; public string ErrorCode { get => _errorCode; set { _errorCode = value; OnPropertyChanged("ErrorCode"); } } private string _containerStatus; public string ContainerStatus { get => _containerStatus; set { _containerStatus = value; OnPropertyChanged("ContainerStatus"); } } private string _clampPosition; public string ClampPosition { get => _clampPosition; set { _clampPosition = value; OnPropertyChanged("ClampPosition"); } } private string _lPDoorLatchPosition; public string LPDoorLatchPosition { get => _lPDoorLatchPosition; set { _lPDoorLatchPosition = value; OnPropertyChanged("LPDoorLatchPosition"); } } private string _vacuumStatus; public string VacuumStatus { get => _vacuumStatus; set { _vacuumStatus = value; OnPropertyChanged("VacuumStatus"); } } private string _lPDoorState; public string LPDoorState { get => _lPDoorState; set { _lPDoorState = value; OnPropertyChanged("LPDoorState"); } } private string _waferProtrusion; public string WaferProtrusion { get => _waferProtrusion; set { _waferProtrusion = value; OnPropertyChanged("WaferProtrusion"); } } private string _elevatorAxisPosition; public string ElevatorAxisPosition { get => _elevatorAxisPosition; set { _elevatorAxisPosition = value; OnPropertyChanged("ElevatorAxisPosition"); } } private string _dockPosition; public string DockPosition { get => _dockPosition; set { _dockPosition = value; OnPropertyChanged("DockPosition"); } } private string _mapperPostion; public string MapperPostion { get => _mapperPostion; set { _mapperPostion = value; OnPropertyChanged("MapperPostion"); } } private string _mappingStatus; public string MappingStatus { get => _mappingStatus; set { _mappingStatus = value; OnPropertyChanged("MappingStatus"); } } private string _model; public string Model { get => _model; set { _model = value; OnPropertyChanged("Model"); } } private string _isFosbModeActual; public string IsFosbModeActual { get => _isFosbModeActual; set { _isFosbModeActual = value; OnPropertyChanged("IsFosbModeActual"); } } private bool _pLInService; public bool PLInService { get => _pLInService; set { _pLInService = value; OnPropertyChanged("PLInService"); } } private bool _enableAutoCarrierIdRead; public bool EnableAutoCarrierIdRead { get => _enableAutoCarrierIdRead; set { _enableAutoCarrierIdRead = value; OnPropertyChanged("EnableAutoCarrierIdRead"); } } private string _dataReadSize; public string DataReadSize { get => _dataReadSize; set { _dataReadSize = value; OnPropertyChanged("DataReadSize"); } } private string _startPage; public string StartPage { get => _startPage; set { _startPage = value; OnPropertyChanged("StartPage"); } } private string _defaultPage; public string DefaultPage { get => _defaultPage; set { _defaultPage = value; OnPropertyChanged("DefaultPage"); } } public ObservableCollection AllSlotThickness { get; set; } = new ObservableCollection(); } public class SlotThickness : NotifyPropertyChangedBase { private string _slotName; public string SlotName { get => _slotName; set { _slotName = value; OnPropertyChanged("SlotName"); } } private int _value; public int Value { get => _value; set { _value = value; OnPropertyChanged("Value"); } } } }