62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using RobotNet10.RobotApp.Client.Shared.Devices;
|
|
|
|
namespace RobotNet10.RobotApp.Devices;
|
|
|
|
/// <summary>
|
|
/// Attribute để đánh dấu và cung cấp metadata cho các class kế thừa từ DeviceBase
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
|
public sealed class DeviceAttribute : Attribute
|
|
{
|
|
/// <summary>
|
|
/// Loại thiết bị
|
|
/// </summary>
|
|
public DeviceType DeviceType { get; }
|
|
|
|
/// <summary>
|
|
/// Thương hiệu/nhà sản xuất của thiết bị (ví dụ: "PhenikaaX", "SICK", "Hokuyo", etc.)
|
|
/// </summary>
|
|
public string Brand { get; }
|
|
|
|
/// <summary>
|
|
/// Tên driver/implementation của thiết bị (ví dụ: "SickLMS100", "HokuyoUST10", "ModbusTCPClient", etc.)
|
|
/// </summary>
|
|
public string DriverName { get; }
|
|
|
|
/// <summary>
|
|
/// Mô tả ngắn về thiết bị (optional)
|
|
/// </summary>
|
|
public string? Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Version của driver (optional)
|
|
/// </summary>
|
|
public string Version { get; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the DeviceAttribute class
|
|
/// </summary>
|
|
/// <param name="deviceType">Loại thiết bị</param>
|
|
/// <param name="brand">Thương hiệu/nhà sản xuất</param>
|
|
/// <param name="driverName">Tên driver/implementation</param>
|
|
/// <param name="version">Tên version/implementation</param>
|
|
/// <exception cref="ArgumentNullException">Thrown when brand or driverName is null or empty</exception>
|
|
public DeviceAttribute(DeviceType deviceType, string brand, string driverName, string version)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(brand))
|
|
throw new ArgumentNullException(nameof(brand), "Brand cannot be null or empty");
|
|
|
|
if (string.IsNullOrWhiteSpace(driverName))
|
|
throw new ArgumentNullException(nameof(driverName), "DriverName cannot be null or empty");
|
|
|
|
if (string.IsNullOrWhiteSpace(version))
|
|
throw new ArgumentNullException(nameof(version), "Version cannot be null or empty");
|
|
|
|
DeviceType = deviceType;
|
|
Brand = brand;
|
|
DriverName = driverName;
|
|
Version = version;
|
|
}
|
|
}
|
|
|