SimLightPdcView.xaml.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using Aitex.Core.UI.MVVM;
  4. using Aitex.Core.Utilities;
  5. using MECF.Framework.Simulator.Core.Commons;
  6. namespace MECF.Framework.Simulator.Core.Light
  7. {
  8. public partial class SimLightPdcView : UserControl
  9. {
  10. //public static readonly DependencyProperty PortProperty = DependencyProperty.Register(
  11. // "Port", typeof(string), typeof(SimHipaceTurboPumpView),
  12. // new FrameworkPropertyMetadata("COM11", FrameworkPropertyMetadataOptions.AffectsRender));
  13. //public string Port
  14. //{
  15. // get { return (string) this.GetValue(PortProperty); }
  16. // set { this.SetValue(PortProperty, value); }
  17. //}
  18. public SimLightPdcView()
  19. {
  20. InitializeComponent();
  21. DataContext = new SimLightPdcViewModel("COM24");
  22. (DataContext as TimerViewModelBase).Start();
  23. this.Loaded += OnViewLoaded;
  24. }
  25. private void OnViewLoaded(object sender, RoutedEventArgs e)
  26. {
  27. if (DataContext == null)
  28. {
  29. }
  30. }
  31. }
  32. class SimLightPdcViewModel : SerialPortDeviceViewModel
  33. {
  34. public string Title
  35. {
  36. get { return "PDC Light Simulator"; }
  37. }
  38. private SimLightPdc _reader;
  39. public bool IsFailed
  40. {
  41. get
  42. {
  43. return _reader.Failed;
  44. }
  45. set
  46. {
  47. _reader.Failed = value;
  48. }
  49. }
  50. public bool IsPumpOn
  51. {
  52. get
  53. {
  54. return _reader.IsPumpOn;
  55. }
  56. set
  57. {
  58. _reader.IsPumpOn = value;
  59. }
  60. }
  61. public bool IsOverTemp
  62. {
  63. get
  64. {
  65. return _reader.IsOverTemp;
  66. }
  67. set
  68. {
  69. _reader.IsOverTemp = value;
  70. }
  71. }
  72. public bool IsAtSpeed
  73. {
  74. get
  75. {
  76. return _reader.IsAtSpeed;
  77. }
  78. set
  79. {
  80. _reader.IsAtSpeed = value;
  81. }
  82. }
  83. //private string _value;
  84. [IgnorePropertyChange]
  85. public string ResultValue
  86. {
  87. get
  88. {
  89. return _reader.ResultValue;
  90. }
  91. set
  92. {
  93. _reader.ResultValue = value;
  94. }
  95. }
  96. public SimLightPdcViewModel(string port) : base("SimLightPdcViewModel")
  97. {
  98. _reader = new SimLightPdc(port);
  99. Init(_reader, false);
  100. }
  101. }
  102. }