using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Observer;
using Aitex.Core.RT.SCCore;
using Aitex.Core.Util;
using Aitex.Triton160.Common;
using Aitex.Triton160.UI.ViewModel;
namespace Aitex.Triton160.UI.Views
{
///
/// FAView.xaml 的交互逻辑
///
public partial class FAView : UserControl
{
public FAView()
{
InitializeComponent();
this.DataContext = new FAViewModel();
this.IsVisibleChanged += OnIsVisibleChanged;
var obj = Wcf.WcfClient.Instance.Query.GetConfig(SCName.System_IsMesMode);
IsAutoToggleButton.IsChecked= obj.ToString()=="True"?true:false;
}
private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
(this.DataContext as FAViewModel).EnableTimer(IsVisible);
}
private void ToggleButton_Checked(object sender, RoutedEventArgs e)
{
GlobalObserver.Instance.IsAutoRaiseChanged(true);
//bool isAuto = IsAutoToggleButton.IsChecked;
Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), SCName.System_IsMesMode, true);
}
private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
{
GlobalObserver.Instance.IsAutoRaiseChanged(false);
//bool isAuto = IsAutoToggleButton.IsChecked == true ? true : false;
Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), SCName.System_IsMesMode, false);
}
}
public enum FAControlState
{
Unknown,
EquipmentOffline,
AttemptOnline,
HostOffline,
OnlineLocal,
OnlineRemote,
}
public enum FACommunicationState
{
Disabled,
Enabled,
EnabledNotCommunicating,
EnabledCommunicating,
WaitCRA,
WaitDelay,
WaitCRFromHost,
}
class FAViewModel : UIViewModelBase
{
[Subscription("System.ControlStatus")]
public string HostControlStatus
{
get;
set;
}
[Subscription("System.CommunicationStatus")]
public string HostCommunicationStatus
{
get;
set;
}
public FACommunicationState FACommunicationState
{
get
{
return string.IsNullOrEmpty(HostCommunicationStatus) ? FACommunicationState.Disabled
: (FACommunicationState)Enum.Parse(typeof(FACommunicationState), HostCommunicationStatus);
}
}
public FAControlState FAControlState
{
get
{
return string.IsNullOrEmpty(HostControlStatus) ? FAControlState.Unknown
: (FAControlState)Enum.Parse(typeof(FAControlState), HostControlStatus);
}
}
//Disabled,
//Enabled,
//EnabledNotCommunicating,
//EnabledCommunicating,
//WaitCRA,
//WaitDelay,
//WaitCRFromHost,
public bool IsEnableEnableButton
{
get { return FACommunicationState == FACommunicationState.Disabled; }
}
public bool IsEnableDisableButton
{
get { return FACommunicationState != FACommunicationState.Disabled; }
}
//Unknown,
//EquipmentOffline,
//AttemptOnline,
//HostOffline,
//OnlineLocal,
//OnlineRemote,
public bool IsEnableOnlineButton
{
get { return FAControlState == FAControlState.Unknown || FAControlState == FAControlState.EquipmentOffline; }
}
public bool IsEnableOfflineButton
{
get { return FAControlState == FAControlState.Unknown || FAControlState != FAControlState.EquipmentOffline; }
}
public bool IsEnableLocalButton
{
get { return FAControlState == FAControlState.OnlineRemote; }
}
public bool IsEnableRemoteButton
{
get { return FAControlState == FAControlState.OnlineLocal; }
}
public FAViewModel():base(nameof(FAViewModel))
{
}
protected override void InvokeBeforeUpdateProperty(Dictionary data)
{
}
}
}