| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 | using Aitex.Core.Common;using LiveCharts;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;namespace PunkHPX8_Themes.UserControls{    /// <summary>    /// TemperatureControllerControl.xaml 的交互逻辑    /// </summary>    public partial class TemperatureControllerControl : UserControl    {        #region 属性        public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(          "ModuleName", typeof(string), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 模块名称        /// </summary>        public string ModuleName        {            get            {                return (string)this.GetValue(ModuleNameProperty);            }            set            {                this.SetValue(ModuleNameProperty, value);            }        }        public static readonly DependencyProperty ModuleTitleProperty = DependencyProperty.Register(           "ModuleTitle", typeof(string), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 标题        /// </summary>        public string ModuleTitle        {            get            {                return (string)this.GetValue(ModuleTitleProperty);            }            set            {                this.SetValue(ModuleTitleProperty, value);            }        }        public static readonly DependencyProperty DisableStatusProperty = DependencyProperty.Register(          "DisableStatus", typeof(string), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 可用性状态        /// </summary>        public string DisableStatus        {            get            {                return (string)this.GetValue(DisableStatusProperty);            }            set            {                this.SetValue(DisableStatusProperty, value);            }        }        public static readonly DependencyProperty IsEnableProperty = DependencyProperty.Register(        "IsEnable", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        ///IsEnable        /// </summary>        public bool IsEnable        {            get            {                return (bool)this.GetValue(IsEnableProperty);            }            set            {                this.SetValue(IsEnableProperty, value);            }        }        public static readonly DependencyProperty IsApplyEnableProperty = DependencyProperty.Register(            "IsApplyEnable", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        ///IsApplyEnable        /// </summary>        public bool IsApplyEnable        {            get            {                return (bool)this.GetValue(IsApplyEnableProperty);            }            set            {                this.SetValue(IsApplyEnableProperty, value);            }        }        public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(         "Status", typeof(string), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata("Normal", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 状态        /// </summary>        public string Status        {            get            {                return (string)this.GetValue(StatusProperty);            }            set            {                this.SetValue(StatusProperty, value);            }        }        public static readonly DependencyProperty AutoStatusProperty = DependencyProperty.Register(         "AutoStatus", typeof(string), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata("Auto", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 自动性状态        /// </summary>        public string AutoStatus        {            get            {                return (string)this.GetValue(AutoStatusProperty);            }            set            {                this.SetValue(AutoStatusProperty, value);            }        }        public static readonly DependencyProperty IsConnectedProperty = DependencyProperty.Register(         "IsConnected", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsConnected        /// </summary>        public bool IsConnected        {            get            {                return (bool)this.GetValue(IsConnectedProperty);            }            set            {                this.SetValue(IsConnectedProperty, value);            }        }        public static readonly DependencyProperty TemperatureReachedProperty = DependencyProperty.Register(          "TemperatureReached", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// TemperatureReached        /// </summary>        public bool TemperatureReached        {            get            {                return (bool)this.GetValue(TemperatureReachedProperty);            }            set            {                this.SetValue(TemperatureReachedProperty, value);            }        }        public static readonly DependencyProperty DeltaExceededProperty = DependencyProperty.Register(          "DeltaExceeded", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// DeltaExceeded        /// </summary>        public bool DeltaExceeded        {            get            {                return (bool)this.GetValue(DeltaExceededProperty);            }            set            {                this.SetValue(DeltaExceededProperty, value);            }        }        #region Alarm        public static readonly DependencyProperty AlarmDataProperty = DependencyProperty.Register(          "AlarmData", typeof(string), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(AlarmDataChanged)));        /// <summary>        /// AlarmData        /// </summary>        public string AlarmData        {            get            {                return (string)this.GetValue(AlarmDataProperty);            }            set            {                this.SetValue(AlarmDataProperty, value);            }        }        private static void AlarmDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)        {            if (e.NewValue != null)            {                string alarm = (string)e.NewValue;                string[] strAry = alarm.Split('-');                int result = 0;                if (strAry.Length == 12)                {                    result += SetAlarmProperty(d, HighTempCutoffProperty, strAry[3] == "1");                    result += SetAlarmProperty(d, LowTempCutoffProperty, strAry[2] == "1");                    result += SetAlarmProperty(d, FanProperty, strAry[1] == "1");                    result += SetAlarmProperty(d, OutputFailureProperty, strAry[0] == "1");                    result += SetAlarmProperty(d, TempLimitWarnProperty, strAry[7] == "1");                    result += SetAlarmProperty(d, RemoteOffProperty, strAry[6] == "1");                    result += SetAlarmProperty(d, ThermostatProperty, strAry[5] == "1");                    result += SetAlarmProperty(d, PowerFailureProperty, strAry[4] == "1");                    result += SetAlarmProperty(d, ExtSensorFailureProperty, strAry[11] == "1");                    result += SetAlarmProperty(d, IntSensorFailureProperty, strAry[10] == "1");                    result += SetAlarmProperty(d, AutoTuningProperty, strAry[9] == "1");                    result += SetAlarmProperty(d, LeakProperty, strAry[8] == "1");                    //if (result == 0)                    //{                    //    d.SetValue(StatusProperty, "Normal");                    //}                    //else                    //{                    //    d.SetValue(StatusProperty, "Error");                    //}                }            }        }        private static int SetAlarmProperty(DependencyObject d,DependencyProperty dependency, bool value)        {            d.SetValue(dependency, value);            return value ? 1 : 0;        }        public static readonly DependencyProperty AutoTuningProperty = DependencyProperty.Register(           "AutoTuning", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// AutoTuning        /// </summary>        public bool AutoTuning        {            get            {                return (bool)this.GetValue(AutoTuningProperty);            }            set            {                this.SetValue(AutoTuningProperty, value);            }        }        public static readonly DependencyProperty FanProperty = DependencyProperty.Register(          "Fan", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// Fan        /// </summary>        public bool Fan        {            get            {                return (bool)this.GetValue(FanProperty);            }            set            {                this.SetValue(FanProperty, value);            }        }        public static readonly DependencyProperty RemoteOffProperty = DependencyProperty.Register(          "RemoteOff", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// RemoteOff        /// </summary>        public bool RemoteOff        {            get            {                return (bool)this.GetValue(RemoteOffProperty);            }            set            {                this.SetValue(RemoteOffProperty, value);            }        }        public static readonly DependencyProperty ExtSensorFailureProperty = DependencyProperty.Register(         "ExtSensorFailure", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// ExtSensorFailure        /// </summary>        public bool ExtSensorFailure        {            get            {                return (bool)this.GetValue(ExtSensorFailureProperty);            }            set            {                this.SetValue(ExtSensorFailureProperty, value);            }        }        public static readonly DependencyProperty HighTempCutoffProperty = DependencyProperty.Register(           "HighTempCutoff", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// HighTempCutoff        /// </summary>        public bool HighTempCutoff        {            get            {                return (bool)this.GetValue(HighTempCutoffProperty);            }            set            {                this.SetValue(HighTempCutoffProperty, value);            }        }        public static readonly DependencyProperty LowTempCutoffProperty = DependencyProperty.Register(           "LowTempCutoff", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// LowTempCutoff        /// </summary>        public bool LowTempCutoff        {            get            {                return (bool)this.GetValue(LowTempCutoffProperty);            }            set            {                this.SetValue(LowTempCutoffProperty, value);            }        }        public static readonly DependencyProperty OutputFailureProperty = DependencyProperty.Register(           "OutputFailure", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// OutputFailure        /// </summary>        public bool OutputFailure        {            get            {                return (bool)this.GetValue(OutputFailureProperty);            }            set            {                this.SetValue(OutputFailureProperty, value);            }        }        public static readonly DependencyProperty IntSensorFailureProperty = DependencyProperty.Register(           "IntSensorFailure", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IntSensorFailure        /// </summary>        public bool IntSensorFailure        {            get            {                return (bool)this.GetValue(IntSensorFailureProperty);            }            set            {                this.SetValue(IntSensorFailureProperty, value);            }        }        public static readonly DependencyProperty TempLimitWarnProperty = DependencyProperty.Register(           "TempLimitWarn", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// TempLimitWarn        /// </summary>        public bool TempLimitWarn        {            get            {                return (bool)this.GetValue(TempLimitWarnProperty);            }            set            {                this.SetValue(TempLimitWarnProperty, value);            }        }        public static readonly DependencyProperty PowerFailureProperty = DependencyProperty.Register(           "PowerFailure", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// PowerFailure        /// </summary>        public bool PowerFailure        {            get            {                return (bool)this.GetValue(PowerFailureProperty);            }            set            {                this.SetValue(PowerFailureProperty, value);            }        }        public static readonly DependencyProperty LeakProperty = DependencyProperty.Register(           "Leak", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// Leak        /// </summary>        public bool Leak        {            get            {                return (bool)this.GetValue(LeakProperty);            }            set            {                this.SetValue(LeakProperty, value);            }        }        public static readonly DependencyProperty ThermostatProperty = DependencyProperty.Register(           "Thermostat", typeof(bool), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// Thermostat        /// </summary>        public bool Thermostat        {            get            {                return (bool)this.GetValue(ThermostatProperty);            }            set            {                this.SetValue(ThermostatProperty, value);            }        }        #endregion        public static readonly DependencyProperty SetPointValueProperty = DependencyProperty.Register(         "SetPointValue", typeof(double), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata((double)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// SetPointValue        /// </summary>        public double SetPointValue        {            get            {                return (double)this.GetValue(SetPointValueProperty);            }            set            {                this.SetValue(SetPointValueProperty, value);            }        }        public static readonly DependencyProperty SetPointMinValueProperty = DependencyProperty.Register(      "SetPointMinValue", typeof(double), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata((double)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// SetPointMinValue        /// </summary>        public double SetPointMinValue        {            get            {                return (double)this.GetValue(SetPointMinValueProperty);            }            set            {                this.SetValue(SetPointMinValueProperty, value);            }        }        public static readonly DependencyProperty SetPointMaxValueProperty = DependencyProperty.Register(      "SetPointMaxValue", typeof(double), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata((double)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// SetPointMaxValue        /// </summary>        public double SetPointMaxValue        {            get            {                return (double)this.GetValue(SetPointMaxValueProperty);            }            set            {                this.SetValue(SetPointMaxValueProperty, value);            }        }        public static readonly DependencyProperty TargetTemperatureValueProperty = DependencyProperty.Register(    "TargetTemperatureValue", typeof(double), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata((double)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// TargetTemperatureValue        /// </summary>        public double TargetTemperatureValue        {            get            {                return (double)this.GetValue(TargetTemperatureValueProperty);            }            set            {                this.SetValue(TargetTemperatureValueProperty, value);            }        }        public static readonly DependencyProperty ReserviorValueProperty = DependencyProperty.Register(   "ReserviorValue", typeof(double), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata((double)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// ReserviorValue        /// </summary>        public double ReserviorValue        {            get            {                return (double)this.GetValue(ReserviorValueProperty);            }            set            {                this.SetValue(ReserviorValueProperty, value);            }        }        public static readonly DependencyProperty HeatExchangerValueProperty = DependencyProperty.Register(   "HeatExchangerValue", typeof(double), typeof(TemperatureControllerControl), new FrameworkPropertyMetadata((double)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// HeatExchangerValue        /// </summary>        public double HeatExchangerValue        {            get            {                return (double)this.GetValue(HeatExchangerValueProperty);            }            set            {                this.SetValue(HeatExchangerValueProperty, value);            }        }        #region 曲线        public static readonly DependencyProperty ReserviorSeriesProperty = DependencyProperty.Register("ReserviorSeries", typeof(ChartValues<double>), typeof(TemperatureControllerControl),            new FrameworkPropertyMetadata(new ChartValues<double>(), FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// ReserviorSeries        /// </summary>        public ChartValues<double> ReserviorSeries        {            get            {                return (ChartValues<double>)this.GetValue(ReserviorSeriesProperty);            }            set            {                this.SetValue(ReserviorSeriesProperty, value);            }        }        public static readonly DependencyProperty HeatExchangerSeriesProperty = DependencyProperty.Register("HeatExchangerSeries", typeof(ChartValues<double>), typeof(TemperatureControllerControl),            new FrameworkPropertyMetadata(new ChartValues<double>(), FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// HeatExchangerSeries        /// </summary>        public ChartValues<double> HeatExchangerSeries        {            get            {                return (ChartValues<double>)this.GetValue(HeatExchangerSeriesProperty);            }            set            {                this.SetValue(HeatExchangerSeriesProperty, value);            }        }        public static readonly DependencyProperty LabelSeriesProperty = DependencyProperty.Register("LabelSeries", typeof(ChartValues<string>), typeof(TemperatureControllerControl),            new FrameworkPropertyMetadata(new ChartValues<string>(), FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// LabelSeries        /// </summary>        public ChartValues<string> LabelSeries        {            get            {                return (ChartValues<string>)this.GetValue(LabelSeriesProperty);            }            set            {                this.SetValue(LabelSeriesProperty, value);            }        }        #endregion        #endregion        /// <summary>        /// 构造函数        /// </summary>        public TemperatureControllerControl()        {            InitializeComponent();        }        #region Button Click        private void Disable_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Disable");        }        private void Enable_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Enable");        }        private void Apply_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Apply", SetPointValue, SetPointMinValue,SetPointMaxValue);        }        #endregion    }}
 |