using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Timers; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml; using Aitex.Core.Common.DeviceData; using Aitex.Core.MES; using Aitex.Core.MES.JC; using Aitex.Core.MES.YZQZ; using Aitex.Core.Observer; using Aitex.Core.RT.SCCore; using Aitex.Core.UI.Control; using Aitex.Core.UI.Dialog; using Aitex.Core.UI.MVVM; using Aitex.Core.Util; using Aitex.Core.Utilities; using Aitex.Platform; using Aitex.Triton160.Common; using Aitex.Triton160.UI; using Aitex.Triton160.UI.Properties; using Aitex.Triton160.UI.ViewModel; using Aitex.Triton160.UI.Views; using Aitex.Triton160.UI.Views.Hz; using Aitex.Triton160.UI.Wcf; namespace Triton160.UI.ViewModel { class OverviewViewModel : UIViewModelBase { [DllImport("User32.dll")] public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); #region Command public ICommand DeviceOperationCommand { get; private set; } public ICommand RecipeSelectCommand { get; private set; } public ICommand RecipeRunCommand { get; private set; } public ICommand RecipeSkipToNextCommand { get; private set; } public ICommand RecipeAbortCommand { get; private set; } public ICommand RecipeBarcodeInputChangedCommand { get; set; } public ICommand LotBarcodeInputChangedCommand { get; set; } public ICommand OperatorInputChangedCommand { get; private set; } public ICommand GetRecipeByMESCommand { get; private set; } #endregion #region Valves [Subscription(TritonDevice.ValveMfc1, SystemDeviceModule)] public AITValveData GP1Valve { get; set; } [Subscription(TritonDevice.ValveMfc2, SystemDeviceModule)] public AITValveData GP2Valve { get; set; } [Subscription(TritonDevice.ValveMfc3, SystemDeviceModule)] public AITValveData GP3Valve { get; set; } [Subscription(TritonDevice.ValveMfc4, SystemDeviceModule)] public AITValveData GP4Valve { get; set; } [Subscription(TritonDevice.ValveMfc5, SystemDeviceModule)] public AITValveData GP5Valve { get; set; } [Subscription(TritonDevice.ValveProcessGasFinal, SystemDeviceModule)] public AITValveData GasFinalValve { get; set; } [Subscription(TritonDevice.ValveChamberPurge, SystemDeviceModule)] public AITValveData ChamberPurgeValve { get; set; } [Subscription(TritonDevice.ValveChamberVent, SystemDeviceModule)] public AITValveData VentValve { get; set; } [Subscription(TritonDevice.ValveChamberPumping, SystemDeviceModule)] public AITValveData ChamberPumpingOpenValve { get; set; } [Subscription(TritonDevice.ValveChamberPumpingClose, SystemDeviceModule)] public AITValveData ChamberPumpingCloseValve { get; set; } #endregion Valves #region MFCs private AITMfcData _mfc1; [Subscription(TritonDevice.MfcGas1, SystemDeviceModule)] public AITMfcData GP1Mfc { get { return _mfc1; } set { _mfc1 = value; if (IsAutoMode) { Mfc1SetPoint = _mfc1.SetPoint.ToString("F1"); InvokePropertyChanged("Mfc1SetPoint"); } } } private AITMfcData _mfc2; [Subscription(TritonDevice.MfcGas2, SystemDeviceModule)] public AITMfcData GP2Mfc { get { return _mfc2; } set { _mfc2 = value; if (IsAutoMode) { Mfc2SetPoint = _mfc2.SetPoint.ToString("F1"); InvokePropertyChanged("Mfc2SetPoint"); } } } private AITMfcData _mfc3; [Subscription(TritonDevice.MfcGas3, SystemDeviceModule)] public AITMfcData GP3Mfc { get { return _mfc3; } set { _mfc3 = value; if (IsAutoMode) { Mfc3SetPoint = _mfc3.SetPoint.ToString("F1"); InvokePropertyChanged("Mfc3SetPoint"); } } } private AITMfcData _mfc4; [Subscription(TritonDevice.MfcGas4, SystemDeviceModule)] public AITMfcData GP4Mfc { get { return _mfc4; } set { _mfc4 = value; if (IsAutoMode) { Mfc4SetPoint = _mfc4.SetPoint.ToString("F1"); InvokePropertyChanged("Mfc4SetPoint"); } } } private AITMfcData _mfc5; [Subscription(TritonDevice.MfcGas5, SystemDeviceModule)] public AITMfcData GP5Mfc { get { return _mfc5; } set { _mfc5 = value; if (IsAutoMode) { Mfc5SetPoint = _mfc5.SetPoint.ToString("F1"); InvokePropertyChanged("Mfc5SetPoint"); } } } #endregion MFCs #region Pressure Meter [Subscription(TritonDevice.PressureMeterChamber, SystemDeviceModule)] public AITPressureMeterData ChamberPressure { get; set; } #endregion Pressure Meter #region Rf private AITRfData _rf; [Subscription(TritonDevice.Rf, SystemDeviceModule)] public AITRfData Rf { get { return _rf; } set { _rf = value; if (IsAutoMode) { RfPowerSetPoint = _rf.PowerSetPoint.ToString("F0"); InvokePropertyChanged("RfPowerSetPoint"); RfDutySetPoint = _rf.DutySetPoint.ToString("F0"); InvokePropertyChanged("RfDutySetPoint"); RfFrequencySetPoint = _rf.FrequencySetPoint.ToString("F0"); InvokePropertyChanged("RfFrequencySetPoint"); RfMatchProcessModeSetPoint = _rf.TritonMatchProcessModeDisplay; InvokePropertyChanged("RfMatchProcessModeSetPoint"); RfMatchPositionC1SetPoint = _rf.MatchPositionC1SetPoint.ToString("F0"); InvokePropertyChanged("RfMatchPositionC1SetPoint"); RfMatchPositionC2SetPoint = _rf.MatchPositionC2SetPoint.ToString("F0"); InvokePropertyChanged("RfMatchPositionC2SetPoint"); RfModeSetPoint = (_rf.WorkMode == (int)RfMode.ContinuousWaveMode) ? "Continuous" : "Pulsing"; InvokePropertyChanged("RfModeSetPoint"); } } } #endregion Rf #region Pump [Subscription(TritonDevice.MainPump, SystemDeviceModule)] public AITPumpData Pump { get; set; } private AITBoostPumpData _boost; [Subscription(TritonDevice.BoostPump, SystemDeviceModule)] public AITBoostPumpData BoostPump { get { return _boost; } set { _boost = value; if (IsAutoMode) { BoostPumpPressureSetPoint = _boost.PressureSetPoint.ToString("F0"); InvokePropertyChanged("BoostPumpPressureSetPoint"); } } } private AITThrottleValveData _tv; [Subscription(TritonDevice.ThrottleValve, SystemDeviceModule)] public AITThrottleValveData Tv { get { return _tv; } set { _tv = value; if (IsAutoMode) { ThrottleValveModeSetPoint = _tv.TextMode; InvokePropertyChanged("ThrottleValveModeSetPoint"); ThrottleValvePositionSetPoint = _tv.PositionSetPoint.ToString("F0"); InvokePropertyChanged("ThrottleValvePositionSetPoint"); ThrottleValvePressureSetPoint = _tv.PressureSetPoint.ToString("F0"); InvokePropertyChanged("ThrottleValvePressureSetPoint"); } } } public double TvHeight { get; set; } public Visibility TvVisible { get; set; } #endregion Pump #region Sensor [Subscription(TritonDevice.SensorBackPanelDoor, SystemDeviceModule)] public AITSensorData SensorBackPanelDoor { get; set; } [Subscription(TritonDevice.SensorChamberDoor, SystemDeviceModule)] public AITSensorData SensorChamberDoor { get; set; } [Subscription(TritonDevice.SensorPumpDoor, SystemDeviceModule)] public AITSensorData SensorPumpDoor { get; set; } public Visibility IsHaveSensorPumpDoor { get { if (SensorPumpDoor == null) { return Visibility.Collapsed; } else { return Visibility.Visible; } } } #endregion Sensor #region state data [Subscription(StateData.ProcessStatus, SystemStateModule)] public string ProcessStatus { get; set; } [Subscription(StateData.RecipeStepTimeElapsed, SystemStateModule)] public string RecipeStepTimeElapsed { get; set; } [Subscription(StateData.RecipeStepTimeSetPoint, SystemStateModule)] public string RecipeStepTimeSetPoint { get; set; } private string _recipeStepRfTimeSetPoint; [Subscription(StateData.RecipeStepRfTimeSetPoint, SystemStateModule)] public string RecipeStepRfTimeSetPoint { get { return _recipeStepRfTimeSetPoint; } set { _recipeStepRfTimeSetPoint = value; if (IsAutoMode) { RfTimeSetPoint = _recipeStepRfTimeSetPoint; InvokePropertyChanged("RfTimeSetPoint"); } } } private bool _isAutoMode; private R_TRIG _trigChangeToAuto = new R_TRIG(); [Subscription(StateData.IsAutoMode, SystemStateModule)] public bool IsAutoMode { get { return _isAutoMode; } set { _isAutoMode = value; _IsEnableLotScan= IsAutoMode && !IsProcessing; _trigChangeToAuto.CLK = _isAutoMode; if (_trigChangeToAuto.Q) { ThrottleValveModeSetPoint = ""; InvokePropertyChanged("ThrottleValveModeSetPoint"); ThrottleValvePositionSetPoint = ""; InvokePropertyChanged("ThrottleValvePositionSetPoint"); ThrottleValvePressureSetPoint = ""; InvokePropertyChanged("ThrottleValvePressureSetPoint"); BoostPumpPressureSetPoint = ""; InvokePropertyChanged("BoostPumpPressureSetPoint"); RfTimeSetPoint = ""; InvokePropertyChanged("RfTimeSetPoint"); RfModeSetPoint = ""; InvokePropertyChanged("RfModeSetPoint"); RfPowerSetPoint = ""; InvokePropertyChanged("RfPowerSetPoint"); RfFrequencySetPoint = ""; InvokePropertyChanged("RfFrequencySetPoint"); RfDutySetPoint = ""; InvokePropertyChanged("RfDutySetPoint"); RfMatchProcessModeSetPoint = ""; InvokePropertyChanged("RfMatchProcessModeSetPoint"); RfMatchPositionC1SetPoint = ""; InvokePropertyChanged("RfMatchPositionC1SetPoint"); RfMatchPositionC2SetPoint = ""; InvokePropertyChanged("RfMatchPositionC2SetPoint"); Mfc1SetPoint = ""; InvokePropertyChanged("Mfc1SetPoint"); Mfc2SetPoint = ""; InvokePropertyChanged("Mfc2SetPoint"); Mfc3SetPoint = ""; InvokePropertyChanged("Mfc3SetPoint"); Mfc4SetPoint = ""; InvokePropertyChanged("Mfc4SetPoint"); Mfc5SetPoint = ""; InvokePropertyChanged("Mfc5SetPoint"); Vapor1SetPoint = ""; InvokePropertyChanged("Vapor1SetPoint"); Vapor2SetPoint = ""; InvokePropertyChanged("Vapor2SetPoint"); ElectrodeTempSetPoint = ""; InvokePropertyChanged("ElectrodeTempSetPoint"); } } } public bool IsManualMode { get { return !IsAutoMode; } } public bool IsMatchPositionInputEnabled { get { if (Rf != null && RfMatchProcessModeSetPoint != "Preset") return false; return IsManualMode; } } [Subscription(StateData.RecipeStepNo, SystemStateModule)] public int RecipeStepNo { get; set; } [Subscription(StateData.RecipeProcessTime, SystemStateModule)] public string RecipeProcessTime { get; set; } [Subscription(StateData.PumpTime, SystemStateModule)] public string PumpTime { get; set; } [Subscription(StateData.PMState, SystemStateModule)] public int PMStatus { get; set; } [Subscription(StateData.IsPumpingOkForProcess, SystemStateModule)] public bool IsPumpingOkForProcess { get; set; } [Subscription(StateData.IsGasFlowingOkForProcess, SystemStateModule)] public bool IsGasFlowingOkForProcess { get; set; } [Subscription(StateData.LotName, SystemStateModule)] public string LotName { get; set; } [Subscription("System.ControlStatus")] public string HostControlStatus { get; set; } [Subscription("System.CommunicationStatus")] public string HostCommunicationStatus { get; set; } public FACommunicationState FACommunicationState { get { return string.IsNullOrEmpty(HostCommunicationStatus) ? FACommunicationState.Disabled : (FACommunicationState)Enum.Parse(typeof(FACommunicationState), HostCommunicationStatus); } } public FAControlState FAControlState { get { return string.IsNullOrEmpty(HostControlStatus) ? FAControlState.Unknown : (FAControlState)Enum.Parse(typeof(FAControlState), HostControlStatus); } } [Subscription(StateData.RecipeName, SystemStateModule)] public string CurrentRecipeName { get; set; } [Subscription(StateData.TotalCycle, SystemStateModule)] public int TotalCycle { get; set; } #endregion state data #region Display public string TvText { get { if (Tv == null || !SCLocal.PressureControlConfig.EnableThrottleValve) return ""; return string.Format("{0}%", Tv.PositionFeedback.ToString("F0")); } } public string TvTextBackground { get { if (Tv == null || !SCLocal.PressureControlConfig.EnableThrottleValve) return "Transparent"; if (Tv.State != 1) return "Red"; return "Green"; } } #endregion Display #region logic display public Visibility VisibleLoadUnload { get { return SCLocal.System.EnableFa ? Visibility.Visible : Visibility.Hidden; } } public bool IsEnableLoad { get { return IsAutoMode && (PMState)PMStatus == PMState.Idle; } } public bool IsEnableUnload { get { return IsAutoMode && (PMState)PMStatus == PMState.Idle; } } public bool IsEnableRecipeScan { get { return IsAutoMode && !IsProcessing; } } private bool _IsEnableLotScan; public bool IsEnableLotScan { get { //_IsEnableLotScan= IsAutoMode && !IsProcessing; return _IsEnableLotScan; } set { _IsEnableLotScan = value; InvokePropertyChanged("IsEnableLotScan"); } } public bool IsEnableSelectRecipe { get { return IsAutoMode && !IsProcessing && !(SCLocal.System.EnableFa && FACommunicationState == FACommunicationState.EnabledCommunicating && FAControlState == FAControlState.OnlineRemote) && (!SCLocal.BarcodeConfig.EnableBarcode || SCLocal.BarcodeConfig.EnableSelectRecipeInAutoRun); } } public bool IsEnableStartRecipe { get { return IsAutoMode && !(SCLocal.System.EnableFa && FACommunicationState == FACommunicationState.EnabledCommunicating && FAControlState == FAControlState.OnlineRemote) && !string.IsNullOrEmpty(SelectedRecipeName) && !IsProcessing; } } public bool IsEnableNextStep { get { return IsAutoMode && IsProcessing; } } public bool IsEnableStopRecipe { get { return IsAutoMode && IsProcessing; } } public bool IsBarcodeEnabled { get; set; } public bool IsRfPowerOn { get { return Rf != null && Rf.IsRfOn; } } public bool SensorValue { get { return false; } } public bool IsManualButtonEnabled { get { return IsAutoMode; } } public bool IsAutoButtonEnabled { get { return !IsAutoMode; } } public bool IsPumping { get { return (PMState)PMStatus == PMState.Pumping; } } public string RecipeStepNoDisplay { get { return (PMState)PMStatus == PMState.Processing ? RecipeStepNo.ToString() : "--"; } } private string _pumpButtonBackground = "CadetBlue"; public string PumpButtonBackground { get { if (IsPumping) { _pumpButtonBackground = _pumpButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7"; return _pumpButtonBackground; } if (IsPumpingOkForProcess) return "#00C900"; return "CadetBlue"; } } public bool IsGasFlowing { get { return (PMState)PMStatus == PMState.GasFlowing; } } private string _gasFlowButtonBackground = "CadetBlue"; public string GasFlowButtonBackground { get { if (IsGasFlowing) { _gasFlowButtonBackground = _gasFlowButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7"; return _gasFlowButtonBackground; } if (IsGasFlowingOkForProcess) return "#00C900"; return "CadetBlue"; } } public bool IsRfPowering { get { return (PMState)PMStatus == PMState.RfPowering; } } private string _rfPowerButtonBackground = "CadetBlue"; public string RfPowerButtonBackground { get { if (IsRfPowering) { _rfPowerButtonBackground = _rfPowerButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7"; return _rfPowerButtonBackground; } return "CadetBlue"; } } public bool IsCyclePurging { get { return (PMState)PMStatus == PMState.CyclePurge; } } private string _cyclePurgeButtonBackground = "CadetBlue"; public string CyclePurgeButtonBackground { get { if (IsCyclePurging) { _cyclePurgeButtonBackground = _cyclePurgeButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7"; return _cyclePurgeButtonBackground; } return "CadetBlue"; } } public bool IsVenting { get { return (PMState)PMStatus == PMState.Vent; } } private string _ventButtonBackground = "CadetBlue"; public string VentButtonBackground { get { if (IsVenting) { _ventButtonBackground = _ventButtonBackground == "#95B3D7" ? "Blue" : "#95B3D7"; return _ventButtonBackground; } return "CadetBlue"; } } public bool IsProcessing { get { return (PMState)PMStatus == PMState.PreProcess || (PMState)PMStatus == PMState.Processing || (PMState)PMStatus == PMState.PostProcess; } } public Visibility RfPowerOnChamberVisibility { get { return IsRfPowerOn ? Visibility.Visible : Visibility.Hidden; } } public Visibility BoostPumpVisibility { get; set; } public bool IsRfPowerOnEnabled { get { return !IsRfPowerOn; } } public bool IsRfPowerOffEnabled { get { return IsRfPowerOn; } } public SolidColorBrush ChamberDoorColor { get { return SensorChamberDoor != null && SensorChamberDoor.Value ? Brushes.Lime : Brushes.Gray; } } public SolidColorBrush PumpDoorColor { get { return SensorPumpDoor != null && SensorPumpDoor.Value ? Brushes.Lime : Brushes.Gray; } } public SolidColorBrush BackpanelDoorColor { get { return SensorBackPanelDoor != null && SensorBackPanelDoor.Value ? Brushes.Lime : Brushes.Gray; } } public string ChamberStatus { get { return string.Format("{0} : {1}", Application.Current.Resources["GlobalLableChamberStatus"], ((PMState)PMStatus)); } } public Brush ChamberStatusBkColor { get { switch ((PMState)PMStatus) { case PMState.Error: return Brushes.Red; case PMState.Idle: return Brushes.Blue; default: return Brushes.LightGreen; } //return Brushes.Transparent; } } public Brush ChamberStatusForeColor { get { if (true) return Brushes.Black; //else if (false) // return Brushes.LightGreen; //return Brushes.Red; } } public double RfReflectPower { get; set; } public double RfForwardPower { get; set; } public object[] RfPowerOnCommandParameter { get { return new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPowerOnOff.ToString(), "true" }; } } public object[] RfPowerOffCommandParameter { get { return new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPowerOnOff.ToString(), "false" }; } } public double LotBarcodeHeight { get { return IsBarcodeEnabled ? 35 : 0; } } public double DataLogHeight { get { return IsBarcodeEnabled ? (SCLocal.System.EnableFa ? 35 : 0) : 35; } } public double RecipeBarcodeHeight { get { return IsBarcodeEnabled ? 35 : 0; } } //public string Barcode1 //{ // get // { // if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 0) // return value[0]; // return ""; // } //} //public string Barcode2 //{ // get // { // if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 1) // return value[1]; // return ""; // } //} //public string Barcode3 //{ // get // { // if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 2) // return value[2]; // return ""; // } //} //public string Barcode4 //{ // get // { // if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 3) // return value[3]; // return ""; // } //} //public string Barcode5 //{ // get // { // if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 4) // return value[4]; // return ""; // } //} //public string Barcode6 //{ // get // { // if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 5) // return value[5]; // return ""; // } //} public string OperatorInputText { get; set; } private ObservableCollection m_Barcodes = new ObservableCollection(); // public ObservableCollection Barcodes { get { return m_Barcodes; } set { m_Barcodes = value; } } public string RecipeBarcodeInputText { get; set; } public int RecipeBarcodeLength { get; set; } public string LotBarcodeInputText { get; set; } public int LotBarcodeLength { get; set; } public int LotBarcodeMaxCount { get; set; } #endregion logic display #region setpoint [IgnorePropertyChange] public string BasePressureSetPoint { get; set; } [IgnorePropertyChange] public string PumpLimitSetPoint { get; set; } [IgnorePropertyChange] public string ThrottleValveModeSetPoint { get; set; } [IgnorePropertyChange] public string ThrottleValvePositionSetPoint { get; set; } [IgnorePropertyChange] public string ThrottleValvePressureSetPoint { get; set; } [IgnorePropertyChange] public string BoostPumpPressureSetPoint { get; set; } [IgnorePropertyChange] public string RfTimeSetPoint { get; set; } [IgnorePropertyChange] public string RfMatchProcessModeSetPoint { get; set; } private string _rfModeSetPoint; [IgnorePropertyChange] public string RfModeSetPoint { get { return _rfModeSetPoint; } set { _rfModeSetPoint = value; } } [IgnorePropertyChange] public string RfPowerSetPoint { get; set; } [IgnorePropertyChange] public string RfFrequencySetPoint { get; set; } [IgnorePropertyChange] public string RfDutySetPoint { get; set; } [IgnorePropertyChange] public string RfMatchPositionC1SetPoint { get; set; } [IgnorePropertyChange] public string RfMatchPositionC2SetPoint { get; set; } [IgnorePropertyChange] public string Mfc1SetPoint { get; set; } [IgnorePropertyChange] public string Mfc2SetPoint { get; set; } [IgnorePropertyChange] public string Mfc3SetPoint { get; set; } [IgnorePropertyChange] public string Mfc4SetPoint { get; set; } [IgnorePropertyChange] public string Mfc5SetPoint { get; set; } [IgnorePropertyChange] public string Vapor1SetPoint { get; set; } [IgnorePropertyChange] public string Vapor2SetPoint { get; set; } [IgnorePropertyChange] public string ElectrodeTempSetPoint { get; set; } [IgnorePropertyChange] //public string SelectedRecipeName { get; set; } private string _rcpName; //private DeviceTimer _timer = new DeviceTimer(); private Timer _timer = new Timer(10000); public string SelectedRecipeName { get { return _rcpName; } set { _rcpName = value; InvokePropertyChanged("SelectedRecipeName"); if (!string.IsNullOrWhiteSpace(_rcpName)) { _timer.Start(); } } } public string SelectedOperation = ""; #endregion setpoint #region recipe //public string RecipeStatus //{ // get // { // if ((PMState)PMStatus == PMState.PreProcess) // return "Pumping down"; // if ((PMState)PMStatus == PMState.Processing) // return "Running"; // if ((PMState)PMStatus == PMState.PostProcess) // return "Cycle Purge"; // return ""; // } //} public string RecipeStatusBackground { get { return IsProcessing ? "Green" : "Blue"; } } #endregion recipe #region config public double GP1Height { get; set; } public double GP2Height { get; set; } public double GP3Height { get; set; } public double GP4Height { get; set; } public double GP5Height { get; set; } public Visibility GP1Visible { get; set; } public Visibility GP2Visible { get; set; } public Visibility GP3Visible { get; set; } public Visibility GP4Visible { get; set; } public Visibility GP5Visible { get; set; } public double RFPulsingHeight { get; set; } public double BoostPumpHeight { get; set; } public ObservableCollection RFModeItems { get; set; } public bool IsRFModeSelectable { get; set; } public bool IsFullControlPermission { get; set; } public bool EnableDeviceControl { get { return SCLocal.System.IsTestMode; } } public bool EnableWaterFlowAlarm { get { return !bSetWaterFlowAlarm; } } public bool DisenableWaterFlowAlarm { get { return !EnableWaterFlowAlarm; } } #endregion config private bool m_IsAuto; public bool IsAuto { get { return m_IsAuto; } set { m_IsAuto = value; } } private bool m_enableManualSelectRecipe; public bool EnableManualSelectRecipe { get { return m_enableManualSelectRecipe; } set { m_enableManualSelectRecipe = value; } } private bool bSetWaterFlowAlarm = false; private List _keys = new List(); private R_TRIG _trigRecipeFinished = new R_TRIG(); private HzOverviewView _hzOverviewView; FabAutoComm _fabAutoComm; string[] barcodes; string userID; private Timer monitorEndTimer = new Timer(5000); List LotsReceipeInfo; public OverviewViewModel(HzOverviewView hzOverviewView) : base("OverviewViewModel") { DeviceOperationCommand = new DelegateCommand(DeviceOperation); InvokeCommand = new DelegateCommand(Invoke); RecipeSelectCommand = new DelegateCommand(SelectRecipe); RecipeRunCommand = new DelegateCommand(RunRecipe); RecipeSkipToNextCommand = new DelegateCommand(SkipRecipe); RecipeAbortCommand = new DelegateCommand(AbortRecipe); RecipeBarcodeInputChangedCommand = new DelegateCommand(RecipeBarcodeInputChanged); LotBarcodeInputChangedCommand = new DelegateCommand(LotBarcodeInputChanged); OperatorInputChangedCommand = new DelegateCommand(OperatorInputChanged); GetRecipeByMESCommand = new DelegateCommand(GetRecipeByMES); BasePressureSetPoint = ((float)(double)Triton160UiSystem.Instance.WCF.Query.GetConfig(SCName.System_PumpBasePressure)).ToString(); PumpLimitSetPoint = ((float)(double)Triton160UiSystem.Instance.WCF.Query.GetConfig(SCName.System_PumpTimeLimit)).ToString(); bSetWaterFlowAlarm = false; SCLocal.RetrieveAll(); AITThrottleValveData tv = (AITThrottleValveData)Triton160UiSystem.Instance.WCF.Query.GetData("Device.System.ThrottleValve"); AITRfData rf = (AITRfData)Triton160UiSystem.Instance.WCF.Query.GetData("Device.System.Rf"); RFModeItems = new ObservableCollection(); RFModeItems.Add("Continuous"); if (tv != null) { ThrottleValveModeSetPoint = tv.TextMode; } if (rf != null) { RfModeSetPoint = rf.TextWorkMode; InvokePropertyChanged("RfModeSetPoint"); RfMatchProcessModeSetPoint = rf.TritonMatchProcessModeDisplay; InvokePropertyChanged("RfMatchProcessModeSetPoint"); } _hzOverviewView = hzOverviewView; GlobalObserver.Instance.OnIsAutoRaiseCahnged += Instance_OnIsAutoRaiseCahnged; monitorEndTimer.Elapsed += MonitorEndTimer_Elapsed; monitorEndTimer.Enabled = false; //switch (WcfClient.Instance.Query.GetConfig(SCName.System_Company)) //{ // case 0: // _fabAutoComm = new JCFabAuto(); // var recipeName = _fabAutoComm.GetRecipeByLot(); // AutoGetRecipe(recipeName); // break; //} var company = WcfClient.Instance.Query.GetConfig(SCName.System_Company); _fabAutoComm = tnt.SelectFab((Fab)Enum.Parse(typeof(Fab), company.ToString())); EnableManualSelectRecipe =(bool) WcfClient.Instance.Query.GetConfig(SCName.BarcodeConfig_EnableSelectRecipeInAutoRun); } private void MonitorEndTimer_Elapsed(object sender, ElapsedEventArgs e) { if (ProcessStatus == "recipe completed" || ProcessStatus == "工艺完成") { _fabAutoComm.CheckOut(); monitorEndTimer.Enabled = false; } } private void Instance_OnIsAutoRaiseCahnged(bool isAuto) { IsAuto = isAuto; } //private void Timer_Elapsed(object sender, ElapsedEventArgs e) //{ // _timer.Stop(); // MessageBox.Show("是否开始工艺?"); //} protected override void InvokeBeforeUpdateProperty(Dictionary data) { UpdateAllConfig(); GP1Visible = SCLocal.GasLineConfig.Gas1Enable ? Visibility.Visible : Visibility.Hidden; GP1Height = SCLocal.GasLineConfig.Gas1Enable ? 26 : 0; GP2Visible = SCLocal.GasLineConfig.Gas2Enable ? Visibility.Visible : Visibility.Hidden; GP2Height = SCLocal.GasLineConfig.Gas2Enable ? 26 : 0; GP3Visible = SCLocal.GasLineConfig.Gas3Enable ? Visibility.Visible : Visibility.Hidden; GP3Height = SCLocal.GasLineConfig.Gas3Enable ? 26 : 0; GP4Visible = SCLocal.GasLineConfig.Gas4Enable ? Visibility.Visible : Visibility.Hidden; GP4Height = SCLocal.GasLineConfig.Gas4Enable ? 26 : 0; GP5Visible = SCLocal.GasLineConfig.Gas5Enable ? Visibility.Visible : Visibility.Hidden; GP5Height = SCLocal.GasLineConfig.Gas5Enable ? 26 : 0; BoostPumpVisibility = SCLocal.PressureControlConfig.EnableBoosterPump ? Visibility.Visible : Visibility.Hidden; BoostPumpHeight = (BoostPumpVisibility == Visibility.Visible) ? 26 : 0; IsBarcodeEnabled = SCLocal.BarcodeConfig.EnableBarcode; LotBarcodeLength = SCLocal.BarcodeConfig.MaxLotInputBarcodeLength; LotBarcodeMaxCount = SCLocal.BarcodeConfig.MaxLotBarcodeCount; RecipeBarcodeLength = SCLocal.BarcodeConfig.MaxRecipeInputBarcodeLength; TvVisible = SCLocal.PressureControlConfig.EnableThrottleValve ? Visibility.Visible : Visibility.Hidden; TvHeight = (SCLocal.PressureControlConfig.EnableThrottleValve) ? 26 : 0; Application.Current.Dispatcher.Invoke(new Action(() => { RFPulsingHeight = SCLocal.RfConfig.EnablePulsingFunction ? 26 : 0; if (SCLocal.RfConfig.EnablePulsingFunction != RFModeItems.Contains("Pulsing")) { if (SCLocal.RfConfig.EnablePulsingFunction) { RFModeItems.Add("Pulsing"); } else { RFModeItems.Remove("Pulsing"); } } if (!SCLocal.RfConfig.EnablePulsingFunction) { RfModeSetPoint = "Continuous"; InvokePropertyChanged("RfModeSetPoint"); } if (SCLocal.System.EnableFa && FAControlState == FAControlState.OnlineRemote) { SelectedRecipeName = CurrentRecipeName; InvokePropertyChanged("SelectedRecipeName"); } })); IsRFModeSelectable = SCLocal.RfConfig.EnablePulsingFunction && IsManualMode; _trigRecipeFinished.CLK = !IsProcessing; if (_trigRecipeFinished.Q) { SelectedRecipeName = ""; RecipeBarcodeInputText = ""; LotBarcodeInputText = ""; Application.Current.Dispatcher.Invoke(new Action(() => { InvokePropertyChanged("SelectedRecipeName"); InvokePropertyChanged("RecipeBarcodeInputText"); InvokePropertyChanged("LotBarcodeInputText"); })); } } //device, operation, parameters void DeviceOperation(object param) { object[] op = (object[])param; Debug.Assert(op.Length >= 2); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), op); } void Invoke(object param) { string[] p = param.ToString().Split(','); if (p.Length == 1) { if (p[0] == "Pump") { DoPump(); return; } if (p[0] == "GasFlow") { DoGasFlow(); return; } if (p[0] == "RfPower") { DoRfPower(); return; } if (p[0] == "CyclePurge") { DoCyclePurge(); return; } if (p[0] == "Vent") { DoVent(); return; } if (p[0] == "ResetWaterFlowAlarm") { DoResetWaterFlowAlarm(); bSetWaterFlowAlarm = true; return; } if (p[0] == "SetWaterFlowAlarm") { DoSetWaterFlowAlarm(); bSetWaterFlowAlarm = false; return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(p[0]); } } private void DoGasFlow() { if (IsGasFlowing) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString()); return; } if (IsGasFlowingOkForProcess) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.StopGasFlow.ToString()); return; } if (Tv != null && SCLocal.PressureControlConfig.EnableThrottleValve && SCLocal.PressureControlConfig.IsIndependentControl) { PressureCtrlMode mode; if (ThrottleValveModeSetPoint == "Pressure") mode = PressureCtrlMode.TVPressureCtrl; else if (ThrottleValveModeSetPoint == "Position") mode = PressureCtrlMode.TVPositionCtrl; else { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_PressureControlMode0IsNotValidShouldSelectFirst, ThrottleValveModeSetPoint)); return; } double pressure = Convert.ToDouble(string.IsNullOrEmpty(ThrottleValvePressureSetPoint) ? "0.0" : ThrottleValvePressureSetPoint); double position = Convert.ToDouble(string.IsNullOrEmpty(ThrottleValvePositionSetPoint) ? "0.0" : ThrottleValvePositionSetPoint); if (mode == PressureCtrlMode.TVPressureCtrl) { if (string.IsNullOrEmpty(ThrottleValvePressureSetPoint) || pressure < 0 || pressure > 756000) { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_Pressure0IsNotValidShouldBeIn0And756000, ThrottleValvePressureSetPoint)); return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetMode.ToString(), mode.ToString() }); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetPressure.ToString(), pressure.ToString() }); } else if (mode == PressureCtrlMode.TVPositionCtrl) { if (string.IsNullOrEmpty(ThrottleValvePositionSetPoint) || position < 0 || position > 100) { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_Position0IsNotValidShouldBeIn0And100, ThrottleValvePositionSetPoint)); return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetMode.ToString(), mode.ToString() }); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.ThrottleValve.ToString(), AITThrottleValveOperation.SetPosition.ToString(), position.ToString() }); } } object[] mfc = new[] { (object)Convert.ToDouble(string.IsNullOrEmpty(Mfc1SetPoint) ? "0.0" : Mfc1SetPoint), Convert.ToDouble(string.IsNullOrEmpty(Mfc2SetPoint) ? "0.0" : Mfc2SetPoint), Convert.ToDouble(string.IsNullOrEmpty(Mfc3SetPoint) ? "0.0" : Mfc3SetPoint), Convert.ToDouble(string.IsNullOrEmpty(Mfc4SetPoint) ? "0.0" : Mfc4SetPoint), Convert.ToDouble(string.IsNullOrEmpty(Mfc5SetPoint) ? "0.0" : Mfc5SetPoint), Convert.ToDouble(string.IsNullOrEmpty(Vapor1SetPoint) ? "0.0" : Vapor1SetPoint), }; if (!Array.Exists(mfc, x => (double)x > 0)) { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoGasFlow_SetFlowValueBeforeFlowingGas)); return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.GasFlow.ToString(), mfc); } #region rf power private void DoRfPower() { if (IsRfPowering) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString()); return; } List errors = new List(); double power = Convert.ToDouble(RfPowerSetPoint); double frequency = Convert.ToDouble(RfFrequencySetPoint); double duty = Convert.ToDouble(RfDutySetPoint); double c1 = Convert.ToDouble(RfMatchPositionC1SetPoint); double c2 = Convert.ToDouble(RfMatchPositionC2SetPoint); //检查输入有效性 RfMode rfMode = RfMode.ContinuousWaveMode; if (RfModeSetPoint == "Continuous") rfMode = RfMode.ContinuousWaveMode; else if (RfModeSetPoint == "Pulsing") rfMode = RfMode.PulsingMode; else { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFControlMode0IsNotValidShouldSelectFirst, RfModeSetPoint)); } RfMatchModeProcess processMode = RfMatchModeProcess.PresetMode; if (RfMatchProcessModeSetPoint == "Preset") processMode = RfMatchModeProcess.PresetMode; else if (RfMatchProcessModeSetPoint == "Hold") processMode = RfMatchModeProcess.HoldMode; else { errors.Add(string.Format("RF match preset mode {0} is not valid", RfMatchProcessModeSetPoint)); } double rfTime = Double.TryParse(RfTimeSetPoint, out rfTime) ? rfTime : 0.0; if (string.IsNullOrEmpty(RfTimeSetPoint) || rfTime <= 0) { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFPowerOnTime0NotValid, RfTimeSetPoint)); } if (string.IsNullOrEmpty(RfPowerSetPoint) || power < 0 || power > Rf.ScalePower) { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_Power0IsNotValidShouldBeIn0And1, RfPowerSetPoint, Rf.ScalePower)); } if (rfMode == RfMode.PulsingMode) { if (string.IsNullOrEmpty(RfFrequencySetPoint) || frequency < 0 || frequency > 1000) { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_Frequency0IsNotValidShouldBeIn0And1000, RfFrequencySetPoint)); } if (string.IsNullOrEmpty(RfDutySetPoint) || duty < 0 || duty > 100) { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_Duty0IsNotValidShouldBeIn0And100, RfDutySetPoint)); } } if (SCLocal.RfConfig.EnableC1C2Position && (processMode == RfMatchModeProcess.HoldMode)) { if (string.IsNullOrEmpty(RfMatchPositionC1SetPoint) || c1 < 0 || c1 > 100) { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFMatchPositionC1Value0IsNotValueShouldBeIn0100, RfMatchPositionC1SetPoint)); } if (string.IsNullOrEmpty(RfMatchPositionC2SetPoint) || c2 < 0 || c2 > 100) { errors.Add(string.Format(Resources.OverviewViewModel_DoRfPower_RFMatchPositionC2Value0IsNotValueShouldBeIn0100, RfMatchPositionC2SetPoint)); } } if (errors.Count > 0) { MessageBox.Show(string.Join("\r\n", errors)); return; } //RF 操作 Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMode.ToString(), rfMode.ToString() }); if (rfMode == RfMode.ContinuousWaveMode) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetContinuousPower.ToString(), power.ToString() }); } else if (rfMode == RfMode.PulsingMode) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPulsingPower.ToString(), power.ToString(), frequency.ToString(), duty.ToString() }); } if (processMode == RfMatchModeProcess.PresetMode) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchProcessMode.ToString(), (int)RfMatchModeProcess.PresetMode }); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), c1.ToString() }); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), c2.ToString() }); } else { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchProcessMode.ToString(), (int)RfMatchModeProcess.HoldMode }); } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.RfPower.ToString(), rfTime); } #endregion rf power #region cycle purge private void DoCyclePurge() { if (IsCyclePurging) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString()); return; } if (IsRfPowering) { MessageBox.Show(Resources.OverviewViewModel_DoCyclePurge_RFOnCanNotPurge); return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Purge.ToString()); } #endregion cycle purge #region vent private void DoVent() { if (IsVenting) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString()); return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Vent.ToString()); } #endregion vent private void DoResetWaterFlowAlarm() { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.WaterFlowAlarm.ToString(), false); } private void DoSetWaterFlowAlarm() { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.WaterFlowAlarm.ToString(), true); } #region pump private void DoPump() { if (IsPumping) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Abort.ToString()); return; } if (IsPumpingOkForProcess) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.StopPump.ToString()); return; } // 底压设置 double basePressure = string.IsNullOrEmpty(BasePressureSetPoint) ? 0 : Convert.ToDouble(BasePressureSetPoint); if (basePressure <= 0.01 || basePressure >= 1000) { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoPump_BasePressure0IsNotValidShouldBeIn0And1000, basePressure)); return; } // 抽气时间设置 double pumpLimit = string.IsNullOrEmpty(PumpLimitSetPoint) ? 0 : Convert.ToDouble(PumpLimitSetPoint); if (pumpLimit <= 0.01 || pumpLimit >= 1200) { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoPump_PumpLimitPressure0IsNotValidShouldBeIn0And1000, pumpLimit)); return; } // if (BoostPump != null && SCLocal.PressureControlConfig.EnableBoosterPump && SCLocal.PressureControlConfig.IsIndependentControl) { double pressure = Convert.ToDouble(BoostPumpPressureSetPoint); if (string.IsNullOrEmpty(BoostPumpPressureSetPoint) || pressure < 0 || pressure > 1000) { MessageBox.Show(string.Format(Resources.OverviewViewModel_DoPump_Pressure0IsNotValidShouldBeIn0And1000, BoostPumpPressureSetPoint)); return; } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.BoostPump.ToString(), AITBoostPumpOperation.SetPressure.ToString(), pressure.ToString() }); } Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), "System_PumpBasePressure", basePressure); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), "System_PumpTimeLimit", pumpLimit); Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.Pump.ToString()); } #endregion pump #region recipe private void SelectRecipe(object param) { RecipeSelectDialog dialog = new RecipeSelectDialog(WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false)) { Owner = Application.Current.MainWindow }; var ret = dialog.ShowDialog(); if (ret.HasValue && ret.Value) { SelectedRecipeName = dialog.SelectedRecipe; RecipeBarcodeInputText = ""; InvokePropertyChanged("RecipeBarcodeInputText"); InvokePropertyChanged("SelectedRecipeName"); } } private void RunRecipe(object param) { //if (string.IsNullOrEmpty(SelectedRecipeName)) //{ // return; //} //LotBarcodeInputText = LotBarcodeInputText ?? ""; //WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText); if (IsAuto == true) { //WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText); //monitorEndTimer.Enabled=true; if (string.IsNullOrEmpty(SelectedRecipeName)) { return; } if (_fabAutoComm.CheckIn() == true) { monitorEndTimer.Enabled = true; WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText,SelectedOperation, string.IsNullOrEmpty(OperatorInputText)?"": OperatorInputText.TrimEnd('/')); } else { WPFMessageBox.ShowError("远程CheckIn失败"); } //if (info != null) //{ // if (info.Success == true) // { // checkInInformation = info; // monitorEndTimer.Enabled = true; // WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText); // } // else // { // MessageBox.Show("远程CheckOut失败"); // } //} //else //{ // MessageBox.Show("远程CheckIn失败"); // return; //} } else { WcfClient.Instance.InvokeService_DoOperation(TritonOperation.RunRecipe.ToString(), SelectedRecipeName, LotBarcodeInputText); } } private void SkipRecipe(object param) { if (MessageBox.Show(Resources.OverviewViewModel_SkipRecipe_SkipToNextStep, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { WcfClient.Instance.InvokeService_DoOperation(TritonOperation.SkipCurrentStep.ToString()); } } private void AbortRecipe(object param) { if (MessageBox.Show(Resources.OverviewViewModel_AbortRecipe_DoYouWantToStopCurrentRecipeRunning, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes) WcfClient.Instance.InvokeService_DoOperation(TritonOperation.AbortRecipe.ToString()); } #endregion recipe #region barcode private void RecipeBarcodeInputChanged(object param) { string barcode = param as string; if (string.IsNullOrEmpty(barcode)) { SelectedRecipeName = ""; return; } SelectedRecipeName = WcfClient.Instance.Recipe.GetRecipeByBarcode(ModuleName.System, barcode); InvokePropertyChanged("SelectedRecipeName"); } private void LotBarcodeInputChanged(object param) { string barcode = param as string; //if (string.IsNullOrEmpty(barcode)) //{ // SelectedRecipeName = ""; // //return; //} //if (string.IsNullOrEmpty(LotBarcodeInputText)) // return ""; // var value = LotBarcodeInputText.Split('/'); // if (value.Length > 3) // return value[3]; // return ""; LotBarcodeInputText = barcode; //InvokePropertyChanged("Barcode1"); //InvokePropertyChanged("Barcode2"); //InvokePropertyChanged("Barcode3"); //InvokePropertyChanged("Barcode4"); //InvokePropertyChanged("Barcode5"); //InvokePropertyChanged("Barcode6"); if (barcode.Length < 11) { return; } barcodes = barcode.Split('/'); if (barcodes.Length < 2) { return; } Barcodes.Clear(); for (int i = barcodes.Length - 1; i >= 0; i--) { if (barcodes[i] != "") { Barcodes.Add(barcodes[i]); } } InvokePropertyChanged("Barcodes"); //if (Barcodes.GroupBy(j => j).Where(g => g.Count() > 0).Count() != Barcodes.Count) //{ // WPFMessageBox.ShowError("重复扫码,请确认并重新扫码"); // Barcodes.Clear(); // InvokePropertyChanged("Barcodes"); // LotBarcodeInputText = ""; //} } private void OperatorInputChanged(object param) { string currentOperator = param as string; OperatorInputText = currentOperator; if (currentOperator.Contains('/')) { keybd_event((byte)(System.Windows.Forms.Keys.Tab), 0, 0, 0); //FocusManager.SetFocusedElement(_hzOverviewView, _hzOverviewView.BarcodeTextBox);//UserName文本框获取光标 } } private void GetRecipeByMES(object obj) { try { if (IsAuto == true) { var lotList = new List(Barcodes); if (OperatorInputText == "") { return; } if (LotBarcodeInputText == "") { return; } if (!string.IsNullOrEmpty(OperatorInputText)) { if (OperatorInputText.Substring(OperatorInputText.Length - 1, 1) == "/") { userID = OperatorInputText.Substring(0, OperatorInputText.Length - 1); } else { userID = OperatorInputText; } } switch (WcfClient.Instance.Query.GetConfig(SCName.System_Company)) { case 0: //_fabAutoComm = new JCFabAuto(); var recipeName = _fabAutoComm.GetRecipeByLot(lotList); if (!string.IsNullOrEmpty(recipeName)) AutoGetRecipe(recipeName); break; case 1: ResponseResult receipeRes = _fabAutoComm.GetRecipeByMultipleLot(lotList, WcfClient.Instance.Query.GetConfig(SCName.System_YZQZMachineNumber).ToString(), WcfClient.Instance.Query.GetConfig(SCName.System_YZQZMachineType).ToString(), WcfClient.Instance.Query.GetConfig(SCName.System_YZQZWebapi).ToString()); AutoGetRecipeYZQZ(receipeRes); break; } //var recipeName = _fabAutoComm.GetRecipeByLot(lotList); //AutoGetRecipe(recipeName); } else { WPFMessageBox.ShowInformation("当前状态为手动过站"); } } catch (Exception ex) { WPFMessageBox.ShowInformation(ex.Message); } } private void AutoGetRecipe(string recipeName) { var xmlReipes = WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false); var recipesNames = GetRecipes(xmlReipes); if (recipesNames.Count == 0) { //MessageBox.Show("请先创建Recipe"); WPFMessageBox.ShowError("请先创建Recipe"); return; } if (!recipesNames.Contains(recipeName)) { WPFMessageBox.ShowError(recipeName + "不存在,请确认"); //MessageBox.Show(recipeName + "不存在,请确认"); return; } SelectedRecipeName = recipeName; RecipeBarcodeInputText = ""; InvokePropertyChanged("RecipeBarcodeInputText"); InvokePropertyChanged("SelectedRecipeName"); } private void AutoGetRecipeYZQZ(ResponseResult receipeRes) { if (receipeRes != null) { string recipeName; if (receipeRes.Status == (int)ResultStatus.Success) { LotsReceipeInfo = receipeRes.Data; if (LotsReceipeInfo != null && LotsReceipeInfo.Count > 0) { recipeName = LotsReceipeInfo[0].RecipeName; SelectedOperation = LotsReceipeInfo[0].Operation; } else return; var xmlReipes = WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false); var recipesNames = GetRecipes(xmlReipes); if (recipesNames.Count == 0) { //MessageBox.Show("请先创建Recipe"); WPFMessageBox.ShowError("请先创建Recipe"); return; } if (!recipesNames.Contains(recipeName)) { WPFMessageBox.ShowError(recipeName + "不存在,请确认"); //MessageBox.Show(recipeName + "不存在,请确认"); return; } SelectedRecipeName = recipeName; RecipeBarcodeInputText = ""; InvokePropertyChanged("RecipeBarcodeInputText"); InvokePropertyChanged("SelectedRecipeName"); } else { MessageBox.Show("接口获取失败,error message:" + receipeRes.Status + "|" + receipeRes.Message); } }else MessageBox.Show("接口获取异常!"); } private void AutoGetRecipeYZQZbySingleLot(KeyValuePair receipeRes) { string recipeName; if (receipeRes.Key == ResultStatus.Success) { if(LotsReceipeInfo!=null) LotsReceipeInfo.Clear(); else LotsReceipeInfo=new List(); if(receipeRes.Value!=null) LotsReceipeInfo.Add(receipeRes.Value); if (LotsReceipeInfo != null && LotsReceipeInfo.Count > 0) { recipeName = LotsReceipeInfo[0].RecipeName; } else return; var xmlReipes = WcfClient.Instance.Recipe.GetXmlRecipeList(ModuleName.System, false); var recipesNames = GetRecipes(xmlReipes); if (recipesNames.Count == 0) { //MessageBox.Show("请先创建Recipe"); WPFMessageBox.ShowError("请先创建Recipe"); return; } if (!recipesNames.Contains(recipeName)) { WPFMessageBox.ShowError(recipeName + "不存在,请确认"); //MessageBox.Show(recipeName + "不存在,请确认"); return; } } else { MessageBox.Show("接口获取失败,error code:" + (int)receipeRes.Key); } } /// /// 读取xml里面所有的recipe名 /// /// public static List GetRecipes(string xml) { var list = new List(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNode root = doc.FirstChild; XmlNodeList nodeList = root.ChildNodes; foreach (XmlNode node in nodeList) { list.Add(node.Attributes[0].InnerText); } return list; } #endregion barcode } }