VpwCellDevice.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.OperationCenter;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using MECF.Framework.Common.Beckhoff.ModuleIO;
  8. using MECF.Framework.Common.CommonData.Prewet;
  9. using MECF.Framework.Common.CommonData.Vpw;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.IOCore;
  12. using MECF.Framework.Common.Persistent.Reservoirs;
  13. using MECF.Framework.Common.Persistent.SRD;
  14. using MECF.Framework.Common.Persistent.Temperature;
  15. using MECF.Framework.Common.Persistent.VpwCell;
  16. using MECF.Framework.Common.Persistent.VpwMain;
  17. using MECF.Framework.Common.ToolLayout;
  18. using MECF.Framework.Common.Utilities;
  19. using PunkHPX8_RT.Devices.AXIS;
  20. using PunkHPX8_RT.Devices.Resistivity;
  21. using PunkHPX8_RT.Devices.VpwMain;
  22. using PunkHPX8_RT.Modules;
  23. using PunkHPX8_RT.Modules.Reservoir;
  24. using PunkHPX8_RT.Modules.VpwMain;
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Linq;
  28. using System.Reflection;
  29. using System.Text;
  30. using System.Threading.Tasks;
  31. namespace PunkHPX8_RT.Devices.VpwCell
  32. {
  33. public class VpwCellDevice : BaseDevice, IDevice
  34. {
  35. #region 常量
  36. private const string COMMON_DATA = "CommonData";
  37. private const string DIW_FLOW = "DiwFlow";
  38. private const string VACUUM_PRESSURE = "VacuumPressure";
  39. private const string FLOW_DRIP = "FlowDrip";
  40. private const string FLOW_SMALL = "FlowSmall";
  41. private const string FLOW_LARGE = "FlowLarge";
  42. private const string VACUUM_VALVE = "VacuumValve";
  43. private const string VENT_VALVE = "VentValve";
  44. private const string DRAIN_VALVE = "DrainValve";
  45. private const string PERSISTENT_VALUE = "PersistentValue";
  46. private const string LOOPDO_VALUE = "LoopDoValue";
  47. #endregion
  48. #region 内部变量
  49. /// <summary>
  50. /// 变量是否初始化字典
  51. /// </summary>
  52. private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
  53. /// <summary>
  54. /// 数据
  55. /// </summary>
  56. private VpwCellCommonData _commonData=new VpwCellCommonData();
  57. /// Vpw main数据
  58. /// </summary>
  59. private VpwMainCommonData _mainCommonData = new VpwMainCommonData();
  60. /// <summary>
  61. /// 持久性数值
  62. /// </summary>
  63. private VpwCellPersistentValue _vpwCellPersistentValue;
  64. /// <summary>
  65. /// 水平电机
  66. /// </summary>
  67. private JetAxisBase _rotationAxis;
  68. /// <summary>
  69. /// 水阻计控制器
  70. /// </summary>
  71. private ResistivityController _resistivityController;
  72. /// <summary>
  73. /// 水阻值
  74. /// </summary>
  75. private double _resistivityValue;
  76. /// <summary>
  77. /// main device
  78. /// </summary>
  79. private VpwMainDevice _vpwMainDevice;
  80. /// <summary>
  81. /// cell flow 初始设定值
  82. /// </summary>
  83. private double _cellFlowSetValue;
  84. /// <summary>
  85. /// total flow 初始设定值
  86. /// </summary>
  87. private double _totalFlowSetValue;
  88. /// <summary>
  89. /// total流量满足初始设定值自动打开排水阀的时间
  90. /// </summary>
  91. private int _dripValveOpenIdlePeriod;
  92. /// <summary>
  93. /// 检测到total flow 满足设定条件的时间
  94. /// </summary>
  95. private DateTime _totalFlowOkDetectTime;
  96. /// <summary>
  97. /// 是否在检测totalflow的周期中
  98. /// </summary>
  99. private bool _isIntotalFlowCheck=false;
  100. /// <summary>
  101. /// 检查cellflow的时机flag
  102. /// </summary>
  103. private bool _cellFlowCheckFlag = false;
  104. #endregion
  105. #region 属性
  106. /// <summary>
  107. /// 数据
  108. /// </summary>
  109. public VpwCellCommonData CommonData { get { return _commonData; } }
  110. /// <summary>
  111. /// vpw main数据
  112. /// </summary>
  113. public VpwMainCommonData MainCommonData { get { return _mainCommonData; } }
  114. /// <summary>
  115. /// 操作模式
  116. /// </summary>
  117. public string OperationMode { get { return _vpwCellPersistentValue.OperatingMode; } }
  118. /// <summary>
  119. /// 工程模式
  120. /// </summary>
  121. public string EngineerMode { get { return _vpwCellPersistentValue.RecipeOperatingMode; } }
  122. /// <summary>
  123. /// LoopDO数值
  124. /// </summary>
  125. public double LoopDOValue { get { return GetLoopDOValue(); } }
  126. #endregion
  127. /// <summary>
  128. /// 构造函数
  129. /// </summary>
  130. /// <param name="moduleName"></param>
  131. public VpwCellDevice(string moduleName) : base(moduleName, moduleName, moduleName, moduleName)
  132. {
  133. }
  134. #region 初始化
  135. /// <summary>
  136. /// 初始化
  137. /// </summary>
  138. /// <returns></returns>
  139. public bool Initialize()
  140. {
  141. InitializeParameter();
  142. InitializeRoutine();
  143. SubscribeData();
  144. SubscribeValueAction();
  145. InitializeOperation();
  146. return true;
  147. }
  148. /// <summary>
  149. /// 初始化参数
  150. /// </summary>
  151. private void InitializeParameter()
  152. {
  153. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  154. _vpwCellPersistentValue = VpwCellPersistentManager.Instance.GetPersistentValue(Module);
  155. VpwCellItem vpwCellItem=VpwCellItemManager.Instance.GetVpwItem(Module);
  156. if (vpwCellItem != null)
  157. {
  158. _resistivityController = DEVICE.GetDevice<ResistivityController>(vpwCellItem.ResistivityID);
  159. }
  160. _vpwMainDevice = DEVICE.GetDevice<VpwMainDevice>($"VPWMain1");
  161. if(_vpwMainDevice != null)
  162. {
  163. _mainCommonData = _vpwMainDevice.CommonData;
  164. }
  165. }
  166. /// <summary>
  167. /// 初始化Routine
  168. /// </summary>
  169. private void InitializeRoutine()
  170. {
  171. }
  172. /// <summary>
  173. /// 订阅
  174. /// </summary>
  175. private void SubscribeData()
  176. {
  177. DATA.Subscribe($"{Module}.{COMMON_DATA}", () => CommonData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  178. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _vpwCellPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  179. DATA.Subscribe($"{Module}.DiwCellFlow", () => CommonData.DiwFlow, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  180. DATA.Subscribe($"{Module}.VacuumValve", () => CommonData.VacuumValve, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  181. DATA.Subscribe($"{Module}.{LOOPDO_VALUE}", ()=> { return GetLoopDOValue(); }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  182. DATA.Subscribe($"{Module}.VpwWaferSize", ()=> { return GetLoopDOValue(); }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  183. }
  184. /// <summary>
  185. /// 获取Loop do数值
  186. /// </summary>
  187. /// <returns></returns>
  188. private double GetLoopDOValue()
  189. {
  190. if (_resistivityController != null)
  191. {
  192. string value = _resistivityController.ResisitivityValue;
  193. if (double.TryParse(value, out _resistivityValue))
  194. {
  195. return _resistivityValue;
  196. }
  197. else
  198. {
  199. _resistivityValue = 0;
  200. return 0;
  201. }
  202. }
  203. else
  204. {
  205. return 0;
  206. }
  207. }
  208. /// <summary>
  209. /// 订阅数据
  210. /// </summary>
  211. private void SubscribeValueAction()
  212. {
  213. IoSubscribeUpdateVariable(DIW_FLOW);
  214. IoSubscribeUpdateVariable(DRAIN_VALVE);
  215. IoSubscribeUpdateVariable(VACUUM_PRESSURE);
  216. IoSubscribeUpdateVariable(VACUUM_VALVE);
  217. IoSubscribeUpdateVariable(VENT_VALVE);
  218. IoSubscribeUpdateVariable(FLOW_DRIP);
  219. IoSubscribeUpdateVariable(FLOW_LARGE);
  220. IoSubscribeUpdateVariable(FLOW_SMALL);
  221. }
  222. /// <summary>
  223. /// 初始化变量
  224. /// </summary>
  225. /// <param name="variable"></param>
  226. private void IoSubscribeUpdateVariable(string variable)
  227. {
  228. _variableInitializeDic[variable] = false;
  229. IOModuleManager.Instance.SubscribeModuleVariable(Module, variable, UpdateVariableValue);
  230. }
  231. /// <summary>
  232. /// 更新变量数值
  233. /// </summary>
  234. /// <param name="variable"></param>
  235. /// <param name="value"></param>
  236. private void UpdateVariableValue(string variable, object value)
  237. {
  238. PropertyInfo property = _commonData.GetType().GetProperty(variable);
  239. if (property != null)
  240. {
  241. property.SetValue(_commonData, value);
  242. if (variable == VACUUM_PRESSURE)
  243. {
  244. double torr = UnitUtil.ConvertToTorr((double)value);
  245. property.SetValue(_commonData, torr);
  246. }
  247. }
  248. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  249. {
  250. _variableInitializeDic[variable] = true;
  251. }
  252. }
  253. /// <summary>
  254. /// 初始化OP
  255. /// </summary>
  256. private void InitializeOperation()
  257. {
  258. OP.Subscribe($"{Module}.FlowDripOn", (cmd,para)=> { return FlowDripOn(); });
  259. OP.Subscribe($"{Module}.FlowDripOff", (cmd, para) => { return FlowDripOff(); });
  260. OP.Subscribe($"{Module}.FlowSmallOn", (cmd, para) => { return FlowSmallOn(); });
  261. OP.Subscribe($"{Module}.FlowSmallOff", (cmd, para) => { return FlowSmallOff(); });
  262. OP.Subscribe($"{Module}.FlowLargeOn", (cmd, para) => { return FlowLargeOn(); });
  263. OP.Subscribe($"{Module}.FlowLargeOff", (cmd, para) => { return FlowLargeOff(); });
  264. OP.Subscribe($"{Module}.VentValveOn", (cmd, para) => { return VentValveOn(); });
  265. OP.Subscribe($"{Module}.VentValveOff", (cmd, para) => { return VentValveOff(); });
  266. OP.Subscribe($"{Module}.DrainValveOn", (cmd, para) => { return DrainValveOn(); });
  267. OP.Subscribe($"{Module}.DrainValveOff", (cmd, para) => { return DrainValveOff(); });
  268. OP.Subscribe($"{Module}.VacuumValveOn", (cmd, para) => { return VacuumValveOn(); });
  269. OP.Subscribe($"{Module}.VacuumValveOff", (cmd, para) => { return VacuumValveOff(); });
  270. OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
  271. OP.Subscribe($"{Module}.ManualAction", ManualOperation);
  272. OP.Subscribe($"{Module}.AutoAction", AutoOperation);
  273. OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
  274. OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
  275. OP.Subscribe($"{Module}.StartRotation", StartRotationAction);
  276. OP.Subscribe($"{Module}.StopRotation", StopRotationAction);
  277. OP.Subscribe($"{Module}.SetVpwCellWaferSize", (cmd, args) => { return SetVpwCellWaferSize(cmd, args); });
  278. }
  279. #endregion
  280. #region Action
  281. private bool StartRotationAction(string cmd, object[] args)
  282. {
  283. if (args.Length < 2 && (int)args[0] < 0 && (int)args[1] < 0)
  284. {
  285. LOG.WriteLog(eEvent.ERR_VPW, Module, $"Start rotation paramater is wrong");
  286. return false;
  287. }
  288. double targetPostion = (int)args[0] * 6 * (int)args[1];
  289. object[] param = new object[] { "",targetPostion };
  290. int degSpeed = (int)args[0] * 6;
  291. SetRotationSpeed(degSpeed);
  292. //return _rotationAxis.JogUpPosition("", param);
  293. double AfterChangetargetPostion = (int)args[0] * 6 * (int)args[1];
  294. return RotationProfilePosition(AfterChangetargetPostion);
  295. }
  296. private bool StopRotationAction(string cmd, object[] args)
  297. {
  298. return _rotationAxis.StopPositionOperation();
  299. }
  300. #region Flow
  301. /// <summary>
  302. /// Flow Drip on
  303. /// </summary>
  304. /// <returns></returns>
  305. public bool FlowDripOn()
  306. {
  307. return WriteVariableValue(FLOW_DRIP, true);
  308. }
  309. /// <summary>
  310. /// Flow Drip Off
  311. /// </summary>
  312. /// <returns></returns>
  313. public bool FlowDripOff()
  314. {
  315. return WriteVariableValue(FLOW_DRIP, false);
  316. }
  317. /// <summary>
  318. /// Flow Small On
  319. /// </summary>
  320. /// <returns></returns>
  321. public bool FlowSmallOn()
  322. {
  323. return WriteVariableValue(FLOW_SMALL, true);
  324. }
  325. /// <summary>
  326. /// Flow Small Off
  327. /// </summary>
  328. /// <returns></returns>
  329. public bool FlowSmallOff()
  330. {
  331. return WriteVariableValue(FLOW_SMALL, false);
  332. }
  333. /// <summary>
  334. /// Flow Large On
  335. /// </summary>
  336. /// <returns></returns>
  337. public bool FlowLargeOn()
  338. {
  339. return WriteVariableValue(FLOW_LARGE, true);
  340. }
  341. /// <summary>
  342. /// Flow Large Off
  343. /// </summary>
  344. /// <returns></returns>
  345. public bool FlowLargeOff()
  346. {
  347. return WriteVariableValue(FLOW_LARGE, false);
  348. }
  349. #endregion
  350. #region Mode Switch
  351. /// <summary>
  352. /// DisabledAction
  353. /// </summary>
  354. /// <param name="cmd"></param>
  355. /// <param name="param"></param>
  356. /// <returns></returns>
  357. private bool DisabledOperation(string cmd, object[] args)
  358. {
  359. string currentOperation = "Disabled";
  360. VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(Module);
  361. if (vpwCellEntity != null && _vpwCellPersistentValue != null && _vpwCellPersistentValue.OperatingMode != currentOperation)
  362. {
  363. string preOperation = _vpwCellPersistentValue.OperatingMode;
  364. if (vpwCellEntity.IsBusy)
  365. {
  366. LOG.WriteLog(eEvent.ERR_VPWMAIN, Module, $"{Module} is Busy, can't switch to Disabled mode");
  367. return false;
  368. }
  369. vpwCellEntity.EnterInit();
  370. _vpwCellPersistentValue.OperatingMode = currentOperation;
  371. LOG.WriteLog(eEvent.INFO_VPWMAIN, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  372. }
  373. VpwCellPersistentManager.Instance.UpdatePersistentValue(Module);
  374. return true;
  375. }
  376. /// <summary>
  377. /// ManualAction
  378. /// </summary>
  379. /// <param name="cmd"></param>
  380. /// <param name="param"></param>
  381. /// <returns></returns>
  382. private bool ManualOperation(string cmd, object[] args)
  383. {
  384. string currentOperation = "Manual";
  385. VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(Module);
  386. if (vpwCellEntity != null && _vpwCellPersistentValue != null && _vpwCellPersistentValue.OperatingMode != currentOperation)
  387. {
  388. string preOperation = _vpwCellPersistentValue.OperatingMode;
  389. if (vpwCellEntity.IsBusy)
  390. {
  391. LOG.WriteLog(eEvent.ERR_VPWMAIN, Module, $"{Module} is Busy, can't switch to Manual mode");
  392. return false;
  393. }
  394. vpwCellEntity.EnterInit();
  395. _vpwCellPersistentValue.OperatingMode = currentOperation;
  396. LOG.WriteLog(eEvent.INFO_VPWMAIN, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  397. }
  398. VpwCellPersistentManager.Instance.UpdatePersistentValue(Module);
  399. return true;
  400. }
  401. /// <summary>
  402. /// AutoAction
  403. /// </summary>
  404. /// <param name="cmd"></param>
  405. /// <param name="param"></param>
  406. /// <returns></returns>
  407. private bool AutoOperation(string cmd, object[] args)
  408. {
  409. string currentOperation = "Auto";
  410. VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(Module);
  411. if (vpwCellEntity != null && _vpwCellPersistentValue != null && _vpwCellPersistentValue.OperatingMode != currentOperation)
  412. {
  413. string preOperation = _vpwCellPersistentValue.OperatingMode;
  414. if (vpwCellEntity.IsBusy)
  415. {
  416. LOG.WriteLog(eEvent.ERR_VPWMAIN, Module, $"{Module} is Busy, can't switch to Auto mode");
  417. return false;
  418. }
  419. vpwCellEntity.EnterInit();
  420. _vpwCellPersistentValue.OperatingMode = currentOperation;
  421. LOG.WriteLog(eEvent.INFO_VPWMAIN, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  422. }
  423. VpwCellPersistentManager.Instance.UpdatePersistentValue(Module);
  424. return true;
  425. }
  426. /// <summary>
  427. /// EngineeringModeAction
  428. /// </summary>
  429. /// <param name="cmd"></param>
  430. /// <param name="param"></param>
  431. /// <returns></returns>
  432. private bool EngineeringModeOperation(string cmd, object[] args)
  433. {
  434. string currentRecipeOperation = "Engineering";
  435. if (_vpwCellPersistentValue != null)
  436. {
  437. _vpwCellPersistentValue.RecipeOperatingMode = currentRecipeOperation;
  438. }
  439. VpwCellPersistentManager.Instance.UpdatePersistentValue(Module);
  440. return true;
  441. }
  442. /// <summary>
  443. /// ProductionAction
  444. /// </summary>
  445. /// <param name="cmd"></param>
  446. /// <param name="param"></param>
  447. /// <returns></returns>
  448. private bool ProductionModeOperation(string cmd, object[] args)
  449. {
  450. string currentRecipeOperation = "Production";
  451. if (_vpwCellPersistentValue != null)
  452. {
  453. _vpwCellPersistentValue.RecipeOperatingMode = currentRecipeOperation;
  454. }
  455. VpwCellPersistentManager.Instance.UpdatePersistentValue(Module);
  456. return true;
  457. }
  458. private bool SetVpwCellWaferSize(string cmd, object[] args)
  459. {
  460. string waferSize = args[0] as string;
  461. if (_vpwCellPersistentValue != null)
  462. {
  463. _vpwCellPersistentValue.VpwCellWaferSize = int.Parse(waferSize);
  464. }
  465. VpwCellPersistentManager.Instance.UpdatePersistentValue(Module);
  466. return true;
  467. }
  468. #endregion
  469. #region Vent Valve
  470. /// <summary>
  471. /// Vent Valve On
  472. /// </summary>
  473. /// <returns></returns>
  474. public bool VentValveOn()
  475. {
  476. return WriteVariableValue(VENT_VALVE, true);
  477. }
  478. /// <summary>
  479. /// Vent Valve Off
  480. /// </summary>
  481. /// <returns></returns>
  482. public bool VentValveOff()
  483. {
  484. return WriteVariableValue(VENT_VALVE, false);
  485. }
  486. #endregion
  487. #region Drain Valve
  488. /// <summary>
  489. /// Drain Valve On
  490. /// </summary>
  491. /// <returns></returns>
  492. public bool DrainValveOn()
  493. {
  494. return WriteVariableValue(DRAIN_VALVE, true);
  495. }
  496. /// <summary>
  497. /// Drain Valve Off
  498. /// </summary>
  499. /// <returns></returns>
  500. public bool DrainValveOff()
  501. {
  502. return WriteVariableValue(DRAIN_VALVE, false);
  503. }
  504. #endregion
  505. #region Vacuum
  506. /// <summary>
  507. /// Vacuum valve on
  508. /// </summary>
  509. /// <returns></returns>
  510. public bool VacuumValveOn()
  511. {
  512. return WriteVariableValue(VACUUM_VALVE, true);
  513. }
  514. /// <summary>
  515. /// Vacuum valve off
  516. /// </summary>
  517. /// <returns></returns>
  518. public bool VacuumValveOff()
  519. {
  520. return WriteVariableValue(VACUUM_VALVE, false);
  521. }
  522. #endregion
  523. /// <summary>
  524. /// 写变量
  525. /// </summary>
  526. /// <param name="variable"></param>
  527. /// <param name="value"></param>
  528. /// <returns></returns>
  529. private bool WriteVariableValue(string variable, object value)
  530. {
  531. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{variable}");
  532. return IOModuleManager.Instance.WriteIoValue(ioName, value);
  533. }
  534. #endregion
  535. #region Axis
  536. /// <summary>
  537. /// 电机是否上电
  538. /// </summary>
  539. /// <returns></returns>
  540. public bool CheckRotationSwitchOn()
  541. {
  542. return _rotationAxis.IsSwitchOn;
  543. }
  544. /// <summary>
  545. /// Home rotation
  546. /// </summary>
  547. /// <returns></returns>
  548. public bool HomeRotation()
  549. {
  550. return _rotationAxis.Home();
  551. }
  552. /// <summary>
  553. /// 检验Rotation Home结果
  554. /// </summary>
  555. /// <returns></returns>
  556. public bool CheckHomeEndStatus()
  557. {
  558. return CheckRotationEndStatus() && _rotationAxis.IsHomed;
  559. }
  560. /// <summary>
  561. /// 检验Rotation结束状态
  562. /// </summary>
  563. /// <returns></returns>
  564. public bool CheckRotationEndStatus()
  565. {
  566. return _rotationAxis.Status == PunkHPX8_Core.RState.End;
  567. }
  568. /// <summary>
  569. /// 检验Rotation失败状态
  570. /// </summary>
  571. /// <returns></returns>
  572. public bool CheckRotationStopStatus()
  573. {
  574. return _rotationAxis.Status == PunkHPX8_Core.RState.Failed;
  575. }
  576. /// <summary>
  577. /// 设置速度
  578. /// </summary>
  579. /// <param name="speed"></param>
  580. /// <returns></returns>
  581. public bool SetRotationSpeed(int speed)
  582. {
  583. _rotationAxis.SetProfileSpeed(speed);
  584. return true;
  585. }
  586. /// <summary>
  587. /// 改变速度
  588. /// </summary>
  589. /// <param name="speed"></param>
  590. /// <returns></returns>
  591. public bool ChangeRotationSpeed(int speed)
  592. {
  593. return _rotationAxis.ChangeSpeed(speed);
  594. }
  595. /// <summary>
  596. /// 电机运动
  597. /// </summary>
  598. /// <param name="position"></param>
  599. /// <returns></returns>
  600. public bool RotationProfilePosition(double position)
  601. {
  602. VpwMainDevice vpwMainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  603. if (vpwMainDevice != null)
  604. {
  605. if (vpwMainDevice.CommonData.ChamberOpened && !vpwMainDevice.CommonData.ChamberClosed)
  606. {
  607. LOG.WriteLog(eEvent.ERR_AXIS, $"{Module}.{Name}", "chamber is not closed, Cannot execute Rotation Profile Position");
  608. return false;
  609. }
  610. }
  611. return _rotationAxis.ProfilePositionOperation(position);
  612. }
  613. /// <summary>
  614. /// 停止运动
  615. /// </summary>
  616. /// <returns></returns>
  617. public bool StopProfilePosition()
  618. {
  619. return _rotationAxis.StopPositionOperation();
  620. }
  621. /// <summary>
  622. /// 是否Rotation运动
  623. /// </summary>
  624. /// <returns></returns>
  625. public bool CheckRotationRunning()
  626. {
  627. return _rotationAxis.IsRun;
  628. }
  629. #endregion
  630. /// <summary>
  631. /// 定时器
  632. /// </summary>
  633. /// <returns></returns>
  634. public bool OnTimer()
  635. {
  636. if (_rotationAxis != null)
  637. {
  638. _rotationAxis.OnTimer();
  639. }
  640. //cell flow满足条件过一段时间自动打开排水阀 (非run recipe期间)
  641. VpwCellEntity vpwcellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(Module);
  642. if(vpwcellEntity != null && vpwcellEntity.IsIdle)
  643. {
  644. CellFlowMonitor();
  645. }
  646. else
  647. {
  648. _isIntotalFlowCheck = false;
  649. }
  650. return true;
  651. }
  652. //total flow满足条件过一段时间自动打开drip阀
  653. private void CellFlowMonitor()
  654. {
  655. _cellFlowSetValue = SC.GetValue<double>("VPWMain.Plumbing.CellFlowStartLowLimit");
  656. _totalFlowSetValue = SC.GetValue<double>("VPWMain.Plumbing.TotalFlowStartLowLimit");
  657. _dripValveOpenIdlePeriod = SC.GetValue<int>($"{Module}.DripValveOpenIdlePeriod");
  658. if (MainCommonData.DiwTotalFlow > _totalFlowSetValue)
  659. {
  660. if (!_isIntotalFlowCheck)
  661. {
  662. _totalFlowOkDetectTime = DateTime.Now;
  663. _isIntotalFlowCheck = true;
  664. }
  665. else if((DateTime.Now - _totalFlowOkDetectTime).TotalSeconds > (_dripValveOpenIdlePeriod * 60) && !_commonData.FlowDrip)
  666. {
  667. _isIntotalFlowCheck = false;//重置监控周期
  668. LOG.WriteLog(eEvent.INFO_VPW, Module, $"total flow is large than start limit more than {_dripValveOpenIdlePeriod} min,Drip valve on!");
  669. FlowDripOn();
  670. if (_commonData.DiwFlow <= 0)
  671. {
  672. _cellFlowCheckFlag = false;
  673. LOG.WriteLog(eEvent.WARN_VPW, Module, $"Drip valve open failed!");
  674. }
  675. }
  676. }
  677. }
  678. /// <summary>
  679. /// 监控
  680. /// </summary>
  681. public void Monitor()
  682. {
  683. }
  684. public void Reset()
  685. {
  686. }
  687. public void Terminate()
  688. {
  689. }
  690. }
  691. }