using Aitex.Core.RT.Device; using Aitex.Core.RT.IOCore; using Aitex.Core.Util; using MECF.Framework.Common.Device.Bases; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace MECF.Framework.RT.EquipmentLibrary.Devices { public class IoSignalLight : BaseDevice, IDevice { public DOAccessor doLight; public LightType lightType; private TowerLightStatus _action; private int _count; public IoSignalLight() { } public bool Initialize() { return true; } public TowerLightStatus GetAciton() { return _action; } public bool GetValue() { return doLight == null ? false : doLight.Value; } public void SetValue(TowerLightStatus action) { if (_action != TowerLightStatus.Blinking && lightType == LightType.Buzzer) { _count = 3; } _action = action; switch (_action) { case TowerLightStatus.On: { _count = 0; doLight.Value = true; } break; case TowerLightStatus.Off: { _count = 0; doLight.Value = false; } break; case TowerLightStatus.Blinking: { } break; default: break; } } public void Monitor() { if (_action == TowerLightStatus.Blinking) { if (_count > 0) { doLight.Value = !doLight.Value; _count--; if(_count == 0) { doLight.Value = false; _action = TowerLightStatus.Off; } } } } public void Reset() { _count = 0; _action = TowerLightStatus.Off; doLight.Value = false; } public void Terminate() { doLight = null; } } }