123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using Caliburn.Micro.Core;
- using RecipeEditorLib.RecipeModel.Params;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MECF.Framework.UI.Client.CenterViews.Parameter
- {
- public class TempPIDTable : ParameterTable
- {
- private ObservableCollection<PIDData> _pIDDataList = new ObservableCollection<PIDData>();
- public ObservableCollection<PIDData> PIDDataList
- {
- get => _pIDDataList;
- set
- {
- _pIDDataList = value;
- NotifyOfPropertyChange("PIDDataList");
- }
- }
- public TempPIDTable() : base()
- {
- }
- public TempPIDTable(ParameterDataBase recipeData)
- {
- if (recipeData.Steps.Count <= 0) return;
- SetCurrentRecipeStep(recipeData, recipeData.Steps[0]);
- }
- public TempPIDTable(ParameterDataBase recipeData, int selectedStepNo)
- {
- ParameterTable step = recipeData.Steps.Where(x => x.StepNo == selectedStepNo).FirstOrDefault();
- SetCurrentRecipeStep(recipeData, step);
- }
- public void SetTempPIDData(string value)
- {
- if (string.IsNullOrEmpty(value)) return;
- string[] strTempPID = value.Split('|');
- foreach (var item in strTempPID)
- {
- if (string.IsNullOrEmpty(item)) continue;
- string[] subTempPID = item.Split(';');
- Dictionary<string, string> dictTempPID = new Dictionary<string, string>();
- foreach (var pid in subTempPID)
- {
- if (string.IsNullOrEmpty(item)) continue;
- var keyValue = pid.Split(':');
- if (keyValue == null || keyValue.Length != 2) continue;
- dictTempPID[keyValue[0]] = keyValue[1];
- }
- var selectPID = PIDDataList.Where(x => x.Name == dictTempPID["Name"]).FirstOrDefault();
- if (selectPID != null)
- {
- selectPID.P.Value = dictTempPID["P"];
- selectPID.I.Value = dictTempPID["I"];
- selectPID.D.Value = dictTempPID["D"];
- }
- }
- }
- }
- public class PIDData : PropertyChangedBase
- {
- private int _index = 1;
- public int Index
- {
- get => _index;
- set
- {
- _index = value;
- NotifyOfPropertyChange("Index");
- }
- }
- private string _name = "";
- public string Name
- {
- get => _name;
- set
- {
- _name = value;
- NotifyOfPropertyChange("Name");
- }
- }
- private DoubleParam _p;
- public DoubleParam P
- {
- get => _p;
- set
- {
- _p = value;
- NotifyOfPropertyChange("P");
- }
- }
- private DoubleParam _i;
- public DoubleParam I
- {
- get => _i;
- set
- {
- _i = value;
- NotifyOfPropertyChange("I");
- }
- }
- private DoubleParam _d;
- public DoubleParam D
- {
- get => _d;
- set
- {
- _d = value;
- NotifyOfPropertyChange("D");
- }
- }
- public override string ToString()
- {
- string[] rtnStrList = new string[5];
- rtnStrList[0] = $"Index:{Index}";
- rtnStrList[1] = $"Name:{Name}";
- rtnStrList[2] = $"P:{P.Value}";
- rtnStrList[3] = $"I:{I.Value}";
- rtnStrList[4] = $"D:{D.Value}";
- return string.Join(";", rtnStrList);
- }
- }
- }
|