2023-04-28 10:15:33 +08:00
|
|
|
|
using Aitex.Common.Util;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using Aitex.Core.Common.DeviceData;
|
|
|
|
|
using Aitex.Core.RT.DataCenter;
|
|
|
|
|
using Aitex.Core.RT.Device;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
using Aitex.Core.RT.IOCore;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using Aitex.Core.RT.Log;
|
|
|
|
|
using Aitex.Core.RT.OperationCenter;
|
|
|
|
|
using Aitex.Core.Util;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
2023-05-05 15:46:00 +08:00
|
|
|
|
using System.Linq;
|
2023-05-01 18:58:42 +08:00
|
|
|
|
using System.Text.RegularExpressions;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
using System.Xml;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
namespace MECF.Framework.Common.Device.Bases
|
|
|
|
|
{
|
2023-04-28 10:15:33 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 信号塔对象。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SignalTowerBase : BaseDevice, IDevice
|
|
|
|
|
{
|
|
|
|
|
#region Variables
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否关闭蜂鸣器输出。
|
|
|
|
|
/// <value>True:蜂鸣器被手动关闭,满足事件条件也不要打开蜂鸣器。</value>
|
|
|
|
|
/// <value>False:根据当前系统状态和配置事件自动输出蜂鸣器状态。</value>
|
|
|
|
|
/// </summary>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
private bool _switchBuzzerOff;
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 信号塔事件字典,从配置文件中读取。
|
|
|
|
|
/// </summary>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
private Dictionary<string, List<SignalTowerPartAction>> _signalTowerEvent;
|
2023-05-05 11:38:25 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 信号塔中组件字典。
|
|
|
|
|
/// </summary>
|
2023-05-05 15:46:00 +08:00
|
|
|
|
private readonly Dictionary<LightType, SignalTowerPartBase> _dicStParts;
|
2023-05-05 11:38:25 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 信号塔组件动作字典。
|
|
|
|
|
/// </summary>
|
2023-05-05 15:46:00 +08:00
|
|
|
|
private Dictionary<LightType, SignalTowerPartAction> _dicMergedActions;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构建信号塔对象的实例。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="module">当前模组名称。</param>
|
|
|
|
|
/// <param name="node">设备配置文件。</param>
|
|
|
|
|
/// <param name="ioModule">所属Module的名称。</param>
|
|
|
|
|
public SignalTowerBase(string module, XmlElement node, string ioModule = "")
|
|
|
|
|
: base(module, node, ioModule)
|
|
|
|
|
{
|
2023-05-05 15:46:00 +08:00
|
|
|
|
_dicStParts = new Dictionary<LightType, SignalTowerPartBase>();
|
|
|
|
|
|
2023-04-28 10:15:33 +08:00
|
|
|
|
var doRedLight = ParseDoNode("doRed", node, ioModule);
|
|
|
|
|
var doYellowLight = ParseDoNode("doYellow", node, ioModule);
|
|
|
|
|
var doGreenLight = ParseDoNode("doGreen", node, ioModule);
|
|
|
|
|
var doBlueLight = ParseDoNode("doBlue", node, ioModule);
|
|
|
|
|
var doWhiteLight = ParseDoNode("doWhite", node, ioModule);
|
|
|
|
|
var doBuzzer = ParseDoNode("doBuzzer", node, ioModule);
|
|
|
|
|
var doBuzzer1 = ParseDoNode("doBuzzer1", node, ioModule);
|
|
|
|
|
var doBuzzer2 = ParseDoNode("doBuzzer2", node, ioModule);
|
|
|
|
|
var doBuzzer3 = ParseDoNode("doBuzzer3", node, ioModule);
|
|
|
|
|
var doBuzzer4 = ParseDoNode("doBuzzer4", node, ioModule);
|
|
|
|
|
var doBuzzer5 = ParseDoNode("doBuzzer5", node, ioModule);
|
2023-05-05 11:38:25 +08:00
|
|
|
|
var aoBuzzerBlinkFreq = ParseAoNode("aoBuzzerBlinkFreq", node, ioModule);
|
|
|
|
|
var eventFile = node.GetAttribute("eventFile");
|
2023-04-28 10:15:33 +08:00
|
|
|
|
|
|
|
|
|
// 红、黄、绿、蜂鸣器是必须定义的元件。
|
|
|
|
|
Debug.Assert(doRedLight != null, "DO RedLight is not valid");
|
|
|
|
|
Debug.Assert(doYellowLight != null, "DO RedLight is not valid");
|
|
|
|
|
Debug.Assert(doGreenLight != null, "DO RedLight is not valid");
|
|
|
|
|
Debug.Assert(doBuzzer != null, "DO RedLight is not valid");
|
|
|
|
|
|
|
|
|
|
// 创建三色灯控制元件。
|
|
|
|
|
CreateSignalPart(LightType.Red, doRedLight);
|
|
|
|
|
CreateSignalPart(LightType.Yellow, doYellowLight);
|
|
|
|
|
CreateSignalPart(LightType.Green, doGreenLight);
|
|
|
|
|
CreateSignalPart(LightType.Blue, doBlueLight);
|
|
|
|
|
CreateSignalPart(LightType.White, doWhiteLight);
|
2023-05-01 18:58:42 +08:00
|
|
|
|
CreateSignalPart(LightType.Buzzer, doBuzzer, aoBuzzerBlinkFreq);
|
2023-04-28 10:15:33 +08:00
|
|
|
|
CreateSignalPart(LightType.Buzzer1, doBuzzer1);
|
|
|
|
|
CreateSignalPart(LightType.Buzzer2, doBuzzer2);
|
|
|
|
|
CreateSignalPart(LightType.Buzzer3, doBuzzer3);
|
|
|
|
|
CreateSignalPart(LightType.Buzzer4, doBuzzer4);
|
|
|
|
|
CreateSignalPart(LightType.Buzzer5, doBuzzer5);
|
|
|
|
|
|
|
|
|
|
//解析三色灯Event
|
2023-05-05 11:38:25 +08:00
|
|
|
|
ParseSignalTowerEvent(eventFile);
|
2023-04-28 10:15:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返回信号塔当前状态数据集。
|
|
|
|
|
/// <remarks>该属性用于RT到UI间的数据传递。</remarks>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public AITSignalTowerData DeviceData => new AITSignalTowerData
|
|
|
|
|
{
|
|
|
|
|
DeviceName = Name,
|
|
|
|
|
DeviceSchematicId = DeviceID,
|
|
|
|
|
DisplayName = Display,
|
|
|
|
|
IsGreenLightOn = GetSignalTowerPartValue(LightType.Green),
|
|
|
|
|
IsRedLightOn = GetSignalTowerPartValue(LightType.Red),
|
|
|
|
|
IsYellowLightOn = GetSignalTowerPartValue(LightType.Yellow),
|
|
|
|
|
IsBlueLightOn = GetSignalTowerPartValue(LightType.Blue),
|
|
|
|
|
IsWhiteLightOn = GetSignalTowerPartValue(LightType.White),
|
|
|
|
|
IsBuzzerOn = GetSignalTowerPartValue(LightType.Buzzer),
|
|
|
|
|
IsBuzzer1On = GetSignalTowerPartValue(LightType.Buzzer1),
|
|
|
|
|
IsBuzzer2On = GetSignalTowerPartValue(LightType.Buzzer2),
|
|
|
|
|
IsBuzzer3On = GetSignalTowerPartValue(LightType.Buzzer3),
|
|
|
|
|
IsBuzzer4On = GetSignalTowerPartValue(LightType.Buzzer4),
|
|
|
|
|
IsBuzzer5On = GetSignalTowerPartValue(LightType.Buzzer5),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建一个信号塔元件,并添加到字典中。
|
|
|
|
|
/// </summary>
|
2023-05-01 18:58:42 +08:00
|
|
|
|
/// <param name="light">信号塔元件类型,请参考<see cref="LightType"/>。</param>
|
|
|
|
|
/// <param name="doSw">控制元件开关的DO。</param>
|
|
|
|
|
/// <param name="aoBlinkFreq">控制Blink频率的AO。</param>
|
|
|
|
|
private void CreateSignalPart(LightType light, DOAccessor doSw, AOAccessor aoBlinkFreq = null)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-01 18:58:42 +08:00
|
|
|
|
if (doSw != null)
|
2023-05-05 15:46:00 +08:00
|
|
|
|
_dicStParts.Add(light, new SignalTowerPartBase(light, doSw, aoBlinkFreq));
|
2023-04-28 10:15:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
private bool ParseSignalTowerEvent(string fileName)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-05 11:38:25 +08:00
|
|
|
|
var cFileName = PathManager.GetCfgDir() + fileName;
|
|
|
|
|
if (!File.Exists(cFileName))
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-05 11:38:25 +08:00
|
|
|
|
LOG.Error($"Unable to find signal tower events config file {cFileName}.");
|
|
|
|
|
return false;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
var stEvents = CustomXmlSerializer.Deserialize<STEvents>(new FileInfo(cFileName));
|
2023-04-28 10:15:33 +08:00
|
|
|
|
_signalTowerEvent = new Dictionary<string, List<SignalTowerPartAction>>();
|
|
|
|
|
|
2023-05-01 18:58:42 +08:00
|
|
|
|
// Blinking配置字符串规则:
|
|
|
|
|
// 1、Blinking
|
|
|
|
|
// 2、Blinking,---..
|
|
|
|
|
// 3、Blinking,0.5
|
|
|
|
|
// 在线校验:https://regex101.com/r/CescBw/1
|
|
|
|
|
var regxBlinkPatternString =
|
|
|
|
|
new Regex(
|
|
|
|
|
@"^(([bB]linking){1}(,{1})(?(2)([-\.]+)$))|(([bB]linking){1}(,{1})(?(6)(\d+\.?\d*)$))|([bB]linking){1}$");
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
foreach (var stEvent in stEvents.Events)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-05 11:38:25 +08:00
|
|
|
|
if (!_signalTowerEvent.ContainsKey(stEvent.Name))
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-05 11:38:25 +08:00
|
|
|
|
_signalTowerEvent[stEvent.Name] = new List<SignalTowerPartAction>();
|
2023-04-28 10:15:33 +08:00
|
|
|
|
|
|
|
|
|
foreach (LightType type in Enum.GetValues(typeof(LightType)))
|
|
|
|
|
{
|
2023-05-05 15:46:00 +08:00
|
|
|
|
if (!_dicStParts.ContainsKey(type))
|
2023-04-28 10:15:33 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
var obj = stEvent.GetType().GetProperty(type.ToString())?.GetValue(stEvent);
|
2023-04-28 10:15:33 +08:00
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
2023-05-01 18:58:42 +08:00
|
|
|
|
TowerLightStatus status = TowerLightStatus.Unknown;
|
|
|
|
|
STBlinkPattern blinkPattern = null;
|
|
|
|
|
|
2023-04-28 10:15:33 +08:00
|
|
|
|
var str = obj.ToString().ToLower();
|
|
|
|
|
if (str.Contains("on"))
|
|
|
|
|
{
|
|
|
|
|
status = TowerLightStatus.On;
|
|
|
|
|
}
|
|
|
|
|
else if (str.Contains("off"))
|
|
|
|
|
{
|
|
|
|
|
status = TowerLightStatus.Off;
|
|
|
|
|
}
|
2023-05-01 18:58:42 +08:00
|
|
|
|
else if (str.Contains("warning"))
|
|
|
|
|
{
|
|
|
|
|
status = TowerLightStatus.Warning;
|
|
|
|
|
blinkPattern = STBlinkPattern.GetSlowBlinkPattern();
|
|
|
|
|
}
|
|
|
|
|
else if (str.Contains("alarm"))
|
|
|
|
|
{
|
|
|
|
|
status = TowerLightStatus.Alarm;
|
|
|
|
|
blinkPattern = STBlinkPattern.GetFastBlinkPattern();
|
|
|
|
|
}
|
|
|
|
|
else if(str.StartsWith(TowerLightStatus.Blinking.ToString().ToLower()))
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-01 18:58:42 +08:00
|
|
|
|
// 如果配置为闪烁方式,检查配置中是否包含BlinkPattern字串
|
|
|
|
|
var matches = regxBlinkPatternString.Match(str);
|
|
|
|
|
if (matches.Success)
|
|
|
|
|
{
|
|
|
|
|
if (matches.Groups[9].Success) // Blinking
|
|
|
|
|
blinkPattern = STBlinkPattern.GetSlowBlinkPattern();
|
|
|
|
|
else if (matches.Groups[6].Success) // Blinking,00.0
|
|
|
|
|
blinkPattern = STBlinkPattern.ParseSTEvent(matches.Groups[8].Value);
|
|
|
|
|
else if (matches.Groups[2].Success) // Blinking,--.-
|
|
|
|
|
blinkPattern = STBlinkPattern.ParseSTEvent(matches.Groups[4].Value);
|
|
|
|
|
else
|
|
|
|
|
blinkPattern = STBlinkPattern.GetFastBlinkPattern();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-28 10:15:33 +08:00
|
|
|
|
status = TowerLightStatus.Blinking;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
_signalTowerEvent[stEvent.Name].Add(new SignalTowerPartAction(type, status, blinkPattern));
|
2023-04-28 10:15:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOG.Error(ex.ToString());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化信号塔对象实例。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// 注册SwitchOffBuzzer操作和DeviceData数据。
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// <returns></returns>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
public bool Initialize()
|
|
|
|
|
{
|
|
|
|
|
OP.Subscribe($"{Module}.{Name}.{AITSignalTowerOperation.SwitchOffBuzzer}", SwitchOffBuzzer);
|
|
|
|
|
DATA.Subscribe(Module + "." + Name + ".DeviceData", () => DeviceData);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 复位信号塔状态及其各个组件。
|
|
|
|
|
/// </summary>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
_switchBuzzerOff = false;
|
|
|
|
|
|
2023-05-05 15:46:00 +08:00
|
|
|
|
foreach (var light in _dicStParts.Values)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
light.Reset();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 终止信号塔对象实例。
|
|
|
|
|
/// </summary>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
public void Terminate()
|
|
|
|
|
{
|
2023-05-05 15:46:00 +08:00
|
|
|
|
foreach (var light in _dicStParts.Values)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
light.Terminate();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 周期性扫描信号塔以执行后台任务。
|
|
|
|
|
/// </summary>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
public void Monitor()
|
|
|
|
|
{
|
2023-05-05 15:46:00 +08:00
|
|
|
|
_dicMergedActions = _dicStParts.ToDictionary(
|
|
|
|
|
x => x.Key,
|
|
|
|
|
v => v.Value.GetAction());
|
2023-04-28 10:15:33 +08:00
|
|
|
|
|
|
|
|
|
// 遍历所有注册的事件,决定信号塔各元件的输出状态。
|
|
|
|
|
foreach (var signalEvent in _signalTowerEvent)
|
|
|
|
|
{
|
|
|
|
|
var obj = DATA.Poll(signalEvent.Key);
|
2023-05-05 15:46:00 +08:00
|
|
|
|
if(obj is not true)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2023-05-05 15:46:00 +08:00
|
|
|
|
foreach (var newAction in signalEvent.Value)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-05 15:46:00 +08:00
|
|
|
|
if (!_dicStParts.TryGetValue(newAction.Light, out var stPart))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// 根据当前设备状态,判断下一步信号组件的输出动作是什么
|
|
|
|
|
var mergedAction = MergeAction(_dicMergedActions[stPart.Light], newAction);
|
|
|
|
|
|
|
|
|
|
_dicMergedActions[stPart.Light] = mergedAction;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
// 设置信号塔每个组件的输出。
|
|
|
|
|
foreach (var action in _dicMergedActions)
|
2023-05-05 15:46:00 +08:00
|
|
|
|
{
|
2023-05-05 17:10:07 +08:00
|
|
|
|
// 创建一个动作副本,解决蜂鸣器被手动关闭后无法启用的问题
|
|
|
|
|
var clonedAction = (SignalTowerPartAction)action.Value?.Clone();
|
|
|
|
|
if(clonedAction == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
2023-05-05 15:46:00 +08:00
|
|
|
|
// 如果蜂鸣器被强制关闭
|
2023-05-05 17:10:07 +08:00
|
|
|
|
if (clonedAction.Light == LightType.Buzzer && _switchBuzzerOff)
|
|
|
|
|
clonedAction.Status = TowerLightStatus.Off;
|
|
|
|
|
|
2023-05-05 15:46:00 +08:00
|
|
|
|
|
2023-05-05 17:10:07 +08:00
|
|
|
|
_dicStParts[action.Key].SetAction(clonedAction);
|
2023-05-05 15:46:00 +08:00
|
|
|
|
}
|
2023-04-28 10:15:33 +08:00
|
|
|
|
|
2023-05-05 11:38:25 +08:00
|
|
|
|
// 扫描信号塔组件状态
|
2023-05-05 15:46:00 +08:00
|
|
|
|
foreach (var light in _dicStParts.Values)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
light?.Monitor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 以指定的模式闪烁指定的信号塔元件。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="light">指定的信号塔元件。</param>
|
|
|
|
|
/// <param name="pattern">闪烁模式。</param>
|
|
|
|
|
/// <returns>True:启动闪烁成功;False:启动闪烁失败。</returns>
|
|
|
|
|
public bool Blink(LightType light, STBlinkPattern pattern)
|
|
|
|
|
{
|
|
|
|
|
if (pattern == null)
|
|
|
|
|
{
|
|
|
|
|
LOG.Error($"{light} Blink Pattern can not be null");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 15:46:00 +08:00
|
|
|
|
if (_dicStParts.TryGetValue(light, out var lightInstance))
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-05 16:11:52 +08:00
|
|
|
|
// 强制使能蜂鸣器
|
|
|
|
|
_switchBuzzerOff = false;
|
2023-05-05 15:46:00 +08:00
|
|
|
|
lightInstance.SetAction(new SignalTowerPartAction(lightInstance.Light, TowerLightStatus.Blinking,
|
|
|
|
|
pattern));
|
2023-04-28 10:15:33 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.Error($"{light} Unable to find this part of signal tower, check configuration");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 打开或关闭蜂鸣器。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isOff"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool SwitchOffBuzzer(bool isOff)
|
|
|
|
|
{
|
|
|
|
|
_switchBuzzerOff = isOff;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭蜂鸣器。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="arg1"></param>
|
|
|
|
|
/// <param name="arg2"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool SwitchOffBuzzer(string arg1, object[] arg2)
|
|
|
|
|
{
|
|
|
|
|
_switchBuzzerOff = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// 合并信号事件。
|
2023-04-28 10:15:33 +08:00
|
|
|
|
/// <remarks>
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// 根据<see cref="SignalTowerPartAction.Status"/>的优先级决定执行的动作。
|
2023-04-28 10:15:33 +08:00
|
|
|
|
/// <br/>
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// 此属性的数值越小,表示优先级越高。
|
2023-04-28 10:15:33 +08:00
|
|
|
|
/// </remarks>
|
|
|
|
|
/// </summary>
|
2023-05-05 11:38:25 +08:00
|
|
|
|
/// <param name="currentAction">当前输出状态。</param>
|
|
|
|
|
/// <param name="nextAction">期望的输出状态。</param>
|
2023-04-28 10:15:33 +08:00
|
|
|
|
/// <returns>合并后的信号灯输出状态。</returns>
|
2023-05-05 11:38:25 +08:00
|
|
|
|
private SignalTowerPartAction MergeAction(SignalTowerPartAction currentAction, SignalTowerPartAction nextAction)
|
2023-04-28 10:15:33 +08:00
|
|
|
|
{
|
2023-05-05 11:38:25 +08:00
|
|
|
|
if (currentAction == null)
|
|
|
|
|
return nextAction;
|
|
|
|
|
if (nextAction == null)
|
|
|
|
|
return currentAction;
|
|
|
|
|
return (int)currentAction.Status < (int)nextAction.Status ? currentAction : nextAction;
|
2023-04-28 10:15:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取指定信号塔元件的输出状态。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="light"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool GetSignalTowerPartValue(LightType light)
|
|
|
|
|
{
|
2023-05-05 15:46:00 +08:00
|
|
|
|
if (_dicStParts.TryGetValue(light, out var part))
|
2023-04-28 10:15:33 +08:00
|
|
|
|
return part.GetValue();
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|