123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Device.Bases;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes;
- namespace JetEfemLib.SignalTowers
- {
- class RorzeSingalLight : SignalLightBase
- {
- public LightType Type { get; set; }
- public IEfemController EfemController { get; set; }
- private F_TRIG _trigError = new F_TRIG();
- private bool _isInit;
- private TowerLightStatus _preState = TowerLightStatus.Unknown;
- public RorzeSingalLight(string module, string name) : base(module, name)
- {
- _isInit = true;
- }
- protected override void SetOn()
- {
- SetLight(TowerLightStatus.On);
- }
- protected override void SetOff()
- {
- SetLight(TowerLightStatus.Off);
- }
- protected override void SetBlinking(bool token)
- {
- SetLight(TowerLightStatus.Blinking);
- }
- private void SetLight(TowerLightStatus setpoint)
- {
- try
- {
- if (setpoint != _preState || _isInit)
- {
- _trigError.CLK = EfemController.SetSignalLight(Type, setpoint, out string reason);
- if (_trigError.Q)
- {
- //EV.PostWarningLog(Module, $"Set {Type} signal light {setpoint} error, {reason}");
- }
- if (_trigError.M)
- {
- _isInit = false;
- _preState = setpoint;
- }
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- }
- public void ResetData()
- {
- _isInit = true;
- }
- public override void Reset()
- {
- _trigError.RST = true;
- base.Reset();
- }
- }
- public class JetEfemSignalTower : SignalTowerBase, IEfemSignalTowerCallback
- {
- private string _efemName;
- private IRorzeEfemController _efem;
- private List<RorzeSingalLight> _lstLight = new List<RorzeSingalLight>();
- public JetEfemSignalTower(string module, XmlElement node, string ioModule) : base("", "")
- {
- var attrModule = node.GetAttribute("module");
- base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
- base.Name = node.GetAttribute("id");
- base.Display = node.GetAttribute("display");
- base.DeviceID = node.GetAttribute("schematicId");
- _efemName = node.GetAttribute("efem");
- }
- public JetEfemSignalTower(string module, string name, string efemName) : base("", "")
- {
- base.Module = module;
- base.Name = name;
-
- _efemName = efemName;
- }
- public override bool Initialize()
- {
- base.Initialize();
- if (_efem == null && !string.IsNullOrEmpty(_efemName))
- {
- _efem = DEVICE.GetDevice<RorzeEfem>(_efemName);
- _efem.SetSignalTowerCallback(ModuleHelper.Converter(Module), this);
- }
- CustomSignalTower();
- return true;
- }
- //重新连接EFEM之后,需要重置灯塔
- public void ResetData()
- {
- foreach (var rorzeSingalLight in _lstLight)
- {
- rorzeSingalLight.ResetData();
- }
- }
- public override SignalLightBase CreateLight(LightType type)
- {
- var light = new RorzeSingalLight(ModuleName.System.ToString(), $"SignalLight{type}")
- { Type = type, EfemController = _efem };
- _lstLight.Add(light);
- return light;
- }
- }
- }
|