RecipeMonitorViewModel.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.Eventing.Reader;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Core.UI.ControlDataContext;
  10. using Aitex.Core.Utilities;
  11. using Application = System.Windows.Application;
  12. namespace Aitex.Triton160.UI.ViewModel
  13. {
  14. class RecipeMonitorViewModel : UIViewModelBase
  15. {
  16. private string _culture = CultureSupported.English;
  17. public ProcessDataChartDataItem ProcessChartData
  18. {
  19. get; set;
  20. }
  21. public RecipeMonitorViewModel()
  22. : base("RecipeMonitorViewModel")
  23. {
  24. ProcessChartData = new ProcessDataChartDataItem(60* 60 * 5); //留5个小时的数据
  25. Triton160UiSystem.Instance.CultureChanged += CultureChanged;
  26. SCLocal.SetKeys(new List<string>()
  27. {
  28. SCName.GasLineConfig_Gas1Enable,
  29. SCName.GasLineConfig_Gas1Name,
  30. SCName.GasLineConfig_Gas2Enable,
  31. SCName.GasLineConfig_Gas2Name,
  32. SCName.GasLineConfig_Gas3Enable,
  33. SCName.GasLineConfig_Gas3Name,
  34. SCName.GasLineConfig_Gas4Enable,
  35. SCName.GasLineConfig_Gas4Name,
  36. SCName.GasLineConfig_Gas5Enable,
  37. SCName.GasLineConfig_Gas5Name,
  38. SCName.RfConfig_EnablePulsingFunction,
  39. SCName.PressureControlConfig_EnableThrottleValve,
  40. SCName.PressureControlConfig_PumpEnableN2Pressure,
  41. SCName.PressureControlConfig_PumpEnableWaterFlow,
  42. });
  43. }
  44. private void CultureChanged(string s)
  45. {
  46. _culture = s;
  47. }
  48. protected override void Poll()
  49. {
  50. List<string> keys = new List<string>();
  51. Application.Current.Dispatcher.Invoke(new Action(() =>
  52. {
  53. Dictionary<string, Tuple<string, string, bool>> dicItems = GetDataElements(_culture);
  54. keys = dicItems.Keys.ToList();
  55. ProcessChartData.UpdateColumns(dicItems);
  56. }));
  57. var result = Triton160UiSystem.Instance.WCF.Query.PollData(keys);
  58. Application.Current.Dispatcher.Invoke(new Action(() =>
  59. {
  60. ProcessChartData.AppendData(result);
  61. }));
  62. }
  63. }
  64. }