FAView.xaml.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Aitex.Core.Observer;
  15. using Aitex.Core.RT.SCCore;
  16. using Aitex.Core.Util;
  17. using Aitex.Triton160.Common;
  18. using Aitex.Triton160.UI.ViewModel;
  19. namespace Aitex.Triton160.UI.Views
  20. {
  21. /// <summary>
  22. /// FAView.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class FAView : UserControl
  25. {
  26. public FAView()
  27. {
  28. InitializeComponent();
  29. this.DataContext = new FAViewModel();
  30. this.IsVisibleChanged += OnIsVisibleChanged;
  31. var obj = Wcf.WcfClient.Instance.Query.GetConfig(SCName.System_IsMesMode);
  32. IsAutoToggleButton.IsChecked= obj.ToString()=="True"?true:false;
  33. }
  34. private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  35. {
  36. (this.DataContext as FAViewModel).EnableTimer(IsVisible);
  37. }
  38. private void ToggleButton_Checked(object sender, RoutedEventArgs e)
  39. {
  40. GlobalObserver.Instance.IsAutoRaiseChanged(true);
  41. //bool isAuto = IsAutoToggleButton.IsChecked;
  42. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), SCName.System_IsMesMode, true);
  43. }
  44. private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
  45. {
  46. GlobalObserver.Instance.IsAutoRaiseChanged(false);
  47. //bool isAuto = IsAutoToggleButton.IsChecked == true ? true : false;
  48. Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), SCName.System_IsMesMode, false);
  49. }
  50. }
  51. public enum FAControlState
  52. {
  53. Unknown,
  54. EquipmentOffline,
  55. AttemptOnline,
  56. HostOffline,
  57. OnlineLocal,
  58. OnlineRemote,
  59. }
  60. public enum FACommunicationState
  61. {
  62. Disabled,
  63. Enabled,
  64. EnabledNotCommunicating,
  65. EnabledCommunicating,
  66. WaitCRA,
  67. WaitDelay,
  68. WaitCRFromHost,
  69. }
  70. class FAViewModel : UIViewModelBase
  71. {
  72. [Subscription("System.ControlStatus")]
  73. public string HostControlStatus
  74. {
  75. get;
  76. set;
  77. }
  78. [Subscription("System.CommunicationStatus")]
  79. public string HostCommunicationStatus
  80. {
  81. get;
  82. set;
  83. }
  84. public FACommunicationState FACommunicationState
  85. {
  86. get
  87. {
  88. return string.IsNullOrEmpty(HostCommunicationStatus) ? FACommunicationState.Disabled
  89. : (FACommunicationState)Enum.Parse(typeof(FACommunicationState), HostCommunicationStatus);
  90. }
  91. }
  92. public FAControlState FAControlState
  93. {
  94. get
  95. {
  96. return string.IsNullOrEmpty(HostControlStatus) ? FAControlState.Unknown
  97. : (FAControlState)Enum.Parse(typeof(FAControlState), HostControlStatus);
  98. }
  99. }
  100. //Disabled,
  101. //Enabled,
  102. //EnabledNotCommunicating,
  103. //EnabledCommunicating,
  104. //WaitCRA,
  105. //WaitDelay,
  106. //WaitCRFromHost,
  107. public bool IsEnableEnableButton
  108. {
  109. get { return FACommunicationState == FACommunicationState.Disabled; }
  110. }
  111. public bool IsEnableDisableButton
  112. {
  113. get { return FACommunicationState != FACommunicationState.Disabled; }
  114. }
  115. //Unknown,
  116. //EquipmentOffline,
  117. //AttemptOnline,
  118. //HostOffline,
  119. //OnlineLocal,
  120. //OnlineRemote,
  121. public bool IsEnableOnlineButton
  122. {
  123. get { return FAControlState == FAControlState.Unknown || FAControlState == FAControlState.EquipmentOffline; }
  124. }
  125. public bool IsEnableOfflineButton
  126. {
  127. get { return FAControlState == FAControlState.Unknown || FAControlState != FAControlState.EquipmentOffline; }
  128. }
  129. public bool IsEnableLocalButton
  130. {
  131. get { return FAControlState == FAControlState.OnlineRemote; }
  132. }
  133. public bool IsEnableRemoteButton
  134. {
  135. get { return FAControlState == FAControlState.OnlineLocal; }
  136. }
  137. public FAViewModel():base(nameof(FAViewModel))
  138. {
  139. }
  140. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  141. {
  142. }
  143. }
  144. }