VpwCellDevice.cs 26 KB

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