using Aitex.Core.UI.MVVM; using Aitex.Core.Util; using Aitex.Sorter.Common; using Aitex.Sorter.UI.Controls.Common; using MECF.Framework.Common.OperationCenter; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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 MECF.Framework.Common.Equipment; using System.Globalization; namespace Aitex.Sorter.UI.Controls { /// /// RobotControl.xaml 的交互逻辑 /// public partial class RobotControlII : ViewModelControl { public Dictionary TargetII { get { return (Dictionary)GetValue(TargetProperty); } set { SetValue(TargetProperty, value); } } // Using a DependencyProperty as the backing store for Target. This enables animation, styling, binding, etc... public static readonly DependencyProperty TargetProperty = DependencyProperty.Register("TargetII", typeof(Dictionary), typeof(RobotControlII), new PropertyMetadata(null)); public bool EnableHighSpeed { get { return (bool)GetValue(EnableHighSpeedProperty); } set { SetValue(EnableHighSpeedProperty, value); } } // Using a DependencyProperty as the backing store for Target. This enables animation, styling, binding, etc... public static readonly DependencyProperty EnableHighSpeedProperty = DependencyProperty.Register("EnableHighSpeed", typeof(bool), typeof(RobotControl), new PropertyMetadata(null)); public RobotControlII() { InitializeComponent(); OperationCommand = new DelegateCommand(Operation, x => !IsMaintenanceMode && !IsAutoMode); Command = new DelegateCommand(DoCommand, x => !IsMaintenanceMode && !IsAutoMode); SetSpeedCommand = new DelegateCommand(Operation, CanSetSpeed); var hands = new List(); hands.Add(Hand.Blade1); hands.Add(Hand.Blade2); Hands = hands.ToArray(); EnableHighSpeed = true; root.DataContext = this; } private bool CanSetSpeed(DependencyObject sender) { var command = CommandHelper.GetCommandItem(sender); var lstParameter = new List(command.Parameters); if (lstParameter[0].ToString() == RobotSpeed) return false; return true; } [Subscription(ParamName.RTStatus, "System")] public int RoutManagerState { get; set; } public bool IsMaintenanceMode { get => RoutManagerState == (int)RtState.Maintenance; } [Subscription(ParamName.IsAutoMode, "System")] public bool IsAutoMode { get; set; } public ICommand OperationCommand { get; private set; } public ICommand Command { get; private set; } public ICommand SetSpeedCommand { get; private set; } void Operation(DependencyObject sender) { var command = CommandHelper.GetCommandItem(sender); InvokeClient.Instance.Service.DoOperation(command.CommandName, command.Parameters); } private void DoCommand(DependencyObject sender) { var command = CommandHelper.GetCommandItem(sender); var lstParameter = new List(command.Parameters); lstParameter.Insert(0, command.Target); lstParameter.Insert(1, command.CommandName); InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation, lstParameter.ToArray()); } [Subscription(ParamName.RobotState, DeviceName.Robot)] public string Status { get; set; } [Subscription(ParamName.RobotPosRotationAxis, DeviceName.Robot)] public string RobotPosRotationAxis { get; set; } [Subscription(ParamName.RobotPosExtensionAxis, DeviceName.Robot)] public string RobotPosExtensionAxis { get; set; } [Subscription(ParamName.RobotPosWrist1Axis, DeviceName.Robot)] public string RobotPosWrist1Axis { get; set; } [Subscription(ParamName.RobotPosWrist2Axis, DeviceName.Robot)] public string RobotPosWrist2Axis { get; set; } [Subscription(ParamName.RobotPosEvevationAxis, DeviceName.Robot)] public string RobotPosEvevationAxis { get; set; } [Subscription(ParamName.RobotBlade1Traget, DeviceName.Robot)] public string RobotBlade1Traget { get; set; } [Subscription(ParamName.RobotBlade2Traget, DeviceName.Robot)] public string RobotBlade2Traget { get; set; } private string robotSpeed; [Subscription(ParamName.RobotSpeed, DeviceName.Robot)] public string RobotSpeed { get { return robotSpeed; } set { ChickSpeedSetBtn(value); robotSpeed = value; } } private void ChickSpeedSetBtn(string speedStr) { switch (speedStr) { case "Fast": IsLowEnabled = true; IsMediumEnabled = true; IsHighEnabled = false; break; case "Medium": IsLowEnabled = true; IsMediumEnabled = false; IsHighEnabled = true; break; case "Slow": IsLowEnabled = false; IsMediumEnabled = true; IsHighEnabled = true; break; default: break; } } public bool IsLowEnabled { get; set; } public bool IsMediumEnabled { get; set; } public bool IsHighEnabled { get; set; } [Subscription(ParamName.RobotError, DeviceName.Robot)] public string ErrorCode { get; set; } public Hand[] Hands { get; set; } } }