using Aitex.Core.UI.View.Common; using MECF.Framework.Common.ControlDataContext; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using Prism.Commands; using Prism.Mvvm; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using Venus_MainPages.Views; namespace Venus_MainPages.ViewModels { public class WaferOffsetViewModel : BindableBase { #region 私有变量 private DateTime m_fromdateTime;//开始时间 private DateTime m_todateTime;//结束时间 private bool m_PMAIsInstalled;//模块安装用于show private bool m_PMBIsInstalled;//模块安装用于show private bool m_PMCIsInstalled;//模块安装用于show private bool m_PMDIsInstalled;//模块安装用于show private bool m_LLAIsInstalled;//模块安装用于show private bool m_LLBIsInstalled;//模块安装用于show private List m_AwcModulesList; private WaferOffsetView m_waferoffset; private DelegateCommand _LoadCommandPD; #endregion #region 公开变量 public bool PMAIsInstalled { get { return m_PMAIsInstalled; } set { SetProperty(ref m_PMAIsInstalled, value); } } public bool PMBIsInstalled { get { return m_PMBIsInstalled; } set { SetProperty(ref m_PMBIsInstalled, value); } } public bool PMCIsInstalled { get { return m_PMCIsInstalled; } set { SetProperty(ref m_PMCIsInstalled, value); } } public bool PMDIsInstalled { get { return m_PMDIsInstalled; } set { SetProperty(ref m_PMDIsInstalled, value); } } public bool LLAIsInstalled { get { return m_LLAIsInstalled; } set { SetProperty(ref m_LLAIsInstalled, value); } } public bool LLBIsInstalled { get { return m_LLBIsInstalled; } set { SetProperty(ref m_LLBIsInstalled, value); } } public DateTime FromDateTime { get => m_fromdateTime; set { SetProperty(ref m_fromdateTime, value); } } public DateTime ToDateTime { get => m_todateTime; set { SetProperty(ref m_todateTime, value); } } public List AwcModulesList { get { return m_AwcModulesList; } set { SetProperty(ref m_AwcModulesList, value); } } public DelegateCommand LoadCommandPD => _LoadCommandPD ?? (_LoadCommandPD = new DelegateCommand(OnLoadPd)); #endregion #region 私有方法 private void OnLoadPd(object obj) { m_waferoffset = (WaferOffsetView)obj; m_waferoffset.TimeFrom.ValueChanged += TimeFrom_ValueChanged; m_waferoffset.TimeTo.ValueChanged += TimeFrom_ValueChanged; m_waferoffset.TimeFrom.Value = DateTime.Today; m_waferoffset.TimeTo.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59, 999); } private void TimeFrom_ValueChanged(object sender, EventArgs e) { if (AwcModulesList.Count > 0) { for (int i = 0; i < AwcModulesList.Count; i++) { AwcModulesList[i].From_date = m_waferoffset.TimeFrom.Value; AwcModulesList[i].End_date = m_waferoffset.TimeTo.Value; } } } #endregion //public ObservableCollection<> public WaferOffsetViewModel() { string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString(); AwcModulesList = new List(); if (allModules.Contains("PMA")) AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMA.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List() }); if (allModules.Contains("PMB")) AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMB.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List() }); if (allModules.Contains("PMC")) AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMC.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List() }); if (allModules.Contains("PMD")) AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMD.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List() }); if (allModules.Contains("LLA")) AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.LLA.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List() }); if (allModules.Contains("LLB")) AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.LLB.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List() }); } } //用于散点展示的数据结构 public class AwcModule : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void InvokePropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } private string _modulename; private DelegateCommand _GetDataCommand; private DelegateCommand _RemoveDataCommand; private List _OffsetItems; private DateTime _From_date; private DateTime _End_date; private List<(double x, double y, int arm, string info)> _PositionInfo; public string Module_Name { get => _modulename; set { _modulename = value; InvokePropertyChanged("Module_Name"); } } public DateTime From_date { get => _From_date; set { _From_date = value; InvokePropertyChanged("From_date"); } } public DateTime End_date { get => _End_date; set { _End_date = value; InvokePropertyChanged("End_date"); } } public List OffsetItems { get => _OffsetItems; set { _OffsetItems = value; InvokePropertyChanged("OffsetItems"); } } public List<(double x, double y, int arm, string info)> PositionInfo { get => _PositionInfo; set { _PositionInfo = value; InvokePropertyChanged("PositionInfo"); } } public DelegateCommand GetDataCommand => _GetDataCommand ?? (_GetDataCommand = new DelegateCommand(getdata)); public DelegateCommand RemoveDataCommand => _RemoveDataCommand ?? (_RemoveDataCommand = new DelegateCommand(() => PositionInfo = new List<(double x, double y, int arm, string info)>())); private DelegateCommand _ShowCommand; public DelegateCommand ShowCommand => _ShowCommand ?? (_ShowCommand = new DelegateCommand(OnShow)); private void getdata() { OffsetItems = QueryDataClient.Instance.Service.QueryOffsetDataByTime(Module_Name, From_date, End_date); List<(double x, double y, int arm, string info)> posInfo = new List<(double x, double y, int arm, string info)>(); foreach (OffsetItem item in OffsetItems) { int armPt; if (item.ArmPosition == "Blade1") armPt = 1; else armPt = 0; string content = string.Format( $"OriginModule:{item.OriginModule}\r\n" + $"OriginSlot:{item.OriginSlot}\r\n" + $"SourceModule:{item.SourceModule}\r\n" + $"SourceSlot:{item.SourceSlot}\r\n" + $"DestinationModule:{item.DestinationModule}\r\n" + $"DestinationSlot:{item.DestinationSlot}\r\n" + $"ArmPosition:{item.ArmPosition}\r\n" + $"ArmPan:{item.ArmPan}\r\n" + $"OffsetX:{item.OffsetX}\r\n" + $"OffsetY:{item.OffsetY}\r\n" + $"OffsetD:{item.OffsetD}\r\n" + $"StartTime:{item.StartTime}\r\n" + $"EndTime:{item.EndTime}\r\n" ); posInfo.Add((item.OffsetX, item.OffsetY, armPt, content)); } PositionInfo = posInfo; } private void OnShow() { } } }