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 TempCorrectionTable : ParameterTable { private DoubleParam _profileTCCalibTemp; public DoubleParam ProfileTCCalibTemp { get => _profileTCCalibTemp; set { _profileTCCalibTemp = value; NotifyOfPropertyChange("ProfileTCCalibTemp"); } } private NumParam _profileConditionTableNo; public NumParam ProfileConditionTableNo { get => _profileConditionTableNo; set { _profileConditionTableNo = value; NotifyOfPropertyChange("ProfileConditionTableNo"); } } private NumParam _tableNo; public NumParam TableNo { get => _tableNo; set { _tableNo = value; NotifyOfPropertyChange("TableNo"); } } private DoubleParam _tableUseRangeMin; public DoubleParam TableUseRangeMin { get => _tableUseRangeMin; set { _tableUseRangeMin = value; NotifyOfPropertyChange("TableUseRangeMin"); } } private DoubleParam _tableUseRangeMax ; public DoubleParam TableUseRangeMax { get => _tableUseRangeMax; set { _tableUseRangeMax = value; NotifyOfPropertyChange("TableUseRangeMax"); } } private string _profileLastUpdate = ""; public string ProfileLastUpdate { get => _profileLastUpdate; set { _profileLastUpdate = value; NotifyOfPropertyChange("ProfileLastUpdate"); } } private ObservableCollection _correctionDataList = new ObservableCollection(); public ObservableCollection CorrectionDataList { get => _correctionDataList; set { _correctionDataList = value; NotifyOfPropertyChange("CorrectionDataList"); } } public TempCorrectionTable() : base() { } public TempCorrectionTable(ParameterDataBase recipeData) { if (recipeData.Steps.Count <= 0) return; SetCurrentRecipeStep(recipeData, recipeData.Steps[0]); } public TempCorrectionTable(ParameterDataBase recipeData, int selectedStepNo) { ParameterTable step = recipeData.Steps.Where(x => x.StepNo == selectedStepNo).FirstOrDefault(); SetCurrentRecipeStep(recipeData, step); } public void SetTempCorrectionData(string value) { if (string.IsNullOrEmpty(value)) return; string[] strTempCorrection = value.Split('|'); foreach (var item in strTempCorrection) { if (string.IsNullOrEmpty(item)) continue; string[] subTempCorrection = item.Split(';'); Dictionary dictTempCorrection = new Dictionary(); foreach (var pid in subTempCorrection) { if (string.IsNullOrEmpty(item)) continue; var keyValue = pid.Split(':'); if (keyValue == null || keyValue.Length != 2) continue; dictTempCorrection[keyValue[0]] = keyValue[1]; } var selectCorrection = CorrectionDataList.Where(x => x.Name == dictTempCorrection["Name"]).FirstOrDefault(); if (selectCorrection != null) { selectCorrection.ProfileTemp.Value = dictTempCorrection["ProfileTemp"]; selectCorrection.ProfileCorrect.Value = dictTempCorrection["ProfileCorrect"]; selectCorrection.CascadeTCCorrect.Value = dictTempCorrection["CascadeTCCorrect"]; selectCorrection.ProfileTCCalib.Value = dictTempCorrection["ProfileTCCalib"]; } } } } public class CorrectionData : 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 _profileTemp; public DoubleParam ProfileTemp { get => _profileTemp; set { _profileTemp = value; NotifyOfPropertyChange("ProfileTemp"); } } private DoubleParam _profileCorrect; public DoubleParam ProfileCorrect { get => _profileCorrect; set { _profileCorrect = value; NotifyOfPropertyChange("ProfileCorrect"); } } private DoubleParam _cascadeTCCorrect; public DoubleParam CascadeTCCorrect { get => _cascadeTCCorrect; set { _cascadeTCCorrect = value; NotifyOfPropertyChange("CascadeTCCorrect"); } } private DoubleParam _profileTCCalib; public DoubleParam ProfileTCCalib { get => _profileTCCalib; set { _profileTCCalib = value; NotifyOfPropertyChange("ProfileTCCalib"); } } public override string ToString() { string[] rtnStrList = new string[6]; rtnStrList[0] = $"Index:{Index}"; rtnStrList[1] = $"Name:{Name}"; rtnStrList[2] = $"ProfileTemp:{ProfileTemp.Value}"; rtnStrList[3] = $"ProfileCorrect:{ProfileCorrect.Value}"; rtnStrList[4] = $"CascadeTCCorrect:{CascadeTCCorrect.Value}"; rtnStrList[5] = $"ProfileTCCalib:{ProfileTCCalib.Value}"; return string.Join(";", rtnStrList); } } }