Files
GreenHomeBack/src/GreenHome.Application/Dtos/Device/DeviceRelayDto.cs
2026-09-11 23:52:11 +03:30

64 lines
2.1 KiB
C#

using Domain = GreenHome.Domain;
namespace GreenHome.Application;
/// <summary>
/// تنظیمات یک رله دستگاه
/// </summary>
public sealed class DeviceRelayDto
{
public int Id { get; set; }
public int DeviceSettingsId { get; set; }
public int RelayIndex { get; set; }
public string Name { get; set; } = string.Empty;
public bool IsEnabled { get; set; } = true;
public Domain.RelayKind RelayKind { get; set; } = Domain.RelayKind.Generic;
/// <summary>
/// گروه‌های شرط رله. گروه‌های هم‌عمل (روشن یا خاموش) با OR ترکیب می‌شوند
/// و شرایط داخل هر گروه با AND.
/// </summary>
public List<DeviceRelayRuleGroupDto> RuleGroups { get; set; } = new();
}
/// <summary>
/// یک گروه شرط برای روشن یا خاموش شدن رله
/// </summary>
public sealed class DeviceRelayRuleGroupDto
{
public int Id { get; set; }
/// <summary>اقدام: روشن (On) یا خاموش (Off)</summary>
public Domain.RelayAction Action { get; set; } = Domain.RelayAction.On;
/// <summary>برچسب اختیاری گروه برای لاگ/اعلان</summary>
public string? Label { get; set; }
public int Order { get; set; }
public List<DeviceRelayRuleConditionDto> Conditions { get; set; } = new();
}
/// <summary>
/// یک شرط واحد داخل گروه (سنسوری یا زمانی)
/// </summary>
public sealed class DeviceRelayRuleConditionDto
{
public int Id { get; set; }
/// <summary>نوع شرط: سنسوری (0) یا زمانی (1)</summary>
public Domain.RelayConditionType ConditionType { get; set; } = Domain.RelayConditionType.Sensor;
// ---- شرط سنسوری ----
public Domain.SensorType? SensorType { get; set; }
public Domain.ComparisonType? ComparisonType { get; set; }
public decimal? Value1 { get; set; }
public decimal? Value2 { get; set; }
// ---- شرط زمانی (دقیقه از نیمه‌شب) ----
public int? StartMinutes { get; set; }
public int? EndMinutes { get; set; }
public int Order { get; set; }
}