PressureDetailViewModel.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.Util;
  3. using Caliburn.Micro;
  4. using FurnaceUI.Client.Dialog;
  5. using FurnaceUI.Models;
  6. using MECF.Framework.Common.DataCenter;
  7. using System.Collections.Generic;
  8. namespace FurnaceUI.Views.Operations
  9. {
  10. public class PressureDetailViewModel : FurnaceUIViewModelBase
  11. {
  12. #region Leak Check
  13. [Subscription("PM1.LeakCheckPressureSensorName")] public string LeakCheckPressureSensorName { get; set; }
  14. [Subscription("PM1.LeakCheckTable")] public string LeakCheckTable { get; set; }
  15. [Subscription("PM1.LeakCheckHightLimitCommand")] public string LeakCheckHightLimitCommand { get; set; }
  16. [Subscription("PM1.LeakCheckLowLimitCommand")] public string LeakCheckLowLimitCommand { get; set; }
  17. [Subscription("PM1.LeakCheckBasePressureLimitCommand")] public string LeakCheckBasePressureLimitCommand { get; set; }
  18. [Subscription("PM1.LeakCheckErrorCommand")] public string LeakCheckErrorCommand { get; set; }
  19. [Subscription("PM1.LeakCheckRetryOverCommand")] public string LeakCheckRetryOverCommand { get; set; }
  20. [Subscription("PM1.LeakCheckHighLimit")] public float LeakCheckHighLimit { get; set; }
  21. [Subscription("PM1.LeakCheckLowLimit")] public float LeakCheckLowLimit { get; set; }
  22. [Subscription("PM1.LeakCheckBasePressureLimit")] public float LeakCheckBasePressureLimit { get; set; }
  23. [Subscription("PM1.LeakCheckDelayTime")] public float LeakCheckDelayTime { get; set; }
  24. [Subscription("PM1.LeakCheckDelayElapseTime")] public float LeakCheckDelayElapseTime { get; set; }
  25. [Subscription("PM1.LeakCheckCheckTime")] public float LeakCheckCheckTime { get; set; }
  26. [Subscription("PM1.LeakCheckElapseTime")] public float LeakCheckElapseTime { get; set; }
  27. [Subscription("PM1.LeakCheckBasePressure")] public float LeakCheckBasePressure { get; set; }
  28. [Subscription("PM1.LeakCheckLeakLimit")] public float LeakCheckLeakLimit { get; set; }
  29. [Subscription("PM1.LeakCheckDelayMonitorPressure")] public float LeakCheckDelayMonitorPressure { get; set; }
  30. [Subscription("PM1.LeakCheckDelayStartPressure")] public float LeakCheckDelayStartPressure { get; set; }
  31. [Subscription("PM1.LeakCheckMonitorPressure")] public float LeakCheckMonitorPressure { get; set; }
  32. [Subscription("PM1.LeakCheckStartPressure")] public float LeakCheckStartPressure { get; set; }
  33. [Subscription("PM1.LeakCheckActualLeak")] public float LeakCheckActualLeak { get; set; }
  34. [Subscription("PM1.LeakCheckRetryCurrentCount")] public int LeakCheckRetryCurrentCount { get; set; }
  35. [Subscription("PM1.LeakCheckRetryLimit")] public int LeakCheckRetryLimit { get; set; }
  36. [Subscription("PM1.LeakCheckStatus")] public string LeakCheckStatus { get; set; }
  37. private float _leakCheckDelayProGress = 0;
  38. public float LeakCheckDelayProGress
  39. {
  40. get { return _leakCheckDelayProGress; }
  41. set { _leakCheckDelayProGress = value; this.NotifyOfPropertyChange(nameof(LeakCheckDelayProGress)); }
  42. }
  43. private float _leakCheckProGress = 0;
  44. public float LeakCheckProGress
  45. {
  46. get { return _leakCheckProGress; }
  47. set { _leakCheckProGress = value; this.NotifyOfPropertyChange(nameof(LeakCheckProGress)); }
  48. }
  49. #endregion
  50. [Subscription("PM1.APC.DeviceData")]
  51. public AITAPCData APCData { get; set; }
  52. [Subscription("PM1.APC.Pressure1Feedback")]
  53. public float Pressure1Feedback { get; set; }
  54. [Subscription("PM1.APC.Pressure2Feedback")]
  55. public float Pressure2Feedback { get; set; }
  56. public PressureDetailViewModel()
  57. {
  58. DefaultUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit");
  59. }
  60. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  61. {
  62. base.InvokeAfterUpdateProperty(data);
  63. if (LeakCheckStatus == "LeakCheckDelay")
  64. {
  65. LeakCheckProGress = 0;
  66. LeakCheckDelayProGress = LeakCheckDelayElapseTime > 0 ? (LeakCheckDelayElapseTime / LeakCheckDelayTime) * 100.0f : 0;
  67. }
  68. if (LeakCheckStatus == "LeakCheck")
  69. {
  70. LeakCheckDelayProGress = 0;
  71. LeakCheckProGress = (LeakCheckElapseTime > 0 ) ? (LeakCheckElapseTime / LeakCheckCheckTime) * 100.0f : 0;
  72. }
  73. if (LeakCheckStatus == "None")
  74. {
  75. LeakCheckDelayProGress = LeakCheckProGress = 0;
  76. }
  77. }
  78. protected override void OnActivate()
  79. {
  80. base.OnActivate();
  81. DefaultUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit");
  82. }
  83. public string CommandSetValueUnit { get; set; }
  84. public string CommandSetValue
  85. {
  86. get
  87. {
  88. if (APCData != null)
  89. {
  90. switch (APCData.TextModeSetPoint)
  91. {
  92. case "Valve Angle":
  93. return APCData.PositionSetPoint.ToString();
  94. case "Press":
  95. case "Press2":
  96. return APCData.PressureSetPoint.ToString();
  97. case "Slow Vac":
  98. return APCData.SlowRateSetPoint.ToString();
  99. }
  100. }
  101. return "0.0";
  102. }
  103. }
  104. public string DefaultUnit { get; set; }
  105. public string _defaultUnit
  106. {
  107. get
  108. {
  109. return DefaultUnit + "/S";
  110. }
  111. }
  112. public void CmdMouseDown(string cmd)
  113. {
  114. WindowManager wm = new WindowManager();
  115. bool? dialogReturn = false;
  116. switch (cmd)
  117. {
  118. case "SensorInfo":
  119. PressureInfoViewModel selectExistViewModel2 = new PressureInfoViewModel();
  120. dialogReturn = wm.ShowDialogWithTitle(selectExistViewModel2, null, "Sensor Information");
  121. if ((bool)dialogReturn)
  122. {
  123. }
  124. break;
  125. }
  126. }
  127. }
  128. }