AITStatisticsData.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Runtime.Serialization;
  7. using System.Text;
  8. using System.Windows.Input;
  9. using Aitex.Core.UI.MVVM;
  10. namespace Aitex.Core.Common.DeviceData
  11. {
  12. [DataContract]
  13. [Serializable]
  14. public class AITStatisticsData : INotifyPropertyChanged, IDeviceData
  15. {
  16. public event PropertyChangedEventHandler PropertyChanged;
  17. public void InvokePropertyChanged(string propertyName)
  18. {
  19. if (PropertyChanged != null)
  20. {
  21. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  22. }
  23. }
  24. public void InvokePropertyChanged()
  25. {
  26. PropertyInfo[] ps = this.GetType().GetProperties();
  27. foreach (PropertyInfo p in ps)
  28. {
  29. InvokePropertyChanged(p.Name);
  30. if (p.PropertyType == typeof(ICommand))
  31. {
  32. DelegateCommand<string> cmd = p.GetValue(this, null) as DelegateCommand<string>;
  33. if (cmd != null)
  34. cmd.RaiseCanExecuteChanged();
  35. }
  36. }
  37. FieldInfo[] fi = this.GetType().GetFields();
  38. foreach (FieldInfo p in fi)
  39. {
  40. InvokePropertyChanged(p.Name);
  41. if (p.FieldType == typeof(ICommand))
  42. {
  43. DelegateCommand<string> cmd = p.GetValue(this) as DelegateCommand<string>;
  44. if (cmd != null)
  45. cmd.RaiseCanExecuteChanged();
  46. }
  47. }
  48. }
  49. /// <summary>
  50. /// 设备的唯一名称,UI与RT交互的ID
  51. /// </summary>
  52. [DataMember]
  53. public string DeviceName
  54. {
  55. get;
  56. set;
  57. }
  58. /// <summary>
  59. /// 显示在界面上的名称
  60. /// </summary>
  61. [DataMember]
  62. public string DisplayName
  63. {
  64. get;
  65. set;
  66. }
  67. /// <summary>
  68. /// IO 表中定义的物理编号,物理追溯使用 比如: M122
  69. /// </summary>
  70. [DataMember]
  71. public string DeviceSchematicId
  72. {
  73. get;
  74. set;
  75. }
  76. [DataMember]
  77. public string Description
  78. {
  79. get;
  80. set;
  81. }
  82. [DataMember]
  83. public string LastPMTime
  84. {
  85. get;
  86. set;
  87. }
  88. [DataMember]
  89. public double TimeFromLastPM
  90. {
  91. get;
  92. set;
  93. }
  94. [DataMember]
  95. public double TimeTotal
  96. {
  97. get;
  98. set;
  99. }
  100. [DataMember]
  101. public double PMInterval
  102. {
  103. get;
  104. set;
  105. }
  106. public string TimeFromLastPMDisplay
  107. {
  108. get
  109. {
  110. TimeSpan ts = TimeSpan.FromSeconds(TimeFromLastPM);
  111. return string.Format("{0} Days {1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
  112. }
  113. }
  114. public string TimeTotalDisplay
  115. {
  116. get
  117. {
  118. TimeSpan ts = TimeSpan.FromSeconds(TimeTotal);
  119. return string.Format("{0} Days {1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
  120. }
  121. }
  122. public AITStatisticsData()
  123. {
  124. DisplayName = "Undefined";
  125. }
  126. public void Update(IDeviceData data)
  127. {
  128. throw new NotImplementedException();
  129. }
  130. }
  131. public enum AITStatisticsOperation
  132. {
  133. Reset,
  134. }
  135. }