using System;
namespace MECF.Framework.Common.Device.Bases
{
///
/// 预设的信号灯塔元件动作。
///
public class STEventAction : IComparable, ICloneable
{
#region Constructors
///
/// 信号灯塔元件动作构造函数。
///
/// 动作名称。
/// 信号塔组件类型(名称)。
/// 信号塔组件输出状态。
/// 信号塔组件工作模式。如果传入空值,则自动调用
/// 以创建默认工作模式。
public STEventAction(string name, LightType light, TowerLightStatus status, STBlinkPattern blinkPattern = null)
{
Name = name;
Light = light;
Status = status;
BlinkPattern = blinkPattern ?? STBlinkPattern.GetDefaultPattern();
}
#endregion
#region Properties
///
/// 动作名称。
///
public string Name { get; }
///
/// 返回信号灯实例。
///
public LightType Light { get; }
///
/// 设置或返回信号灯的输出状态。
/// 支持的状态请参考枚举。
///
public TowerLightStatus Status { get; set; }
///
/// 设置或返回信号灯闪烁模式。
///
public STBlinkPattern BlinkPattern { get; set; }
#endregion
#region Methods
///
public int CompareTo(object obj)
{
if (obj is not STEventAction target)
return -1;
return (BlinkPattern.CompareTo(target.BlinkPattern) == 0
&& Status == target.Status
&& Light == target.Light)
? 0
: -1;
}
///
public object Clone()
{
return new STEventAction(Name, Light, Status, (STBlinkPattern)BlinkPattern.Clone());
}
///
public override string ToString()
{
return $"{Light}, {Status}";
}
#endregion
}
}