SimAePowerView.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using MECF.Framework.Simulator.Core.Commons;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace MECF.Framework.Simulator.Core.RFs.AE
  20. {
  21. /// <summary>
  22. /// SimAePowerView.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class SimAePowerView : UserControl
  25. {
  26. public static readonly DependencyProperty PortProperty = DependencyProperty.Register(
  27. "Port", typeof(string), typeof(SimAePowerView),
  28. new FrameworkPropertyMetadata("COM5", FrameworkPropertyMetadataOptions.AffectsRender));
  29. public string Port
  30. {
  31. get
  32. {
  33. return (string)this.GetValue(PortProperty);
  34. }
  35. set
  36. {
  37. this.SetValue(PortProperty, value);
  38. }
  39. }
  40. public SimAePowerView()
  41. {
  42. InitializeComponent();
  43. this.Loaded += OnViewLoaded;
  44. }
  45. private void OnViewLoaded(object sender, RoutedEventArgs e)
  46. {
  47. if (DesignerProperties.GetIsInDesignMode(this))
  48. return;
  49. if (DataContext == null)
  50. {
  51. DataContext = new SimRfPowerViewModel(Port);
  52. (DataContext as TimerViewModelBase).Start();
  53. }
  54. }
  55. }
  56. class SimRfPowerViewModel : SerialPortDeviceViewModel
  57. {
  58. public string Title
  59. {
  60. get { return "AE RF Power Simulator"; }
  61. }
  62. private SimAeRfPower _sim;
  63. public bool IsFailed
  64. {
  65. get
  66. {
  67. return _sim.Failed;
  68. }
  69. set
  70. {
  71. _sim.Failed = value;
  72. }
  73. }
  74. public bool IsHalo
  75. {
  76. get
  77. {
  78. return _sim.IsHalo;
  79. }
  80. set
  81. {
  82. _sim.IsHalo = value;
  83. }
  84. }
  85. public bool IsOn
  86. {
  87. get
  88. {
  89. return _sim.IsOn;
  90. }
  91. set
  92. {
  93. _sim.IsOn = value;
  94. }
  95. }
  96. public bool IsContinueAck
  97. {
  98. get
  99. {
  100. return _sim.IsContinueAck;
  101. }
  102. set
  103. {
  104. _sim.IsContinueAck = value;
  105. }
  106. }
  107. //private string _value;
  108. [IgnorePropertyChange]
  109. public string ResultValue
  110. {
  111. get
  112. {
  113. return _sim.ResultValue;
  114. }
  115. set
  116. {
  117. _sim.ResultValue = value;
  118. }
  119. }
  120. public SimRfPowerViewModel(string port) : base("SimRfPowerViewModel")
  121. {
  122. _sim = new SimAeRfPower(port);
  123. Init(_sim);
  124. }
  125. }
  126. }