IoHeater.cs 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  1. using Aitex.Common.Util;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.RT.DataCenter;
  4. using Aitex.Core.RT.Device;
  5. using Aitex.Core.RT.Device.Unit;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.IOCore;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.RT.OperationCenter;
  10. using Aitex.Core.RT.ParameterCenter;
  11. using Aitex.Core.RT.SCCore;
  12. using Aitex.Core.RT.Tolerance;
  13. using Aitex.Core.Util;
  14. using FurnaceRT.Equipments.PMs;
  15. using FurnaceRT.Equipments.Systems;
  16. using MECF.Framework.Common.CommonData;
  17. using MECF.Framework.Common.Device.Bases;
  18. using MECF.Framework.Common.Equipment;
  19. using MECF.Framework.Common.Event;
  20. using System;
  21. using System.Collections.Generic;
  22. using System.Diagnostics;
  23. using System.IO;
  24. using System.Linq;
  25. using System.Text;
  26. using System.Threading.Tasks;
  27. using System.Xml;
  28. namespace FurnaceRT.Devices
  29. {
  30. public class IoHeater : HeaterBase
  31. {
  32. private R_TRIG _trigTrigFurnaceTempabnormal = new R_TRIG();
  33. public IoHeater(string module, XmlElement node, string ioModule = "")
  34. {
  35. base.Module = string.IsNullOrEmpty(node.GetAttribute("module")) ? module : node.GetAttribute("module");
  36. base.Name = node.GetAttribute("id");
  37. base.Display = node.GetAttribute("display");
  38. base.DeviceID = node.GetAttribute("schematicId");
  39. formatString = node.GetAttribute("formatString");
  40. InstallZone = node.GetAttribute("installzone");
  41. _uniqueName = $"{Module}{Name}";
  42. _isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float");
  43. _aiCascadePV = ParseAiNode("aiCascadePV", node, ioModule);
  44. _aiHeaterPV = ParseAiNode("aiHeaterPV", node, ioModule);
  45. _aiWorkingOutput = ParseAiNode("aiWorkingOutput", node, ioModule);
  46. _aiOverTemp = ParseAiNode("aiOverTemp", node, ioModule);
  47. _aoCascadeControlModeSetPoint = ParseAoNode("aoCascadeControlModeSetPoint", node, ioModule);
  48. _aoHeaterControlModeSetPoint = ParseAoNode("aoHeaterControlModeSetPoint", node, ioModule);
  49. _aoCascadePID_P = ParseAoNode("aoCascadePID_P", node, ioModule);
  50. _aoCascadePID_I = ParseAoNode("aoCascadePID_I", node, ioModule);
  51. _aoCascadePID_D = ParseAoNode("aoCascadePID_D", node, ioModule);
  52. _aoHeaterPID_P = ParseAoNode("aoHeaterPID_P", node, ioModule);
  53. _aoHeaterPID_I = ParseAoNode("aoHeaterPID_I", node, ioModule);
  54. _aoHeaterPID_D = ParseAoNode("aoHeaterPID_D", node, ioModule);
  55. _aoUpRate = ParseAoNode("aoUpRate", node, ioModule);
  56. _aoDownRate = ParseAoNode("aoDownRate", node, ioModule);
  57. _aoTCOpenOffsetOffset = ParseAoNode("aoTCOpenOffsetOffset", node, ioModule);
  58. _diCascadePVSBrk = ParseDiNode("diCascadePVSBrk", node, ioModule);
  59. _diHeaterPVSBrk = ParseDiNode("diHeaterPVSBrk", node, ioModule);
  60. _diEnableOutput = ParseDiNode("diEnableOutput", node, ioModule);
  61. _doEnableIn = ParseDoNode("doEnableIn", node, ioModule);
  62. _doAutoManual = ParseDoNode("doAutoManual", node, ioModule);
  63. _doSelect = ParseDoNode("doMainPVSelect", node, ioModule);
  64. _doCascadeMode = ParseDoNode("doCascadeMode", node, ioModule);
  65. _scRoot = node.GetAttribute("scRoot");
  66. }
  67. #region fields
  68. private AIAccessor _aiCascadePV;
  69. private AIAccessor _aiHeaterPV;
  70. private AIAccessor _aiWorkingOutput;
  71. private AIAccessor _aiOverTemp;
  72. private AOAccessor _aoCascadeControlModeSetPoint;
  73. private AOAccessor _aoHeaterControlModeSetPoint;
  74. private AOAccessor _aoCascadePID_P;
  75. private AOAccessor _aoCascadePID_I;
  76. private AOAccessor _aoCascadePID_D;
  77. private AOAccessor _aoHeaterPID_P;
  78. private AOAccessor _aoHeaterPID_I;
  79. private AOAccessor _aoHeaterPID_D;
  80. private AOAccessor _aoUpRate;
  81. private AOAccessor _aoDownRate;
  82. private AOAccessor _aoTCOpenOffsetOffset;
  83. private DIAccessor _diCascadePVSBrk;
  84. private DIAccessor _diHeaterPVSBrk;
  85. private DIAccessor _diEnableOutput;
  86. private DOAccessor _doEnableIn;
  87. private DOAccessor _doAutoManual;
  88. private DOAccessor _doSelect;
  89. private DOAccessor _doCascadeMode;
  90. private string formatString;
  91. private const int physicalMax = 16000;
  92. private ToleranceChecker _toleranceCheckerWarning = new ToleranceChecker();
  93. private ToleranceChecker _toleranceCheckerAlarm = new ToleranceChecker();
  94. //tolerance check
  95. private float _alarmJudgmentRange;
  96. private float _warningJudgmentRange;
  97. private float _alarmJudgmentTime;
  98. private float _warningJudgmentTime;
  99. private float _toleranceJudgmentDelayTime;
  100. private DeviceTimer _toleranceJudgmentDelayTimer = new DeviceTimer();
  101. //stable check
  102. private Stopwatch _stableJudgmentTimer = new Stopwatch();
  103. private float _stableJudgmentTime = 1;
  104. private float _stableMinValue;
  105. private float _stableMaxValue;
  106. private SCConfigItem _scEnableCalibration;
  107. private SCConfigItem _scCalibrationTable;
  108. private SCConfigItem _scRange;
  109. private SCConfigItem _scRampRate;//°C/min
  110. private List<CalibrationItem> _calibrationTable = new List<CalibrationItem>();
  111. private string _previousSetting;
  112. private DeviceTimer _rampTimer = new DeviceTimer();
  113. private double _rampTarget;
  114. private double _rampInitValue;
  115. private int _rampTime;
  116. private DeviceTimer _stableTimer = new DeviceTimer();
  117. private bool _isWarned;
  118. private string _uniqueName;
  119. private float _tempSetpoint = 0.0f;
  120. private string _scRoot;
  121. private bool _isStartRamp = false;
  122. private bool _isFloatAioType = false;
  123. private Dictionary<string, int> _pidTableAssociate;
  124. #region temp correct
  125. private float _profileTemp = 0;
  126. private float _profileCorrect = 0;
  127. private float _profileTCCalib = 0;
  128. private float _cascadeTCCorrect = 0;
  129. public string CurrentCorrectFileName { get; private set; }
  130. public int CurrentCorrectIndex { get; private set; }
  131. private string _writeLog = "";
  132. #endregion
  133. #region temp profile
  134. private float _preheatTime = 0;
  135. private float _checkTime = 0;
  136. private float _checkLimit = 0;
  137. private float _alarmLimit = 0;
  138. private float _totalTime = 0;
  139. private Stopwatch _profileTimer = new Stopwatch();
  140. private Stopwatch _profileStableTimer = new Stopwatch();
  141. public bool IsProfileMode => _profileTimer != null && _profileTimer.IsRunning;
  142. public bool IsProfileSuccess { get; set; }
  143. private R_TRIG _profileTotalTimeoutTrig = new R_TRIG();
  144. private R_TRIG _profileAlarmLimitTrig = new R_TRIG();
  145. private R_TRIG _profileSuccessTrig = new R_TRIG();
  146. private bool _isWait;
  147. private float _waitHigh;
  148. private float _waitLow;
  149. private bool _isInit = false;
  150. private Stopwatch _initTimer = new Stopwatch();
  151. #endregion
  152. #endregion
  153. #region properties
  154. public string InstallZone { get; set; }
  155. public double Range => _scRange.DoubleValue;
  156. public AlarmEventItem AlarmToleranceWarning { get; set; }
  157. public AlarmEventItem AlarmToleranceAlarm { get; set; }
  158. public AlarmEventItem InterlockAlarm { get; set; }
  159. public AlarmEventItem HeaterErrorAlarm { get; set; }
  160. public AlarmEventItem HeaterErrorRecoveryWarning { get; set; }
  161. public AlarmEventItem HeaterStripBreakAlarm { get; set; }
  162. public AlarmEventItem HeaterStripBreakWarning { get; set; }
  163. public bool IsHeaterStripBreak { get; set; }
  164. private RD_TRIG _trigHeaterErrorSignalOn = new RD_TRIG();
  165. public R_TRIG TrigHeaterStripBreakSignalOn = new R_TRIG();
  166. public DeviceTimer HeaterStripBreakTimer = new DeviceTimer();
  167. public string InstallPosition => SC.GetStringValue($"{_scRoot}.Heater.{InstallZone}.{Name}.InstallPosition");
  168. public bool IsError => _diCascadePVSBrk == null || _diHeaterPVSBrk == null ? false : _diCascadePVSBrk.Value || _diHeaterPVSBrk.Value;
  169. private R_TRIG _tcBreakTrig = new R_TRIG();
  170. public bool IsStable
  171. {
  172. get
  173. {
  174. if (_stableJudgmentTimer.IsRunning)
  175. {
  176. if (DeviceData.FeedBack < (DeviceData.SetPoint - _stableMinValue) ||
  177. DeviceData.FeedBack > (DeviceData.SetPoint + _stableMaxValue))
  178. {
  179. _stableJudgmentTimer.Restart();
  180. }
  181. if (_stableJudgmentTimer.ElapsedMilliseconds >= _stableJudgmentTime * 1000)
  182. {
  183. return true;
  184. }
  185. }
  186. else
  187. {
  188. _stableJudgmentTimer.Restart();
  189. }
  190. return false;
  191. }
  192. }
  193. public override float TempSetPoint
  194. {
  195. get
  196. {
  197. return _tempSetpoint;
  198. }
  199. set
  200. {
  201. if (_aoCascadeControlModeSetPoint != null && _aoHeaterControlModeSetPoint != null)
  202. {
  203. if (_isFloatAioType)
  204. {
  205. if (ControlMode == 0)
  206. {
  207. if (Math.Abs(_aoCascadeControlModeSetPoint.FloatValue - value) > 0.0001)
  208. {
  209. _aoCascadeControlModeSetPoint.SetPulseValue(value, 1500);
  210. }
  211. }
  212. else
  213. {
  214. if (Math.Abs(_aoHeaterControlModeSetPoint.FloatValue - value) > 0.0001)
  215. {
  216. _aoHeaterControlModeSetPoint.SetPulseValue(value, 1500);
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. public float HeaterPID_P
  224. {
  225. get
  226. {
  227. return _aoHeaterPID_P.FloatValue;
  228. }
  229. set
  230. {
  231. if (Math.Abs(_aoHeaterPID_P.FloatValue - value) > 0.0001)
  232. _aoHeaterPID_P.FloatValue = value;
  233. }
  234. }
  235. public float HeaterPID_I
  236. {
  237. get
  238. {
  239. return _aoHeaterPID_I.FloatValue;
  240. }
  241. set
  242. {
  243. if (Math.Abs(_aoHeaterPID_I.FloatValue - value) > 0.0001)
  244. _aoHeaterPID_I.FloatValue = value;
  245. }
  246. }
  247. public float HeaterPID_D
  248. {
  249. get
  250. {
  251. return _aoHeaterPID_D.FloatValue;
  252. }
  253. set
  254. {
  255. if (Math.Abs(_aoHeaterPID_D.FloatValue - value) > 0.0001)
  256. _aoHeaterPID_D.FloatValue = value;
  257. }
  258. }
  259. public float CascadePID_P
  260. {
  261. get
  262. {
  263. return _aoCascadePID_P.FloatValue;
  264. }
  265. set
  266. {
  267. if (Math.Abs(_aoCascadePID_P.FloatValue - value) > 0.0001)
  268. _aoCascadePID_P.FloatValue = value;
  269. }
  270. }
  271. public float CascadePID_I
  272. {
  273. get
  274. {
  275. return _aoCascadePID_I.FloatValue;
  276. }
  277. set
  278. {
  279. if (Math.Abs(_aoCascadePID_I.FloatValue - value) > 0.0001)
  280. _aoCascadePID_I.FloatValue = value;
  281. }
  282. }
  283. public float CascadePID_D
  284. {
  285. get
  286. {
  287. return _aoCascadePID_D.FloatValue;
  288. }
  289. set
  290. {
  291. if (Math.Abs(_aoCascadePID_D.FloatValue - value) > 0.0001)
  292. _aoCascadePID_D.FloatValue = value;
  293. }
  294. }
  295. public float UpRate
  296. {
  297. get
  298. {
  299. return _aoUpRate.FloatValue;
  300. }
  301. set
  302. {
  303. if (Math.Abs(_aoUpRate.FloatValue - value) > 0.0001)
  304. _aoUpRate.FloatValue = value;
  305. }
  306. }
  307. public float DownRate
  308. {
  309. get
  310. {
  311. return _aoDownRate.FloatValue;
  312. }
  313. set
  314. {
  315. if (Math.Abs(_aoDownRate.FloatValue - value) > 0.0001)
  316. _aoDownRate.FloatValue = value;
  317. }
  318. }
  319. public int ControlMode
  320. {
  321. get
  322. {
  323. if (_doSelect != null && _doCascadeMode != null)
  324. {
  325. if (!_doSelect.Value && !_doCascadeMode.Value)
  326. {
  327. // Furnace control
  328. return 0;
  329. }
  330. else if (!_doSelect.Value && _doCascadeMode.Value)
  331. {
  332. // Heater control
  333. return 1;
  334. }
  335. else if (_doSelect.Value && _doCascadeMode.Value)
  336. {
  337. //Furnace Diect control
  338. return 2;
  339. }
  340. }
  341. return 0;
  342. }
  343. }
  344. public float TCOpenOffsetOffset
  345. {
  346. get
  347. {
  348. return _aoTCOpenOffsetOffset != null ? _aoTCOpenOffsetOffset.FloatValue : 0;
  349. }
  350. set
  351. {
  352. if (_aoTCOpenOffsetOffset != null && Math.Abs(_aoTCOpenOffsetOffset.FloatValue - value) > 0.0001)
  353. _aoTCOpenOffsetOffset.FloatValue = value;
  354. }
  355. }
  356. public override float TempFeedback => (float)(ControlMode == 1 ? (_aiHeaterPV == null ? 0 : _aiHeaterPV.FloatValue - _profileTCCalib) : (_aiCascadePV == null ? 0 : _aiCascadePV.FloatValue - _profileTCCalib));
  357. #endregion
  358. public override bool Initialize()
  359. {
  360. DeviceData = new AITHeaterData()
  361. {
  362. DeviceName = Name,
  363. DeviceSchematicId = DeviceID,
  364. DisplayName = Display,
  365. Module = Module,
  366. Scale = SC.GetValue<double>($"{_scRoot}.{Name}.Range"),
  367. OverTempScale = SC.GetValue<double>($"{_scRoot}.{Name}.OverTempRange"),
  368. //Scale = 1200,
  369. Unit = "°C",
  370. //SetPoint = TempSetPoint,
  371. FeedBack = TempFeedback,
  372. };
  373. _pidTableAssociate = new Dictionary<string, int>()
  374. {
  375. { "HeaterU",0 },
  376. { "HeaterCU",1 },
  377. { "HeaterC",2 },
  378. { "HeaterCL",3 },
  379. { "HeaterL",4 },
  380. };
  381. _scEnableCalibration = SC.GetConfigItem($"{_scRoot}.{Name}.EnableCalibration");
  382. _scCalibrationTable = SC.GetConfigItem($"{_scRoot}.{Name}.CalibrationTable");
  383. //_scRange = SC.GetConfigItem($"{_scRoot}.{Name}.Range");
  384. _scRampRate = SC.GetConfigItem($"{_scRoot}.{Name}.RampRate");
  385. //AlarmToleranceWarning = SubscribeAlarm($"{_scRoot}.{Name}.ToleranceWarning", "", ResetWarningChecker, EventLevel.Warning);
  386. //AlarmToleranceAlarm = SubscribeAlarm($"{_scRoot}.{Name}.ToleranceAlarm", "", ResetAlarmChecker);
  387. //AlarmToleranceWarning.Id = SC.ContainsItem($"{_scRoot}.{Name}.ToleranceWarningID") ? SC.GetValue<int>($"{_scRoot}.{Name}.ToleranceWarningID") : 0;
  388. //AlarmToleranceAlarm.Id = SC.ContainsItem($"{_scRoot}.{Name}.ToleranceAlarmID") ? SC.GetValue<int>($"{_scRoot}.{Name}.ToleranceAlarmID") : 0;
  389. //_stableJudgmentTime = (float)SC.GetValue<double>($"{_scRoot}.{Name}.Stabilize.JudgmentTime");
  390. //_stableMinValue = (float)SC.GetValue<double>($"{_scRoot}.{Name}.Stabilize.MinusValue");
  391. //_stableMaxValue = (float)SC.GetValue<double>($"{_scRoot}.{Name}.Stabilize.PlusValue");
  392. DATA.Subscribe($"{Module}.{Name}.CascadePV", () => (float)DeviceData.CascadePV);
  393. DATA.Subscribe($"{Module}.{Name}.HeaterPV", () => (float)DeviceData.HeaterPV);
  394. DATA.Subscribe($"{Module}.{Name}.CascadePID_P", () => (float)DeviceData.CascadePID_P);
  395. DATA.Subscribe($"{Module}.{Name}.CascadePID_I", () => (float)DeviceData.CascadePID_I);
  396. DATA.Subscribe($"{Module}.{Name}.CascadePID_D", () => (float)DeviceData.CascadePID_D);
  397. DATA.Subscribe($"{Module}.{Name}.HeaterPID_P", () => (float)DeviceData.HeaterPID_P);
  398. DATA.Subscribe($"{Module}.{Name}.HeaterPID_I", () => (float)DeviceData.HeaterPID_I);
  399. DATA.Subscribe($"{Module}.{Name}.HeaterPID_D", () => (float)DeviceData.HeaterPID_D);
  400. DATA.Subscribe($"{Module}.{Name}.CascadeControlModeSV", () => _aoCascadeControlModeSetPoint != null ? _aoCascadeControlModeSetPoint.FloatValue : 0.0f);
  401. DATA.Subscribe($"{Module}.{Name}.HeaterControlModeSV", () => _aoHeaterControlModeSetPoint != null ? _aoHeaterControlModeSetPoint.FloatValue : 0.0f);
  402. DATA.Subscribe($"{Module}.{Name}.UpRate", () => UpRate);
  403. DATA.Subscribe($"{Module}.{Name}.DownRate", () => DownRate);
  404. DATA.Subscribe($"{Module}.{Name}.WorkingOutput", () => _aiWorkingOutput.FloatValue);
  405. DATA.Subscribe($"{Module}.{Name}.OverTemp", () => _aiOverTemp.FloatValue);
  406. DATA.Subscribe($"{Module}.{Name}.IsCascadePVBreak", () => _diCascadePVSBrk.Value);
  407. DATA.Subscribe($"{Module}.{Name}.IsHeaterPVBreak", () => _diHeaterPVSBrk.Value);
  408. DATA.Subscribe($"{Module}.{Name}.IsEnableOutput", () => _diEnableOutput.Value);
  409. DATA.Subscribe($"{Module}.{Name}.IsEnableIn", () => _doEnableIn.Value);
  410. DATA.Subscribe($"{Module}.{Name}.IsAutoManual", () => _doAutoManual.Value);
  411. DATA.Subscribe($"{Module}.{Name}.IsSelect", () => _doSelect.Value);
  412. DATA.Subscribe($"{Module}.{Name}.IsCascadeMode", () => _doCascadeMode.Value);
  413. DATA.Subscribe($"{Module}.{Name}.ControlMode", () => ControlMode);
  414. DATA.Subscribe($"{Module}.{Name}.TCOpenOffsetOffset", () => TCOpenOffsetOffset);
  415. OP.Subscribe($"{Module}.{Name}.SetRemoteMode", SetRemoteMode);
  416. OP.Subscribe($"{Module}.{Name}.SetAutoTuning", SetAutoTuning);
  417. OP.Subscribe($"{Module}.{Name}.SetOnOff", SetOnOff);
  418. OP.Subscribe($"{Module}.{Name}.SetUpDownRate", (out string reason, int time, object[] param) =>
  419. {
  420. reason = string.Empty;
  421. SetUpDownRate(param);
  422. return true;
  423. });
  424. OP.Subscribe($"{Module}.{Name}.SetManualParameters", (out string reason, int time, object[] param) =>
  425. {
  426. reason = string.Empty;
  427. SetManualParameters(param);
  428. return true;
  429. });
  430. //recipe
  431. OP.Subscribe($"PM1.{Name}.SetParameters", (out string reason, int time, object[] param) =>
  432. {
  433. reason = string.Empty;
  434. SetParameters(param);
  435. return true;
  436. });
  437. _doEnableIn.SetValue(true, out _);
  438. var setLastPoint = SC.GetConfigItem($"PM1.Heater.{this.Name}.SetLastPoint");
  439. if (setLastPoint != null)
  440. {
  441. _tempSetpoint = (float)setLastPoint.DoubleValue;
  442. DeviceData.SetPoint = _tempSetpoint;
  443. }
  444. SetCorrectParameters(SC.GetStringValue("PM1.TempCorrection"));
  445. return base.Initialize();
  446. }
  447. public override void Monitor()
  448. {
  449. if (!string.IsNullOrEmpty(_writeLog))
  450. {
  451. LOG.Write(_writeLog);
  452. _writeLog = "";
  453. }
  454. if (!_isInit)
  455. {
  456. if (!_initTimer.IsRunning)
  457. _initTimer.Start();
  458. if (_initTimer.ElapsedMilliseconds > 5 * 1000)
  459. {
  460. _initTimer.Stop();
  461. _isInit = true;
  462. if (_tempSetpoint == 0)
  463. {
  464. if (ControlMode == 0)
  465. {
  466. if (_aoCascadeControlModeSetPoint != null && _aoCascadeControlModeSetPoint.FloatValue > 0)
  467. {
  468. _tempSetpoint = _aoCascadeControlModeSetPoint.FloatValue;
  469. }
  470. }
  471. else
  472. {
  473. if (_aoCascadeControlModeSetPoint != null && _aoHeaterControlModeSetPoint.FloatValue > 0)
  474. {
  475. _tempSetpoint = _aoHeaterControlModeSetPoint.FloatValue;
  476. }
  477. }
  478. }
  479. SetPIDParameters(SC.GetStringValue("PM1.Heater.PID"));
  480. }
  481. }
  482. if (DeviceData != null)
  483. {
  484. DeviceData.CascadePID_P = _aoCascadePID_P == null ? 0 : _aoCascadePID_P.FloatValue;
  485. DeviceData.CascadePID_I = _aoCascadePID_I == null ? 0 : _aoCascadePID_I.FloatValue;
  486. DeviceData.CascadePID_D = _aoCascadePID_D == null ? 0 : _aoCascadePID_D.FloatValue;
  487. DeviceData.HeaterPID_P = _aoHeaterPID_P == null ? 0 : _aoHeaterPID_P.FloatValue;
  488. DeviceData.HeaterPID_I = _aoHeaterPID_I == null ? 0 : _aoHeaterPID_I.FloatValue;
  489. DeviceData.HeaterPID_D = _aoHeaterPID_D == null ? 0 : _aoHeaterPID_D.FloatValue;
  490. DeviceData.OverTemp = _aiOverTemp == null ? 0 : _aiOverTemp.FloatValue;
  491. DeviceData.CascadePV = _aiCascadePV == null ? 0 : _aiCascadePV.FloatValue;
  492. DeviceData.HeaterPV = _aiHeaterPV == null ? 0 : _aiHeaterPV.FloatValue;
  493. DeviceData.FeedBack = TempFeedback;
  494. DeviceData.SetPoint = _tempSetpoint;
  495. DeviceData.ManipulatedVariable = _aiWorkingOutput == null ? 0 : _aiWorkingOutput.FloatValue;
  496. DeviceData.RampSetPoint = TempSetPoint;//Ramp的过程值
  497. DeviceData.Ramping = _aoUpRate == null ? 0 : _aoUpRate.FloatValue;
  498. DeviceData.ControlMode = ControlMode;// 控制模式
  499. DeviceData.IsAlarm = IsError;
  500. DeviceData.UpRateSetPoint = UpRate;
  501. DeviceData.DownRateSetPoint = DownRate;
  502. DeviceData.EnableOutput = _diEnableOutput.Value;
  503. DeviceData.IsCascadePVBreak = _diCascadePVSBrk.Value;
  504. DeviceData.IsHeaterPVBreak = _diHeaterPVSBrk.Value;
  505. DeviceData.IsProfiling = IsProfileMode;
  506. DeviceData.IsOverTempError = DeviceData.OverTemp > DeviceData.OverTempScale;
  507. DeviceData.IsTempLmtError = DeviceData.FeedBack > DeviceData.Scale;
  508. if (_profileTimer != null && _profileTimer.IsRunning)
  509. {
  510. DeviceData.ProfileTotalTime = _totalTime - _profileTimer.ElapsedMilliseconds / 1000 > 0 ? _totalTime - _profileTimer.ElapsedMilliseconds / 1000 : 0;
  511. DeviceData.ProfilePreheatTime = _preheatTime - _profileTimer.ElapsedMilliseconds / 1000 > 0 ? _preheatTime - _profileTimer.ElapsedMilliseconds / 1000 : 0;
  512. }
  513. if (_profileStableTimer != null && _profileStableTimer.IsRunning)
  514. {
  515. DeviceData.ProfileCheckTime = _checkTime - _profileStableTimer.ElapsedMilliseconds / 1000 > 0 ? _checkTime - _profileStableTimer.ElapsedMilliseconds / 1000 : 0;
  516. }
  517. }
  518. MonitorTolerance();
  519. Ramping();
  520. MonitorToOverTemp();
  521. _tcBreakTrig.CLK = IsError;
  522. if (_tcBreakTrig.Q)
  523. TCOpenOffsetOffset = _profileCorrect;
  524. base.Monitor();
  525. }
  526. private void MonitorToOverTemp()
  527. {
  528. // < !--7个温区中的任意一个温区的 aiCascadePV或者aiHeaterPV或者aiOverTemp达到限定值, 关闭使能 >
  529. var heaterLimitData = SC.ContainsItem("System.Heater.") ? SC.GetValue<double>("System.Heater.") : 1000;
  530. _trigTrigFurnaceTempabnormal.CLK = (_aiCascadePV != null && _aiCascadePV.FloatValue >= heaterLimitData) || (_aiHeaterPV != null && _aiHeaterPV.FloatValue >= heaterLimitData) || (_aiOverTemp != null && _aiOverTemp.FloatValue >= heaterLimitData);
  531. if (_trigTrigFurnaceTempabnormal.Q)
  532. {
  533. var pm = Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule;
  534. pm.FurnaceTempabnormalAlarm.Set($"{Name} trigger FurnaceTempabnormal, Feedback:{TempFeedback} ,Temperature exceeding {heaterLimitData}.");
  535. pm.InitFurnaceZone(false);
  536. }
  537. }
  538. public override void SetTemperature(float temperature)
  539. {
  540. //if (temperature != SetpointFeedback)
  541. {
  542. var _rampTime = _scRampRate.DoubleValue != 0 ? (Math.Abs(temperature - TempFeedback) / _scRampRate.DoubleValue) * 60 * 1000 : 0;
  543. Ramp(temperature, (int)_rampTime);
  544. }
  545. }
  546. public void SetRamping(float ramping)
  547. {
  548. SaveRampRate(ramping.ToString("F1"));
  549. }
  550. private void SetManualParameters(object[] param)
  551. {
  552. SetEnable(true);
  553. //value:ramp
  554. if (param == null || param.Length < 1)
  555. {
  556. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature set parameter");
  557. return;
  558. }
  559. var array = param[0].ToString().Split(';');
  560. if (array == null || array.Length < 2)
  561. {
  562. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature set parameter");
  563. return;
  564. }
  565. float.TryParse(array[0], out float temperature);
  566. float.TryParse(array[1], out float rampTime);//°C/min
  567. DeviceData.SetPoint = temperature;
  568. DeviceData.RampSetPoint = rampTime;
  569. var profileCorrect = 0.0f;
  570. var profileTCCalib = 0.0f;
  571. //var actualSet = temperature - profileCorrect < 0 ? 0 : temperature - profileCorrect;
  572. var actualSet = temperature + _profileTCCalib;//加上flat zone的值
  573. UpRate = rampTime;
  574. DownRate = rampTime;
  575. var controlMode = "";
  576. if (array.Length > 2)
  577. {
  578. controlMode = array.Length > 2 ? array[2].ToString() : "";
  579. SetControlMode(controlMode);
  580. }
  581. _tempSetpoint = temperature;
  582. TempSetPoint = actualSet;
  583. LOG.Write($"{Name} setpoint={temperature} control mode={controlMode}");
  584. //Ramp(actualSet, (int)rampTime);
  585. }
  586. public void SetControlMode(string mode, string recipeProfileFileName = "")
  587. {
  588. var reason = "";
  589. DeviceData.ControlModeSetpoint = mode;
  590. switch (mode.ToLower())
  591. {
  592. case "heater":
  593. case "heater control":
  594. if (_doSelect.Value)
  595. _doSelect.SetValue(false, out reason);
  596. if (!_doCascadeMode.Value)
  597. _doCascadeMode.SetValue(true, out reason);
  598. break;
  599. case "furnace":
  600. case "furnace control":
  601. if (_doSelect.Value)
  602. _doSelect.SetValue(false, out reason);
  603. if (_doCascadeMode.Value)
  604. _doCascadeMode.SetValue(false, out reason);
  605. break;
  606. case "furnace direct":
  607. case "furnace direct control":
  608. if (!_doSelect.Value)
  609. _doSelect.SetValue(true, out reason);
  610. if (!_doCascadeMode.Value)
  611. _doCascadeMode.SetValue(true, out reason);
  612. break;
  613. default:
  614. if (mode.ToLower().StartsWith("profile"))
  615. {
  616. var arry = mode.Replace(")", "").Split('(');
  617. if (arry != null && arry.Length > 1)
  618. {
  619. var profileArray = arry[1].Split(',');
  620. if (profileArray != null && profileArray.Length > 2)
  621. {
  622. var profileFileName = profileArray[0];
  623. int.TryParse(profileArray[1], out int profileTableIndex);
  624. GetProfileParameters(profileFileName, profileTableIndex, recipeProfileFileName);
  625. _profileTimer.Restart();
  626. _profileStableTimer.Stop();
  627. _profileTotalTimeoutTrig.RST = true;
  628. _profileAlarmLimitTrig.RST = true;
  629. _profileSuccessTrig.RST = true;
  630. IsProfileSuccess = false;
  631. DeviceData.ProfileResult = 0;
  632. LOG.Write($"{Name} profile start preheatTime={_preheatTime} checkTime={_checkTime} totalTime={_totalTime} checkLimit={_checkLimit} alarmLimit={_alarmLimit}");
  633. }
  634. }
  635. }
  636. break;
  637. }
  638. }
  639. private void SetUpDownRate(object[] param)
  640. {
  641. }
  642. public void SetParameters(object[] param)
  643. {
  644. SetEnable(true);
  645. if (param != null && param.Length > 0)
  646. {
  647. string zoneName = "";
  648. float temperature = 0.0f;
  649. string tempUnit = "";
  650. float ramp = 0.0f;
  651. string rampUnit = "";
  652. string controlMode = "";
  653. string correct = "";
  654. string PID = "";
  655. var array = param[0].ToString().Split(';');//zoneName;temp;tempUnit;ramp;rampUnit;checkWait;tempHigh;tempLow;unitStepCompletionCondition;controlMode;correct;PID
  656. if (System.Text.RegularExpressions.Regex.Match(array[1].ToString(), @"[a-zA-Z]").Success)
  657. {
  658. var table = array[1].ToString().Split(':');//AssociateParameterTable
  659. if (SC.ContainsItem($"PM1.RecipeEditParameter.TempSetting.{table[0]}.{Name}"))
  660. {
  661. temperature = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.TempSetting.{table[0]}.{Name}");
  662. }
  663. }
  664. else
  665. {
  666. float.TryParse(array[1].ToString(), out temperature);
  667. }
  668. tempUnit = array.Length > 2 ? array[2].ToString() : "";
  669. if (array.Length > 3)
  670. {
  671. float.TryParse(array[3], out ramp);
  672. }
  673. rampUnit = array.Length > 4 ? array[4].ToString() : "";
  674. if (array.Length > 5)
  675. {
  676. bool.TryParse(array[5], out _isWait);
  677. }
  678. if (array.Length > 6)
  679. {
  680. float.TryParse(array[6], out _waitHigh);
  681. }
  682. if (array.Length > 7)
  683. {
  684. float.TryParse(array[7], out _waitLow);
  685. }
  686. var unitStepCompletionCondition = array.Length > 8 ? array[8].ToString() : "";
  687. _stableJudgmentTimer.Stop();
  688. controlMode = array.Length > 9 ? array[9].ToString() : "";
  689. correct = array.Length > 10 ? array[10].ToString() : "";
  690. PID = array.Length > 11 ? array[11].ToString() : "";
  691. var correctileName = array.Length > 12 ? array[12].ToString() : "";
  692. var PIDFileName = array.Length > 13 ? array[13].ToString() : "";
  693. var profileFileName = array.Length > 14 ? array[14].ToString() : "";
  694. var DPR = array.Length > 16 ? (array[15].ToString().ToLower() == "open" ? true : false) : false;
  695. var BWR = array.Length > 16 ? (array[15].ToString().ToLower() == "open" ? true : false) : false;
  696. SetControlMode(controlMode, profileFileName);
  697. SetPIDParameters(PID, PIDFileName);
  698. SetCorrectParameters(correct, correctileName, profileFileName);
  699. var profileCorrect = 0.0f;
  700. var profileTCCalib = 0.0f;
  701. //var actualSet = temperature - profileCorrect < 0 ? 0 : temperature - profileCorrect;
  702. var actualSet = temperature + _profileTCCalib;//加上flat zone的值
  703. float _rampTime = 0;
  704. if (DPR && BWR)
  705. {
  706. DownRate = 0;
  707. UpRate = 0;
  708. }
  709. else
  710. {
  711. if (ramp == 0)
  712. {
  713. DownRate = Math.Abs(TempFeedback - actualSet);//单位是°C/min
  714. UpRate = Math.Abs(TempFeedback - actualSet);//单位是°C/min
  715. }
  716. else if (rampUnit.ToLower() == "time")
  717. {
  718. DownRate = Math.Abs(TempFeedback - actualSet) / ramp;//单位是°C/min
  719. UpRate = Math.Abs(TempFeedback - actualSet) / ramp;//单位是°C/min
  720. }
  721. else
  722. {
  723. DownRate = ramp;//单位是°C/min
  724. UpRate = ramp;//单位是°C/min
  725. }
  726. }
  727. DeviceData.SetPoint = temperature;
  728. DeviceData.RampSetPoint = _rampTime;
  729. if (_tempSetpoint != temperature)
  730. {
  731. SC.SetItemValueFromString($"PM1.Heater.{this.Name}.SetLastPoint", temperature.ToString("F1"));
  732. }
  733. _tempSetpoint = temperature;
  734. TempSetPoint = actualSet;
  735. //LOG.Write($"{Name} setpoint={temperature} control mode={controlMode}, PID={PID}, correct={correct}");
  736. _writeLog = $"{Name} setpoint={temperature} control mode={controlMode}, PID={PID}, correct={correct}";
  737. //Ramp(actualSet, (int)_rampTime);
  738. }
  739. return;
  740. }
  741. private bool SetRemoteMode(out string reason, int time, params object[] param)
  742. {
  743. reason = string.Empty;
  744. if (param == null || param.Length == 0)
  745. {
  746. reason = $"invalid parameter";
  747. return false;
  748. }
  749. bool.TryParse(param[0].ToString(), out bool isRemoteMode);
  750. //_doRemoteControl.SetValue(isRemoteMode, out _);
  751. return true;
  752. }
  753. private bool SetOnOff(out string reason, int time, params object[] param)
  754. {
  755. reason = string.Empty;
  756. if (param == null || param.Length == 0)
  757. {
  758. reason = $"invalid parameter";
  759. return false;
  760. }
  761. bool.TryParse(param[0].ToString(), out bool isOn);
  762. //if (!_doStartHeating.Check(isOn, out reason))
  763. //{
  764. // return false;
  765. //}
  766. //return _doStartHeating.SetValue(isOn, out reason);
  767. return true;
  768. }
  769. public void SetRun(bool isOn)
  770. {
  771. //_doStartHeating.SetValue(isOn, out _);
  772. EV.PostInfoLog(Name, $"{Name}.SetRun({isOn})");
  773. }
  774. public void SetRemote(bool isRemote)
  775. {
  776. //_doRemoteControl.SetValue(isRemote, out _);
  777. }
  778. private bool SetAutoTuning(out string reason, int time, params object[] param)
  779. {
  780. reason = string.Empty;
  781. if (param == null || param.Length == 0)
  782. {
  783. reason = $"invalid parameter";
  784. return false;
  785. }
  786. bool.TryParse(param[0].ToString(), out bool isAutoSetAutoTuning);
  787. if (isAutoSetAutoTuning)
  788. {
  789. //_doCanWritePara.SetPulseValue(true, 2000);
  790. //_doStopAutoTunningMode.SetValue(false, out _);
  791. //_doStartAutoTunningMode.SetPulseValue(true, 2000);
  792. }
  793. else
  794. {
  795. //_doCanWritePara.SetPulseValue(true, 2000);
  796. //_doStartAutoTunningMode.SetValue(false, out _);
  797. //_doStopAutoTunningMode.SetPulseValue(true, 2000);
  798. }
  799. return true;
  800. }
  801. public override void Terminate()
  802. {
  803. ProfileFinish();
  804. base.Terminate();
  805. }
  806. public void ProfileFinish()
  807. {
  808. _profileTimer.Stop();
  809. _profileStableTimer.Stop();
  810. _profileTotalTimeoutTrig.RST = true;
  811. _profileAlarmLimitTrig.RST = true;
  812. _profileSuccessTrig.RST = true;
  813. IsProfileSuccess = false;
  814. DeviceData.ProfileTable = "";
  815. DeviceData.ProfileTotalTime = 0;
  816. DeviceData.ProfilePreheatTime = 0;
  817. DeviceData.ProfileCheckTime = 0;
  818. DeviceData.ProfileAlarmLimit = 0;
  819. DeviceData.ProfileCheckLimit = 0;
  820. }
  821. public bool SetEnable(bool isEnable)
  822. {
  823. return _doEnableIn.SetValue(isEnable, out _);
  824. }
  825. public bool ResetWarningChecker()
  826. {
  827. _toleranceCheckerWarning.Reset(_warningJudgmentTime);
  828. return true;
  829. }
  830. public bool ResetAlarmChecker()
  831. {
  832. _toleranceCheckerAlarm.Reset(_alarmJudgmentTime);
  833. return true;
  834. }
  835. public override void Reset()
  836. {
  837. AlarmToleranceWarning?.Reset();
  838. AlarmToleranceAlarm?.Reset();
  839. _toleranceJudgmentDelayTimer?.Stop();
  840. }
  841. public void ResetHeaterError()
  842. {
  843. _trigHeaterErrorSignalOn.RST = true;
  844. if (HeaterErrorAlarm != null)
  845. HeaterErrorAlarm.IsAcknowledged = true;
  846. }
  847. public void ResetHeaterStripBreak()
  848. {
  849. TrigHeaterStripBreakSignalOn.RST = true;
  850. if (HeaterStripBreakAlarm != null)
  851. HeaterStripBreakAlarm.IsAcknowledged = true;
  852. }
  853. private void MonitorTolerance()
  854. {
  855. if (IsHeaterStripBreak || TempSetPoint < 0.001 || _toleranceJudgmentDelayTimer.IsIdle() || _toleranceJudgmentDelayTimer.GetElapseTime() < _toleranceJudgmentDelayTime * 1000)
  856. {
  857. _toleranceCheckerWarning.RST = true;
  858. _toleranceCheckerAlarm.RST = true;
  859. return;
  860. }
  861. if (_alarmJudgmentRange != 0 && _alarmJudgmentTime > 0)
  862. {
  863. _toleranceCheckerAlarm.Monitor(DeviceData.FeedBack, DeviceData.RampSetPoint - Math.Abs(_alarmJudgmentRange), DeviceData.RampSetPoint + Math.Abs(_alarmJudgmentRange), _alarmJudgmentTime);
  864. }
  865. if (_warningJudgmentRange != 0 && _warningJudgmentTime > 0)
  866. {
  867. _toleranceCheckerWarning.Monitor(DeviceData.FeedBack, DeviceData.RampSetPoint - Math.Abs(_warningJudgmentRange), DeviceData.RampSetPoint + Math.Abs(_warningJudgmentRange), _warningJudgmentTime);
  868. }
  869. }
  870. public override bool CheckToleranceAlarm()
  871. {
  872. return _toleranceCheckerAlarm.Result;
  873. }
  874. public override bool CheckToleranceWarning()
  875. {
  876. return _toleranceCheckerWarning.Result;
  877. }
  878. public void SetToleranceAlarm()
  879. {
  880. AlarmToleranceAlarm.Description = $"{Display} temperature out of range {_alarmJudgmentRange} °C in {_alarmJudgmentTime:F0} seconds";
  881. AlarmToleranceAlarm.Set();
  882. }
  883. public void SetToleranceWarning()
  884. {
  885. AlarmToleranceWarning.Description = $"{Display} temperature out of range {_warningJudgmentRange} °C in {_warningJudgmentTime:F0} seconds";
  886. AlarmToleranceWarning.Set();
  887. }
  888. public void Ramp(double target, int time)
  889. {
  890. target = Math.Max(0, target);
  891. //target = Math.Min(Range, target);
  892. _rampInitValue = TempFeedback; //ramp 初始值取当前设定值,而非实际读取值.零漂问题
  893. _rampTime = time;
  894. _rampTarget = target;
  895. _rampTimer.Start(_rampTime);
  896. _isStartRamp = true;
  897. }
  898. private void Ramping()
  899. {
  900. //只有修改了温度,才开始ramp,避免一开机温度设定值大于0的问题。
  901. if (!_isStartRamp)
  902. return;
  903. if (_rampTimer.IsTimeout() || _rampTime == 0)
  904. {
  905. TempSetPoint = (float)_rampTarget;
  906. }
  907. else
  908. {
  909. TempSetPoint = (float)(_rampInitValue + (_rampTarget - _rampInitValue) * _rampTimer.GetElapseTime() / _rampTime);
  910. }
  911. }
  912. private void SaveRampRate(string ramping)
  913. {
  914. SC.SetItemValueFromString($"{_scRoot}.{Name}.RampRate", ramping);
  915. }
  916. public void SetCorrectParameters(string name, string recipeCorrectFileName = null, string recipeProfileFileName = null)
  917. {
  918. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  919. //var defaultPID = SC.GetStringValue("PM1.APCPID");
  920. if (string.IsNullOrEmpty(name))
  921. {
  922. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file is empty");
  923. name = SC.GetStringValue("PM1.TempCorrection");
  924. }
  925. var array = name.Split(',');
  926. if (array == null || array.Length < 2)
  927. {
  928. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature correct parameter");
  929. name = SC.GetStringValue("PM1.TempCorrection");
  930. array = name.Split(',');
  931. }
  932. if (!File.Exists($"{PathManager.GetParameterDir()}\\{array[0]}.rcp"))
  933. {
  934. name = SC.GetStringValue("PM1.TempCorrection");
  935. var temp = name.Split(',');
  936. if (temp != null && array.Length > 0)
  937. {
  938. array[0] = temp[0];
  939. name = string.Join(",", array);
  940. }
  941. }
  942. if (array == null || array.Length < 2)
  943. {
  944. return;
  945. }
  946. var fileNameAndPath = array[0];
  947. int.TryParse(array[1], out int index);
  948. var para = fileNameAndPath.Split('\\').ToList().Skip(2);//"Parameter\\TempCorrection"
  949. if (para == null)
  950. {
  951. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file is empty");
  952. return;
  953. }
  954. var fileName = string.Join("\\", para.ToArray());
  955. if (!string.IsNullOrEmpty(recipeCorrectFileName))
  956. fileName = recipeCorrectFileName;
  957. CurrentCorrectFileName = fileName;
  958. CurrentCorrectIndex = index;
  959. var content = ParameterFileManager.Instance.LoadParameter("Parameter\\TempCorrection", fileName, false);
  960. if (string.IsNullOrEmpty(content))
  961. {
  962. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"{fileNameAndPath} heater temperature correct file is empty");
  963. return;
  964. }
  965. var doc = new XmlDocument();
  966. doc.LoadXml(content);
  967. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='']/Step");
  968. if (nodeSteps == null)
  969. nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Step");
  970. if (nodeSteps == null)
  971. {
  972. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature correct file {fileNameAndPath}");
  973. return;
  974. }
  975. Dictionary<int, CorrectTableParameter> dic = new Dictionary<int, CorrectTableParameter>();
  976. for (int i = 0; i < nodeSteps.Count; i++)
  977. {
  978. var step = nodeSteps[i];
  979. XmlElement stepNode = step as XmlElement;
  980. var correctTableParameter = new CorrectTableParameter();
  981. correctTableParameter.CorrectParameterLst = new List<CorrectParameter>();
  982. int tableIndex = i + 1;
  983. foreach (XmlAttribute att in stepNode.Attributes)
  984. {
  985. switch (att.Name.ToLower())
  986. {
  987. case "index":
  988. int.TryParse(att.Value, out int no);
  989. correctTableParameter.No = no;
  990. break;
  991. case "name":
  992. correctTableParameter.Name = att.Value;
  993. break;
  994. case "tableuserangemax":
  995. float.TryParse(att.Value, out float tableuserangemax);
  996. correctTableParameter.TableUseRangeMax = tableuserangemax;
  997. break;
  998. case "tableuserangemin":
  999. float.TryParse(att.Value, out float tableuserangemin);
  1000. correctTableParameter.TableUseRangeMin = tableuserangemin;
  1001. break;
  1002. case "profileconditiontableno":
  1003. int.TryParse(att.Value, out int profileconditiontableno);
  1004. correctTableParameter.ProfileConditionTableNo = profileconditiontableno;
  1005. break;
  1006. case "pemppidtableno":
  1007. int.TryParse(att.Value, out int pemppidtableno);
  1008. correctTableParameter.TempPIDTableNo = pemppidtableno;
  1009. break;
  1010. case "profiletccalibtemp":
  1011. float.TryParse(att.Value, out float profiletccalibtemp);
  1012. correctTableParameter.ProfileTCCalibTemp = profiletccalibtemp;
  1013. break;
  1014. }
  1015. if (att.Name.ToLower() == "correctiondata" && !dic.ContainsKey(tableIndex))
  1016. {
  1017. //"Index:1;Name:U;ProfileTemp:0;ProfileCorrect:0;CascadeTCCorrect:0;ProfileTCCalib:0|Index:2;Name:CU;ProfileTemp:0;ProfileCorrect:0;CascadeTCCorrect:0;ProfileTCCalib:0|Index:3;Name:C;ProfileTemp:0;ProfileCorrect:0;CascadeTCCorrect:0;ProfileTCCalib:0|Index:4;Name:CL;ProfileTemp:0;ProfileCorrect:0;CascadeTCCorrect:0;ProfileTCCalib:0|Index:5;Name:L;ProfileTemp:0;ProfileCorrect:0;CascadeTCCorrect:0;ProfileTCCalib:0"
  1018. var correctionDataString = att.Value;
  1019. if (string.IsNullOrEmpty(correctionDataString))
  1020. {
  1021. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file is empty");
  1022. return;
  1023. }
  1024. var correctionDatas = correctionDataString.Split('|');
  1025. if (correctionDatas.Length < 5)
  1026. {
  1027. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file data length is invalid");
  1028. return;
  1029. }
  1030. foreach (var datas in correctionDatas)
  1031. {
  1032. var dataArry = datas.Split(';');
  1033. if (dataArry.Length < 6)
  1034. {
  1035. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file data length is invalid");
  1036. return;
  1037. }
  1038. var correctParameter = new CorrectParameter();
  1039. foreach (var item in dataArry)
  1040. {
  1041. var itemArry = item.Split(':');
  1042. if (itemArry.Length < 2)
  1043. {
  1044. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file data length is invalid");
  1045. return;
  1046. }
  1047. switch (itemArry[0].ToLower())
  1048. {
  1049. case "index":
  1050. int.TryParse(itemArry[1], out int no);
  1051. correctParameter.No = no;
  1052. break;
  1053. case "name":
  1054. correctParameter.Name = itemArry[1];
  1055. break;
  1056. case "profiletemp":
  1057. float.TryParse(itemArry[1], out float profiletemp);
  1058. correctParameter.ProfileTemp = profiletemp;
  1059. break;
  1060. case "profilecorrect":
  1061. float.TryParse(itemArry[1], out float profilecorrect);
  1062. correctParameter.ProfileCorrect = profilecorrect;
  1063. break;
  1064. case "cascadetccorrect":
  1065. float.TryParse(itemArry[1], out float cascadetccorrect);
  1066. correctParameter.CascadeTCCorrect = cascadetccorrect;
  1067. break;
  1068. case "profiletccalib":
  1069. float.TryParse(itemArry[1], out float profiletccalib);
  1070. correctParameter.ProfileTCCalib = profiletccalib;
  1071. break;
  1072. }
  1073. }
  1074. correctTableParameter.CorrectParameterLst.Add(correctParameter);
  1075. }
  1076. break;
  1077. }
  1078. }
  1079. dic.Add(tableIndex, correctTableParameter);
  1080. }
  1081. if (dic.ContainsKey(index))
  1082. {
  1083. var item = dic[index];
  1084. var heaterIndex = GetHeaterIndex() - 1;//U的index是0
  1085. if (item.CorrectParameterLst.Count > heaterIndex)
  1086. {
  1087. _profileTemp = item.CorrectParameterLst[heaterIndex].ProfileTemp;
  1088. _profileCorrect = item.CorrectParameterLst[heaterIndex].ProfileCorrect;
  1089. _profileTCCalib = item.CorrectParameterLst[heaterIndex].ProfileTCCalib;
  1090. _cascadeTCCorrect = item.CorrectParameterLst[heaterIndex].CascadeTCCorrect;
  1091. }
  1092. else
  1093. {
  1094. _profileTemp = 0;
  1095. _profileCorrect = 0;
  1096. _profileTCCalib = 0;
  1097. _cascadeTCCorrect = 0;
  1098. }
  1099. GetProfileParameters(SC.GetStringValue("PM1.TempProfile"), item.ProfileConditionTableNo, recipeProfileFileName);
  1100. }
  1101. else
  1102. {
  1103. _profileTemp = 0;
  1104. _profileCorrect = 0;
  1105. _profileTCCalib = 0;
  1106. _cascadeTCCorrect = 0;
  1107. //auto select
  1108. }
  1109. var temperature = DeviceData.SetPoint;
  1110. var actualSet = temperature + _profileTCCalib;
  1111. if (temperature > 0)
  1112. TempSetPoint = (float)actualSet;
  1113. DeviceData.CorrectTable = name;
  1114. if (SC.GetStringValue("PM1.TempCorrection") != name)
  1115. SC.SetItemValueFromString("PM1.TempCorrection", name);
  1116. }
  1117. public void SetPIDParameters(string name, string recipePIDFileName = null)
  1118. {
  1119. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  1120. //var defaultPID = SC.GetStringValue("PM1.APCPID");
  1121. if (string.IsNullOrEmpty(name))
  1122. {
  1123. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature PID file is empty");
  1124. return;
  1125. }
  1126. var array = name.Split(',');
  1127. if (array == null || array.Length < 2)
  1128. {
  1129. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature PID parameter");
  1130. return;
  1131. }
  1132. if (!File.Exists($"{PathManager.GetParameterDir()}\\{array[0]}.rcp"))
  1133. return;
  1134. var fileNameAndPath = array[0];
  1135. int.TryParse(array[1], out int index);
  1136. var para = fileNameAndPath.Split('\\').ToList().Skip(2);//"Parameter\\TempPID"
  1137. if (para == null)
  1138. {
  1139. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature PID file is empty");
  1140. return;
  1141. }
  1142. var fileName = string.Join("\\", para.ToArray());
  1143. if (!string.IsNullOrEmpty(recipePIDFileName))
  1144. fileName = recipePIDFileName;
  1145. var content = ParameterFileManager.Instance.LoadParameter("Parameter\\TempPID", fileName, false);
  1146. if (string.IsNullOrEmpty(content))
  1147. {
  1148. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"{fileNameAndPath} heater temperature PID file is empty");
  1149. return;
  1150. }
  1151. var doc = new XmlDocument();
  1152. doc.LoadXml(content);
  1153. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='']/Step");
  1154. if (nodeSteps == null)
  1155. nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Step");
  1156. if (nodeSteps == null)
  1157. {
  1158. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature PID file {fileNameAndPath}");
  1159. return;
  1160. }
  1161. Dictionary<int, List<PIDParameter>> dic = new Dictionary<int, List<PIDParameter>>();
  1162. for (int i = 0; i < nodeSteps.Count; i++)
  1163. {
  1164. var step = nodeSteps[i];
  1165. XmlElement stepNode = step as XmlElement;
  1166. var pidParameters = new List<PIDParameter>();
  1167. int tableIndex = i + 1;
  1168. foreach (XmlAttribute att in stepNode.Attributes)
  1169. {
  1170. if (att.Name == "PIDData" && !dic.ContainsKey(tableIndex))
  1171. {
  1172. //"Index:1;Name:HT.U;P:11.5;I:12;D:13|Index:2;Name:HTCU;P:21.5;I:22;D:23|Index:3;Name:HT.C;P:31.5;I:32;D:33|Index:4;Name:HTCL;P:41.5;I:42;D:43|Index:5;Name:HT.L;P:51.5;I:52;D:53|Index:6;Name:PR.U;P:0.5;I:10;D:0|Index:7;Name:PRCU;P:0.5;I:10;D:0|Index:8;Name:PR.C;P:0.5;I:10;D:0|Index:9;Name:PRCL;P:0.5;I:10;D:0|Index:10;Name:PR.L;P:0.5;I:10;D:0"
  1173. var PIDDataString = att.Value;
  1174. if (string.IsNullOrEmpty(PIDDataString))
  1175. {
  1176. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature PID file is empty");
  1177. return;
  1178. }
  1179. var pidDatas = PIDDataString.Split('|');
  1180. if (pidDatas.Length < 5)
  1181. {
  1182. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature PID file data length is invalid");
  1183. return;
  1184. }
  1185. foreach (var datas in pidDatas)
  1186. {
  1187. var dataArry = datas.Split(';');
  1188. if (dataArry.Length < 5)
  1189. {
  1190. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature PID file data length is invalid");
  1191. return;
  1192. }
  1193. var pidParameter = new PIDParameter();
  1194. foreach (var item in dataArry)
  1195. {
  1196. var itemArry = item.Split(':');
  1197. if (itemArry.Length < 2)
  1198. {
  1199. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature PID file data length is invalid");
  1200. return;
  1201. }
  1202. switch (itemArry[0].ToLower())
  1203. {
  1204. case "index":
  1205. int.TryParse(itemArry[1], out int no);
  1206. pidParameter.No = no;
  1207. break;
  1208. case "name":
  1209. pidParameter.Name = itemArry[1];
  1210. break;
  1211. case "p":
  1212. float.TryParse(itemArry[1], out float p);
  1213. pidParameter.P = p;
  1214. break;
  1215. case "i":
  1216. float.TryParse(itemArry[1], out float ii);
  1217. pidParameter.I = ii;
  1218. break;
  1219. case "d":
  1220. float.TryParse(itemArry[1], out float d);
  1221. pidParameter.D = d;
  1222. break;
  1223. }
  1224. }
  1225. pidParameters.Add(pidParameter);
  1226. }
  1227. break;
  1228. }
  1229. }
  1230. dic.Add(tableIndex, pidParameters);
  1231. }
  1232. if (dic.ContainsKey(index))
  1233. {
  1234. var item = dic[index];
  1235. if (_pidTableAssociate.ContainsKey(Name) && item.Count > _pidTableAssociate[Name] + 5)
  1236. {
  1237. HeaterPID_P = item[_pidTableAssociate[Name]].P;
  1238. HeaterPID_I = item[_pidTableAssociate[Name]].I;
  1239. HeaterPID_D = item[_pidTableAssociate[Name]].D;
  1240. CascadePID_P = item[_pidTableAssociate[Name] + 5].P;
  1241. CascadePID_I = item[_pidTableAssociate[Name] + 5].I;
  1242. CascadePID_D = item[_pidTableAssociate[Name] + 5].D;
  1243. }
  1244. }
  1245. else
  1246. {
  1247. //auto select
  1248. }
  1249. if (SC.GetStringValue("PM1.Heater.PID") != name)
  1250. SC.SetItemValueFromString("PM1.Heater.PID", name);
  1251. DeviceData.PIDTable = name;
  1252. }
  1253. public void GetProfileParameters(string fileNameAndPath, int index, string recipeProfileFileName = null)
  1254. {
  1255. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  1256. if (string.IsNullOrEmpty(fileNameAndPath))
  1257. {
  1258. DeviceData.ProfileTable = "";
  1259. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature Profile file is empty");
  1260. return;
  1261. }
  1262. if (!File.Exists($"{PathManager.GetParameterDir()}\\{fileNameAndPath}.rcp"))
  1263. return;
  1264. var para = fileNameAndPath.Split('\\').ToList().Skip(2);//"Parameter\\TempPID"
  1265. if (para == null)
  1266. {
  1267. DeviceData.ProfileTable = "";
  1268. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature Profile file is empty");
  1269. return;
  1270. }
  1271. var fileName = string.Join("\\", para.ToArray());
  1272. if (!string.IsNullOrEmpty(recipeProfileFileName))
  1273. fileName = recipeProfileFileName;
  1274. var content = ParameterFileManager.Instance.LoadParameter("Parameter\\TempProfile", fileName, false);
  1275. if (string.IsNullOrEmpty(content))
  1276. {
  1277. DeviceData.ProfileTable = "";
  1278. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"{fileNameAndPath} heater temperature Profile file is empty");
  1279. return;
  1280. }
  1281. var doc = new XmlDocument();
  1282. doc.LoadXml(content);
  1283. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='']/Step");
  1284. if (nodeSteps == null)
  1285. nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Step");
  1286. if (nodeSteps == null)
  1287. {
  1288. DeviceData.ProfileTable = "";
  1289. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid heater temperature Profile file {fileNameAndPath}");
  1290. return;
  1291. }
  1292. Dictionary<int, ProfileParameter> dic = new Dictionary<int, ProfileParameter>();
  1293. for (int i = 0; i < nodeSteps.Count; i++)
  1294. {
  1295. var step = nodeSteps[i];
  1296. XmlElement stepNode = step as XmlElement;
  1297. var profileParameter = new ProfileParameter();
  1298. int tableIndex = i + 1;
  1299. foreach (XmlAttribute att in stepNode.Attributes)
  1300. {
  1301. switch (att.Name.ToLower())
  1302. {
  1303. case "index":
  1304. int.TryParse(att.Value, out int no);
  1305. profileParameter.No = no;
  1306. break;
  1307. case "name":
  1308. profileParameter.Name = att.Value;
  1309. break;
  1310. case "preheattime":
  1311. float.TryParse(att.Value, out float preheattime);
  1312. profileParameter.PreheatTime = preheattime;
  1313. break;
  1314. case "checktime":
  1315. float.TryParse(att.Value, out float checktime);
  1316. profileParameter.CheckTime = checktime;
  1317. break;
  1318. case "totaltime":
  1319. int.TryParse(att.Value, out int totaltime);
  1320. profileParameter.TotalTime = totaltime;
  1321. break;
  1322. case "alarmlimit":
  1323. int.TryParse(att.Value, out int alarmlimit);
  1324. profileParameter.AlarmLimit = alarmlimit;
  1325. break;
  1326. case "u":
  1327. float.TryParse(att.Value, out float u);
  1328. profileParameter.U = u;
  1329. break;
  1330. case "cu":
  1331. float.TryParse(att.Value, out float cu);
  1332. profileParameter.CU = cu;
  1333. break;
  1334. case "c":
  1335. float.TryParse(att.Value, out float c);
  1336. profileParameter.C = c;
  1337. break;
  1338. case "cl":
  1339. float.TryParse(att.Value, out float cl);
  1340. profileParameter.CL = cl;
  1341. break;
  1342. case "l":
  1343. float.TryParse(att.Value, out float l);
  1344. profileParameter.L = l;
  1345. break;
  1346. }
  1347. }
  1348. dic.Add(tableIndex, profileParameter);
  1349. }
  1350. if (dic.ContainsKey(index))
  1351. {
  1352. var item = dic[index];
  1353. _preheatTime = item.PreheatTime;
  1354. _checkTime = item.CheckTime;
  1355. _alarmLimit = item.AlarmLimit;
  1356. _totalTime = item.TotalTime;
  1357. DeviceData.ProfileTable = $"{fileNameAndPath},{index},{item.Name}";
  1358. switch (Name)
  1359. {
  1360. case "HeaterU":
  1361. _checkLimit = item.U;
  1362. break;
  1363. case "HeaterCU":
  1364. _checkLimit = item.CU;
  1365. break;
  1366. case "HeaterC":
  1367. _checkLimit = item.C;
  1368. break;
  1369. case "HeaterCL":
  1370. _checkLimit = item.CL;
  1371. break;
  1372. case "HeaterL":
  1373. _checkLimit = item.L;
  1374. break;
  1375. }
  1376. DeviceData.ProfileTotalTime = _totalTime;
  1377. DeviceData.ProfilePreheatTime = _preheatTime;
  1378. DeviceData.ProfileCheckTime = _checkTime;
  1379. DeviceData.ProfileAlarmLimit = _alarmLimit;
  1380. DeviceData.ProfileCheckLimit = _checkLimit;
  1381. DeviceData.ProfileStatus = "PreHeat";
  1382. }
  1383. else
  1384. {
  1385. _checkLimit = 0;
  1386. _preheatTime = 0;
  1387. _checkTime = 0;
  1388. _alarmLimit = 0;
  1389. _totalTime = 0;
  1390. DeviceData.ProfileTable = "";
  1391. DeviceData.ProfileTotalTime = 0;
  1392. DeviceData.ProfilePreheatTime = 0;
  1393. DeviceData.ProfileCheckTime = 0;
  1394. DeviceData.ProfileAlarmLimit = 0;
  1395. DeviceData.ProfileCheckLimit = 0;
  1396. }
  1397. }
  1398. public bool CheckProfileFinish(out string reason)
  1399. {
  1400. reason = "";
  1401. if (_profileTimer != null && _profileTimer.IsRunning)
  1402. {
  1403. _profileTotalTimeoutTrig.CLK = _profileTimer.ElapsedMilliseconds >= _totalTime * 1000;
  1404. if (_profileTotalTimeoutTrig.Q)
  1405. {
  1406. LOG.Write($"{Name} profile timeout={_totalTime}");
  1407. EV.PostWarningLog(ModuleName.PM1.ToString(), $"{Name} profile timeout={_totalTime}");//超过total time之后,只是报warning提示
  1408. }
  1409. if (_profileTimer.ElapsedMilliseconds >= _preheatTime * 1000)//preheat time之后,才开始判断
  1410. {
  1411. DeviceData.ProfileStatus = "Profile Check";
  1412. if (_profileStableTimer != null)
  1413. {
  1414. if (!_profileStableTimer.IsRunning)
  1415. _profileStableTimer.Restart();
  1416. if (Math.Abs(TempFeedback - TempSetPoint) > _checkLimit)
  1417. _profileStableTimer.Restart();
  1418. _profileAlarmLimitTrig.CLK = Math.Abs(TempFeedback - TempSetPoint) > _alarmLimit && _alarmLimit > 0;
  1419. if (_profileAlarmLimitTrig.Q)
  1420. EV.PostWarningLog(ModuleName.PM1.ToString(), $"{Name} profile success setpoint={TempSetPoint} feedback={TempFeedback}, difference={Math.Abs(TempFeedback - TempSetPoint)} is more than alarm limit={_alarmLimit}");
  1421. _profileSuccessTrig.CLK = _profileStableTimer.ElapsedMilliseconds > _checkTime * 1000;
  1422. if (_profileStableTimer.ElapsedMilliseconds > _checkTime * 1000)
  1423. {
  1424. IsProfileSuccess = true;
  1425. if (_profileSuccessTrig.Q)
  1426. LOG.Write($"{Name} profile success setpoint={TempSetPoint} feedback={TempFeedback}");
  1427. return true;
  1428. }
  1429. }
  1430. }
  1431. reason = $"{Name} profile not finish";
  1432. return false;
  1433. }
  1434. else
  1435. {
  1436. return true;
  1437. }
  1438. }
  1439. private int GetHeaterIndex()
  1440. {
  1441. int.TryParse(Name.Replace("Heater", ""), out int heaterIndex);//改了heater数量这边需要改
  1442. switch (Name)
  1443. {
  1444. case "HeaterU":
  1445. heaterIndex = 1;
  1446. break;
  1447. case "HeaterCU":
  1448. heaterIndex = 2;
  1449. break;
  1450. case "HeaterC":
  1451. heaterIndex = 3;
  1452. break;
  1453. case "HeaterCL":
  1454. heaterIndex = 4;
  1455. break;
  1456. case "HeaterL":
  1457. heaterIndex = 5;
  1458. break;
  1459. }
  1460. return heaterIndex;
  1461. }
  1462. public bool CheckWaitCondition(out string reason)
  1463. {
  1464. reason = "";
  1465. if (!_isWait || _waitHigh == 0 || _waitLow == 0)
  1466. return true;
  1467. if (_stableJudgmentTimer.IsRunning)
  1468. {
  1469. if (TempFeedback < _tempSetpoint - _waitLow ||
  1470. TempFeedback > _tempSetpoint + _waitHigh)
  1471. {
  1472. _stableJudgmentTimer.Restart();
  1473. }
  1474. if (_stableJudgmentTimer.ElapsedMilliseconds >= _stableJudgmentTime * 1000)
  1475. {
  1476. return true;
  1477. }
  1478. }
  1479. else
  1480. {
  1481. _stableJudgmentTimer.Restart();
  1482. }
  1483. reason = $"{Name} feedback={TempFeedback}, wait limit is ({_tempSetpoint - _waitLow}, {_tempSetpoint + _waitHigh})";
  1484. return false;
  1485. }
  1486. struct PIDParameter
  1487. {
  1488. public int No { get; set; }
  1489. public string Name { get; set; }
  1490. public float P { get; set; }
  1491. public float I { get; set; }
  1492. public float D { get; set; }
  1493. }
  1494. struct CorrectTableParameter
  1495. {
  1496. public int No { get; set; }
  1497. public string Name { get; set; }
  1498. public float ProfileTCCalibTemp { get; set; }
  1499. public float TableUseRangeMin { get; set; }
  1500. public float TableUseRangeMax { get; set; }
  1501. public int ProfileConditionTableNo { get; set; }
  1502. public int TempPIDTableNo { get; set; }
  1503. public List<CorrectParameter> CorrectParameterLst { get; set; }
  1504. }
  1505. struct ProfileParameter
  1506. {
  1507. public int No { get; set; }
  1508. public string Name { get; set; }
  1509. public float PreheatTime { get; set; }
  1510. public float CheckTime { get; set; }
  1511. public float TotalTime { get; set; }
  1512. public float AlarmLimit { get; set; }
  1513. public float U { get; set; }
  1514. public float CU { get; set; }
  1515. public float C { get; set; }
  1516. public float CL { get; set; }
  1517. public float L { get; set; }
  1518. }
  1519. }
  1520. public struct CorrectParameter
  1521. {
  1522. public int No { get; set; }
  1523. public string Name { get; set; }
  1524. public float ProfileTemp { get; set; }
  1525. public float ProfileTCCalib { get; set; }
  1526. public float ProfileCorrect { get; set; }
  1527. public float CascadeTCCorrect { get; set; }
  1528. }
  1529. }