DataLogViewModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.UI.ControlDataContext;
  9. using Aitex.Core.Utilities;
  10. using Aitex.Triton160.Common;
  11. namespace Aitex.Triton160.UI.ViewModel
  12. {
  13. class DataLogViewModel : UIViewModelBase
  14. {
  15. private string _culture = CultureSupported.English;
  16. public class DbSusceptorDetails
  17. {
  18. public string Time { get; set; }
  19. public string ItemType { get; set; }
  20. public string ItemData { get; set; }
  21. public string ItemDescription { get; set; }
  22. }
  23. public ProcessDataChartDataItem ProcessChartData
  24. {
  25. get;
  26. set;
  27. }
  28. public ObservableCollection<string> RecipeList
  29. {
  30. get; set;
  31. }
  32. public List<DataLogItem> DataLogList
  33. {
  34. get; set;
  35. }
  36. public List<HistoryDataItem> ProcessData { get; set; }
  37. public DataLogViewModel() : base("DataLogViewModel")
  38. {
  39. ProcessChartData = new ProcessDataChartDataItem(60000);
  40. Triton160UiSystem.Instance.CultureChanged += CultureChanged;
  41. SCLocal.SetKeys(new List<string>()
  42. {
  43. SCName.GasLineConfig_Gas1Enable,
  44. SCName.GasLineConfig_Gas1Name,
  45. SCName.GasLineConfig_Gas2Enable,
  46. SCName.GasLineConfig_Gas2Name,
  47. SCName.GasLineConfig_Gas3Enable,
  48. SCName.GasLineConfig_Gas3Name,
  49. SCName.GasLineConfig_Gas4Enable,
  50. SCName.GasLineConfig_Gas4Name,
  51. SCName.GasLineConfig_Gas5Enable,
  52. SCName.GasLineConfig_Gas5Name,
  53. SCName.RfConfig_EnablePulsingFunction,
  54. SCName.PressureControlConfig_EnableThrottleValve,
  55. SCName.PressureControlConfig_PumpEnableN2Pressure,
  56. SCName.PressureControlConfig_PumpEnableWaterFlow,
  57. });
  58. }
  59. private void CultureChanged(string s)
  60. {
  61. _culture = s;
  62. }
  63. public void UpdateRecipeList(DateTime from, DateTime to)
  64. {
  65. ObservableCollection<string> lst = new ObservableCollection<string>();
  66. List<string> result = Triton160UiSystem.Instance.WCF.Query.GetHistoryRecipeList(from, to);
  67. if (result != null)
  68. result.ForEach(lst.Add);
  69. RecipeList = lst;
  70. InvokePropertyChanged("RecipeList");
  71. }
  72. public void UpdateDataLogList(DateTime from, DateTime to, string recipe, string lot)
  73. {
  74. DataLogList = Triton160UiSystem.Instance.WCF.Query.GetHistoryDataLogList(from, to, recipe, lot);
  75. InvokePropertyChanged("DataLogList");
  76. }
  77. public void UpdateData(DataLogItem dataLog)
  78. {
  79. if (dataLog == null)
  80. {
  81. ProcessChartData.ClearData();
  82. return;
  83. }
  84. List<string> keys = new List<string>();
  85. Application.Current.Dispatcher.Invoke(new Action(() =>
  86. {
  87. Dictionary<string, Tuple<string, string, bool>> dicItems = GetDataElements(_culture);
  88. keys = dicItems.Keys.ToList();
  89. ProcessChartData.UpdateColumns(dicItems);
  90. }));
  91. ProcessData = Triton160UiSystem.Instance.WCF.Query.GetHistoryData(keys, dataLog.RecipeRunGuid);
  92. Application.Current.Dispatcher.Invoke(new Action(() =>
  93. {
  94. ProcessChartData.SetInfo(dataLog.LotName);
  95. ProcessChartData.UpdateData(ProcessData);
  96. }));
  97. }
  98. }
  99. }