PlatingCellDevice.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  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.PlatingCell;
  11. using MECF.Framework.Common.CommonData.Reservoir;
  12. using MECF.Framework.Common.Equipment;
  13. using MECF.Framework.Common.IOCore;
  14. using MECF.Framework.Common.Persistent.Reservoirs;
  15. using MECF.Framework.Common.ToolLayout;
  16. using MECF.Framework.RT.Core.Equipments;
  17. using PunkHPX8_Core;
  18. using PunkHPX8_RT.Devices.AXIS;
  19. using PunkHPX8_RT.Devices.Facilities;
  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 = 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. SystemFacilities facilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  540. if (facilities != null && facilities.CDAEnable &&
  541. !facilities.FacilitiesDataDic["CDA1Pressure"].IsError &&
  542. !facilities.FacilitiesDataDic["CDA2Pressure"].IsError)
  543. {
  544. if (!JudgeRunningState(PlatingCellCommonOperation.ClamShellClose))
  545. {
  546. _currentOperation = PlatingCellCommonOperation.ClamShellClose;
  547. _status = _closeRoutine.Start(true);
  548. return _status == RState.Running;
  549. }
  550. else
  551. {
  552. return false;
  553. }
  554. }
  555. else
  556. {
  557. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"facility CDA is abnormal,can not do clamShell close");
  558. return false;
  559. }
  560. }
  561. /// <summary>
  562. /// ClamShell Open
  563. /// </summary>
  564. /// <param name="cmd"></param>
  565. /// <param name="args"></param>
  566. /// <returns></returns>
  567. public bool ClamShellOpen()
  568. {
  569. SystemFacilities facilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  570. if(facilities != null && facilities.CDAEnable &&
  571. !facilities.FacilitiesDataDic["CDA1Pressure"].IsError &&
  572. !facilities.FacilitiesDataDic["CDA2Pressure"].IsError)
  573. {
  574. if (!JudgeRunningState(PlatingCellCommonOperation.ClamShellOpen))
  575. {
  576. _currentOperation = PlatingCellCommonOperation.ClamShellOpen;
  577. _status = _closeRoutine.Start(false);
  578. return _status == RState.Running;
  579. }
  580. else
  581. {
  582. return false;
  583. }
  584. }
  585. else
  586. {
  587. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"facility CDA is abnormal,can not do clamShell open");
  588. return false;
  589. }
  590. }
  591. /// <summary>
  592. /// 判定运行状态
  593. /// </summary>
  594. /// <returns></returns>
  595. private bool JudgeRunningState(PlatingCellCommonOperation operation)
  596. {
  597. if (_status == RState.Running)
  598. {
  599. EV.PostAlarmLog($"{Module}", eEvent.ERR_PLATINGCELL, $"{Module} current execute {_currentOperation},cannot {operation}");
  600. return true;
  601. }
  602. return false;
  603. }
  604. #endregion
  605. /// <summary>
  606. /// DisabledAction
  607. /// </summary>
  608. /// <param name="cmd"></param>
  609. /// <param name="param"></param>
  610. /// <returns></returns>
  611. public bool DisabledOperation(string cmd, object[] args)
  612. {
  613. string currentOperation = "Disabled";
  614. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  615. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  616. {
  617. string preOperation = _persistentValue.OperatingMode;
  618. if (platingCellEntity.IsBusy)
  619. {
  620. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Disabled mode");
  621. return false;
  622. }
  623. //if (SchedulerMetalTimeManager.Instance.Contained(Module))
  624. //{
  625. // LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Disabled mode");
  626. // return false;
  627. //}
  628. platingCellEntity.EnterInit();
  629. _persistentValue.OperatingMode = currentOperation;
  630. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  631. }
  632. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  633. return true;
  634. }
  635. /// <summary>
  636. /// ManualAction
  637. /// </summary>
  638. /// <param name="cmd"></param>
  639. /// <param name="param"></param>
  640. /// <returns></returns>
  641. public bool ManualOperation(string cmd, object[] args)
  642. {
  643. string currentOperation = "Manual";
  644. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  645. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  646. {
  647. string preOperation = _persistentValue.OperatingMode;
  648. if (platingCellEntity.IsBusy)
  649. {
  650. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Manual mode");
  651. return false;
  652. }
  653. //if (SchedulerMetalTimeManager.Instance.Contained(Module))
  654. //{
  655. // LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Manual mode");
  656. // return false;
  657. //}
  658. platingCellEntity.EnterInit();
  659. _persistentValue.OperatingMode = currentOperation;
  660. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  661. }
  662. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  663. return true;
  664. }
  665. /// <summary>
  666. /// AutoAction
  667. /// </summary>
  668. /// <param name="cmd"></param>
  669. /// <param name="param"></param>
  670. /// <returns></returns>
  671. public bool AutoOperation(string cmd, object[] args)
  672. {
  673. string currentOperation = "Auto";
  674. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(_reservoirName);
  675. if (reservoirEntity!=null && reservoirEntity.PersistentValue.OperatingMode!="Auto")
  676. {
  677. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{_reservoirName} not in Auto mode, can't switch to Auto mode");
  678. return false;
  679. }
  680. PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
  681. if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
  682. {
  683. string preOperation = _persistentValue.OperatingMode;
  684. if (platingCellEntity.IsBusy)
  685. {
  686. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Auto mode");
  687. return false;
  688. }
  689. platingCellEntity.EnterInit();
  690. _persistentValue.OperatingMode = currentOperation;
  691. LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  692. }
  693. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  694. return true;
  695. }
  696. /// <summary>
  697. /// EngineeringModeAction
  698. /// </summary>
  699. /// <param name="cmd"></param>
  700. /// <param name="param"></param>
  701. /// <returns></returns>
  702. private bool EngineeringModeOperation(string cmd, object[] args)
  703. {
  704. string currentRecipeOperation = "Engineering";
  705. if (_persistentValue != null)
  706. {
  707. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  708. }
  709. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  710. return true;
  711. }
  712. /// <summary>
  713. /// ProductionAction
  714. /// </summary>
  715. /// <param name="cmd"></param>
  716. /// <param name="param"></param>
  717. /// <returns></returns>
  718. private bool ProductionModeOperation(string cmd, object[] args)
  719. {
  720. string currentRecipeOperation = "Production";
  721. if (_persistentValue != null)
  722. {
  723. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  724. }
  725. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  726. return true;
  727. }
  728. private bool SetPlatingCellWaferSize(string cmd, object[] args)
  729. {
  730. string metalWaferSize = args[0] as string;
  731. if (_persistentValue != null)
  732. {
  733. _persistentValue.PlatingCellWaferSize = int.Parse(metalWaferSize);
  734. }
  735. PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
  736. return true;
  737. }
  738. /// <summary>
  739. /// 获取Reservoir设备
  740. /// </summary>
  741. /// <returns></returns>
  742. private ReservoirDevice GetReservoirDevice()
  743. {
  744. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module);
  745. return DEVICE.GetDevice<ReservoirDevice>(reservoir);
  746. }
  747. /// <summary>
  748. /// CCR当前步骤
  749. /// </summary>
  750. /// <param name="tmp"></param>
  751. public void UpdateStatus(string tmp)
  752. {
  753. _currentCCRStep = tmp;
  754. }
  755. /// <summary>
  756. /// CCR当前步骤剩余时间
  757. /// </summary>
  758. /// <param name="tmp"></param>
  759. public void UpdateCCRTimeRemain(double timeRemain)
  760. {
  761. _timeRemain = timeRemain;
  762. }
  763. #endregion
  764. #region RotationAxis
  765. /// <summary>
  766. /// 电机是否上电
  767. /// </summary>
  768. /// <returns></returns>
  769. public bool CheckRotationSwitchOn()
  770. {
  771. return _rotationAxis.IsSwitchOn;
  772. }
  773. /// <summary>
  774. /// Home rotation
  775. /// </summary>
  776. /// <returns></returns>
  777. public bool HomeRotation()
  778. {
  779. return _rotationAxis.Home();
  780. }
  781. /// <summary>
  782. /// 检验Rotation Home结果
  783. /// </summary>
  784. /// <returns></returns>
  785. public bool CheckHomeEndStatus()
  786. {
  787. return CheckRotationEndStatus() && _rotationAxis.IsHomed;
  788. }
  789. /// <summary>
  790. /// 检验Rotation结束状态
  791. /// </summary>
  792. /// <returns></returns>
  793. public bool CheckRotationEndStatus()
  794. {
  795. return _rotationAxis.Status == PunkHPX8_Core.RState.End;
  796. }
  797. /// <summary>
  798. /// 检验Rotation失败状态
  799. /// </summary>
  800. /// <returns></returns>
  801. public bool CheckRotationStopStatus()
  802. {
  803. return _rotationAxis.Status == PunkHPX8_Core.RState.Failed;
  804. }
  805. /// <summary>
  806. /// 设置速度
  807. /// </summary>
  808. /// <param name="speed"></param>
  809. /// <returns></returns>
  810. public bool SetRotationSpeed(int speed)
  811. {
  812. _rotationAxis.SetProfileSpeed(speed);
  813. return true;
  814. }
  815. /// <summary>
  816. /// 改变速度
  817. /// </summary>
  818. /// <param name="speed"></param>
  819. /// <returns></returns>
  820. public bool ChangeRotationSpeed(int speed)
  821. {
  822. return _rotationAxis.ChangeSpeed(speed);
  823. }
  824. /// <summary>
  825. /// 电机运动
  826. /// </summary>
  827. /// <param name="position"></param>
  828. /// <returns></returns>
  829. public bool RotationProfilePosition(double position)
  830. {
  831. return _rotationAxis.ProfilePositionOperation(position);
  832. }
  833. /// <summary>
  834. /// 停止运动
  835. /// </summary>
  836. /// <returns></returns>
  837. public bool StopProfilePosition()
  838. {
  839. return _rotationAxis.StopPositionOperation();
  840. }
  841. /// <summary>
  842. /// 是否Rotation运动
  843. /// </summary>
  844. /// <returns></returns>
  845. public bool CheckRotationRunning()
  846. {
  847. return _rotationAxis.IsRun;
  848. }
  849. #endregion
  850. public virtual void Monitor()
  851. {
  852. }
  853. public virtual void Reset()
  854. {
  855. }
  856. public virtual void Terminate()
  857. {
  858. }
  859. }
  860. }