123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.ParameterCenter;
- using Caliburn.Micro.Core;
- using MECF.Framework.Common.ParameterCenter;
- using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
- using RecipeEditorLib.RecipeModel.Params;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Xml;
- namespace MECF.Framework.UI.Client.CenterViews.Parameter
- {
- public class TempCorrectionParameterData : ParameterDataBase
- {
- private ParameterProvider _parameterProvider = new ParameterProvider();
- private ParameterFormatBuilder _columnBuilder = new ParameterFormatBuilder();
- private Dictionary<string, ObservableCollection<ParameterTemplateColumnBase>> ParameterTemplate;
- public TempCorrectionParameterData() : base()
- {
- string vars = _parameterProvider.GetParameterFormatXml($"Parameter\\TempCorrection");
- _columnBuilder.Build($"Parameter\\TempCorrection");
- ParameterTemplate = _parameterProvider.GetGroupParameterTemplate();
- TableNumber = _columnBuilder.TableNumber;
- Version = _columnBuilder.Version;
- for (int i = 1; i < TableNumber+1; i++)
- {
- Steps.Add(CreateStep());
- }
- }
- public override ParameterTable CreateStep(XmlNode stepNode = null)
- {
- ParameterTable table = new TempCorrectionTable();
- var step = table as TempCorrectionTable;
- if (stepNode != null)
- {
- if (stepNode.Attributes["StepNo"] != null)
- step.StepNo = int.Parse(stepNode.Attributes["StepNo"].Value);
- if (stepNode.Attributes["Name"] != null)
- step.Name = stepNode.Attributes["Name"].Value;
- }
- else
- {
- step.StepNo = StepNo;
- step.Name = "Name" + StepNo.ToString();
- // step.UseTemp = "0";
- StepNo++;
-
- }
- int pIDIndex = 1;
- var profileTCCalibTempcom = ParameterTemplate["Parameter Information"].Where(x => x.ControlName == "ProfileTCCalibTemp").FirstOrDefault();
- if (profileTCCalibTempcom != null)
- {
- DoubleParam profileTCCalibParam = new DoubleParam()
- {
- Name = profileTCCalibTempcom.ControlName,
- Value = profileTCCalibTempcom.Value.ToString(),
- DisplayName = profileTCCalibTempcom.DisplayName,
- Minimun = profileTCCalibTempcom.Minimun,
- Maximun = profileTCCalibTempcom.Maximun,
- Resolution = 0
- };
- step.ProfileTCCalibTemp = profileTCCalibParam;
- }
- var profileCTableNocom = ParameterTemplate["Parameter Information"].Where(x => x.ControlName == "ProfileConditionTableNo").FirstOrDefault();
- if (profileCTableNocom != null)
- {
- NumParam profileCTableNoParam = new NumParam()
- {
- Name = profileCTableNocom.ControlName,
- Value = (int)profileCTableNocom.Value,
- DisplayName = profileCTableNocom.DisplayName,
- Minimun = profileCTableNocom.Minimun,
- Maximun = profileCTableNocom.Maximun,
- };
- step.ProfileConditionTableNo = profileCTableNoParam;
- }
- var tableNocom = ParameterTemplate["Parameter Information"].Where(x => x.ControlName == "TempPIDTableNo").FirstOrDefault();
- if (tableNocom != null)
- {
- NumParam TableNo = new NumParam()
- {
- Name = tableNocom.ControlName,
- Value = (int)tableNocom.Value,
- DisplayName = tableNocom.DisplayName,
- Minimun = tableNocom.Minimun,
- Maximun = tableNocom.Maximun,
- };
- step.TableNo = TableNo;
- }
- var tableUseRangeMincom = ParameterTemplate["Parameter Information"].Where(x => x.ControlName == "TableUseRangeMin").FirstOrDefault();
- if (tableUseRangeMincom != null)
- {
- DoubleParam tableUseRangeMinParam = new DoubleParam()
- {
- Name = tableUseRangeMincom.ControlName,
- Value = tableUseRangeMincom.Value.ToString(),
- DisplayName = tableUseRangeMincom.DisplayName,
- Minimun = tableUseRangeMincom.Minimun,
- Maximun = tableUseRangeMincom.Maximun,
- Resolution = 0
- };
- step.TableUseRangeMin = tableUseRangeMinParam;
- }
- var tableUseRangeMaxcom = ParameterTemplate["Parameter Information"].Where(x => x.ControlName == "TableUseRangeMax").FirstOrDefault();
- if (tableUseRangeMaxcom != null)
- {
- DoubleParam tableUseRangeMaxParam = new DoubleParam()
- {
- Name = tableUseRangeMaxcom.ControlName,
- Value = tableUseRangeMaxcom.Value.ToString(),
- DisplayName = tableUseRangeMaxcom.DisplayName,
- Minimun = tableUseRangeMaxcom.Minimun,
- Maximun = tableUseRangeMaxcom.Maximun,
- Resolution = 0
- };
- step.TableUseRangeMax = tableUseRangeMaxParam;
- }
- foreach (var item in ParameterTemplate)
- {
- if (item.Key != "Parameter Information")
- {
- var _correctionData = new CorrectionData()
- {
- Name = item.Key,
- Index = pIDIndex
- };
- var profileTempcom = item.Value.Where(x => x.ControlName == "ProfileTemp").FirstOrDefault();
- if (profileTempcom != null)
- {
- DoubleParam profileTempParam = new DoubleParam()
- {
- Name = profileTempcom.ControlName,
- Value = profileTempcom.Value.ToString(),
- DisplayName = profileTempcom.DisplayName,
- Minimun = profileTempcom.Minimun,
- Maximun = profileTempcom.Maximun,
- Resolution = 0
- };
- _correctionData.ProfileTemp= profileTempParam;
- }
- var profileCorrectcom = item.Value.Where(x => x.ControlName == "ProfileCorrect").FirstOrDefault();
- if (profileCorrectcom != null)
- {
- DoubleParam profileCorrectParam = new DoubleParam()
- {
- Name = profileCorrectcom.ControlName,
- Value = profileCorrectcom.Value.ToString(),
- DisplayName = profileCorrectcom.DisplayName,
- Minimun = profileCorrectcom.Minimun,
- Maximun = profileCorrectcom.Maximun,
- Resolution = 0
- };
- _correctionData.ProfileCorrect = profileCorrectParam;
- }
- var cascadeTCCorrectcom = item.Value.Where(x => x.ControlName == "CascadeTCCorrect").FirstOrDefault();
- if (cascadeTCCorrectcom != null)
- {
- DoubleParam cascadeTCCorrectcomParam = new DoubleParam()
- {
- Name = cascadeTCCorrectcom.ControlName,
- Value = cascadeTCCorrectcom.Value.ToString(),
- DisplayName = cascadeTCCorrectcom.DisplayName,
- Minimun = cascadeTCCorrectcom.Minimun,
- Maximun = cascadeTCCorrectcom.Maximun,
- Resolution = 0
- };
- _correctionData.CascadeTCCorrect = cascadeTCCorrectcomParam;
- }
- var profileTCCalibcom = item.Value.Where(x => x.ControlName == "ProfileTCCalib").FirstOrDefault();
- if (profileTCCalibcom != null)
- {
- DoubleParam profileTCCalibParam = new DoubleParam()
- {
- Name = profileTCCalibcom.ControlName,
- Value = profileTCCalibcom.Value.ToString(),
- DisplayName = profileTCCalibcom.DisplayName,
- Minimun = profileTCCalibcom.Minimun,
- Maximun = profileTCCalibcom.Maximun,
- Resolution = 0
- };
- _correctionData.ProfileTCCalib = profileTCCalibParam;
- }
- ((TempCorrectionTable)step).CorrectionDataList.Add(_correctionData);
- pIDIndex++;
- }
- }
- if (stepNode != null)
- {
- if (stepNode.Attributes["ProfileTCCalibTemp"] != null)
- step.ProfileTCCalibTemp.Value = stepNode.Attributes["ProfileTCCalibTemp"].Value;
- if (stepNode.Attributes["ProfileConditionTableNo"] != null)
- step.ProfileConditionTableNo.Value = Convert.ToInt32(stepNode.Attributes["ProfileConditionTableNo"].Value);
- if (stepNode.Attributes["TempPIDTableNo"] != null)
- step.TableNo.Value = Convert.ToInt32(stepNode.Attributes["TempPIDTableNo"].Value);
- if (stepNode.Attributes["TableUseRangeMin"] != null)
- step.TableUseRangeMin.Value = stepNode.Attributes["TableUseRangeMin"].Value;
- if (stepNode.Attributes["TableUseRangeMax"] != null)
- step.TableUseRangeMax.Value = stepNode.Attributes["TableUseRangeMax"].Value;
- if (stepNode.Attributes["ProfileLastUpdate"] != null)
- step.ProfileLastUpdate = stepNode.Attributes["ProfileLastUpdate"].Value;
- foreach (var item in ((TempCorrectionTable)step).CorrectionDataList)
- {
- if (stepNode.Attributes["CorrectionData"] != null)
- {
- ((TempCorrectionTable)step).SetTempCorrectionData(stepNode.Attributes["CorrectionData"].Value.ToString());
- }
- }
- }
- return step;
- }
- public override string GetXmlString()
- {
- XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableParameterData") as XmlElement;
- nodeData.SetAttribute("CreatedBy", Creator);
- nodeData.SetAttribute("CreationTime", CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
- nodeData.SetAttribute("LastRevisedBy", Revisor);
- nodeData.SetAttribute("LastRevisionTime", ReviseTime.ToString("yyyy-MM-dd HH:mm:ss"));
- nodeData.SetAttribute("Description", Description);
- nodeData.SetAttribute("ParameterChamberType", ChamberType);
- nodeData.SetAttribute("Version", Version);
- nodeData.SetAttribute("TableNumber", TableNumber.ToString());
- nodeData.SetAttribute("Permission", Permission);
- nodeData.SetAttribute("ParameterLevel", Level);
- XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableParameterData/Module[@Name='{_module}']");
- if (nodeModule == null)
- {
- nodeModule = _doc.CreateElement("Module");
- nodeData.AppendChild(nodeModule);
- }
- nodeModule.RemoveAll();
- (nodeModule as XmlElement).SetAttribute("Name", _module);
- int i = 0;
- foreach (TempCorrectionTable parameter in Steps)
- {
- XmlElement nodeStep = _doc.CreateElement("Step");
-
- nodeStep.SetAttribute("StepNo", parameter.StepNo.ToString());
- nodeStep.SetAttribute("Name", parameter.Name);
- // nodeStep.SetAttribute("UseTemp", parameter.UseTemp);
- nodeStep.SetAttribute("ProfileTCCalibTemp", parameter.ProfileTCCalibTemp.Value.ToString());
- nodeStep.SetAttribute("ProfileConditionTableNo", parameter.ProfileConditionTableNo.Value.ToString());
- nodeStep.SetAttribute("TempPIDTableNo", parameter.TableNo.Value.ToString());
- nodeStep.SetAttribute("TableUseRangeMin", parameter.TableUseRangeMin.Value.ToString());
- nodeStep.SetAttribute("TableUseRangeMax", parameter.TableUseRangeMax.Value.ToString());
- nodeStep.SetAttribute("ProfileLastUpdate", parameter.ProfileLastUpdate);
- var correctionDatas = ((TempCorrectionTable)parameter).CorrectionDataList.Select(x => x.ToString()).ToArray();
- nodeStep.SetAttribute($"CorrectionData",string.Join("|" ,correctionDatas));
- nodeModule.AppendChild(nodeStep);
- i++;
- }
-
- return _doc.OuterXml;
- }
- public override void InitData(string prefixPath, string recipeName, string recipeContent, string module)
- {
- IsCompatibleWithCurrentFormat = false;
- _module = module;
- Name = recipeName;
- PrefixPath = prefixPath;
- try
- {
- _doc = new XmlDocument();
- _doc.LoadXml(recipeContent);
- if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableParameterData")))
- return;
- XmlNodeList nodeSteps = _doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='{module}']/Step");
- if (nodeSteps == null)
- nodeSteps = _doc.SelectNodes($"Aitex/TableParameterData/Step");
- LoadSteps(nodeSteps);
- var index = 1;
- foreach (ParameterTable parameters in Steps)
- {
- parameters.Value = index.ToString();
- index++;
- }
- // ValidLoopData();
- XmlNode nodeConfig =
- _doc.SelectSingleNode($"Aitex/TableParameterData/Module[@Name='{module}']/Config");
- if (nodeSteps == null)
- nodeConfig = _doc.SelectSingleNode($"Aitex/TableParameterData/Config");
- IsCompatibleWithCurrentFormat = true;
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- }
- public override void LoadSteps(XmlNodeList steps)
- {
- Steps.Clear();
- PopSettingSteps.Clear();
- StepTolerances.Clear();
- StepNos.Clear();
- int index = 1;
-
- foreach (XmlNode nodeStep in steps)
- {
- ParameterTable stepTable = this.CreateStep(nodeStep);
- StepNos.Add(stepTable.StepNo);
- Steps.Add(stepTable);
- index++;
- }
- }
-
- }
- }
|