PlatingCellDevice.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. if (_rotationAxis != null)
  172. {
  173. _rotationAxis.OnTimer();
  174. }
  175. return true;
  176. }
  177. /// <summary>
  178. /// 初始化参数
  179. /// </summary>
  180. private void InitializeParameter()
  181. {
  182. _persistentValue = PlatingCellPersistentManager.Instance.GetPlatingCellPersistentValue(Module);
  183. if (_persistentValue == null)
  184. {
  185. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Persistent Value Object is not exist");
  186. }
  187. _platingCellItem = PlatingCellItemManager.Instance.GetPlatingCellItem(Module);
  188. if (_platingCellItem != null)
  189. {
  190. }
  191. _platingCellItem = PlatingCellItemManager.Instance.GetPlatingCellItem(Module);
  192. if (_platingCellItem != null)
  193. {
  194. _powerSupplier = DEVICE.GetDevice<CellPowerSupplier>(_platingCellItem.PlatingPowerSupplyID);
  195. }
  196. _overflowLevelHigh = SC.GetValue<int>($"PlatingCell.OverflowLevelHigh");
  197. _overflowLevelLow = SC.GetValue<int>($"PlatingCell.OverflowLevelLow");
  198. _reservoirData = GetReservoirDevice().ReservoirData;
  199. _reservoirName = GetReservoirDevice().Module;
  200. if("PlatingCell1".Equals(Module) || "PlatingCell2".Equals(Module))
  201. {
  202. _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell1_2.Vertical");
  203. }
  204. else
  205. {
  206. _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell3_4.Vertical");
  207. }
  208. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  209. }
  210. protected virtual void SubscribeValueAction()
  211. {
  212. IoSubscribeUpdateVariable(IS_HEAD_TILT);
  213. IoSubscribeUpdateVariable(IS_HEAD_VERTICAL);
  214. IoSubscribeUpdateVariable(CLAMSHELL_DISTANCE);
  215. IoSubscribeUpdateVariable(CLAMSHELL_CYLINDER_PRESSURE);
  216. IoSubscribeUpdateVariable(OVERFLOW_LEVEL);
  217. IoSubscribeUpdateVariable(CLAMSHELL_CLOSE);
  218. IoSubscribeUpdateVariable(HEAD_TILT);
  219. IoSubscribeUpdateVariable(CCR_ENABLE);
  220. IoSubscribeUpdateVariable(RINSE_ENABLE);
  221. }
  222. /// <summary>
  223. /// 订阅IO变量
  224. /// </summary>
  225. /// <param name="variable"></param>
  226. protected 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. if (!_platingCellData.IsDataInitialized)
  239. {
  240. _platingCellData.IsDataInitialized = true;
  241. }
  242. PropertyInfo property = _platingCellData.GetType().GetProperty(variable);
  243. if (property != null)
  244. {
  245. property.SetValue(_platingCellData, value);
  246. if (variable == OVERFLOW_LEVEL)
  247. {
  248. double waterLevel = CurrentToWaterLevel(Convert.ToDouble(value));
  249. _platingCellData.OverFlowLevel = waterLevel;
  250. if (_platingCellData.OverFlowLevel >= _overflowLevelHigh)
  251. {
  252. _platingCellData.OverFlowStatus = "High";
  253. }
  254. else if(_platingCellData.OverFlowLevel <= _overflowLevelLow)
  255. {
  256. _platingCellData.OverFlowStatus = "Empty";
  257. }
  258. else
  259. {
  260. _platingCellData.OverFlowStatus = "Full";
  261. }
  262. }
  263. }
  264. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  265. {
  266. _variableInitializeDic[variable] = true;
  267. }
  268. }
  269. /// <summary>
  270. /// 把电流mA转成水深mm
  271. /// </summary>
  272. /// <param name="current"></param>
  273. private double CurrentToWaterLevel(double current)
  274. {
  275. double result = (current - 4) / 8 / 9.8 * 1000;
  276. return result;
  277. }
  278. /// <summary>
  279. /// 写变量
  280. /// </summary>
  281. /// <param name="variable"></param>
  282. /// <param name="value"></param>
  283. /// <returns></returns>
  284. protected bool WriteVariableValue(string variable, object value)
  285. {
  286. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{variable}");
  287. return IOModuleManager.Instance.WriteIoValue(ioName, value);
  288. }
  289. /// <summary>
  290. /// 订阅数据
  291. /// </summary>
  292. private void SubscribeData()
  293. {
  294. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _persistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  295. DATA.Subscribe($"{Module}.{PLATINGCELLDATA}", () => _platingCellData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  296. DATA.Subscribe($"{Module}.ReservoirCommonData", () => _reservoirData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  297. DATA.Subscribe($"{Module}.ReservoirName", () => _reservoirName, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  298. DATA.Subscribe($"{Module}.CurrentCCRStep", () => _currentCCRStep, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  299. DATA.Subscribe($"{Module}.CurrentCCRTimeRemain", () => _timeRemain, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  300. DATA.Subscribe($"{Module}.PowerSupplierData", () => _powerSupplier.PowerSupplierData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  301. DATA.Subscribe($"{Module}.PowerSupplier.ID", () => _powerSupplier.Module, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  302. DATA.Subscribe($"{Module}.PowerSupplier.IsConnected", () => _powerSupplier.IsConnected, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  303. DATA.Subscribe($"{Module}.PowerSupplier.Voltage", () => _powerSupplier.PowerSupplierData.Voltage, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  304. DATA.Subscribe($"{Module}.PowerSupplier.Current", () => _powerSupplier.PowerSupplierData.Current, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  305. DATA.Subscribe($"{Module}.PowerSupplier.SetPoint", () => _powerSupplier.PowerSupplierData.SetPoint, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  306. DATA.Subscribe($"{Module}.PowerSupplier.RunModel", () => _powerSupplier.PowerSupplierData.PowerRunModelContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  307. DATA.Subscribe($"{Module}.PowerSupplier.PowerControl", () => _powerSupplier.PowerSupplierData.PowerControlContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  308. DATA.Subscribe($"{Module}.PowerSupplier.PowerStatus", () => _powerSupplier.PowerSupplierData.PowerStatusContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  309. DATA.Subscribe($"{Module}.PowerSupplier.Enable", () => _powerSupplier.PowerSupplierData.Enabled, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  310. DATA.Subscribe($"{Module}.PowerSupplier.PowerGrade", () => _powerSupplier.PowerSupplierData.PowerGradeContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  311. }
  312. /// <summary>
  313. /// 初始化操作
  314. /// </summary>
  315. protected virtual void InitializeOperation()
  316. {
  317. OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
  318. OP.Subscribe($"{Module}.ManualAction", ManualOperation);
  319. OP.Subscribe($"{Module}.AutoAction", AutoOperation);
  320. OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
  321. OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
  322. OP.Subscribe($"{Module}.SetPlatingCellWaferSize", (cmd, args) => { return SetPlatingCellWaferSize(cmd, args); });
  323. OP.Subscribe($"{Module}.ClamShellClose", (cmd, para) => { return ClamShellClose(); });
  324. OP.Subscribe($"{Module}.ClamShellOpen", (cmd, para) => { return ClamShellOpen(); });
  325. OP.Subscribe($"{Module}.HeadtTilt", (cmd, para) => { return HeadtTiltAction(); });
  326. OP.Subscribe($"{Module}.HeadVertical", (cmd, para) => { return HeadtVerticalAction(); });
  327. OP.Subscribe($"{Module}.CCREnable", (cmd, para) => { return CCREnableAction(); });
  328. OP.Subscribe($"{Module}.CCRDisable", (cmd, para) => { return CCRDisableAction(); });
  329. OP.Subscribe($"{Module}.RinseEnable", (cmd, para) => { return RinseEnableAction(); });
  330. OP.Subscribe($"{Module}.RinseDisable", (cmd, para) => { return RinseDisableAction(); });
  331. OP.Subscribe($"{Module}.StartRotation", StartRotationAction);
  332. OP.Subscribe($"{Module}.StopRotation", StopRotationAction);
  333. }
  334. #region Operation
  335. private bool StartRotationAction(string cmd, object[] args)
  336. {
  337. if (args.Length < 2 && (int)args[0] < 0 && (int)args[1] < 0)
  338. {
  339. LOG.WriteLog(eEvent.ERR_VPW, Module, $"Start rotation paramater is wrong");
  340. return false;
  341. }
  342. double targetPostion = (int)args[0] * 6 * (int)args[1];
  343. object[] param = new object[] { "", targetPostion };
  344. int degSpeed = (int)args[0] * 6;
  345. SetRotationSpeed(degSpeed);
  346. double AfterChangetargetPostion = (int)args[0] * 6 * (int)args[1];
  347. return RotationProfilePosition(AfterChangetargetPostion);
  348. }
  349. private bool StopRotationAction(string cmd, object[] args)
  350. {
  351. return _rotationAxis.StopPositionOperation();
  352. }
  353. public bool ClamShellClose()
  354. {
  355. return WriteVariableValue(CLAMSHELL_CLOSE, true);
  356. }
  357. public bool ClamShellOpen()
  358. {
  359. return WriteVariableValue(CLAMSHELL_CLOSE, false);
  360. }
  361. public bool HeadtTiltAction()
  362. {
  363. return WriteVariableValue(HEAD_TILT, true);
  364. }
  365. public bool HeadtVerticalAction()
  366. {
  367. return WriteVariableValue(HEAD_TILT, false);
  368. }
  369. public bool CCREnableAction()
  370. {
  371. return WriteVariableValue(CCR_ENABLE, true);
  372. }
  373. public bool CCRDisableAction()
  374. {
  375. return WriteVariableValue(CCR_ENABLE, false);
  376. }
  377. public bool RinseEnableAction()
  378. {
  379. return WriteVariableValue(RINSE_ENABLE, true);
  380. }
  381. public bool RinseDisableAction()
  382. {
  383. return WriteVariableValue(RINSE_ENABLE, false);
  384. }
  385. /// <summary>
  386. /// DisabledAction
  387. /// </summary>
  388. /// <param name="cmd"></param>
  389. /// <param name="param"></param>
  390. /// <returns></returns>
  391. public bool DisabledOperation(string cmd, object[] args)
  392. {
  393. string currentOperation = "Disabled";
  394. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  395. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  396. {
  397. string preOperation = _persistentValue.OperatingMode;
  398. if (platingCellEntity.IsBusy)
  399. {
  400. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Disabled mode");
  401. return false;
  402. }
  403. //if (SchedulerMetalTimeManager.Instance.Contained(Module))
  404. //{
  405. // LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Disabled mode");
  406. // return false;
  407. //}
  408. platingCellEntity.EnterInit();
  409. _persistentValue.OperatingMode = currentOperation;
  410. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  411. }
  412. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  413. return true;
  414. }
  415. /// <summary>
  416. /// ManualAction
  417. /// </summary>
  418. /// <param name="cmd"></param>
  419. /// <param name="param"></param>
  420. /// <returns></returns>
  421. public bool ManualOperation(string cmd, object[] args)
  422. {
  423. string currentOperation = "Manual";
  424. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  425. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  426. {
  427. string preOperation = _persistentValue.OperatingMode;
  428. if (platingCellEntity.IsBusy)
  429. {
  430. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Manual mode");
  431. return false;
  432. }
  433. //if (SchedulerMetalTimeManager.Instance.Contained(Module))
  434. //{
  435. // LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Manual mode");
  436. // return false;
  437. //}
  438. platingCellEntity.EnterInit();
  439. _persistentValue.OperatingMode = currentOperation;
  440. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  441. }
  442. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  443. return true;
  444. }
  445. /// <summary>
  446. /// AutoAction
  447. /// </summary>
  448. /// <param name="cmd"></param>
  449. /// <param name="param"></param>
  450. /// <returns></returns>
  451. public bool AutoOperation(string cmd, object[] args)
  452. {
  453. string currentOperation = "Auto";
  454. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(_reservoirName);
  455. if (reservoirEntity!=null && reservoirEntity.PersistentValue.OperatingMode!="Auto")
  456. {
  457. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{_reservoirName} not in Auto mode, can't switch to Auto mode");
  458. return false;
  459. }
  460. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  461. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  462. {
  463. string preOperation = _persistentValue.OperatingMode;
  464. if (platingCellEntity.IsBusy)
  465. {
  466. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Auto mode");
  467. return false;
  468. }
  469. platingCellEntity.EnterInit();
  470. _persistentValue.OperatingMode = currentOperation;
  471. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  472. }
  473. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  474. return true;
  475. }
  476. /// <summary>
  477. /// EngineeringModeAction
  478. /// </summary>
  479. /// <param name="cmd"></param>
  480. /// <param name="param"></param>
  481. /// <returns></returns>
  482. private bool EngineeringModeOperation(string cmd, object[] args)
  483. {
  484. string currentRecipeOperation = "Engineering";
  485. if (_persistentValue != null)
  486. {
  487. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  488. }
  489. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  490. return true;
  491. }
  492. /// <summary>
  493. /// ProductionAction
  494. /// </summary>
  495. /// <param name="cmd"></param>
  496. /// <param name="param"></param>
  497. /// <returns></returns>
  498. private bool ProductionModeOperation(string cmd, object[] args)
  499. {
  500. string currentRecipeOperation = "Production";
  501. if (_persistentValue != null)
  502. {
  503. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  504. }
  505. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  506. return true;
  507. }
  508. private bool SetPlatingCellWaferSize(string cmd, object[] args)
  509. {
  510. string metalWaferSize = args[0] as string;
  511. if (_persistentValue != null)
  512. {
  513. _persistentValue.PlatingCellWaferSize = int.Parse(metalWaferSize);
  514. }
  515. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  516. return true;
  517. }
  518. /// <summary>
  519. /// 获取Reservoir设备
  520. /// </summary>
  521. /// <returns></returns>
  522. private ReservoirDevice GetReservoirDevice()
  523. {
  524. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module);
  525. return DEVICE.GetDevice<ReservoirDevice>(reservoir);
  526. }
  527. /// <summary>
  528. /// CCR当前步骤
  529. /// </summary>
  530. /// <param name="tmp"></param>
  531. public void UpdateStatus(string tmp)
  532. {
  533. _currentCCRStep = tmp;
  534. }
  535. /// <summary>
  536. /// CCR当前步骤剩余时间
  537. /// </summary>
  538. /// <param name="tmp"></param>
  539. public void UpdateCCRTimeRemain(double timeRemain)
  540. {
  541. _timeRemain = timeRemain;
  542. }
  543. #endregion
  544. #region RotationAxis
  545. /// <summary>
  546. /// 电机是否上电
  547. /// </summary>
  548. /// <returns></returns>
  549. public bool CheckRotationSwitchOn()
  550. {
  551. return _rotationAxis.IsSwitchOn;
  552. }
  553. /// <summary>
  554. /// Home rotation
  555. /// </summary>
  556. /// <returns></returns>
  557. public bool HomeRotation()
  558. {
  559. return _rotationAxis.Home();
  560. }
  561. /// <summary>
  562. /// 检验Rotation Home结果
  563. /// </summary>
  564. /// <returns></returns>
  565. public bool CheckHomeEndStatus()
  566. {
  567. return CheckRotationEndStatus() && _rotationAxis.IsHomed;
  568. }
  569. /// <summary>
  570. /// 检验Rotation结束状态
  571. /// </summary>
  572. /// <returns></returns>
  573. public bool CheckRotationEndStatus()
  574. {
  575. return _rotationAxis.Status == PunkHPX8_Core.RState.End;
  576. }
  577. /// <summary>
  578. /// 检验Rotation失败状态
  579. /// </summary>
  580. /// <returns></returns>
  581. public bool CheckRotationStopStatus()
  582. {
  583. return _rotationAxis.Status == PunkHPX8_Core.RState.Failed;
  584. }
  585. /// <summary>
  586. /// 设置速度
  587. /// </summary>
  588. /// <param name="speed"></param>
  589. /// <returns></returns>
  590. public bool SetRotationSpeed(int speed)
  591. {
  592. _rotationAxis.SetProfileSpeed(speed);
  593. return true;
  594. }
  595. /// <summary>
  596. /// 改变速度
  597. /// </summary>
  598. /// <param name="speed"></param>
  599. /// <returns></returns>
  600. public bool ChangeRotationSpeed(int speed)
  601. {
  602. return _rotationAxis.ChangeSpeed(speed);
  603. }
  604. /// <summary>
  605. /// 电机运动
  606. /// </summary>
  607. /// <param name="position"></param>
  608. /// <returns></returns>
  609. public bool RotationProfilePosition(double position)
  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. public virtual void Monitor()
  631. {
  632. }
  633. public virtual void Reset()
  634. {
  635. }
  636. public virtual void Terminate()
  637. {
  638. }
  639. }
  640. }