SimChillerSmcHRZView.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using MECF.Framework.Simulator.Core.Commons;
  4. using System.ComponentModel;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Input;
  8. namespace MECF.Framework.Simulator.Core.Chillers
  9. {
  10. /// <summary>
  11. /// SimChillerSmcHRZView.xaml 的交互逻辑
  12. /// </summary>
  13. public partial class SimChillerSmcHRZView : UserControl
  14. {
  15. public static readonly DependencyProperty PortProperty = DependencyProperty.Register(
  16. "Port", typeof(string), typeof(SimChillerSmcHRZView),
  17. new FrameworkPropertyMetadata("COM2", FrameworkPropertyMetadataOptions.AffectsRender));
  18. public string Port
  19. {
  20. get
  21. {
  22. return (string)this.GetValue(PortProperty);
  23. }
  24. set
  25. {
  26. this.SetValue(PortProperty, value);
  27. }
  28. }
  29. public SimChillerSmcHRZView()
  30. {
  31. InitializeComponent();
  32. this.Loaded += OnViewLoaded;
  33. }
  34. private void OnViewLoaded(object sender, RoutedEventArgs e)
  35. {
  36. if (DesignerProperties.GetIsInDesignMode(this))
  37. return;
  38. if (DataContext == null || !(DataContext is SimSimChillerSmcHRZViewModel))
  39. {
  40. DataContext = new SimSimChillerSmcHRZViewModel(Port);
  41. (DataContext as TimerViewModelBase).Start();
  42. }
  43. }
  44. }
  45. class SimSimChillerSmcHRZViewModel : SerialPortDeviceViewModel
  46. {
  47. public string Title
  48. {
  49. get { return "SMC Chiller HRZ Simulator"; }
  50. }
  51. private SimChillerSmcHRZ _sim;
  52. public bool IsNoResponse
  53. {
  54. get
  55. {
  56. return _sim.IsNoResponse;
  57. }
  58. set
  59. {
  60. _sim.IsNoResponse = value;
  61. }
  62. }
  63. public bool IsRemote
  64. {
  65. get
  66. {
  67. return _sim.IsRemote;
  68. }
  69. set
  70. {
  71. _sim.IsRemote = value;
  72. }
  73. }
  74. public bool IsRun
  75. {
  76. get
  77. {
  78. return _sim.IsRun;
  79. }
  80. set
  81. {
  82. _sim.IsRun = value;
  83. }
  84. }
  85. public bool IsFault
  86. {
  87. get
  88. {
  89. return _sim.IsFault;
  90. }
  91. set
  92. {
  93. _sim.IsFault = value;
  94. }
  95. }
  96. public float TempFeedback
  97. {
  98. get
  99. {
  100. return _sim.TempFeedback;
  101. }
  102. set
  103. {
  104. _sim.TempFeedback = value;
  105. }
  106. }
  107. [IgnorePropertyChange]
  108. public string TempSetPoint
  109. {
  110. get
  111. {
  112. return _sim.TempSetPoint;
  113. }
  114. set
  115. {
  116. _sim.TempSetPoint = value;
  117. }
  118. }
  119. public ICommand SetTempCommand { get; set; }
  120. public SimSimChillerSmcHRZViewModel(string port) : base("SimChillerSmcHRZViewModel")
  121. {
  122. _sim = new SimChillerSmcHRZ(port);
  123. Init(_sim);
  124. SetTempCommand = new DelegateCommand<string>(SetTemp);
  125. }
  126. private void SetTemp(string obj)
  127. {
  128. _sim.SetTemp();
  129. }
  130. }
  131. }