PlatingCellDevice.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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.Metal;
  9. using MECF.Framework.Common.CommonData.PlatingCell;
  10. using MECF.Framework.Common.CommonData.Reservoir;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.IOCore;
  13. using MECF.Framework.Common.Persistent.Reservoirs;
  14. using MECF.Framework.Common.ToolLayout;
  15. using PunkHPX8_Core;
  16. using PunkHPX8_RT.Devices.AXIS;
  17. using PunkHPX8_RT.Devices.LinMot;
  18. using PunkHPX8_RT.Devices.PowerSupplier;
  19. using PunkHPX8_RT.Devices.Reservoir;
  20. using PunkHPX8_RT.Devices.VpwMain;
  21. using PunkHPX8_RT.Modules;
  22. using PunkHPX8_RT.Modules.PlatingCell;
  23. using PunkHPX8_RT.Modules.Reservoir;
  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.PlatingCell
  31. {
  32. public class PlatingCellDevice : BaseDevice, IDevice
  33. {
  34. #region 常量
  35. private const string PERSISTENT_VALUE = "PersistentValue";
  36. private const string PLATINGCELLDATA = "PlatingCellData";
  37. private const string AUTO = "Auto";
  38. private const string MANUAL = "Manual";
  39. private const string STRATUS = "Stratus";
  40. private const string DISABLED = "Disabled";
  41. private const string IS_HEAD_TILT = "IsHeadTilt";
  42. private const string IS_HEAD_VERTICAL = "IsHeadVertical";
  43. private const string CLAMSHELL_DISTANCE = "ClamShellDistance";
  44. private const string CLAMSHELL_CYLINDER_PRESSURE = "ClamShellCylinderPressure";
  45. private const string OVERFLOW_LEVEL = "OverFlowLevel";
  46. private const string CLAMSHELL_CLOSE = "ClamShellClose";
  47. private const string HEAD_TILT = "HeadTilt";
  48. private const string CCR_ENABLE = "CCREnable";
  49. private const string RINSE_ENABLE = "RinseEnable";
  50. #endregion
  51. #region 内部变量
  52. /// 变量是否初始化字典
  53. /// </summary>
  54. private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
  55. /// <summary>
  56. /// 操作当前状态
  57. /// </summary>
  58. protected RState _status;
  59. /// <summary>
  60. /// 持久化数据
  61. /// </summary>
  62. protected PlatingCellPersistentValue _persistentValue;
  63. /// <summary>
  64. /// PlatingCell项
  65. /// </summary>
  66. private PlatingCellItem _platingCellItem;
  67. /// <summary>
  68. /// overflow
  69. /// </summary>
  70. private int _overflowLevelHigh = 85;
  71. private int _overflowLevelLow = 25;
  72. /// <summary>
  73. /// 对应reservoir的名字
  74. /// </summary>
  75. private string _reservoirName;
  76. /// <summary>
  77. /// PowerSupplier
  78. /// </summary>
  79. protected CellPowerSupplier _powerSupplier;
  80. /// <summary>
  81. /// vertical电机
  82. /// </summary>
  83. private JetAxisBase _verticalAxis;
  84. /// <summary>
  85. /// vertical电机
  86. /// </summary>
  87. private JetAxisBase _rotationAxis;
  88. /// <summary>
  89. /// CCR当前执行步骤
  90. /// </summary>
  91. private string _currentCCRStep = "";
  92. /// <summary>
  93. /// CCR当前剩余时间
  94. /// </summary>
  95. private double _timeRemain;
  96. #endregion
  97. #region 属性
  98. /// <summary>
  99. /// 状态
  100. /// </summary>
  101. public RState Status { get { return _status; } }
  102. /// <summary>
  103. /// 是否禁用
  104. /// </summary>
  105. public bool IsDisable { get { return _persistentValue == null || _persistentValue.OperatingMode == DISABLED; } }
  106. /// <summary>
  107. /// 操作模式
  108. /// </summary>
  109. public string OperationMode { get { return _persistentValue.OperatingMode; } }
  110. /// <summary>
  111. /// 工程模式
  112. /// </summary>
  113. public string EngineerMode { get { return _persistentValue.RecipeOperatingMode; } }
  114. /// <summary>
  115. /// 是否为Auto
  116. /// </summary>
  117. public bool IsAuto { get { return _persistentValue != null ? _persistentValue.OperatingMode == AUTO : false; } }
  118. /// <summary>
  119. /// 是否为Auto
  120. /// </summary>
  121. public bool IsManual { get { return _persistentValue != null ? _persistentValue.OperatingMode == MANUAL : false; } }
  122. /// <summary>
  123. /// A面PowerSupplier
  124. /// </summary>
  125. public CellPowerSupplier PowerSupplier { get { return _powerSupplier; } }
  126. #endregion
  127. #region 共享变量
  128. /// <summary>
  129. /// 数据
  130. /// </summary>
  131. protected PlatingCellData _platingCellData = new PlatingCellData();
  132. /// <summary>
  133. /// 对应reservoir数据
  134. /// </summary>
  135. protected ReservoirData _reservoirData = new ReservoirData();
  136. #endregion
  137. #region 属性
  138. /// <summary>
  139. /// 设备数据
  140. /// </summary>
  141. public PlatingCellData PlatingCellDeviceData { get { return _platingCellData; } }
  142. #endregion
  143. /// <summary>
  144. /// 构造函数
  145. /// </summary>
  146. /// <param name="moduleName"></param>
  147. public PlatingCellDevice(string moduleName) : base(moduleName, moduleName, moduleName, moduleName)
  148. {
  149. }
  150. /// <summary>
  151. /// 初始化
  152. /// </summary>
  153. /// <returns></returns>
  154. public virtual bool Initialize()
  155. {
  156. InitializeParameter();
  157. SubscribeData();
  158. InitializeOperation();
  159. SubscribeValueAction();
  160. return true;
  161. }
  162. /// <summary>
  163. /// 定时器执行
  164. /// </summary>
  165. public bool OnTimer(int interval)
  166. {
  167. if (_verticalAxis != null)
  168. {
  169. _verticalAxis.OnTimer();
  170. }
  171. else
  172. {
  173. if ("PlatingCell1".Equals(Module) || "PlatingCell2".Equals(Module))
  174. {
  175. _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell1_2.Vertical");
  176. }
  177. else
  178. {
  179. _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell3_4.Vertical");
  180. }
  181. }
  182. if (_rotationAxis != null)
  183. {
  184. _rotationAxis.OnTimer();
  185. }
  186. return true;
  187. }
  188. /// <summary>
  189. /// 初始化参数
  190. /// </summary>
  191. private void InitializeParameter()
  192. {
  193. _persistentValue = PlatingCellPersistentManager.Instance.GetPlatingCellPersistentValue(Module);
  194. if (_persistentValue == null)
  195. {
  196. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Persistent Value Object is not exist");
  197. }
  198. _platingCellItem = PlatingCellItemManager.Instance.GetPlatingCellItem(Module);
  199. if (_platingCellItem != null)
  200. {
  201. }
  202. _platingCellItem = PlatingCellItemManager.Instance.GetPlatingCellItem(Module);
  203. if (_platingCellItem != null)
  204. {
  205. _powerSupplier = DEVICE.GetDevice<CellPowerSupplier>(_platingCellItem.PlatingPowerSupplyID);
  206. }
  207. _overflowLevelHigh = SC.GetValue<int>($"PlatingCell.OverflowLevelHigh");
  208. _overflowLevelLow = SC.GetValue<int>($"PlatingCell.OverflowLevelLow");
  209. _reservoirData = GetReservoirDevice().ReservoirData;
  210. _reservoirName = GetReservoirDevice().Module;
  211. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  212. }
  213. protected virtual void SubscribeValueAction()
  214. {
  215. IoSubscribeUpdateVariable(IS_HEAD_TILT);
  216. IoSubscribeUpdateVariable(IS_HEAD_VERTICAL);
  217. IoSubscribeUpdateVariable(CLAMSHELL_DISTANCE);
  218. IoSubscribeUpdateVariable(CLAMSHELL_CYLINDER_PRESSURE);
  219. IoSubscribeUpdateVariable(OVERFLOW_LEVEL);
  220. IoSubscribeUpdateVariable(CLAMSHELL_CLOSE);
  221. IoSubscribeUpdateVariable(HEAD_TILT);
  222. IoSubscribeUpdateVariable(CCR_ENABLE);
  223. IoSubscribeUpdateVariable(RINSE_ENABLE);
  224. }
  225. /// <summary>
  226. /// 订阅IO变量
  227. /// </summary>
  228. /// <param name="variable"></param>
  229. protected void IoSubscribeUpdateVariable(string variable)
  230. {
  231. _variableInitializeDic[variable] = false;
  232. IOModuleManager.Instance.SubscribeModuleVariable(Module, variable, UpdateVariableValue);
  233. }
  234. /// <summary>
  235. /// 更新变量数值
  236. /// </summary>
  237. /// <param name="variable"></param>
  238. /// <param name="value"></param>
  239. private void UpdateVariableValue(string variable, object value)
  240. {
  241. if (!_platingCellData.IsDataInitialized)
  242. {
  243. _platingCellData.IsDataInitialized = true;
  244. }
  245. PropertyInfo property = _platingCellData.GetType().GetProperty(variable);
  246. if (property != null)
  247. {
  248. property.SetValue(_platingCellData, value);
  249. if (variable == OVERFLOW_LEVEL)
  250. {
  251. double waterLevel = CurrentToWaterLevel(Convert.ToDouble(value));
  252. _platingCellData.OverFlowLevel = waterLevel;
  253. if (_platingCellData.OverFlowLevel >= _overflowLevelHigh)
  254. {
  255. _platingCellData.OverFlowStatus = "High";
  256. }
  257. else if(_platingCellData.OverFlowLevel <= _overflowLevelLow)
  258. {
  259. _platingCellData.OverFlowStatus = "Empty";
  260. }
  261. else
  262. {
  263. _platingCellData.OverFlowStatus = "Full";
  264. }
  265. }
  266. }
  267. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  268. {
  269. _variableInitializeDic[variable] = true;
  270. }
  271. }
  272. /// <summary>
  273. /// 把电流mA转成水深mm
  274. /// </summary>
  275. /// <param name="current"></param>
  276. private double CurrentToWaterLevel(double current)
  277. {
  278. double result = (current - 4) / 8 / 9.8 * 1000;
  279. return result;
  280. }
  281. /// <summary>
  282. /// 写变量
  283. /// </summary>
  284. /// <param name="variable"></param>
  285. /// <param name="value"></param>
  286. /// <returns></returns>
  287. protected bool WriteVariableValue(string variable, object value)
  288. {
  289. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{variable}");
  290. return IOModuleManager.Instance.WriteIoValue(ioName, value);
  291. }
  292. /// <summary>
  293. /// 订阅数据
  294. /// </summary>
  295. private void SubscribeData()
  296. {
  297. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _persistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  298. DATA.Subscribe($"{Module}.{PLATINGCELLDATA}", () => _platingCellData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  299. DATA.Subscribe($"{Module}.ReservoirCommonData", () => _reservoirData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  300. DATA.Subscribe($"{Module}.ReservoirName", () => _reservoirName, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  301. DATA.Subscribe($"{Module}.CurrentCCRStep", () => _currentCCRStep, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  302. DATA.Subscribe($"{Module}.CurrentCCRTimeRemain", () => _timeRemain, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  303. DATA.Subscribe($"{Module}.PowerSupplierData", () => _powerSupplier.PowerSupplierData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  304. DATA.Subscribe($"{Module}.PowerSupplier.ID", () => _powerSupplier.Module, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  305. DATA.Subscribe($"{Module}.PowerSupplier.IsConnected", () => _powerSupplier.IsConnected, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  306. DATA.Subscribe($"{Module}.PowerSupplier.Voltage", () => _powerSupplier.PowerSupplierData.Voltage, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  307. DATA.Subscribe($"{Module}.PowerSupplier.Current", () => _powerSupplier.PowerSupplierData.Current, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  308. DATA.Subscribe($"{Module}.PowerSupplier.SetPoint", () => _powerSupplier.PowerSupplierData.SetPoint, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  309. DATA.Subscribe($"{Module}.PowerSupplier.RunModel", () => _powerSupplier.PowerSupplierData.PowerRunModelContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  310. DATA.Subscribe($"{Module}.PowerSupplier.PowerControl", () => _powerSupplier.PowerSupplierData.PowerControlContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  311. DATA.Subscribe($"{Module}.PowerSupplier.PowerStatus", () => _powerSupplier.PowerSupplierData.PowerStatusContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  312. DATA.Subscribe($"{Module}.PowerSupplier.Enable", () => _powerSupplier.PowerSupplierData.Enabled, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  313. DATA.Subscribe($"{Module}.PowerSupplier.PowerGrade", () => _powerSupplier.PowerSupplierData.PowerGradeContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  314. }
  315. /// <summary>
  316. /// 初始化操作
  317. /// </summary>
  318. protected virtual void InitializeOperation()
  319. {
  320. OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
  321. OP.Subscribe($"{Module}.ManualAction", ManualOperation);
  322. OP.Subscribe($"{Module}.AutoAction", AutoOperation);
  323. OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
  324. OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
  325. OP.Subscribe($"{Module}.SetPlatingCellWaferSize", (cmd, args) => { return SetPlatingCellWaferSize(cmd, args); });
  326. OP.Subscribe($"{Module}.ClamShellClose", (cmd, para) => { return ClamShellClose(); });
  327. OP.Subscribe($"{Module}.ClamShellOpen", (cmd, para) => { return ClamShellOpen(); });
  328. OP.Subscribe($"{Module}.HeadtTilt", (cmd, para) => { return HeadtTiltAction(); });
  329. OP.Subscribe($"{Module}.HeadVertical", (cmd, para) => { return HeadtVerticalAction(); });
  330. OP.Subscribe($"{Module}.CCREnable", (cmd, para) => { return CCREnableAction(); });
  331. OP.Subscribe($"{Module}.CCRDisable", (cmd, para) => { return CCRDisableAction(); });
  332. OP.Subscribe($"{Module}.RinseEnable", (cmd, para) => { return RinseEnableAction(); });
  333. OP.Subscribe($"{Module}.RinseDisable", (cmd, para) => { return RinseDisableAction(); });
  334. OP.Subscribe($"{Module}.StartRotation", StartRotationAction);
  335. OP.Subscribe($"{Module}.StopRotation", StopRotationAction);
  336. }
  337. #region Operation
  338. private bool StartRotationAction(string cmd, object[] args)
  339. {
  340. if (args.Length < 2 && (int)args[0] < 0 && (int)args[1] < 0)
  341. {
  342. LOG.WriteLog(eEvent.ERR_VPW, Module, $"Start rotation paramater is wrong");
  343. return false;
  344. }
  345. double targetPostion = (int)args[0] * 6 * (int)args[1];
  346. object[] param = new object[] { "", targetPostion };
  347. int degSpeed = (int)args[0] * 6;
  348. SetRotationSpeed(degSpeed);
  349. double AfterChangetargetPostion = (int)args[0] * 6 * (int)args[1];
  350. return RotationProfilePosition(AfterChangetargetPostion);
  351. }
  352. private bool StopRotationAction(string cmd, object[] args)
  353. {
  354. return _rotationAxis.StopPositionOperation();
  355. }
  356. public bool ClamShellClose()
  357. {
  358. return WriteVariableValue(CLAMSHELL_CLOSE, true);
  359. }
  360. public bool ClamShellOpen()
  361. {
  362. return WriteVariableValue(CLAMSHELL_CLOSE, false);
  363. }
  364. public bool HeadtTiltAction()
  365. {
  366. return WriteVariableValue(HEAD_TILT, true);
  367. }
  368. public bool HeadtVerticalAction()
  369. {
  370. return WriteVariableValue(HEAD_TILT, false);
  371. }
  372. public bool CCREnableAction()
  373. {
  374. return WriteVariableValue(CCR_ENABLE, true);
  375. }
  376. public bool CCRDisableAction()
  377. {
  378. return WriteVariableValue(CCR_ENABLE, false);
  379. }
  380. public bool RinseEnableAction()
  381. {
  382. return WriteVariableValue(RINSE_ENABLE, true);
  383. }
  384. public bool RinseDisableAction()
  385. {
  386. return WriteVariableValue(RINSE_ENABLE, false);
  387. }
  388. /// <summary>
  389. /// DisabledAction
  390. /// </summary>
  391. /// <param name="cmd"></param>
  392. /// <param name="param"></param>
  393. /// <returns></returns>
  394. public bool DisabledOperation(string cmd, object[] args)
  395. {
  396. string currentOperation = "Disabled";
  397. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  398. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  399. {
  400. string preOperation = _persistentValue.OperatingMode;
  401. if (platingCellEntity.IsBusy)
  402. {
  403. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Disabled mode");
  404. return false;
  405. }
  406. //if (SchedulerMetalTimeManager.Instance.Contained(Module))
  407. //{
  408. // LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Disabled mode");
  409. // return false;
  410. //}
  411. platingCellEntity.EnterInit();
  412. _persistentValue.OperatingMode = currentOperation;
  413. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  414. }
  415. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  416. return true;
  417. }
  418. /// <summary>
  419. /// ManualAction
  420. /// </summary>
  421. /// <param name="cmd"></param>
  422. /// <param name="param"></param>
  423. /// <returns></returns>
  424. public bool ManualOperation(string cmd, object[] args)
  425. {
  426. string currentOperation = "Manual";
  427. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  428. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  429. {
  430. string preOperation = _persistentValue.OperatingMode;
  431. if (platingCellEntity.IsBusy)
  432. {
  433. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Manual mode");
  434. return false;
  435. }
  436. //if (SchedulerMetalTimeManager.Instance.Contained(Module))
  437. //{
  438. // LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Manual mode");
  439. // return false;
  440. //}
  441. platingCellEntity.EnterInit();
  442. _persistentValue.OperatingMode = currentOperation;
  443. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  444. }
  445. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  446. return true;
  447. }
  448. /// <summary>
  449. /// AutoAction
  450. /// </summary>
  451. /// <param name="cmd"></param>
  452. /// <param name="param"></param>
  453. /// <returns></returns>
  454. public bool AutoOperation(string cmd, object[] args)
  455. {
  456. string currentOperation = "Auto";
  457. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(_reservoirName);
  458. if (reservoirEntity!=null && reservoirEntity.PersistentValue.OperatingMode!="Auto")
  459. {
  460. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{_reservoirName} not in Auto mode, can't switch to Auto mode");
  461. return false;
  462. }
  463. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  464. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  465. {
  466. string preOperation = _persistentValue.OperatingMode;
  467. if (platingCellEntity.IsBusy)
  468. {
  469. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Auto mode");
  470. return false;
  471. }
  472. platingCellEntity.EnterInit();
  473. _persistentValue.OperatingMode = currentOperation;
  474. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  475. }
  476. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  477. return true;
  478. }
  479. /// <summary>
  480. /// EngineeringModeAction
  481. /// </summary>
  482. /// <param name="cmd"></param>
  483. /// <param name="param"></param>
  484. /// <returns></returns>
  485. private bool EngineeringModeOperation(string cmd, object[] args)
  486. {
  487. string currentRecipeOperation = "Engineering";
  488. if (_persistentValue != null)
  489. {
  490. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  491. }
  492. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  493. return true;
  494. }
  495. /// <summary>
  496. /// ProductionAction
  497. /// </summary>
  498. /// <param name="cmd"></param>
  499. /// <param name="param"></param>
  500. /// <returns></returns>
  501. private bool ProductionModeOperation(string cmd, object[] args)
  502. {
  503. string currentRecipeOperation = "Production";
  504. if (_persistentValue != null)
  505. {
  506. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  507. }
  508. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  509. return true;
  510. }
  511. private bool SetPlatingCellWaferSize(string cmd, object[] args)
  512. {
  513. string metalWaferSize = args[0] as string;
  514. if (_persistentValue != null)
  515. {
  516. _persistentValue.PlatingCellWaferSize = int.Parse(metalWaferSize);
  517. }
  518. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  519. return true;
  520. }
  521. /// <summary>
  522. /// 获取Reservoir设备
  523. /// </summary>
  524. /// <returns></returns>
  525. private ReservoirDevice GetReservoirDevice()
  526. {
  527. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module);
  528. return DEVICE.GetDevice<ReservoirDevice>(reservoir);
  529. }
  530. /// <summary>
  531. /// CCR当前步骤
  532. /// </summary>
  533. /// <param name="tmp"></param>
  534. public void UpdateStatus(string tmp)
  535. {
  536. _currentCCRStep = tmp;
  537. }
  538. /// <summary>
  539. /// CCR当前步骤剩余时间
  540. /// </summary>
  541. /// <param name="tmp"></param>
  542. public void UpdateCCRTimeRemain(double timeRemain)
  543. {
  544. _timeRemain = timeRemain;
  545. }
  546. #endregion
  547. #region RotationAxis
  548. /// <summary>
  549. /// 电机是否上电
  550. /// </summary>
  551. /// <returns></returns>
  552. public bool CheckRotationSwitchOn()
  553. {
  554. return _rotationAxis.IsSwitchOn;
  555. }
  556. /// <summary>
  557. /// Home rotation
  558. /// </summary>
  559. /// <returns></returns>
  560. public bool HomeRotation()
  561. {
  562. return _rotationAxis.Home();
  563. }
  564. /// <summary>
  565. /// 检验Rotation Home结果
  566. /// </summary>
  567. /// <returns></returns>
  568. public bool CheckHomeEndStatus()
  569. {
  570. return CheckRotationEndStatus() && _rotationAxis.IsHomed;
  571. }
  572. /// <summary>
  573. /// 检验Rotation结束状态
  574. /// </summary>
  575. /// <returns></returns>
  576. public bool CheckRotationEndStatus()
  577. {
  578. return _rotationAxis.Status == PunkHPX8_Core.RState.End;
  579. }
  580. /// <summary>
  581. /// 检验Rotation失败状态
  582. /// </summary>
  583. /// <returns></returns>
  584. public bool CheckRotationStopStatus()
  585. {
  586. return _rotationAxis.Status == PunkHPX8_Core.RState.Failed;
  587. }
  588. /// <summary>
  589. /// 设置速度
  590. /// </summary>
  591. /// <param name="speed"></param>
  592. /// <returns></returns>
  593. public bool SetRotationSpeed(int speed)
  594. {
  595. _rotationAxis.SetProfileSpeed(speed);
  596. return true;
  597. }
  598. /// <summary>
  599. /// 改变速度
  600. /// </summary>
  601. /// <param name="speed"></param>
  602. /// <returns></returns>
  603. public bool ChangeRotationSpeed(int speed)
  604. {
  605. return _rotationAxis.ChangeSpeed(speed);
  606. }
  607. /// <summary>
  608. /// 电机运动
  609. /// </summary>
  610. /// <param name="position"></param>
  611. /// <returns></returns>
  612. public bool RotationProfilePosition(double position)
  613. {
  614. return _rotationAxis.ProfilePositionOperation(position);
  615. }
  616. /// <summary>
  617. /// 停止运动
  618. /// </summary>
  619. /// <returns></returns>
  620. public bool StopProfilePosition()
  621. {
  622. return _rotationAxis.StopPositionOperation();
  623. }
  624. /// <summary>
  625. /// 是否Rotation运动
  626. /// </summary>
  627. /// <returns></returns>
  628. public bool CheckRotationRunning()
  629. {
  630. return _rotationAxis.IsRun;
  631. }
  632. #endregion
  633. public virtual void Monitor()
  634. {
  635. }
  636. public virtual void Reset()
  637. {
  638. }
  639. public virtual void Terminate()
  640. {
  641. }
  642. }
  643. }