using Aitex.Core.Util; using MECF.Framework.Common.Device.Bases; using MECF.Framework.Common.Equipment; using System; using System.Collections.Generic; using Aitex.Core.RT.Log; using Venus_RT.Devices.EFEM; using Venus_RT.Modules; namespace Venus_RT.Devices { class KeplerSignalLight : SignalLightBase { public MECF.Framework.Common.Device.Bases.LightType Type { get; set; } public EfemBase EfemController { get; set; } private F_TRIG _trigError = new F_TRIG(); private bool _isInit; private TowerLightStatus _preState = TowerLightStatus.Unknown; //IoSignalTower _SignalTower; public KeplerSignalLight(string module, string name, EfemBase _efem) : base(module, name) { _isInit = true; //_SignalTower= Aitex.Core.RT.Device.DEVICE.GetDevice($"PMA.SignalTower"); EfemController = _efem; } protected override void SetOn() { SetLight(TowerLightStatus.On); } protected override void SetOff() { SetLight(TowerLightStatus.Off); } protected override void SetBlinking(bool token) { SetLight(TowerLightStatus.Blinking); } private bool SetSignalLight(MECF.Framework.Common.Device.Bases.LightType type, TowerLightStatus setpoint) { LightType venusType; switch (type) { case MECF.Framework.Common.Device.Bases.LightType.Red: venusType = LightType.RED; break; case MECF.Framework.Common.Device.Bases.LightType.Yellow: venusType = LightType.YELLOW; break; case MECF.Framework.Common.Device.Bases.LightType.Green: venusType = LightType.GREEN; break; case MECF.Framework.Common.Device.Bases.LightType.White: venusType = LightType.WHITE; break; case MECF.Framework.Common.Device.Bases.LightType.Blue: venusType = LightType.BLUE; break; case MECF.Framework.Common.Device.Bases.LightType.Buzzer: case MECF.Framework.Common.Device.Bases.LightType.Buzzer1: venusType = LightType.BUZZER1; break; default: venusType = LightType.BUZZER1; break; } LightStatus venusSetpoint; //LightState lightState; switch (setpoint) { case TowerLightStatus.Blinking: venusSetpoint = LightStatus.BLINK; //lightState = LightState.Blink; break; case TowerLightStatus.On: venusSetpoint = LightStatus.ON; //lightState = LightState.On; break; case TowerLightStatus.Off: venusSetpoint = LightStatus.OFF; //lightState = LightState.Off; break; default: venusSetpoint = LightStatus.OFF; //lightState = LightState.Off; break; } if (RtInstance.ConfigType == Venus_Core.ConfigType.Kepler2200 || RtInstance.ConfigType == Venus_Core.ConfigType.Kepler2300) { Singleton.Instance.EFEM?.SendEfemBackroundCommand(EfemEntity.MSG.Light, venusType, venusSetpoint); } return true; } private void SetLight(TowerLightStatus setpoint) { try { if (setpoint != _preState || _isInit) { _trigError.CLK = SetSignalLight(Type, setpoint); //if (_trigError.Q) //{ // //EV.PostWarningLog(Module, $"Set {Type} signal light {setpoint} error, {reason}"); //} if (_trigError.M) { _isInit = false; _preState = setpoint; } } } catch (Exception ex) { LOG.WriteExeption(ex); } } public void ResetData() { _isInit = true; } public override void Reset() { _trigError.RST = true; base.Reset(); } } public class KeplerSignalTower : SignalTowerBase { private EfemBase _efem; private List _lights = new List(); public KeplerSignalTower(string module, string name) : base("", "") { base.Module = module; base.Name = name; base.Display = name; base.DeviceID = ""; } public override bool Initialize() { base.Initialize(); if (_efem == null && Singleton.Instance.EFEM!=null) { _efem = Singleton.Instance.EFEM.EfemDevice; } CustomSignalTower(); return true; } //重新连接EFEM之后,需要重置灯塔 public void ResetData() { foreach (var rorzeSingalLight in _lights) { rorzeSingalLight.ResetData(); } } public override SignalLightBase CreateLight(MECF.Framework.Common.Device.Bases.LightType type) { var light = new KeplerSignalLight(ModuleName.System.ToString(), $"SignalLight{type}", _efem) { Type = type}; _lights.Add(light); return light; } } }