using Caliburn.Micro; using Caliburn.Micro.Core; using Aitex.Core.Common.DeviceData; using Aitex.Core.UI.ControlDataContext; using Aitex.Core.Util; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using FurnaceUI.Models; using FurnaceUI.Views.Editors; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Threading.Tasks; using System.Reflection; using System; using Aitex.Core.RT.Log; using System.Linq; using System.Windows; using Aitex.Core.RT.SCCore; using MECF.Framework.Common.SubstrateTrackings; using OpenSEMI.ClientBase; using DocumentFormat.OpenXml.Office.Word; namespace FurnaceUI.Views.Maintenances { public class LPSensorViewModel : FurnaceModuleUIViewModelBase { public bool IsManagerPermission { get => this.Permission == 3; } [Subscription("Rt.Status")] public string RtStatus { get; set; } public bool IsEnableManualOperation => IsSystemStaus; public bool IsSystemStaus => (RtStatus != "AutoRunning"); #region stage sensors //[Subscription("System.SensorStation17Presence.DeviceData")] //public AITSensorData SensorStation17Presence { get; set; } //[Subscription("System.SensorStation18Presence.DeviceData")] //public AITSensorData SensorStation18Presence { get; set; } //[Subscription("System.SensorStation17APresence.DeviceData")] //public AITSensorData SensorStation17APresence { get; set; } //[Subscription("System.SensorStation18APresence.DeviceData")] //public AITSensorData SensorStation18APresence { get; set; } //[Subscription("System.Valve1EX.DeviceData")] //public AITSensorData Valve1EX { get; set; } //[Subscription("System.Valve1RE.DeviceData")] //public AITSensorData Valve1RE { get; set; } //[Subscription("System.Valve2EX.DeviceData")] //public AITSensorData Valve2EX { get; set; } //[Subscription("System.Valve2RE.DeviceData")] //public AITSensorData Valve2RE { get; set; } [Subscription("LP1.Status")] public string LP1State { get; set; } [Subscription("LP2.Status")] public string LP2State { get; set; } //[Subscription("LP2.LoadportState")] //public string LP2State { get; set; } //[Subscription("LP3.LoadportState")] //public string LP3State { get; set; } //[Subscription("LP4.LoadportState")] //public string LP4State { get; set; } //[Subscription("LP1.CarrierId")] //public string LP1CarrierId { get; set; } //[Subscription("LP2.CarrierId")] //public string LP2CarrierId { get; set; } //[Subscription("LP3.CarrierId")] //public string LP3CarrierId { get; set; } //[Subscription("LP4.CarrierId")] //public string LP4CarrierId { get; set; } [Subscription("LP1.AccessMode")] public string LP1AccessMode { get; set; } [Subscription("LP2.AccessMode")] public string LP2AccessMode { get; set; } [Subscription("LP1.DeviceStatus")] public string LP1DeviceStatus { get; set; } [Subscription("LP2.DeviceStatus")] public string LP2DeviceStatus { get; set; } [Subscription("LP1.Carrier")] public CarrierInfo LP1CarrierInfo { get; set; } [Subscription("LP2.Carrier")] public CarrierInfo LP2CarrierInfo { get; set; } #endregion private bool _lP2BorderVisibility = true; public bool LP2BorderVisibility { get => _lP2BorderVisibility; set { _lP2BorderVisibility = value; NotifyOfPropertyChange(nameof(LP2BorderVisibility)); } } private bool _lP1BorderVisibility = true; public bool LP1BorderVisibility { get => _lP1BorderVisibility; set { _lP1BorderVisibility = value; NotifyOfPropertyChange(nameof(LP1BorderVisibility)); } } // public ObservableCollection LPSensors { get; set; } = new ObservableCollection(); public LPSensorViewModel() { } protected override void InvokeAfterUpdateProperty(Dictionary data) { base.InvokeAfterUpdateProperty(data); } //protected override void InvokeBeforeUpdateProperty(Dictionary data) //{ // base.InvokeBeforeUpdateProperty(data); //} //public override void UpdateSubscribe(Dictionary data, object target, string module = null) //{ // Parallel.ForEach(target.GetType().GetProperties().Where(_hasSubscriptionAttribute), // property => // { // PropertyInfo pi = (PropertyInfo)property; // SubscriptionAttribute subscription = property.GetCustomAttributes(false).First(_isSubscriptionAttribute) as SubscriptionAttribute; // string key = subscription.ModuleKey; // key = module == null ? key : string.Format("{0}.{1}", module, key); // if (_subscribedKeys.Contains(key) && data.ContainsKey(key)) // { // try // { // var convertedValue = Convert.ChangeType(data[key], pi.PropertyType); // var originValue = Convert.ChangeType(pi.GetValue(target, null), pi.PropertyType); // if ((convertedValue as AITSensorData) != null && originValue != convertedValue) // { // pi.SetValue(target, convertedValue, null); // //if ((convertedValue as AITSensorData).DeviceName.ToLower().Contains(_para)) // //{ // Update(LPSensors, convertedValue as AITSensorData); // //} // } // } // catch (Exception ex) // { // LOG.Error("由RT返回的数据更新失败" + key, ex); // } // } // }); // base.UpdateSubscribe(data, target, module); //} //private void Update(ObservableCollection sensors, object obj) //{ // AITSensorData data = obj as AITSensorData; // if (data != null && sensors.Count > 0) // { // var item = sensors.SingleOrDefault(x => x.Name == data.DeviceName); // if (item != null) // { // item.Value = data.Value; // } // } //} public void DoLoadPortCmd(string deviceName, string cmd) { if (cmd == "SetAMHS" && deviceName == "LP1" && LP1CarrierInfo != null && !LP1CarrierInfo.IsEmpty) { DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present"); return; } if (cmd == "SetAMHS" && deviceName == "LP2" && LP2CarrierInfo != null && !LP2CarrierInfo.IsEmpty) { DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present"); return; } InvokeClient.Instance.Service.DoOperation($"{deviceName}.{cmd}"); } public void Home(object para) { InvokeClient.Instance.Service.DoOperation($"{para}.Home", ""); } public void SetClamp(object para) { InvokeClient.Instance.Service.DoOperation($"{para}.Unload", ""); } public void SetRelease(object para) { InvokeClient.Instance.Service.DoOperation($"{para}.Load", ""); } public void ReadCarrierId(string moduleID) { InvokeClient.Instance.Service.DoOperation($"{moduleID}.ReadCarrierId"); } public void ClosedCmd() { (GetView() as Window).Close(); } } }