WaferOffsetViewModel.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using Aitex.Core.UI.View.Common;
  2. using MECF.Framework.Common.ControlDataContext;
  3. using MECF.Framework.Common.DataCenter;
  4. using MECF.Framework.Common.Equipment;
  5. using Prism.Commands;
  6. using Prism.Mvvm;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using Venus_MainPages.Views;
  14. namespace Venus_MainPages.ViewModels
  15. {
  16. public class WaferOffsetViewModel : BindableBase
  17. {
  18. #region 私有变量
  19. private DateTime m_fromdateTime;//开始时间
  20. private DateTime m_todateTime;//结束时间
  21. private bool m_PMAIsInstalled;//模块安装用于show
  22. private bool m_PMBIsInstalled;//模块安装用于show
  23. private bool m_PMCIsInstalled;//模块安装用于show
  24. private bool m_PMDIsInstalled;//模块安装用于show
  25. private bool m_LLAIsInstalled;//模块安装用于show
  26. private bool m_LLBIsInstalled;//模块安装用于show
  27. private List<AwcModule> m_AwcModulesList;
  28. private WaferOffsetView m_waferoffset;
  29. private DelegateCommand<object> _LoadCommandPD;
  30. #endregion
  31. #region 公开变量
  32. public bool PMAIsInstalled
  33. {
  34. get { return m_PMAIsInstalled; }
  35. set { SetProperty(ref m_PMAIsInstalled, value); }
  36. }
  37. public bool PMBIsInstalled
  38. {
  39. get { return m_PMBIsInstalled; }
  40. set { SetProperty(ref m_PMBIsInstalled, value); }
  41. }
  42. public bool PMCIsInstalled
  43. {
  44. get { return m_PMCIsInstalled; }
  45. set { SetProperty(ref m_PMCIsInstalled, value); }
  46. }
  47. public bool PMDIsInstalled
  48. {
  49. get { return m_PMDIsInstalled; }
  50. set { SetProperty(ref m_PMDIsInstalled, value); }
  51. }
  52. public bool LLAIsInstalled
  53. {
  54. get { return m_LLAIsInstalled; }
  55. set { SetProperty(ref m_LLAIsInstalled, value); }
  56. }
  57. public bool LLBIsInstalled
  58. {
  59. get { return m_LLBIsInstalled; }
  60. set { SetProperty(ref m_LLBIsInstalled, value); }
  61. }
  62. public DateTime FromDateTime
  63. {
  64. get => m_fromdateTime;
  65. set
  66. {
  67. SetProperty(ref m_fromdateTime, value);
  68. }
  69. }
  70. public DateTime ToDateTime
  71. {
  72. get => m_todateTime;
  73. set
  74. {
  75. SetProperty(ref m_todateTime, value);
  76. }
  77. }
  78. public List<AwcModule> AwcModulesList
  79. {
  80. get { return m_AwcModulesList; }
  81. set { SetProperty(ref m_AwcModulesList, value); }
  82. }
  83. public DelegateCommand<object> LoadCommandPD =>
  84. _LoadCommandPD ?? (_LoadCommandPD = new DelegateCommand<object>(OnLoadPd));
  85. #endregion
  86. #region 私有方法
  87. private void OnLoadPd(object obj)
  88. {
  89. m_waferoffset = (WaferOffsetView)obj;
  90. m_waferoffset.TimeFrom.ValueChanged += TimeFrom_ValueChanged;
  91. m_waferoffset.TimeTo.ValueChanged += TimeFrom_ValueChanged;
  92. m_waferoffset.TimeFrom.Value = DateTime.Today;
  93. m_waferoffset.TimeTo.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59, 999);
  94. }
  95. private void TimeFrom_ValueChanged(object sender, EventArgs e)
  96. {
  97. if (AwcModulesList.Count > 0)
  98. {
  99. for (int i = 0; i < AwcModulesList.Count; i++)
  100. {
  101. AwcModulesList[i].From_date = m_waferoffset.TimeFrom.Value;
  102. AwcModulesList[i].End_date = m_waferoffset.TimeTo.Value;
  103. }
  104. }
  105. }
  106. #endregion
  107. //public ObservableCollection<>
  108. public WaferOffsetViewModel()
  109. {
  110. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  111. AwcModulesList = new List<AwcModule>();
  112. if (allModules.Contains("PMA"))
  113. AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMA.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List<OffsetItem>() });
  114. if (allModules.Contains("PMB"))
  115. AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMB.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List<OffsetItem>() });
  116. if (allModules.Contains("PMC"))
  117. AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMC.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List<OffsetItem>() });
  118. if (allModules.Contains("PMD"))
  119. AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.PMD.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List<OffsetItem>() });
  120. if (allModules.Contains("LLA"))
  121. AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.LLA.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List<OffsetItem>() });
  122. if (allModules.Contains("LLB"))
  123. AwcModulesList.Add(new AwcModule() { Module_Name = ModuleName.LLB.ToString(), From_date = FromDateTime, End_date = ToDateTime, OffsetItems = new List<OffsetItem>() });
  124. }
  125. }
  126. //用于散点展示的数据结构
  127. public class AwcModule : INotifyPropertyChanged
  128. {
  129. public event PropertyChangedEventHandler PropertyChanged;
  130. public void InvokePropertyChanged(string propertyName)
  131. {
  132. if (PropertyChanged != null)
  133. {
  134. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  135. }
  136. }
  137. private string _modulename;
  138. private DelegateCommand _GetDataCommand;
  139. private DelegateCommand _RemoveDataCommand;
  140. private List<OffsetItem> _OffsetItems;
  141. private DateTime _From_date;
  142. private DateTime _End_date;
  143. private List<(double x, double y, int arm, string info)> _PositionInfo;
  144. public string Module_Name { get => _modulename; set { _modulename = value; InvokePropertyChanged("Module_Name"); } }
  145. public DateTime From_date { get => _From_date; set { _From_date = value; InvokePropertyChanged("From_date"); } }
  146. public DateTime End_date { get => _End_date; set { _End_date = value; InvokePropertyChanged("End_date"); } }
  147. public List<OffsetItem> OffsetItems { get => _OffsetItems; set { _OffsetItems = value; InvokePropertyChanged("OffsetItems"); } }
  148. public List<(double x, double y, int arm, string info)> PositionInfo
  149. {
  150. get => _PositionInfo;
  151. set
  152. {
  153. _PositionInfo = value;
  154. InvokePropertyChanged("PositionInfo");
  155. }
  156. }
  157. public DelegateCommand GetDataCommand =>
  158. _GetDataCommand ?? (_GetDataCommand = new DelegateCommand(getdata));
  159. public DelegateCommand RemoveDataCommand =>
  160. _RemoveDataCommand ?? (_RemoveDataCommand = new DelegateCommand(() => PositionInfo = new List<(double x, double y, int arm, string info)>()));
  161. private DelegateCommand _ShowCommand;
  162. public DelegateCommand ShowCommand =>
  163. _ShowCommand ?? (_ShowCommand = new DelegateCommand(OnShow));
  164. private void getdata()
  165. {
  166. OffsetItems = QueryDataClient.Instance.Service.QueryOffsetDataByTime(Module_Name, From_date, End_date);
  167. List<(double x, double y, int arm, string info)> posInfo = new List<(double x, double y, int arm, string info)>();
  168. foreach (OffsetItem item in OffsetItems)
  169. {
  170. int armPt;
  171. if (item.ArmPosition == "Blade1")
  172. armPt = 1;
  173. else
  174. armPt = 0;
  175. string content = string.Format(
  176. $"OriginModule:{item.OriginModule}\r\n" +
  177. $"OriginSlot:{item.OriginSlot}\r\n" +
  178. $"SourceModule:{item.SourceModule}\r\n" +
  179. $"SourceSlot:{item.SourceSlot}\r\n" +
  180. $"DestinationModule:{item.DestinationModule}\r\n" +
  181. $"DestinationSlot:{item.DestinationSlot}\r\n" +
  182. $"ArmPosition:{item.ArmPosition}\r\n" +
  183. $"ArmPan:{item.ArmPan}\r\n" +
  184. $"OffsetX:{item.OffsetX}\r\n" +
  185. $"OffsetY:{item.OffsetY}\r\n" +
  186. $"OffsetD:{item.OffsetD}\r\n" +
  187. $"StartTime:{item.StartTime}\r\n" +
  188. $"EndTime:{item.EndTime}\r\n"
  189. );
  190. posInfo.Add((item.OffsetX, item.OffsetY, armPt, content));
  191. }
  192. PositionInfo = posInfo;
  193. }
  194. private void OnShow()
  195. {
  196. }
  197. }
  198. }