| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 | 
							- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Windows;
 
- using Aitex.Core.RT.IOCore;
 
- using MECF.Framework.Common.DataCenter;
 
- using MECF.Framework.Common.IOCore;
 
- using MECF.Framework.Common.OperationCenter;
 
- using MECF.Framework.UI.Client.ClientBase;
 
- using OpenSEMI.ClientBase.IO;
 
- namespace FurnaceUI.Models.Maintenances.IO1
 
- {
 
-     public class IO1ViewModel : UiViewModelBase, ISupportMultipleSystem
 
-     {
 
-         public bool IsPermission { get => this.Permission == 3; }
 
-         public string SystemName { get; set; }
 
-         public Visibility DIVisibility
 
-         {
 
-             get { return DIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
 
-         }
 
-         public Visibility DOVisibility
 
-         {
 
-             get { return DOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
 
-         }
 
-         public Visibility AIVisibility
 
-         {
 
-             get { return AIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
 
-         }
 
-         public Visibility AOVisibility
 
-         {
 
-             get { return AOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
 
-         }
 
-         public int DIWidth
 
-         {
 
-             get { return (DIs.Count / 31 + 1) * 355; }
 
-         }
 
-         public int DOWidth
 
-         {
 
-             get { return (DOs.Count / 31 + 1) * 405; }
 
-         }
 
-         public int AIWidth
 
-         {
 
-             get { return (AIs.Count / 31 + 1) * 550; }
 
-         }
 
-         public int AOWidth
 
-         {
 
-             get { return (AOs.Count / 31 + 1) * 370; }
 
-         }
 
-         public ObservableCollection<IOItem<float>> AIs { get; private set; }
 
-         public ObservableCollection<AOItemFloat> AOs { get; private set; }
 
-         public ObservableCollection<IOItem<bool>> DIs { get; private set; }
 
-         public ObservableCollection<IOItem<bool>> DOs { get; private set; }
 
-         private string _diKey;
 
-         private string _doKey;
 
-         private string _aiKey;
 
-         private string _aoKey;
 
-         private List<string> _fitlerIOKey;
 
-         protected override void OnInitialize()
 
-         {
 
-             base.OnInitialize();
 
-             LoadFitlerIOData();
 
-             _diKey = $"{SystemName}.DIItemList";
 
-             _doKey = $"{SystemName}.DOItemList";
 
-             _aiKey = $"{SystemName}.AIItemList";
 
-             _aoKey = $"{SystemName}.AOItemList";
 
-             this.AIs = InitIOData<float>(IOType.AI, _aiKey);
 
-             this.AOs = InitIOData(IOType.AO, _aoKey);
 
-             this.DIs = InitIOData<bool>(IOType.DI, _diKey);
 
-             this.DOs = InitIOData<bool>(IOType.DO, _doKey);
 
-             _diKey = $"{SystemName}.DIList";
 
-             _doKey = $"{SystemName}.DOList";
 
-             _aiKey = $"{SystemName}.AIList";
 
-             _aoKey = $"{SystemName}.AOList";
 
-             Subscribe(_aiKey);
 
-             Subscribe(_aoKey);
 
-             Subscribe(_diKey);
 
-             Subscribe(_doKey);
 
-         }
 
-         protected override void OnActivate()
 
-         {
 
-             base.OnActivate();
 
-         }
 
-         protected override void OnDeactivate(bool close)
 
-         {
 
-             base.OnDeactivate(close);
 
-         }
 
-         protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
 
-         {
 
-             base.InvokeAfterUpdateProperty(data);
 
-             if (data.ContainsKey(_aiKey)&&data[_aiKey] != null)
 
-             {
 
-                 List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aiKey];
 
-                 Dictionary<string, float> dicValues = new Dictionary<string, float>();
 
-                 for (int i = 0; i < lstData.Count; i++)
 
-                 {
 
-                     dicValues[lstData[i].Name] = lstData[i].FloatValue;
 
-                 }
 
-                 foreach (IOItem<float> item in AIs)
 
-                 {
 
-                     if (dicValues.ContainsKey(item.Name))
 
-                         item.Value = dicValues[item.Name];
 
-                 }
 
-             }
 
-             if (data.ContainsKey(_aoKey) && data[_aoKey] != null)
 
-             {
 
-                 List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aoKey];
 
-                 Dictionary<string, float> dicValues = new Dictionary<string, float>();
 
-                 for (int i = 0; i < lstData.Count; i++)
 
-                 {
 
-                     dicValues[lstData[i].Name] = lstData[i].FloatValue;
 
-                 }
 
-                 foreach (IOItem<float> item in AOs)
 
-                 {
 
-                     if (dicValues.ContainsKey(item.Name))
 
-                         item.Value = dicValues[item.Name];
 
-                 }
 
-             }
 
-             if (data.ContainsKey(_diKey) && data[_diKey] != null)
 
-             {
 
-                 List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_diKey];
 
-                 Dictionary<string, bool> dicValues = new Dictionary<string, bool>();
 
-                 for (int i = 0; i < lstData.Count; i++)
 
-                 {
 
-                     dicValues[lstData[i].Name] = lstData[i].BoolValue;
 
-                 }
 
-                 foreach (IOItem<bool> item in DIs)
 
-                 {
 
-                     if (dicValues.ContainsKey(item.Name))
 
-                         item.Value = dicValues[item.Name];
 
-                 }
 
-             }
 
-             if (data.ContainsKey(_doKey) && data[_doKey] != null)
 
-             {
 
-                 List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_doKey];
 
-                 Dictionary<string, bool> dicValues = new Dictionary<string, bool>();
 
-                 for (int i = 0; i < lstData.Count; i++)
 
-                 {
 
-                     dicValues[lstData[i].Name] = lstData[i].BoolValue;
 
-                 }
 
-                 foreach (IOItem<bool> item in DOs)
 
-                 {
 
-                     if (dicValues.ContainsKey(item.Name))
 
-                         item.Value = dicValues[item.Name];
 
-                 }
 
-             }
 
-         }
 
-         public void SetDO(IOItem<bool> doItem)
 
-         {
 
-             if (MessageBox.Show(
 
-                 $"Please be attention, direct control DO is generally forbidden, Are you sure you want to do the operation?\r\n {doItem.Name} = {!doItem.Value}",
 
-                 "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
 
-                 return;
 
-             InvokeClient.Instance.Service.DoOperation("System.SetDoValue", doItem.Name, !doItem.Value);
 
-         }
 
-         public void SetAO(AOItemFloat aoItem)
 
-         {
 
-             if (MessageBox.Show(
 
-                 $"Please be attention, direct control AO is generally forbidden, Are you sure you want to do the operation?\r\n {aoItem.Name} = {aoItem.NewValueFloat}",
 
-                 "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
 
-                 return;
 
-             InvokeClient.Instance.Service.DoOperation("System.SetAoValueFloat", aoItem.Name, aoItem.NewValueFloat);
 
-             aoItem.TextSavedFloat = true;
 
-         }
 
-  
 
-         public ObservableCollection<IOItem<T>> InitIOData<T>(IOType type, string dataName)
 
-         {
 
-             //get the whole informations
 
-             ObservableCollection<IOItem<T>> da = new ObservableCollection<IOItem<T>>();
 
-             if (type == IOType.DI)
 
-             {
 
-                 var diList = QueryDataClient.Instance.Service.GetData(dataName);
 
-                 if (diList != null)
 
-                 {
 
-                     List<NotifiableIoItem> di = (List<NotifiableIoItem>)diList;
 
-                     for (int i = 0; i < di.Count; i++)
 
-                     {
 
-                         bool value = true;
 
-                         if (value is T && !_fitlerIOKey.Contains(di[i].Name))
 
-                         {
 
-                             da.Add(new IOItem<T>()
 
-                             {
 
-                                 Index = da.Count,
 
-                                 Name = di[i].Name,
 
-                                 //DisplayName = di[i].Name.Substring(di[i].Name.IndexOf('.') + 1),
 
-                                 DisplayName = di[i].Description,
 
-                                 Value = (T)(object)di[i].BoolValue,
 
-                                 Address = di[i].Address
 
-                             }) ; 
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             if (type == IOType.DO)
 
-             {
 
-                 var diList = QueryDataClient.Instance.Service.GetData(dataName);
 
-                 if (diList != null)
 
-                 {
 
-                     List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
 
-                     for (int i = 0; i < item.Count; i++)
 
-                     {
 
-                         bool value = true;
 
-                         if (value is T)
 
-                         {
 
-                             da.Add(new IOItem<T>()
 
-                             {
 
-                                 Index = da.Count,
 
-                                 Name = item[i].Name ,
 
-                                 //DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
 
-                                 DisplayName = item[i].Description,
 
-                                 Value = (T)(object)item[i].BoolValue,
 
-                                 Address = item[i].Address
 
-                             });
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             if (type == IOType.AI)
 
-             {
 
-                 var diList = QueryDataClient.Instance.Service.GetData(dataName);
 
-                 if (diList != null)
 
-                 {
 
-                     List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
 
-                     for (int i = 0; i < item.Count; i++)
 
-                     {
 
-                         da.Add(new IOItem<T>()
 
-                         {
 
-                             Index = da.Count,
 
-                             Name = item[i].Name ,
 
-                             //DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
 
-                             DisplayName = item[i].Description,
 
-                             Value = (T)(object)item[i].FloatValue,
 
-                             Address = item[i].Address
 
-                         });
 
-                     }
 
-                 }
 
-             }
 
-             return da;
 
-         }
 
-         public ObservableCollection<AOItemFloat> InitIOData(IOType type, string dataName)
 
-         {
 
-             //get the whole informations
 
-             ObservableCollection<AOItemFloat> da = new ObservableCollection<AOItemFloat>();
 
-             if (type == IOType.AO)
 
-             {
 
-                 var diList = QueryDataClient.Instance.Service.GetData(dataName);
 
-                 if (diList != null)
 
-                 {
 
-                     List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
 
-                     for (int i = 0; i < item.Count; i++)
 
-                     {
 
-                         {
 
-                             da.Add(new AOItemFloat()
 
-                             {
 
-                                 Index = da.Count,
 
-                                 Name = item[i].Name ,
 
-                                 //DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
 
-                                 DisplayName = item[i].Description,
 
-                                 Value = item[i].FloatValue,
 
-                                 Address = item[i].Address
 
-                             });
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             return da;
 
-         }
 
-         private void LoadFitlerIOData()
 
-         {
 
-             _fitlerIOKey = new List<string>();
 
-             //{
 
-             //    "EFEM.DI_LightCurtainsStateEFEM",
 
-             //    "EFEM.DI_CDAPressureSensorState",
 
-             //    "EFEM.DI_EMOState",
 
-             //    "EFEM.DI_SafeDoorState",
 
-             //    "EFEM.DI_SystemPowerONState",
 
-             //    "EFEM.DI_CSFfuOK",
 
-             //    "EFEM.DI_IOPortFfuOK",
 
-             //    "EFEM.DI_IOBtmExhFanOK",
 
-             //    "EFEM.DI_FncExhFanOK",
 
-             //    "EFEM.DI_Station1PresenceSensor",
 
-             //    "EFEM.DI_Station2PresenceSensor",
 
-             //    "EFEM.DI_Station3PresenceSensor",
 
-             //    "EFEM.DI_Station4PresenceSensor",
 
-             //    "EFEM.DI_Station5PresenceSensor",
 
-             //    "EFEM.DI_Station6PresenceSensor",
 
-             //    "EFEM.DI_Station7PresenceSensor",
 
-             //    "EFEM.DI_Station8PresenceSensor",
 
-             //    "EFEM.DI_Station9PresenceSensor",
 
-             //    "EFEM.DI_Station10PresenceSensor",
 
-             //    "EFEM.DI_Station11PresenceSensor",
 
-             //    "EFEM.DI_Station12PresenceSensor",
 
-             //    "EFEM.DI_Station13PresenceSensor",
 
-             //    "EFEM.DI_Station14PresenceSensor",
 
-             //    "EFEM.DI_Station15PresenceSensor",
 
-             //    "EFEM.DI_Station16PresenceSensor",
 
-             //    "EFEM.DI_Station17PresenceSensor",
 
-             //    "EFEM.DI_Station18PresenceSensor",
 
-             //    "EFEM.DI_Station19PresenceSensor",
 
-             //    "EFEM.DI_Station20PresenceSensor",
 
-             //    "EFEM.DI_Station21PresenceSensor",
 
-             //    "EFEM.DI_CassetteProtrusionSensor1",
 
-             //    "EFEM.DI_CassetteProtrusionSensor2",
 
-             //    "EFEM.DI_CassetteProtrusionSensor3",
 
-             //    "EFEM.DI_CassetteProtrusionSensor4",
 
-             //    "EFEM.DI_CassetteProtrusionSensor5",
 
-             //    "EFEM.DI_CassetteProtrusionSensor6",
 
-             //    "EFEM.DI_CassetteProtrusionSensor7",
 
-             //    "EFEM.DI_CassetteProtrusionSensor8",
 
-             //    "EFEM.DI_CassetteProtrusionSensor9",
 
-             //    "EFEM.DI_Stage1LockPosition",
 
-             //    "EFEM.DI_Stage1UnlockPosition",
 
-             //    "EFEM.DI_Stage2LockPosition",
 
-             //    "EFEM.DI_Stage2UnlockPosition",
 
-             //    "EFEM.DI_Stage1CASSPresenceSensor",
 
-             //    "EFEM.DI_Stage2CASSPresenceSensor",
 
-             //    "EFEM.DI_R3NotExtendToStage1",
 
-             //    "EFEM.DI_R3NotExtendToStage2",
 
-             //    "EFEM.DI_R5NotExtendToStage1",
 
-             //    "EFEM.DI_R5NotExtendToStage2",
 
-             //    "MF.DI_ASOpenPosition",
 
-             //    "MF.DI_ASClosePosition",
 
-             //    "MF.DI_ASUpPosition",
 
-             //    "MF.DI_ASDownPosition",
 
-             //    "MF.DI_ASOpenStatus",
 
-             //    "MF.DI_ASTiltStatus",
 
-             //    "MF.DI_SideDoorFfuOK",
 
-             //    "MF.DI_ZAxisUpLimit",
 
-             //    "MF.DI_ZAxisDownLimit",
 
-             //    "MF.DI_BEHumanInterlockSensor",
 
-             //    "MF.DI_CapCloseSensor",
 
-             //    "MF.DI_Zone1Sensor",
 
-             //    "MF.DI_Zone2Sensor",
 
-             //    "MF.DI_R5ArmNotExtendToBE",
 
-             //    "MF.DI_CapILOK",
 
-             //    "MF.DI_PPPosition",
 
-             //    "MF.DI_HomePosition",
 
-             //    "PM1.DI_A_SClosePosition",
 
-             //    "SMIF.DI_LightCurtainsStateSMIF",
 
-             //    "SMIF.DI_Smif1PodLockPosition",
 
-             //    "SMIF.DI_Smif1PodUnlockPositionSersor",
 
-             //    "SMIF.DI_Smif1PodOpenPositionSensor",
 
-             //    "SMIF.DI_Smif1PodClosePositionSensor",
 
-             //    "SMIF.DI_Smif1PodPresenceSensor",
 
-             //    "SMIF.DI_Smif1ZAxisUnloadPositionSensor",
 
-             //    "SMIF.DI_Smif1ZAxisLoadPositionSensor",
 
-             //    "SMIF.DI_Smif1ZAxisPosition1Sensor",
 
-             //    "SMIF.DI_Smif1ZAxisPosition2Sensor",
 
-             //    "SMIF.DI_Smif1RotateAxisCheckSensor1",
 
-             //    "SMIF.DI_Smif1RotateAxisCheckSensor2",
 
-             //    "SMIF.DI_Smif1SlideAxisExtendSensor",
 
-             //    "SMIF.DI_Smif1SlideAxisRetractSensor",
 
-             //    "SMIF.DI_Smif1ProtrudedWaferSensor",
 
-             //    "SMIF.DI_Smif1MappingSensor",
 
-             //    "SMIF.DI_Smif2PodLockPosition",
 
-             //    "SMIF.DI_Smif2PodUnlockPositionSersor",
 
-             //    "SMIF.DI_Smif2PodOpenPositionSensor",
 
-             //    "SMIF.DI_Smif2PodClosePositionSensor",
 
-             //    "SMIF.DI_Smif2PodPresenceSensor",
 
-             //    "SMIF.DI_Smif2ZAxisUnloadPositionSensor",
 
-             //    "SMIF.DI_Smif2ZAxisLoadPositionSensor",
 
-             //    "SMIF.DI_Smif2ZAxisPosition1Sensor",
 
-             //    "SMIF.DI_Smif2ZAxisPosition2Sensor",
 
-             //    "SMIF.DI_Smif2RotateAxisCheckSensor1",
 
-             //    "SMIF.DI_Smif2RotateAxisCheckSensor2",
 
-             //    "SMIF.DI_Smif2SlideAxisExtendSensor",
 
-             //    "SMIF.DI_Smif2SlideAxisRetractSensor",
 
-             //    "SMIF.DI_Smif2ProtrudedWaferSensor",
 
-             //    "SMIF.DI_Smif2MappingSensor",
 
-             //    "SMIF.DI_SmifFfuOK",
 
-             //    "SMIF.DI_R3ArmNotExtendToSmif1",
 
-             //    "SMIF.DI_R3ArmNotExtendToSmif2",
 
-             //};
 
-         }
 
-     }
 
- }
 
 
  |