PlatingCellDevice.cs 32 KB

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