TempCorrectionTable.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using Caliburn.Micro.Core;
  2. using RecipeEditorLib.RecipeModel.Params;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MECF.Framework.UI.Client.CenterViews.Parameter
  10. {
  11. public class TempCorrectionTable : ParameterTable
  12. {
  13. private DoubleParam _profileTCCalibTemp;
  14. public DoubleParam ProfileTCCalibTemp
  15. {
  16. get => _profileTCCalibTemp;
  17. set
  18. {
  19. _profileTCCalibTemp = value;
  20. NotifyOfPropertyChange("ProfileTCCalibTemp");
  21. }
  22. }
  23. private NumParam _profileConditionTableNo;
  24. public NumParam ProfileConditionTableNo
  25. {
  26. get => _profileConditionTableNo;
  27. set
  28. {
  29. _profileConditionTableNo = value;
  30. NotifyOfPropertyChange("ProfileConditionTableNo");
  31. }
  32. }
  33. private NumParam _tableNo;
  34. public NumParam TableNo
  35. {
  36. get => _tableNo;
  37. set
  38. {
  39. _tableNo = value;
  40. NotifyOfPropertyChange("TableNo");
  41. }
  42. }
  43. private DoubleParam _tableUseRangeMin;
  44. public DoubleParam TableUseRangeMin
  45. {
  46. get => _tableUseRangeMin;
  47. set
  48. {
  49. _tableUseRangeMin = value;
  50. NotifyOfPropertyChange("TableUseRangeMin");
  51. }
  52. }
  53. private DoubleParam _tableUseRangeMax ;
  54. public DoubleParam TableUseRangeMax
  55. {
  56. get => _tableUseRangeMax;
  57. set
  58. {
  59. _tableUseRangeMax = value;
  60. NotifyOfPropertyChange("TableUseRangeMax");
  61. }
  62. }
  63. private string _profileLastUpdate = "";
  64. public string ProfileLastUpdate
  65. {
  66. get => _profileLastUpdate;
  67. set
  68. {
  69. _profileLastUpdate = value;
  70. NotifyOfPropertyChange("ProfileLastUpdate");
  71. }
  72. }
  73. private ObservableCollection<CorrectionData> _correctionDataList = new ObservableCollection<CorrectionData>();
  74. public ObservableCollection<CorrectionData> CorrectionDataList
  75. {
  76. get => _correctionDataList;
  77. set
  78. {
  79. _correctionDataList = value;
  80. NotifyOfPropertyChange("CorrectionDataList");
  81. }
  82. }
  83. public TempCorrectionTable() : base()
  84. {
  85. }
  86. public TempCorrectionTable(ParameterDataBase recipeData)
  87. {
  88. if (recipeData.Steps.Count <= 0) return;
  89. SetCurrentRecipeStep(recipeData, recipeData.Steps[0]);
  90. }
  91. public TempCorrectionTable(ParameterDataBase recipeData, int selectedStepNo)
  92. {
  93. ParameterTable step = recipeData.Steps.Where(x => x.StepNo == selectedStepNo).FirstOrDefault();
  94. SetCurrentRecipeStep(recipeData, step);
  95. }
  96. public void SetTempCorrectionData(string value)
  97. {
  98. if (string.IsNullOrEmpty(value)) return;
  99. string[] strTempCorrection = value.Split('|');
  100. foreach (var item in strTempCorrection)
  101. {
  102. if (string.IsNullOrEmpty(item)) continue;
  103. string[] subTempCorrection = item.Split(';');
  104. Dictionary<string, string> dictTempCorrection = new Dictionary<string, string>();
  105. foreach (var pid in subTempCorrection)
  106. {
  107. if (string.IsNullOrEmpty(item)) continue;
  108. var keyValue = pid.Split(':');
  109. if (keyValue == null || keyValue.Length != 2) continue;
  110. dictTempCorrection[keyValue[0]] = keyValue[1];
  111. }
  112. var selectCorrection = CorrectionDataList.Where(x => x.Name == dictTempCorrection["Name"]).FirstOrDefault();
  113. if (selectCorrection != null)
  114. {
  115. selectCorrection.ProfileTemp.Value = dictTempCorrection["ProfileTemp"];
  116. selectCorrection.ProfileCorrect.Value = dictTempCorrection["ProfileCorrect"];
  117. selectCorrection.CascadeTCCorrect.Value = dictTempCorrection["CascadeTCCorrect"];
  118. selectCorrection.ProfileTCCalib.Value = dictTempCorrection["ProfileTCCalib"];
  119. }
  120. }
  121. }
  122. }
  123. public class CorrectionData : PropertyChangedBase
  124. {
  125. private int _index = 1;
  126. public int Index
  127. {
  128. get => _index;
  129. set
  130. {
  131. _index = value;
  132. NotifyOfPropertyChange("Index");
  133. }
  134. }
  135. private string _name = "";
  136. public string Name
  137. {
  138. get => _name;
  139. set
  140. {
  141. _name = value;
  142. NotifyOfPropertyChange("Name");
  143. }
  144. }
  145. private DoubleParam _profileTemp;
  146. public DoubleParam ProfileTemp
  147. {
  148. get => _profileTemp;
  149. set
  150. {
  151. _profileTemp = value;
  152. NotifyOfPropertyChange("ProfileTemp");
  153. }
  154. }
  155. private DoubleParam _profileCorrect;
  156. public DoubleParam ProfileCorrect
  157. {
  158. get => _profileCorrect;
  159. set
  160. {
  161. _profileCorrect = value;
  162. NotifyOfPropertyChange("ProfileCorrect");
  163. }
  164. }
  165. private DoubleParam _cascadeTCCorrect;
  166. public DoubleParam CascadeTCCorrect
  167. {
  168. get => _cascadeTCCorrect;
  169. set
  170. {
  171. _cascadeTCCorrect = value;
  172. NotifyOfPropertyChange("CascadeTCCorrect");
  173. }
  174. }
  175. private DoubleParam _profileTCCalib;
  176. public DoubleParam ProfileTCCalib
  177. {
  178. get => _profileTCCalib;
  179. set
  180. {
  181. _profileTCCalib = value;
  182. NotifyOfPropertyChange("ProfileTCCalib");
  183. }
  184. }
  185. public override string ToString()
  186. {
  187. string[] rtnStrList = new string[6];
  188. rtnStrList[0] = $"Index:{Index}";
  189. rtnStrList[1] = $"Name:{Name}";
  190. rtnStrList[2] = $"ProfileTemp:{ProfileTemp.Value}";
  191. rtnStrList[3] = $"ProfileCorrect:{ProfileCorrect.Value}";
  192. rtnStrList[4] = $"CascadeTCCorrect:{CascadeTCCorrect.Value}";
  193. rtnStrList[5] = $"ProfileTCCalib:{ProfileTCCalib.Value}";
  194. return string.Join(";", rtnStrList);
  195. }
  196. }
  197. }