CarrierRobotModuleDevice.cs 11 KB

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