VpwCellDevice.cs 25 KB

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