PlatingCellDevice.cs 33 KB

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