| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Diagnostics;
 
- using System.Linq;
 
- using System.Reflection;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Shell;
 
- using Aitex.Core.Common.DeviceData;
 
- using Aitex.Core.RT.IOCore;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.UI.DeviceControl;
 
- using Aitex.Core.Util;
 
- using Caliburn.Micro.Core;
 
- using FurnaceUI.Models;
 
- using FurnaceUI.Views.Recipes;
 
- using MECF.Framework.Common.CommonData.DeviceData;
 
- using MECF.Framework.Common.DataCenter;
 
- using MECF.Framework.Common.Device;
 
- using MECF.Framework.Common.OperationCenter;
 
- using MECF.Framework.UI.Client.CenterViews.Dialogs;
 
- using OpenSEMI.ClientBase;
 
- namespace FurnaceUI.Views.Maintenances
 
- {
 
-     public class FFUConfigViewModel : FurnaceUIViewModelBase
 
-     {
 
-         public bool SetField<T>(ref T field, T value, string propertyName)
 
-         {
 
-             if (EqualityComparer<T>.Default.Equals(field, value)) return false;
 
-             field = value;
 
-             NotifyOfPropertyChange(propertyName);
 
-             return true;
 
-         }
 
-         [Subscription("System.FFUKeyDict")]
 
-         public List<string> FFUKeyDict { get; set; }
 
-         public bool IsPermission { get => this.Permission == 3; }
 
-         private ObservableCollection<FFUData> _ffuDatas = new ObservableCollection<FFUData>();
 
-         public ObservableCollection<FFUData> FFUDataList
 
-         {
 
-             get => _ffuDatas;
 
-             set
 
-             {
 
-                 _ffuDatas = value;
 
-                 NotifyOfPropertyChange(nameof(FFUDataList));
 
-             }
 
-         }
 
-         private bool _powerOffVisibility = false;
 
-         public bool PowerOffVisibility
 
-         {
 
-             get => _powerOffVisibility;
 
-             set => SetField(ref _powerOffVisibility, value, nameof(PowerOffVisibility));
 
-         }
 
-         private bool _powerOnVisibility = true;
 
-         public bool PowerOnVisibility
 
-         {
 
-             get => _powerOnVisibility;
 
-             set => SetField(ref _powerOnVisibility, value, nameof(PowerOnVisibility));
 
-         }
 
-         protected override void OnActivate()
 
-         {
 
-             base.OnActivate();
 
-             FFUKeyDict = QueryDataClient.Instance.Service.GetData("System.FFUKeyDict") as List<string>;
 
-             FFUDataList.Clear();
 
-             foreach (var item in FFUKeyDict)
 
-             {
 
-                 var deviceName = item.Split('.').ToList()[1];
 
-                 var ffuConfigData = QueryDataClient.Instance.Service.GetConfig($"FFU.{deviceName}.SetSpeed");
 
-                 FFUDataList.Add(new FFUData()
 
-                 {
 
-                     RTName = deviceName,
 
-                     Value = ffuConfigData.ToString(),
 
-                 });
 
-             }
 
-         }
 
-         protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
 
-         {
 
-             base.InvokeAfterUpdateProperty(data);
 
-             if (FFUDataList != null && FFUDataList.Count > 0)
 
-             {
 
-                 var allFfuName = FFUDataList.Select(a => $"PM1.{a.RTName}.DeviceData").ToList();
 
-                 var allRtData = QueryDataClient.Instance.Service.PollData(allFfuName);
 
-                 foreach (var item in FFUDataList)
 
-                 {
 
-                     var rtItem = allRtData.FirstOrDefault(a => a.Key == $"PM1.{item.RTName}.DeviceData");
 
-                     if (rtItem.Value == null)
 
-                         continue;
 
-                     item.DisplayName = ((AITFFUData)rtItem.Value).DisplayName;
 
-                     item.ActualValue = ((AITFFUData)rtItem.Value).Feedback;
 
-                     item.IsSwitch = ((AITFFUData)rtItem.Value).IsSwitchOn;
 
-                 }
 
-             }
 
-         }
 
-         public void AllFFUPower(string value)
 
-         {
 
-             var setValue = bool.Parse(value);
 
-             if (setValue)
 
-             {
 
-                 PowerOnVisibility = false;
 
-                 PowerOffVisibility = true;
 
-             }
 
-             else
 
-             {
 
-                 PowerOnVisibility = true;
 
-                 PowerOffVisibility = false;
 
-             }
 
-             InvokeClient.Instance.Service.DoOperation($"PM1.SetAllFFUPower", setValue);
 
-         }
 
-         public void SetValueTextChanged(string type, object sender, object item)
 
-         {
 
-             try
 
-             {
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.Write(ex);
 
-             }
 
-         }
 
-         public void Save()
 
-         {
 
-             if (!DialogBox.Confirm("Are you sure Determine the speed parameters for  FFU"))
 
-                 return;
 
-             foreach (var item in FFUDataList)
 
-             {
 
-                 InvokeClient.Instance.Service.DoOperation($"PM1.{item.RTName}.SetCurrectSpeed", item.Value);
 
-             }
 
-             (GetView() as Window).Close();
 
-         }
 
-         public void Cancle()
 
-         {
 
-             (GetView() as Window).Close();
 
-         }
 
-         public void AllSetClick(object sender)
 
-         {
 
-             string stSetValue = ShowNumberKeyboard(sender as Button, "", 1);
 
-             var values = QueryDataClient.Instance.Service.PollData(FFUKeyDict).Values.Select(a => (a as AITFFUData)).ToList();
 
-             foreach (var item in FFUDataList)
 
-             {
 
-                 var rtData = values.FirstOrDefault(a => a.RTName == item.RTName);
 
-                 if (rtData == null)
 
-                     continue;
 
-                 item.Value = stSetValue;
 
-             }
 
-         }
 
-         private string ShowNumberKeyboard(Control control, string defaultValue, int keepDecimals = -1)
 
-         {
 
-             NumberKeyboard numberKeyboard = new NumberKeyboard("", defaultValue);
 
-             numberKeyboard.KeepDecimals = keepDecimals;
 
-             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 class FFUData : PropertyChangedBase
 
-     {
 
-         private int _no;
 
-         public int No
 
-         {
 
-             get => _no;
 
-             set
 
-             {
 
-                 _no = value;
 
-                 NotifyOfPropertyChange(nameof(No));
 
-             }
 
-         }
 
-         private string _rtName;
 
-         public string RTName
 
-         {
 
-             get => _rtName;
 
-             set
 
-             {
 
-                 _rtName = value;
 
-                 NotifyOfPropertyChange(nameof(RTName));
 
-             }
 
-         }
 
-         private string _displayName;
 
-         public string DisplayName
 
-         {
 
-             get => _displayName;
 
-             set
 
-             {
 
-                 _displayName = value;
 
-                 NotifyOfPropertyChange(nameof(DisplayName));
 
-             }
 
-         }
 
-         private double _lastSetValue;
 
-         public double LastSetValue
 
-         {
 
-             get => _lastSetValue;
 
-             set
 
-             {
 
-                 _lastSetValue = value;
 
-                 NotifyOfPropertyChange(nameof(LastSetValue));
 
-             }
 
-         }
 
-         private double _actualValue;
 
-         public double ActualValue
 
-         {
 
-             get => _actualValue;
 
-             set
 
-             {
 
-                 _actualValue = value;
 
-                 NotifyOfPropertyChange(nameof(ActualValue));
 
-             }
 
-         }
 
-         private string _value;
 
-         public string Value
 
-         {
 
-             get => _value;
 
-             set
 
-             {
 
-                 _value = value;
 
-                 NotifyOfPropertyChange(nameof(Value));
 
-             }
 
-         }
 
-         private bool _isSwitch;
 
-         public bool IsSwitch
 
-         {
 
-             get => _isSwitch;
 
-             set
 
-             {
 
-                 _isSwitch = value;
 
-                 NotifyOfPropertyChange(nameof(IsSwitch));
 
-             }
 
-         }
 
-         private string _maxValue;
 
-         public string MaxValue
 
-         {
 
-             get => _maxValue; set
 
-             {
 
-                 _maxValue = value;
 
-                 NotifyOfPropertyChange(nameof(MaxValue));
 
-             }
 
-         }
 
-         private string _minValue;
 
-         public string MinValue
 
-         {
 
-             get => _minValue; set
 
-             {
 
-                 _minValue = value;
 
-                 NotifyOfPropertyChange(nameof(MinValue));
 
-             }
 
-         }
 
-         private bool _isSetChanged = true;
 
-         public bool IsSetChanged
 
-         {
 
-             get => _isSetChanged;
 
-             set
 
-             {
 
-                 _isSetChanged = value;
 
-                 NotifyOfPropertyChange(nameof(IsSetChanged));
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |