HopperFeederParam.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Team.FFFeederService.Models
  9. {
  10. /// <summary>
  11. /// 料斗参数
  12. /// </summary>
  13. public class HopperFeederParam: INotifyPropertyChanged
  14. {
  15. private bool _HopperDigitalOutput1;
  16. /// <summary>
  17. /// 数字量输出1
  18. /// </summary>
  19. public bool HopperDigitalOutput1
  20. {
  21. get { return _HopperDigitalOutput1; }
  22. set { SetProperty(ref _HopperDigitalOutput1,value); }
  23. }
  24. private int _HopperAnalogOutput1;
  25. /// <summary>
  26. /// 模拟量输出11
  27. /// </summary>
  28. public int HopperAnalogOutput1
  29. {
  30. get { return _HopperAnalogOutput1; }
  31. set { SetProperty(ref _HopperAnalogOutput1, value); }
  32. }
  33. private bool _HopperDigitalOutput2;
  34. /// <summary>
  35. /// 数字量输出2
  36. /// </summary>
  37. public bool HopperDigitalOutput2
  38. {
  39. get { return _HopperDigitalOutput2; }
  40. set { SetProperty(ref _HopperDigitalOutput2, value); }
  41. }
  42. private int _HopperAnalogOutput2;
  43. /// <summary>
  44. /// 模拟量输出2
  45. /// </summary>
  46. public int HopperAnalogOutput2
  47. {
  48. get { return _HopperAnalogOutput2; }
  49. set { SetProperty(ref _HopperAnalogOutput2, value); }
  50. }
  51. private int _HopperVibrationAmpl;
  52. /// <summary>
  53. /// 料斗振动振幅
  54. /// </summary>
  55. public int HopperVibrationAmpl
  56. {
  57. get { return _HopperVibrationAmpl; }
  58. set { SetProperty(ref _HopperVibrationAmpl, value); }
  59. }
  60. private int _HopperVibrationFreq;
  61. /// <summary>
  62. /// 料斗振动频率
  63. /// </summary>
  64. public int HopperVibrationFreq
  65. {
  66. get { return _HopperVibrationFreq; }
  67. set { SetProperty(ref _HopperVibrationFreq, value); }
  68. }
  69. private int _HopperVibrationWaveform;
  70. /// <summary>
  71. /// 料斗振动波形
  72. /// </summary>
  73. public int HopperVibrationWaveform
  74. {
  75. get { return _HopperVibrationWaveform; }
  76. set { SetProperty(ref _HopperVibrationWaveform, value); }
  77. }
  78. private int _HopperDuration;
  79. /// <summary>
  80. /// 振动持续时间
  81. /// </summary>
  82. public int HopperDuration
  83. {
  84. get { return _HopperDuration; }
  85. set { SetProperty(ref _HopperDuration, value); }
  86. }
  87. #region 属性更改通知
  88. /// <summary>
  89. /// Occurs when a property value changes.
  90. /// </summary>
  91. public event PropertyChangedEventHandler PropertyChanged;
  92. /// <summary>
  93. /// Checks if a property already matches a desired value. Sets the property and
  94. /// notifies listeners only when necessary.
  95. /// </summary>
  96. /// <typeparam name="T">Type of the property.</typeparam>
  97. /// <param name="storage">Reference to a property with both getter and setter.</param>
  98. /// <param name="value">Desired value for the property.</param>
  99. /// <param name="propertyName">Name of the property used to notify listeners. This
  100. /// value is optional and can be provided automatically when invoked from compilers that
  101. /// support CallerMemberName.</param>
  102. /// <returns>True if the value was changed, false if the existing value matched the
  103. /// desired value.</returns>
  104. protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
  105. {
  106. if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
  107. storage = value;
  108. RaisePropertyChanged(propertyName);
  109. return true;
  110. }
  111. /// <summary>
  112. /// Checks if a property already matches a desired value. Sets the property and
  113. /// notifies listeners only when necessary.
  114. /// </summary>
  115. /// <typeparam name="T">Type of the property.</typeparam>
  116. /// <param name="storage">Reference to a property with both getter and setter.</param>
  117. /// <param name="value">Desired value for the property.</param>
  118. /// <param name="propertyName">Name of the property used to notify listeners. This
  119. /// value is optional and can be provided automatically when invoked from compilers that
  120. /// support CallerMemberName.</param>
  121. /// <param name="onChanged">Action that is called after the property value has been changed.</param>
  122. /// <returns>True if the value was changed, false if the existing value matched the
  123. /// desired value.</returns>
  124. protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
  125. {
  126. if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
  127. storage = value;
  128. onChanged?.Invoke();
  129. RaisePropertyChanged(propertyName);
  130. return true;
  131. }
  132. /// <summary>
  133. /// Raises this object's PropertyChanged event.
  134. /// </summary>
  135. /// <param name="propertyName">Name of the property used to notify listeners. This
  136. /// value is optional and can be provided automatically when invoked from compilers
  137. /// that support <see cref="CallerMemberNameAttribute"/>.</param>
  138. protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
  139. {
  140. OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
  141. }
  142. /// <summary>
  143. /// Raises this object's PropertyChanged event.
  144. /// </summary>
  145. /// <param name="args">The PropertyChangedEventArgs</param>
  146. protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
  147. {
  148. PropertyChanged?.Invoke(this, args);
  149. }
  150. #endregion
  151. }
  152. }