using System.Windows; using System.Windows.Controls; using System.Windows.Input; using Aitex.Core.UI.MVVM; using Aitex.Sorter.Common; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.OperationCenter; namespace Aitex.Sorter.UI.Controls { /// /// SMIFNoMapStatus.xaml 的交互逻辑 /// public partial class SMIFNoMapStatus : UserControl { // Using a DependencyProperty as the backing store for Placed. This enables animation, styling, binding, etc... public static readonly DependencyProperty PlacedProperty = DependencyProperty.Register("Placed", typeof(bool), typeof(SMIFNoMapStatus), new PropertyMetadata(false)); // Using a DependencyProperty as the backing store for Present. This enables animation, styling, binding, etc... public static readonly DependencyProperty PresentProperty = DependencyProperty.Register("Present", typeof(bool), typeof(SMIFNoMapStatus), new PropertyMetadata(false)); // Using a DependencyProperty as the backing store for UnitName. This enables animation, styling, binding, etc... public static readonly DependencyProperty StationSetProperty = DependencyProperty.Register("Station", typeof(ModuleName), typeof(SMIFNoMapStatus), new PropertyMetadata(ModuleName.System)); // Using a DependencyProperty as the backing store for FoupID. This enables animation, styling, binding, etc... public static readonly DependencyProperty FoupIDProperty = DependencyProperty.Register("FoupID", typeof(string), typeof(SMIFNoMapStatus), new PropertyMetadata(null)); // Using a DependencyProperty as the backing store for RFReader. This enables animation, styling, binding, etc... public static readonly DependencyProperty RFReaderProperty = DependencyProperty.Register("RFReader", typeof(string), typeof(SMIFNoMapStatus), new PropertyMetadata(null)); // Using a DependencyProperty as the backing store for Status. This enables animation, styling, binding, etc... public static readonly DependencyProperty StatusProperty = DependencyProperty.Register("Status", typeof(string), typeof(SMIFNoMapStatus), new PropertyMetadata(null)); // Using a DependencyProperty as the backing store for CassetteState. This enables animation, styling, binding, etc... public static readonly DependencyProperty CassetteStateProperty = DependencyProperty.Register("CassetteState", typeof(string), typeof(SMIFNoMapStatus), new PropertyMetadata(null)); // Using a DependencyProperty as the backing store for ClampStatus. This enables animation, styling, binding, etc... public static readonly DependencyProperty ClampStatusProperty = DependencyProperty.Register("ClampStatus", typeof(string), typeof(SMIFNoMapStatus), new PropertyMetadata(null)); // Using a DependencyProperty as the backing store for FoupDoorStatus. This enables animation, styling, binding, etc... public static readonly DependencyProperty FoupDoorStatusProperty = DependencyProperty.Register("FoupDoorStatus", typeof(string), typeof(SMIFNoMapStatus), new PropertyMetadata(null)); // Using a DependencyProperty as the backing store for LoadPortLoaded. This enables animation, styling, binding, etc... public static readonly DependencyProperty LoadPortLoadedProperty = DependencyProperty.Register("LoadPortLoaded", typeof(bool), typeof(SMIFNoMapStatus), new PropertyMetadata(false)); // Using a DependencyProperty as the backing store for LoadPortUnloaded. This enables animation, styling, binding, etc... public static readonly DependencyProperty LoadPortUnloadedProperty = DependencyProperty.Register("LoadPortUnloaded", typeof(bool), typeof(SMIFNoMapStatus), new PropertyMetadata(false)); // Using a DependencyProperty as the backing store for IsAlarm. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsAlarmProperty = DependencyProperty.Register("IsAlarm", typeof(bool), typeof(SMIFNoMapStatus), new PropertyMetadata(false)); // Using a DependencyProperty as the backing store for RoutManagerState. This enables animation, styling, binding, etc... public static readonly DependencyProperty RoutManagerStateProperty = DependencyProperty.Register("RoutManagerState", typeof(int), typeof(SMIFNoMapStatus), new PropertyMetadata((int) RtState.Init, StateChangedCallback)); // Using a DependencyProperty as the backing store for IsAutoMode. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsAutoModeProperty = DependencyProperty.Register("IsAutoMode", typeof(bool), typeof(SMIFNoMapStatus), new PropertyMetadata(false, StateChangedCallback)); public SMIFNoMapStatus() { InitializeComponent(); DeviceOperationCommand = new DelegateCommand(DeviceOperation, x => RoutManagerState != (int) RtState.Maintenance && !IsAutoMode); RFReaderCommand = new DelegateCommand(RFReaderOperation, x => RoutManagerState != (int) RtState.Maintenance && !IsAutoMode); root.DataContext = this; } public bool Placed { get => (bool) GetValue(PlacedProperty); set => SetValue(PlacedProperty, value); } public bool Present { get => (bool) GetValue(PresentProperty); set => SetValue(PresentProperty, value); } public ModuleName Station { get => (ModuleName) GetValue(StationSetProperty); set => SetValue(StationSetProperty, value); } public string FoupID { get => (string) GetValue(FoupIDProperty); set => SetValue(FoupIDProperty, value); } public string RFReader { get => (string) GetValue(RFReaderProperty); set => SetValue(RFReaderProperty, value); } public string Status { get => (string) GetValue(StatusProperty); set => SetValue(StatusProperty, value); } public string CassetteState { get => (string) GetValue(CassetteStateProperty); set => SetValue(CassetteStateProperty, value); } public string ClampStatus { get => (string) GetValue(ClampStatusProperty); set => SetValue(ClampStatusProperty, value); } public string FoupDoorStatus { get => (string) GetValue(FoupDoorStatusProperty); set => SetValue(FoupDoorStatusProperty, value); } public bool LoadPortLoaded { get => (bool) GetValue(LoadPortLoadedProperty); set => SetValue(LoadPortLoadedProperty, value); } public bool LoadPortUnloaded { get => (bool) GetValue(LoadPortUnloadedProperty); set => SetValue(LoadPortUnloadedProperty, value); } public bool IsAlarm { get => (bool) GetValue(IsAlarmProperty); set => SetValue(IsAlarmProperty, value); } public int RoutManagerState { get => (int) GetValue(RoutManagerStateProperty); set => SetValue(RoutManagerStateProperty, value); } public bool IsAutoMode { get => (bool) GetValue(IsAutoModeProperty); set => SetValue(IsAutoModeProperty, value); } public ICommand DeviceOperationCommand { get; } public ICommand RFReaderCommand { get; } public static void StateChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { var self = d as SMIFNoMapStatus; if (self.DeviceOperationCommand != null) ((IDelegateCommand) self.DeviceOperationCommand).RaiseCanExecuteChanged(); if (self.RFReaderCommand != null) ((IDelegateCommand) self.RFReaderCommand).RaiseCanExecuteChanged(); } private void DeviceOperation(string cmd) { var deviceName = Station.ToString(); var param = new object[] {deviceName, cmd}; InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation, param); } private void RFReaderOperation(string cmd) { var deviceName = RFReader; var param = new object[] {deviceName, cmd}; InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation, param); } } }