| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 | using Aitex.Core.UI.MVVM;using Aitex.Core.Utilities;using MECF.Framework.Common.CommonData.Prewet;using MECF.Framework.Common.CommonData.SRD;using MECF.Framework.Common.OperationCenter;using MECF.Framework.Common.Persistent.Prewet;using MECF.Framework.Common.Persistent.SRD;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;namespace PunkHPX8_Themes.UserControls{    /// <summary>    /// PrewetLeftSideControl.xaml 的交互逻辑    /// </summary>    public partial class PrewetLeftSideControl : UserControl    {        public PrewetLeftSideControl()        {            KeyDownCommand = new DelegateCommand<object[]>(KeyDownAction);            InitializeComponent();        }        #region 属性        public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(           "ModuleName", typeof(string), typeof(PrewetLeftSideControl),           new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 模块名称        /// </summary>        public string ModuleName        {            get            {                return (string)this.GetValue(ModuleNameProperty);            }            set            {                this.SetValue(ModuleNameProperty, value);            }        }        public static readonly DependencyProperty StateMachineProperty = DependencyProperty.Register(            "StateMachine", typeof(string), typeof(PrewetLeftSideControl),                new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// StateMachine        /// </summary>        public string StateMachine        {            get            {                return (string)this.GetValue(StateMachineProperty);            }            set            {                this.SetValue(StateMachineProperty, value);            }        }        public static readonly DependencyProperty StatusValueProperty = DependencyProperty.Register(                "StatusValue", typeof(string), typeof(PrewetLeftSideControl),                    new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// StatusValue        /// </summary>        public string StatusValue        {            get            {                return (string)this.GetValue(StatusValueProperty);            }            set            {                this.SetValue(StatusValueProperty, value);            }        }        public static readonly DependencyProperty IsManualProperty = DependencyProperty.Register(             "IsManual", typeof(bool), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// OperatingMode        /// </summary>        public bool IsManual        {            get            {                return (bool)this.GetValue(IsManualProperty);            }            set            {                this.SetValue(IsManualProperty, value);            }        }        public static readonly DependencyProperty StateProperty = DependencyProperty.Register(            "State", typeof(string), typeof(PrewetLeftSideControl),            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// State        /// </summary>        public string State        {            get            {                return (string)this.GetValue(StateProperty);            }            set            {                this.SetValue(StateProperty, value);            }        }        public static readonly DependencyProperty PumpDataProperty = DependencyProperty.Register(          "PumpData", typeof(PrewetPumpData), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// PumpData        /// </summary>        public PrewetPumpData PumpData        {            get            {                return (PrewetPumpData)this.GetValue(PumpDataProperty);            }            set            {                this.SetValue(PumpDataProperty, value);            }        }        public static readonly DependencyProperty InputPumpSpeedProperty = DependencyProperty.Register(        "InputPumpSpeed", typeof(short), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata((short)300, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// InputLowThreshold        /// </summary>        public short InputPumpSpeed        {            get            {                return (short)this.GetValue(InputPumpSpeedProperty);            }            set            {                this.SetValue(InputPumpSpeedProperty, value);            }        }        public static readonly DependencyProperty LinmotPostionProperty = DependencyProperty.Register(        "LinmotPostion", typeof(double), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(0.00, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// LinmotPostion        /// </summary>        public double LinmotPostion        {            get            {                return (double)this.GetValue(LinmotPostionProperty);            }            set            {                this.SetValue(LinmotPostionProperty, value);            }        }        public static readonly DependencyProperty CurrentScanedCompletedProperty = DependencyProperty.Register(            "CurrentScanedCompleted", typeof(int), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// ScanedTimes        /// </summary>        public int CurrentScanedCompleted        {            get            {                return (int)this.GetValue(CurrentScanedCompletedProperty);            }            set            {                this.SetValue(CurrentScanedCompletedProperty, value);            }        }        public static readonly DependencyProperty KeepWetLimitProperty = DependencyProperty.Register(           "KeepWetLimit", typeof(int), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// ScanedTimes        /// </summary>        public int KeepWetLimit        {            get            {                return (int)this.GetValue(KeepWetLimitProperty);            }            set            {                this.SetValue(KeepWetLimitProperty, value);            }        }        public static readonly DependencyProperty PersistentValueProperty = DependencyProperty.Register(            "PersistentValue", typeof(PrewetPersistentValue), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnItemsSourceChanged)));        /// <summary>        /// PersistentValue        /// </summary>        public PrewetPersistentValue PersistentValue        {            get            {                return (PrewetPersistentValue)this.GetValue(PersistentValueProperty);            }            set            {                this.SetValue(PersistentValueProperty, value);            }        }        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)        {            if (e.NewValue != null)            {                PrewetPersistentValue data = (PrewetPersistentValue)e.NewValue;                d.SetValue(InputPumpSpeedProperty, data.Speed);                          }        }        #endregion        [IgnorePropertyChange]        public ICommand KeyDownCommand        {            get;            private set;        }        private void KeyDownAction(object[] param)        {            if (param.Length >= 1)            {                if (short.TryParse(param[1].ToString(), out short paramValue))                {                    if(paramValue < 300 || paramValue > 7300)                    {                        MessageBox.Show("qualified values 300 ~ 7300", "Invalid Speed Input", MessageBoxButton.OK, MessageBoxImage.Error);                    }                    else                    {                        InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpSpeedKeyDown", paramValue);                    }                                    }            }        }        #region 按钮事件        private void PreparetoTransfer_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PrepareToTransfer");        }        private void KeepWet_Click(object sender, RoutedEventArgs e)        {             InvokeClient.Instance.Service.DoOperation($"{ModuleName}.KeepWet");        }        private void PumpOff_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpDisable");        }        private void PumpOn_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpEnable");        }        private void Auto_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpSpeedAuto");        }        private void Manual_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpSpeedManual");        }        private void Close_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpValveOff");        }        private void Open_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpValveOn");        }        #endregion    }}
 |