using System;
namespace TeamAAS.Communication.Attributes
{
///
/// 通讯设备特性标记。实现 ICommunication 的设备类必须标记本特性,
/// 反射加载时会根据 DisplayName 生成下拉选项,按 Category 分组。
/// 新增设备只需:实现 ICommunication + 加本特性,无需改动任何现有代码。
///
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class CommunicationAttribute : Attribute
{
/// 显示名称,如"三菱 PLC"
public string DisplayName { get; }
/// 分类,如"PLC"、"仪器",用于下拉框分组,默认 PLC
public string Category { get; }
/// 说明
public string Description { get; }
///
/// 品牌专属调试页类型(必须是 System.Windows.FrameworkElement 的子类,且建议实现
/// TeamAAS.Communication.UI.ICommunicationDebugPage 以接收通讯设备实例)。
/// 为 null(默认)时,宿主使用通用的通讯测试面板。
/// 用法:[Communication("三菱 PLC", "PLC", DebugPageType = typeof(MitsubishiDebugPage))]
///
public Type DebugPageType { get; set; }
public CommunicationAttribute(string displayName, string category = "PLC", string description = "")
{
DisplayName = displayName;
Category = category;
Description = description;
}
}
}