fix conditions logic

This commit is contained in:
2026-09-11 23:52:11 +03:30
parent 8eb465c0e7
commit a48deb95da
19 changed files with 2545 additions and 453 deletions

View File

@@ -1,43 +1,54 @@
namespace GreenHome.Application;
/// <summary>
/// DTO for relay alert conditions (notificationType > 0)
/// DTO for relay conditions sent to the device firmware.
/// </summary>
public sealed class RelayConditionDto
{
public int Enabled { get; set; }
public int TimeType { get; set; }
/// <summary>
/// شناسه رله برای سازگاری با فریم‌ور قبلی (مثلاً R1)
/// </summary>
/// <summary>شناسه رله برای سازگاری با فریم‌ور قبلی (مثلاً R1)</summary>
public string Relay { get; set; } = string.Empty;
/// <summary>
/// نام نمایشی رله (فن، هیتر و ...)
/// </summary>
/// <summary>شماره رله (۱ تا RelayCount)</summary>
public int RelayIndex { get; set; }
/// <summary>نام نمایشی رله (فن، هیتر و ...)</summary>
public string Name { get; set; } = string.Empty;
public List<RelayRuleDto> Rules { get; set; } = new();
/// <summary>گروه‌های روشن شدن (OR بین گروه‌ها)</summary>
public List<RelayGroupDto> On { get; set; } = new();
/// <summary>گروه‌های خاموش شدن (OR بین گروه‌ها)</summary>
public List<RelayGroupDto> Off { get; set; } = new();
}
/// <summary>
/// DTO for relay condition rules
/// یک گروه شرط (AND داخل گروه)
/// </summary>
public sealed class RelayGroupDto
{
/// <summary>برچسب اختیاری گروه برای لاگ/اعلان</summary>
public string? Label { get; set; }
public List<RelayRuleDto> Conditions { get; set; } = new();
}
/// <summary>
/// یک شرط واحد: سنسوری (Kind=0) یا زمانی (Kind=1)
/// </summary>
public sealed class RelayRuleDto
{
public string Sensor { get; set; } = string.Empty;
public string Op { get; set; } = string.Empty;
public decimal V1 { get; set; }
/// <summary>نوع شرط: 0 = سنسوری، 1 = زمانی</summary>
public int Kind { get; set; }
// سنسوری
public int? Sensor { get; set; }
public int? Op { get; set; }
public decimal? V1 { get; set; }
public decimal? V2 { get; set; }
/// <summary>
/// اقدام: 0 = روشن، 1 = خاموش
/// </summary>
public int Action { get; set; }
/// <summary>
/// زمان اعمال: 0 = روز، 1 = شب، 2 = همیشه
/// </summary>
public int TimeType { get; set; }
// زمانی (دقیقه از نیمه‌شب)
public int? Start { get; set; }
public int? End { get; set; }
}