| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 | using System;using System.Collections.Generic;using System.Linq;using Aitex.Core.Util;using Aitex.Core.Common.DeviceData;using System.Text;using System.Threading.Tasks;using System.Windows;using FurnaceUI.Models;using Caliburn.Micro;using Caliburn.Micro.Core;using System.Windows.Controls;using MECF.Framework.UI.Client.CenterViews.Dialogs;using FurnaceUI.Views.Editors;using OpenSEMI.ClientBase;using MECF.Framework.Common.OperationCenter;using FurnaceUI.Client;using MECF.Framework.Common.DataCenter;namespace FurnaceUI.Views.Operations{    public class TemperatureDetailViewModel : FurnaceUIViewModelBase    {        public bool IsManagerPermission { get; set; } = false;        public bool IsLspMode { get; set; } = false;        [Subscription("System.Heater1.DeviceData")]        public AITHeaterData Heater1Data { get; set; }        [Subscription("System.Heater2.DeviceData")]        public AITHeaterData Heater2Data { get; set; }        [Subscription("System.Heater3.DeviceData")]        public AITHeaterData Heater3Data { get; set; }        [Subscription("System.Heater4.DeviceData")]        public AITHeaterData Heater4Data { get; set; }        [Subscription("System.Heater5.DeviceData")]        public AITHeaterData Heater5Data { get; set; }        [Subscription("PM1.BottomHeaterData")]        public AITHeaterData BottomHeaterData { get; set; }        [Subscription("PM1.CenterBottomHeaterData")]        public AITHeaterData CenterBottomHeaterData { get; set; }        [Subscription("PM1.CenterHeaterData")]        public AITHeaterData CenterHeaterData { get; set; }        [Subscription("PM1.TopCenterHeaterData")]        public AITHeaterData TopCenterHeaterData { get; set; }        [Subscription("PM1.TopHeaterData")]        public AITHeaterData TopHeaterData { get; set; }        [Subscription("PM1.Status")]        public string PM1Status { get; set; }        [Subscription("PM1.RecipeHold")]        public bool PM1RecipeHold { get; set; }        public bool IsMannualButtonEnabled        {            get            {                return PM1Status != "Process" || (PM1Status == "Process" && PM1RecipeHold);            }        }        #region AnaLog        [Subscription("PM1.HTCurrent1.DeviceData")]        public AITWaterFlowMeterData HTCurrent1 { get; set; }        [Subscription("PM1.HTCurrent2.DeviceData")]        public AITWaterFlowMeterData HTCurrent2 { get; set; }        [Subscription("PM1.HTCurrent3.DeviceData")]        public AITWaterFlowMeterData HTCurrent3 { get; set; }        [Subscription("PM1.HTCurrent4.DeviceData")]        public AITWaterFlowMeterData HTCurrent4 { get; set; }        [Subscription("PM1.HTCurrent5.DeviceData")]        public AITWaterFlowMeterData HTCurrent5 { get; set; }        [Subscription("PM1.HTVoltage1.DeviceData")]        public AITWaterFlowMeterData HTVoltage1 { get; set; }        [Subscription("PM1.HTVoltage2.DeviceData")]        public AITWaterFlowMeterData HTVoltage2 { get; set; }        [Subscription("PM1.HTVoltage3.DeviceData")]        public AITWaterFlowMeterData HTVoltage3 { get; set; }        [Subscription("PM1.HTVoltage4.DeviceData")]        public AITWaterFlowMeterData HTVoltage4 { get; set; }        [Subscription("PM1.HTVoltage5.DeviceData")]        public AITWaterFlowMeterData HTVoltage5 { get; set; }        public string HTCurrent1Feedback { get; set; }        public string HTCurrent2Feedback { get; set; }        public string HTCurrent3Feedback { get; set; }        public string HTCurrent4Feedback { get; set; }        public string HTCurrent5Feedback { get; set; }        public string HTVoltage1Feedback { get; set; }        public string HTVoltage2Feedback { get; set; }        public string HTVoltage3Feedback { get; set; }        public string HTVoltage4Feedback { get; set; }        public string HTVoltage5Feedback { get; set; }        #endregion        public Dictionary<string, double> _dicTemperatualMaxValue;        private string _topHeaterSetPoint;        public string TopHeaterSetPoint        {            get { return _topHeaterSetPoint; }            set            {                _topHeaterSetPoint = value;                NotifyOfPropertyChange("TopHeaterSetPoint");            }        }        private string _topCenterHeaterSetPoint;        public string TopCenterHeaterSetPoint        {             get { return _topCenterHeaterSetPoint; }            set             {                _topCenterHeaterSetPoint = value;                NotifyOfPropertyChange("TopCenterHeaterSetPoint");            }                }        private string _centerHeaterSetPoint;        public string CenterHeaterSetPoint        {            get { return _centerHeaterSetPoint; }            set            {                _centerHeaterSetPoint = value;                NotifyOfPropertyChange("CenterHeaterSetPoint");            }        }        private string _centerBottomHeaterSetPoint;        public string CenterBottomHeaterSetPoint        {            get { return _centerBottomHeaterSetPoint; }            set            {                _centerBottomHeaterSetPoint = value;                NotifyOfPropertyChange("CenterBottomHeaterSetPoint");            }        }        private string _bottomHeaterSetPoint;        public string BottomHeaterSetPoint        {            get { return _bottomHeaterSetPoint; }            set            {                _bottomHeaterSetPoint = value;                NotifyOfPropertyChange("BottomHeaterSetPoint");            }        }        private bool _isEnableMannual = false;        public bool IsEnableMannual        {            get => _isEnableMannual;            set            {                _isEnableMannual = value;                NotifyOfPropertyChange(nameof(IsEnableMannual));            }        }        private int _mannualSelectCount;        private string _lspModel;        public string LspModel         {            get => _lspModel;            set            {                _lspModel = value;                NotifyOfPropertyChange(nameof(LspModel));            }        }        private string _topHeaterRampSetPoint;        public string TopHeaterRampSetPoint        {            get => _topHeaterRampSetPoint;            set            {                _topHeaterRampSetPoint = value;                NotifyOfPropertyChange(nameof(TopHeaterRampSetPoint));            }        }        private string _topCenterHeaterRampSetPoint;        public string TopCenterHeaterRampSetPoint        {            get => _topCenterHeaterRampSetPoint;            set            {                _topCenterHeaterRampSetPoint = value;                NotifyOfPropertyChange(nameof(TopCenterHeaterRampSetPoint));            }        }        private string _centerHeaterRampSetPoint;        public string CenterHeaterRampSetPoint        {            get => _centerHeaterRampSetPoint;            set            {                _centerHeaterRampSetPoint = value;                NotifyOfPropertyChange(nameof(CenterHeaterRampSetPoint));            }        }        private string _bottomCenterHeaterRampSetPoint;        public string BottomCenterHeaterRampSetPoint        {            get => _bottomCenterHeaterRampSetPoint;            set            {                _bottomCenterHeaterRampSetPoint = value;                NotifyOfPropertyChange(nameof(BottomCenterHeaterRampSetPoint));            }        }        private string _bottomHeaterRampSetPoint;        public string BottomHeaterRampSetPoint        {            get => _bottomHeaterRampSetPoint;            set            {                _bottomHeaterRampSetPoint = value;                NotifyOfPropertyChange(nameof(BottomHeaterRampSetPoint));            }        }        //public string ProfileTable        //{        //    get        //    {        //        return (string.IsNullOrEmpty(Heater2Data.ProfileTable) || Heater2Data.ProfileTable == "None") ? "None" : Heater2Data.ProfileTable;        //    }        //}        protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)        {            if (!IsEnableMannual)            {                //LspModel= Heater2Data.IsLspModeFeedBack ? "Outer Control" : "Inner Control";                //InitSetPoint();                //InitRampRate();            }        }        public void InitSetPoint()         {            TopHeaterSetPoint = TopHeaterData.SetPoint.ToString("F1");            TopCenterHeaterSetPoint = TopCenterHeaterData.SetPoint.ToString("F1");            CenterHeaterSetPoint = CenterHeaterData.SetPoint.ToString("F1");            CenterBottomHeaterSetPoint = CenterBottomHeaterData.SetPoint.ToString("F1");            BottomHeaterSetPoint = BottomHeaterData.SetPoint.ToString("F1");            HTCurrent1Feedback = HTCurrent1?.FeedBack.ToString("F3");            HTCurrent2Feedback = HTCurrent2?.FeedBack.ToString("F3");            HTCurrent3Feedback = HTCurrent3?.FeedBack.ToString("F3");            HTCurrent4Feedback = HTCurrent4?.FeedBack.ToString("F3");            HTCurrent5Feedback = HTCurrent5?.FeedBack.ToString("F3");            HTVoltage1Feedback = HTVoltage1?.FeedBack.ToString("F3");            HTVoltage2Feedback = HTVoltage2?.FeedBack.ToString("F3");            HTVoltage3Feedback = HTVoltage3?.FeedBack.ToString("F3");            HTVoltage4Feedback = HTVoltage4?.FeedBack.ToString("F3");            HTVoltage5Feedback = HTVoltage5?.FeedBack.ToString("F3");        }        public void InitRampRate()         {            TopHeaterRampSetPoint = CompterRampPoint(TopHeaterData).ToString("F1");            TopCenterHeaterRampSetPoint = CompterRampPoint(TopCenterHeaterData).ToString("F1");            CenterHeaterRampSetPoint = CompterRampPoint(CenterHeaterData).ToString("F1");            BottomCenterHeaterRampSetPoint = CompterRampPoint(CenterBottomHeaterData).ToString("F1");            BottomHeaterRampSetPoint = CompterRampPoint(BottomHeaterData).ToString("F1");        }        protected override void OnInitialize()        {            base.OnInitialize();            string[] strTempsNames = { "Heater1", "Heater3", "Heater5", "Heater7", "Heater9", "Heater2", "Heater4", "Heater6", "Heater8", "Heater10" };            _dicTemperatualMaxValue = new Dictionary<string, double>();            //获取温度限制配置信息            for (int i = 0; i < strTempsNames.Length; i++)            {                object obj = QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{strTempsNames[i]}.Range");                _dicTemperatualMaxValue.Add(strTempsNames[i],Convert.ToDouble(obj));            }        }        public void MannualSelectCmd()         {            _mannualSelectCount++;            if (_mannualSelectCount == 1)             {                IsEnableMannual = true;            }            else             {                _mannualSelectCount = 0;                IsEnableMannual = false;            }        }        public double CompterRampPoint(AITHeaterData data)         {            if(data.IsLspModeFeedBack)            {                return data.FeedBack >= data.SetPoint ? data.LspDecreaseRampRateFeedBack : data.LspIncreaseRampRateFeedBack;            }            else             {                return data.FeedBack >= data.SetPoint ? data.RspDecreaseRampRateFeedBack : data.RspIncreaseRampRateFeedBack;            }        }        public void ManualCmd()        {            //((Window)GetView()).DialogResult = true;             var wm = IoC.Get<IWindowManager>();            SetTemperatureViewModel setTemperatureViewModel = new SetTemperatureViewModel();            (wm as WindowManager)?.ShowDialogWithTitle(setTemperatureViewModel, null, "Set Temperature");        }        public void SetCmd(object senderName, object sender, object typeName)        {            double temval = 0;            string name = senderName.ToString();            switch (typeName.ToString())            {                case "setpoint":                    double maxvalue = 0;                    string tName = GetTempratualMaxValue(name);                    if (!string.IsNullOrEmpty(tName))                     {                        maxvalue = _dicTemperatualMaxValue[tName];                    }                                        string strRetValue = ShowNumberKeyboard(sender as Button, "",true, maxvalue);                    if (strRetValue != "Cancel")                    {                        //if (double.TryParse(strRetValue, out temval))                        {                            SelectPostionSetPoint(name, strRetValue);                        }                    }                    break;                case "ramp":                    strRetValue = ShowNumberKeyboard(sender as Button,"",false,0);                    if (strRetValue != "Cancel")                    {                        //if (double.TryParse(strRetValue, out temval))                        {                            SelectPositionRamp(name, strRetValue);                        }                    }                    break;            }        }        private string GetTempratualMaxValue(string typeName)         {            string dicName = string.Empty;            bool isLspMode = LspModel!= "Outer Control";            switch (typeName)             {                case "TopHeater":                    dicName = isLspMode ? "Heater1" : "Heater2";                    break;                case "TopCenterHeater":                    dicName = isLspMode ? "Heater3" : "Heater4";                    break;                case "CenterHeater":                    dicName = isLspMode ? "Heater5" : "Heater6";                    break;                case "CenterBottomHeater":                    dicName = isLspMode ? "Heater7" : "Heater8";                    break;                case "BottomHeater":                    dicName = isLspMode ? "Heater9" : "Heater10";                    break;            }            return dicName;        }        private void SelectPostionSetPoint(string name,string value)         {            switch (name)             {                case "TopHeater":                    TopHeaterSetPoint = value;                    break;                case "TopCenterHeater":                    TopCenterHeaterSetPoint = value;                    break;                case "CenterHeater":                    CenterHeaterSetPoint = value;                    break;                case "CenterBottomHeater":                    CenterBottomHeaterSetPoint = value;                    break;                case "BottomHeater":                    BottomHeaterSetPoint = value;                    break;            }        }        private void SelectPositionRamp(string name, string value)        {            switch (name)            {                case "TopHeater":                    TopHeaterRampSetPoint = value;                    break;                case "TopCenterHeater":                    TopCenterHeaterRampSetPoint = value;                    break;                case "CenterHeater":                    CenterHeaterRampSetPoint = value;                    break;                case "CenterBottomHeater":                    BottomCenterHeaterRampSetPoint = value;                    break;                case "BottomHeater":                    BottomHeaterRampSetPoint = value;                    break;            }        }        private string ShowNumberKeyboard(Control control, string defaultValue,bool isValidate,double maxValue=double.MaxValue)        {            NumberKeyboard numberKeyboard = new NumberKeyboard("", defaultValue);            var point = control.PointFromScreen(new Point(0, 0));            double wx = SystemParameters.WorkArea.Width;            double hy = SystemParameters.WorkArea.Height;            if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < hy)            {                numberKeyboard.Top = -point.Y + control.ActualHeight + 5;            }            else            {                numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;            }            if (-point.X + numberKeyboard.Width < wx)            {                numberKeyboard.Left = -point.X;            }            else            {                numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);            }            if ((bool)numberKeyboard.ShowDialog())                return numberKeyboard.ValueString;            else                return "Cancel";        }        public void SelectControlMode()         {            var windowManager = IoC.Get<IWindowManager>();            RecipeConditionCheckConModeViewModel recipeConditionCheckConModeViewModel = new RecipeConditionCheckConModeViewModel();            recipeConditionCheckConModeViewModel.SelectControlMode = LspModel;            var result = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeConditionCheckConModeViewModel, null, "Temperature Control Mode Setting");            LspModel = recipeConditionCheckConModeViewModel.SelectControlMode;        }        public void AllZone(string obj)        {            var windowManager = IoC.Get<IWindowManager>();            TemperatureDetailAllZoneViewModel temperatureDetailAllZoneViewModel = new TemperatureDetailAllZoneViewModel();            switch (obj)            {                case "Set":                    if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(temperatureDetailAllZoneViewModel, null, "Temperature Value Set"))                    {                        TopHeaterSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        TopCenterHeaterSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        CenterHeaterSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        CenterBottomHeaterSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        BottomHeaterSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                    }                    break;                case "Ramp":                    if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(temperatureDetailAllZoneViewModel, null, "Temperature Ramp Set"))                    {                        TopHeaterRampSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        TopCenterHeaterRampSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        CenterHeaterRampSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        BottomCenterHeaterRampSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                        BottomHeaterRampSetPoint = temperatureDetailAllZoneViewModel.TempSetValue;                    }                    break;                default:                    break;            }        }        public void ExecCmd()        {            if (!DialogBox.Confirm("Ara you sure to execute?"))                return;            if (LspModel != "Outer Control")            {                InvokeClient.Instance.Service.DoOperation("PM1.Heater1.SetParameters", $"{BottomHeaterSetPoint};{BottomHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater2.SetParameters", $"{BottomHeaterSetPoint};{BottomHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater3.SetParameters", $"{CenterBottomHeaterSetPoint};{BottomCenterHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater4.SetParameters", $"{CenterBottomHeaterSetPoint};{BottomCenterHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater5.SetParameters", $"{CenterHeaterSetPoint};{CenterHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater6.SetParameters", $"{CenterHeaterSetPoint};{CenterHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater7.SetParameters", $"{TopCenterHeaterSetPoint};{TopCenterHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater8.SetParameters", $"{TopCenterHeaterSetPoint};{TopCenterHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater9.SetParameters", $"{TopHeaterSetPoint};{TopHeaterRampSetPoint};inner");                InvokeClient.Instance.Service.DoOperation("PM1.Heater10.SetParameters", $"{TopHeaterSetPoint};{TopHeaterRampSetPoint};inner");            }            else            {                InvokeClient.Instance.Service.DoOperation("PM1.Heater1.SetParameters", $"{BottomHeaterSetPoint};{BottomHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater2.SetParameters", $"{BottomHeaterSetPoint};{BottomHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater3.SetParameters", $"{CenterBottomHeaterSetPoint};{BottomCenterHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater4.SetParameters", $"{CenterBottomHeaterSetPoint};{BottomCenterHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater5.SetParameters", $"{CenterHeaterSetPoint};{CenterHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater6.SetParameters", $"{CenterHeaterSetPoint};{CenterHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater7.SetParameters", $"{TopCenterHeaterSetPoint};{TopCenterHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater8.SetParameters", $"{TopCenterHeaterSetPoint};{TopCenterHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater9.SetParameters", $"{TopHeaterSetPoint};{TopHeaterRampSetPoint};outer");                InvokeClient.Instance.Service.DoOperation("PM1.Heater10.SetParameters", $"{TopHeaterSetPoint};{TopHeaterRampSetPoint};outer");            }            _mannualSelectCount = 0;            IsEnableMannual = false;        }        public void CloseCmd()        {            ClientApp.Instance.SwitchPage("status", "main", null);        }    }}
 |