CarrierRobotModuleDevice.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using Aitex.Core.Common;
  5. using Aitex.Core.RT.DataCenter;
  6. using Aitex.Core.RT.Device;
  7. using Aitex.Core.RT.Device.Unit;
  8. using Aitex.Core.RT.Event;
  9. using Aitex.Core.RT.Fsm;
  10. using Aitex.Core.RT.OperationCenter;
  11. using Aitex.Core.RT.Routine;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Utilities;
  14. using Aitex.Sorter.Common;
  15. using MECF.Framework.Common.Alarms;
  16. using MECF.Framework.Common.Equipment;
  17. using MECF.Framework.Common.Event;
  18. using MECF.Framework.Common.Schedulers;
  19. using MECF.Framework.Common.SubstrateTrackings;
  20. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  21. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  22. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  23. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  24. using FurnaceRT.Equipments.Systems;
  25. using FurnaceRT.Devices;
  26. using IoDoor = FurnaceRT.Devices.IoDoor;
  27. using Aitex.Core.Util;
  28. namespace FurnaceRT.Equipments.CarrierRobots
  29. {
  30. public partial class CarrierRobotModule
  31. {
  32. private List<AlarmEventItem> _triggeredAlarmList = new List<AlarmEventItem>();
  33. private int _alarmNumber;
  34. public IoTrigger TrigActionCommand => _trigActionCommand;
  35. public RobotBaseDevice CarrierRobotDevice { get; set; }
  36. public IoBufferMotor BufferDevice { get; set; }
  37. private IoTrigger _trigAlarmReset;
  38. private IoTrigger _trigActionCommand;
  39. private IoAlarmSignal _alarmSignaRobotAlarm;
  40. private R_TRIG _alarmSignaRobotAlarmTrig = new R_TRIG();
  41. public IoDoor DoorDevice { get; set; }
  42. public IoAlarmSignal AlarmSignaFOUPRobotTPStatusWarning { get; set; }
  43. private Dictionary<string, int> _actionCommand;
  44. private Dictionary<string, int> _actionCommandStocker;
  45. public void InitDevice()
  46. {
  47. CarrierRobotDevice = DEVICE.GetDevice<RobotBaseDevice>($"{Module}");
  48. BufferDevice = DEVICE.GetDevice<IoBufferMotor>($"PM1.BufferServo");
  49. DoorDevice = DEVICE.GetDevice<IoDoor>($"PM1.AGVDoor");
  50. AlarmSignaFOUPRobotTPStatusWarning = DEVICE.GetDevice<IoAlarmSignal>($"PM1.AlarmSignaFOUPRobotTPStatusWarning");
  51. _alarmSignaRobotAlarm = DEVICE.GetDevice<IoAlarmSignal>($"PM1.AlarmSignaFOUPRobotAlarm");
  52. _trigAlarmReset = DEVICE.GetDevice<IoTrigger>($"PM1.TrigFOUPRobotAlarmReset");
  53. _trigActionCommand = DEVICE.GetDevice<IoTrigger>($"PM1.TrigFOUPRobotActionCommand");
  54. CarrierManager.Instance.SubscribeLocation(Module, 1, SC.GetValue<int>("System.CassetteSlotCount"));
  55. WaferManager.Instance.SubscribeLocation(Module, SC.GetValue<int>("System.CassetteSlotCount"));
  56. this.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
  57. CarrierRobotDevice.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
  58. _actionCommandStocker = new Dictionary<string, int>()
  59. {
  60. {"Stocker1.Pick",101 },
  61. {"Stocker1.Place",201 },
  62. {"Stocker2.Pick",102 },
  63. {"Stocker2.Place",202 },
  64. {"Stocker3.Pick",103 },
  65. {"Stocker3.Place",203 },
  66. {"Stocker4.Pick",104 },
  67. {"Stocker4.Place",204 },
  68. {"Stocker5.Pick",105 },
  69. {"Stocker5.Place",205 },
  70. {"Stocker6.Pick",106 },
  71. {"Stocker6.Place",206 },
  72. {"Stocker7.Pick",107 },
  73. {"Stocker7.Place",207 },
  74. {"Stocker8.Pick",108 },
  75. {"Stocker8.Place",208 },
  76. {"Stocker9.Pick",109 },
  77. {"Stocker9.Place",209 },
  78. {"Stocker10.Pick",110 },
  79. {"Stocker10.Place",210 },
  80. {"Stocker11.Pick",111 },
  81. {"Stocker11.Place",211 },
  82. {"Stocker12.Pick",112 },
  83. {"Stocker12.Place",212 },
  84. {"Stocker13.Pick",113 },
  85. {"Stocker13.Place",213 },
  86. {"Stocker14.Pick",114 },
  87. {"Stocker14.Place",214 },
  88. {"Stocker15.Pick",115 },
  89. {"Stocker15.Place",215 },
  90. {"Stocker16.Pick",116 },
  91. {"Stocker16.Place",216 },
  92. {"Stocker17.Pick",117 },
  93. {"Stocker17.Place",217 },
  94. {"Stocker18.Pick",118 },
  95. {"Stocker18.Place",218 },
  96. };
  97. _actionCommand = new Dictionary<string, int>()
  98. {
  99. {"C01.Pick",1 },
  100. {"C01.Place",2 },
  101. {"C02.Pick",3 },
  102. {"C02.Place",4 },
  103. {"C03.Pick",5 },
  104. {"C03.Place",6 },
  105. {"C04.Pick",7 },
  106. {"C04.Place",8 },
  107. {"C05.Pick",9 },
  108. {"C05.Place",10 },
  109. {"C06.Pick",11 },
  110. {"C06.Place",12 },
  111. {"C07.Pick",13 },
  112. {"C07.Place",14 },
  113. {"C08.Pick",15 },
  114. {"C08.Place",16 },
  115. {"C09.Pick",17 },
  116. {"C09.Place",18 },
  117. {"C10.Pick",19 },
  118. {"C10.Place",20 },
  119. {"C11.Pick",21 },
  120. {"C11.Place",22 },
  121. {"C12.Pick",23 },
  122. {"C12.Place",24 },
  123. };
  124. }
  125. public void OnModuleDeviceAlarmStateChanged(string deviceId, AlarmEventItem alarmItem)
  126. {
  127. if (alarmItem.IsTriggered)
  128. {
  129. EventLevel level = alarmItem.Level;
  130. _triggeredAlarmList.Add(alarmItem);
  131. if (level == EventLevel.Alarm)
  132. {
  133. try
  134. {
  135. EV.PostAlarmLog(Module, alarmItem);
  136. }
  137. catch (Exception ex)
  138. {
  139. EV.WriteEvent(ex.Message.ToString());
  140. }
  141. }
  142. else
  143. {
  144. EV.PostWarningLog(Module, alarmItem);
  145. }
  146. }
  147. else
  148. {
  149. }
  150. }
  151. public void SetCassetteRobotReset()
  152. {
  153. CarrierRobotDevice.RobotReset();
  154. }
  155. public bool SetCassetteRobotHome(out string reason)
  156. {
  157. reason = string.Empty;
  158. return CarrierRobotDevice.HomeModule(null);
  159. }
  160. public bool SetSpeed(int speed, out string reason)
  161. {
  162. reason = string.Empty;
  163. return CarrierRobotDevice.SetSpeed("SetSpeed", speed);
  164. }
  165. public bool RequestCassettePresent(Hand hand, out string reason)
  166. {
  167. reason = string.Empty;
  168. RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Blade2;
  169. List<object> paras = new List<object>() { "CurrentStatus", arm };
  170. return CarrierRobotDevice.ReadParameter(paras.ToArray());
  171. }
  172. public bool RobotPick(ModuleName target, int targetSlot, Hand hand, out string reason)
  173. {
  174. reason = string.Empty;
  175. RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Both;
  176. return CarrierRobotDevice.Pick(arm, target.ToString(), targetSlot);
  177. }
  178. public bool RobotPlace(ModuleName target, int targetSlot, Hand hand, out string reason)
  179. {
  180. reason = string.Empty;
  181. RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Both;
  182. return CarrierRobotDevice.Place(arm, target.ToString(), targetSlot);
  183. }
  184. public bool RobotGoto(ModuleName target, int targetSlot, Hand hand, bool isPickReady, out string reason)
  185. {
  186. reason = string.Empty;
  187. RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Blade2;
  188. List<object> paras = new List<object>() { arm, target, targetSlot, isPickReady ? "PickReady" : "PlaceReady" };
  189. return CarrierRobotDevice.GoTo(paras.ToArray());
  190. }
  191. public void Stop()
  192. {
  193. CarrierRobotDevice.Stop();
  194. }
  195. public void SetBufferTargetPosition(string module)
  196. {
  197. int.TryParse(module.Replace("Stocker", ""), out int target);
  198. BufferDevice.SetServoTargetPosition(target);
  199. }
  200. public bool SetBufferMoveTo()
  201. {
  202. return BufferDevice.SetServoMoveTo();
  203. }
  204. public bool CheckBufferTargetPosition(string module)
  205. {
  206. int.TryParse(module.Replace("Stocker", ""), out int target);
  207. return (int)(BufferDevice.ServoMovePositionSet + 0.00001) == target && BufferDevice.TargetPositionFb == target;
  208. }
  209. public void SetRobotActionCommand(ModuleName traget, EnumTransferType transferType)
  210. {
  211. if (!CarrierRobotDevice.ModuleAssociateStationDic.ContainsKey(traget.ToString()))
  212. return;
  213. if(_actionCommandStocker.ContainsKey($"{traget}.{transferType}"))
  214. {
  215. //Stocker相关工位
  216. _trigActionCommand.SetAOTrigger(_actionCommandStocker[$"{traget}.{transferType}"], out _);
  217. return;
  218. }
  219. var station = CarrierRobotDevice.ModuleAssociateStationDic[traget.ToString()];
  220. if(!_actionCommand.ContainsKey($"{station}.{transferType}"))
  221. return;
  222. _trigActionCommand.SetAOTrigger(_actionCommand[$"{station}.{transferType}"], out _);
  223. }
  224. public bool CheckRobotActionCommand(ModuleName traget, EnumTransferType transferType)
  225. {
  226. if (!CarrierRobotDevice.ModuleAssociateStationDic.ContainsKey(traget.ToString()))
  227. return false;
  228. if (_actionCommandStocker.ContainsKey($"{traget}.{transferType}"))
  229. {
  230. //Stocker相关工位
  231. return Math.Abs(_trigActionCommand.AIValue - _actionCommandStocker[$"{traget}.{transferType}"]) < 0.001;
  232. }
  233. var station = CarrierRobotDevice.ModuleAssociateStationDic[traget.ToString()];
  234. if (!_actionCommand.ContainsKey($"{station}.{transferType}"))
  235. return false;
  236. return Math.Abs( _trigActionCommand.AIValue - _actionCommand[$"{station}.{transferType}"]) < 0.001;
  237. }
  238. public void ResetRobotActionCommand()
  239. {
  240. _trigActionCommand?.SetAOTrigger(0, out _);
  241. }
  242. }
  243. }