| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 | using System;using System.Collections.Generic;using System.Diagnostics;using Aitex.Core.Common;using Aitex.Core.RT.DataCenter;using Aitex.Core.RT.Device;using Aitex.Core.RT.Device.Unit;using Aitex.Core.RT.Event;using Aitex.Core.RT.Fsm;using Aitex.Core.RT.OperationCenter;using Aitex.Core.RT.Routine;using Aitex.Core.RT.SCCore;using Aitex.Core.Utilities;using Aitex.Sorter.Common;using MECF.Framework.Common.Alarms;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.Event;using MECF.Framework.Common.Schedulers;using MECF.Framework.Common.SubstrateTrackings;using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;using FurnaceRT.Equipments.Systems;using FurnaceRT.Devices;using IoDoor =  FurnaceRT.Devices.IoDoor;using Aitex.Core.Util;namespace FurnaceRT.Equipments.CarrierRobots{    public partial class CarrierRobotModule    {        private List<AlarmEventItem> _triggeredAlarmList = new List<AlarmEventItem>();        private int _alarmNumber;        public IoTrigger TrigActionCommand => _trigActionCommand;        public RobotBaseDevice CarrierRobotDevice { get; set; }        public IoBufferMotor BufferDevice { get; set; }        public IoSensor SensorFTRHomeCX;        private IoTrigger _trigAlarmReset;        private IoTrigger _trigActionCommand;        private IoAlarmSignal _alarmSignaRobotAlarm;        private R_TRIG _alarmSignaRobotAlarmTrig = new R_TRIG();        public IoDoor DoorDevice { get; set; }        public IoAlarmSignal AlarmSignaFOUPRobotTPStatusWarning { get; set; }        private Dictionary<string, int> _actionCommand;        private Dictionary<string, int> _actionCommandStocker;        public void InitDevice()        {            CarrierRobotDevice = DEVICE.GetDevice<RobotBaseDevice>($"{Module}");            BufferDevice = DEVICE.GetDevice<IoBufferMotor>($"PM1.BufferServo");            DoorDevice = DEVICE.GetDevice<IoDoor>($"PM1.AGVDoor");            AlarmSignaFOUPRobotTPStatusWarning = DEVICE.GetDevice<IoAlarmSignal>($"PM1.AlarmSignaFOUPRobotTPStatusWarning");            _alarmSignaRobotAlarm = DEVICE.GetDevice<IoAlarmSignal>($"PM1.AlarmSignaFOUPRobotAlarm");            SensorFTRHomeCX = DEVICE.GetDevice<IoSensor>($"PM1.SensorFTRHomeCX");            _trigAlarmReset = DEVICE.GetDevice<IoTrigger>($"PM1.TrigFOUPRobotAlarmReset");            _trigActionCommand = DEVICE.GetDevice<IoTrigger>($"PM1.TrigFOUPRobotActionCommand");            CarrierManager.Instance.SubscribeLocation(Module, 1, SC.GetValue<int>("System.CassetteSlotCount"));            WaferManager.Instance.SubscribeLocation(Module, SC.GetValue<int>("System.CassetteSlotCount"));            this.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;            CarrierRobotDevice.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;            _actionCommand = new Dictionary<string, int>()            {                {"C01.Pick",1 },                {"C01.Place",2 },                {"C02.Pick",3 },                {"C02.Place",4 },                {"C03.Pick",5 },                {"C03.Place",6 },                {"C04.Pick",7 },                {"C04.Place",8 },                {"C05.Pick",9 },                {"C05.Place",10 },                {"C06.Pick",11 },                {"C06.Place",12 },                {"C07.Pick",13 },                {"C07.Place",14 },                {"C08.Pick",15 },                {"C08.Place",16 },                {"C09.Pick",17 },                {"C09.Place",18 },                {"C10.Pick",19 },                {"C10.Place",20 },                {"C11.Pick",21 },                {"C11.Place",22 },                {"C12.Pick",23 },                {"C12.Place",24 },            };            _actionCommandStocker = new Dictionary<string, int>()            {                {"Stocker1.Pick",171 },                {"Stocker1.Place",181 },                {"Stocker2.Pick",172 },                {"Stocker2.Place",182 },                {"Stocker3.Pick",173 },                {"Stocker3.Place",183 },                {"Stocker4.Pick",174 },                {"Stocker4.Place",184 },                {"Stocker5.Pick",191 },                {"Stocker5.Place",201 },                {"Stocker6.Pick",192 },                {"Stocker6.Place",202 },                {"Stocker7.Pick",193 },                {"Stocker7.Place",203 },                {"Stocker8.Pick",194 },                {"Stocker8.Place",204 },                {"Stocker9.Pick",211 },                {"Stocker9.Place",221 },                {"Stocker10.Pick",212 },                {"Stocker10.Place",222 },                {"Stocker11.Pick",213 },                {"Stocker11.Place",223 },                {"Stocker12.Pick",214 },                {"Stocker12.Place",224 },                {"Stocker13.Pick",231 },                {"Stocker13.Place",241 },                {"Stocker14.Pick",232 },                {"Stocker14.Place",242 },                {"Stocker15.Pick",233 },                {"Stocker15.Place",243 },                {"Stocker16.Pick",234 },                {"Stocker16.Place",244 },            };        }        public void OnModuleDeviceAlarmStateChanged(string deviceId, AlarmEventItem alarmItem)        {            if (alarmItem.IsTriggered)            {                EventLevel level = alarmItem.Level;                _triggeredAlarmList.Add(alarmItem);                if (level == EventLevel.Alarm)                {                    try                    {                        EV.PostAlarmLog(Module, alarmItem);                    }                    catch (Exception ex)                    {                        EV.WriteEvent(ex.Message.ToString());                    }                }                else                {                    EV.PostWarningLog(Module, alarmItem);                }            }            else            {            }        }        public void SetCassetteRobotReset()        {            CarrierRobotDevice.RobotReset();        }        public bool SetCassetteRobotHome(out string reason)        {            reason = string.Empty;            return CarrierRobotDevice.HomeModule(null);        }        public bool SetSpeed(int speed, out string reason)        {            reason = string.Empty;            return CarrierRobotDevice.SetSpeed("SetSpeed", speed);        }        public bool RequestCassettePresent(Hand hand, out string reason)        {            reason = string.Empty;            RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Blade2;            List<object> paras = new List<object>() { "CurrentStatus", arm };            return CarrierRobotDevice.ReadParameter(paras.ToArray());        }        public bool RobotPick(ModuleName target, int targetSlot, Hand hand, out string reason)        {            reason = string.Empty;            RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Both;            return CarrierRobotDevice.Pick(arm, target.ToString(), targetSlot);        }        public bool RobotPlace(ModuleName target, int targetSlot, Hand hand, out string reason)        {            reason = string.Empty;            RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Both;            return CarrierRobotDevice.Place(arm, target.ToString(), targetSlot);        }        public bool RobotGoto(ModuleName target, int targetSlot, Hand hand, bool isPickReady, out string reason)        {            reason = string.Empty;            RobotArmEnum arm = hand == Hand.Blade1 ? RobotArmEnum.Blade1 : RobotArmEnum.Blade2;            List<object> paras = new List<object>() { arm, target, targetSlot, isPickReady ? "PickReady" : "PlaceReady" };            return CarrierRobotDevice.GoTo(paras.ToArray());        }        public void Stop()        {            CarrierRobotDevice.Stop();        }        public void SetBufferTargetPosition(string module)        {            int.TryParse(module.Replace("Stocker", ""), out int target);            BufferDevice.SetServoTargetPosition(target);        }        public bool SetBufferMoveTo()        {            return BufferDevice.SetServoMoveTo();        }        public bool CheckBufferTargetPosition(string module)        {            int.TryParse(module.Replace("Stocker", ""), out int target);            return (int)(BufferDevice.ServoMovePositionSet + 0.00001) == target && BufferDevice.TargetPositionFb == target;        }        public void SetRobotActionCommand(ModuleName traget, EnumTransferType transferType)        {            if (!CarrierRobotDevice.ModuleAssociateStationDic.ContainsKey(traget.ToString()))                return;            if (_actionCommandStocker.ContainsKey($"{traget}.{transferType}"))            {                //Stocker相关工位                _trigActionCommand.SetAOTrigger(_actionCommandStocker[$"{traget}.{transferType}"], out _);                return;            }            var station = CarrierRobotDevice.ModuleAssociateStationDic[traget.ToString()];            if (!_actionCommand.ContainsKey($"{station}.{transferType}"))                return;            _trigActionCommand.SetAOTrigger(_actionCommand[$"{station}.{transferType}"], out _);        }        public bool CheckRobotActionCommand(ModuleName traget, EnumTransferType transferType)        {            if (!CarrierRobotDevice.ModuleAssociateStationDic.ContainsKey(traget.ToString()))                return false;            if (_actionCommandStocker.ContainsKey($"{traget}.{transferType}"))            {                //Stocker相关工位                return Math.Abs(_trigActionCommand.AIValue - _actionCommandStocker[$"{traget}.{transferType}"]) < 0.001;            }            var station = CarrierRobotDevice.ModuleAssociateStationDic[traget.ToString()];            if (!_actionCommand.ContainsKey($"{station}.{transferType}"))                return false;            return Math.Abs(_trigActionCommand.AIValue - _actionCommand[$"{station}.{transferType}"]) < 0.001;        }        public void ResetRobotActionCommand()        {            _trigActionCommand?.SetAOTrigger(0, out _);        }    }}
 |