CarrierRobotModuleDevice.cs 10 KB

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