MFCVerificationViewModel.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Threading;
  8. using Aitex.Core.Common.DeviceData;
  9. using MECF.Framework.Common.DataCenter;
  10. using MECF.Framework.Common.OperationCenter;
  11. using Prism.Commands;
  12. using Prism.Mvvm;
  13. using Venus_Core;
  14. namespace Venus_MainPages.ViewModels
  15. {
  16. public class MFCVerificationViewModel : BindableBase
  17. {
  18. #region 私有字段
  19. public ObservableCollection<int> m_MFC1VerificationPoints = new ObservableCollection<int>();
  20. public ObservableCollection<int> m_MFC2VerificationPoints = new ObservableCollection<int>();
  21. public ObservableCollection<int> m_MFC3VerificationPoints = new ObservableCollection<int>();
  22. public ObservableCollection<int> m_MFC4VerificationPoints = new ObservableCollection<int>();
  23. public ObservableCollection<int> m_MFC5VerificationPoints = new ObservableCollection<int>();
  24. public ObservableCollection<int> m_MFC6VerificationPoints = new ObservableCollection<int>();
  25. public ObservableCollection<int> m_MFC7VerificationPoints = new ObservableCollection<int>();
  26. public ObservableCollection<int> m_MFC8VerificationPoints = new ObservableCollection<int>();
  27. private AITMfcData m_MFCData;
  28. private AITMfcData m_MFC1Data;
  29. private AITMfcData m_MFC2Data;
  30. private AITMfcData m_MFC3Data;
  31. private AITMfcData m_MFC4Data;
  32. private AITMfcData m_MFC5Data;
  33. private AITMfcData m_MFC6Data;
  34. private AITMfcData m_MFC7Data;
  35. private AITMfcData m_MFC8Data;
  36. private List<string> m_RtDataKeys = new List<string>();
  37. private Dictionary<string, object> m_RtDataValues;
  38. public string ModuleName;
  39. private ObservableCollection<int> m_MFCVerificationPoints = new ObservableCollection<int>();
  40. private int m_GasSelectedIndex;
  41. private int m_PointsSelectedIndex;
  42. #endregion
  43. #region 属性
  44. public ObservableCollection<int> MFCVerificationPoints
  45. {
  46. get { return m_MFCVerificationPoints; }
  47. set
  48. {
  49. SetProperty(ref m_MFCVerificationPoints, value);
  50. }
  51. }
  52. public ObservableCollection<int> MFC1VerificationPoints
  53. {
  54. get { return m_MFC1VerificationPoints; }
  55. set
  56. {
  57. SetProperty(ref m_MFC1VerificationPoints, value);
  58. }
  59. }
  60. public ObservableCollection<int> MFC2VerificationPoints
  61. {
  62. get { return m_MFC2VerificationPoints; }
  63. set
  64. {
  65. SetProperty(ref m_MFC2VerificationPoints, value);
  66. }
  67. }
  68. public ObservableCollection<int> MFC3VerificationPoints
  69. {
  70. get { return m_MFC3VerificationPoints; }
  71. set
  72. {
  73. SetProperty(ref m_MFC3VerificationPoints, value);
  74. }
  75. }
  76. public ObservableCollection<int> MFC4VerificationPoints
  77. {
  78. get { return m_MFC4VerificationPoints; }
  79. set
  80. {
  81. SetProperty(ref m_MFC4VerificationPoints, value);
  82. }
  83. }
  84. public ObservableCollection<int> MFC5VerificationPoints
  85. {
  86. get { return m_MFC5VerificationPoints; }
  87. set
  88. {
  89. SetProperty(ref m_MFC5VerificationPoints, value);
  90. }
  91. }
  92. public ObservableCollection<int> MFC6VerificationPoints
  93. {
  94. get { return m_MFC6VerificationPoints; }
  95. set
  96. {
  97. SetProperty(ref m_MFC6VerificationPoints, value);
  98. }
  99. }
  100. public ObservableCollection<int> MFC7VerificationPoints
  101. {
  102. get { return m_MFC7VerificationPoints; }
  103. set
  104. {
  105. SetProperty(ref m_MFC7VerificationPoints, value);
  106. }
  107. }
  108. public ObservableCollection<int> MFC8VerificationPoints
  109. {
  110. get { return m_MFC8VerificationPoints; }
  111. set
  112. {
  113. SetProperty(ref m_MFC8VerificationPoints, value);
  114. }
  115. }
  116. public Dictionary<string, object> RtDataValues
  117. {
  118. get { return m_RtDataValues; }
  119. set { SetProperty(ref m_RtDataValues, value); }
  120. }
  121. public AITMfcData MFCData
  122. {
  123. get { return m_MFCData; }
  124. set { SetProperty(ref m_MFCData, value); }
  125. }
  126. public AITMfcData MFC1Data
  127. {
  128. get { return m_MFC1Data; }
  129. set { SetProperty(ref m_MFC1Data, value); }
  130. }
  131. public AITMfcData MFC2Data
  132. {
  133. get { return m_MFC2Data; }
  134. set { SetProperty(ref m_MFC2Data, value); }
  135. }
  136. public AITMfcData MFC3Data
  137. {
  138. get { return m_MFC3Data; }
  139. set { SetProperty(ref m_MFC3Data, value); }
  140. }
  141. public AITMfcData MFC4Data
  142. {
  143. get { return m_MFC4Data; }
  144. set { SetProperty(ref m_MFC4Data, value); }
  145. }
  146. public AITMfcData MFC5Data
  147. {
  148. get { return m_MFC5Data; }
  149. set { SetProperty(ref m_MFC5Data, value); }
  150. }
  151. public AITMfcData MFC6Data
  152. {
  153. get { return m_MFC6Data; }
  154. set { SetProperty(ref m_MFC6Data, value); }
  155. }
  156. public AITMfcData MFC7Data
  157. {
  158. get { return m_MFC7Data; }
  159. set { SetProperty(ref m_MFC7Data, value); }
  160. }
  161. public AITMfcData MFC8Data
  162. {
  163. get { return m_MFC8Data; }
  164. set { SetProperty(ref m_MFC8Data, value); }
  165. }
  166. public int GasSelectedIndex
  167. {
  168. get { return m_GasSelectedIndex; }
  169. set { SetProperty(ref m_GasSelectedIndex, value); }
  170. }
  171. public int PointsSelectedIndex
  172. {
  173. get { return m_PointsSelectedIndex; }
  174. set { SetProperty(ref m_PointsSelectedIndex, value); }
  175. }
  176. #endregion
  177. #region 命令
  178. private DelegateCommand<object> _StartOnePointVerificationCommand;
  179. public DelegateCommand<object> StartOnePointVerificationCommand =>
  180. _StartOnePointVerificationCommand ?? (_StartOnePointVerificationCommand = new DelegateCommand<object>(OnStartOnePointVerification));
  181. private DelegateCommand<object> _StartTenPointVerificationCommand;
  182. public DelegateCommand<object> StartTenPointVerificationCommand =>
  183. _StartTenPointVerificationCommand ?? (_StartTenPointVerificationCommand = new DelegateCommand<object>(OnStartTenPointVerification));
  184. private DelegateCommand _AbortCommand;
  185. public DelegateCommand AbortCommand =>
  186. _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));
  187. private DelegateCommand _SelectGasCommand;
  188. public DelegateCommand SelectGasCommand =>
  189. _SelectGasCommand ?? (_SelectGasCommand = new DelegateCommand(OnSelectGas));
  190. #endregion
  191. public MFCVerificationViewModel()
  192. {
  193. //DispatcherTimer timer = new DispatcherTimer();
  194. //timer.Interval = TimeSpan.FromSeconds(1);
  195. //timer.Tick += timer_Tick;
  196. //timer.Start();
  197. }
  198. #region 命令方法
  199. private void OnStartOnePointVerification(object obj)
  200. {
  201. var values = (object[])obj;
  202. string gasName = values[0].ToString();
  203. float flow = float.Parse(values[1].ToString());
  204. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{RtOperation.MFCVerification}", gasName, flow, 1);
  205. }
  206. private void OnStartTenPointVerification(object obj)
  207. {
  208. var values = (object[])obj;
  209. string gasName = values[0].ToString();
  210. float flow = float.Parse(values[1].ToString());
  211. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{RtOperation.MFCVerification}", gasName, flow, 10);
  212. }
  213. public void OnAbort()
  214. {
  215. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Abort");
  216. }
  217. private void OnSelectGas()
  218. {
  219. MFCVerificationPoints.Clear();
  220. MFCData = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas{(GasSelectedIndex + 1).ToString()}");
  221. int delta1 = (int)MFCData.Scale / 10;
  222. for (int i = 0; i < 10; i++)
  223. {
  224. MFCVerificationPoints.Add(delta1 + delta1 * i);
  225. }
  226. PointsSelectedIndex = 0;
  227. }
  228. #endregion
  229. #region 私有方法
  230. public void Init()
  231. {
  232. OnSelectGas();
  233. }
  234. #endregion
  235. }
  236. }