fix conditions logic
This commit is contained in:
@@ -13,20 +13,51 @@ public sealed class DeviceRelayDto
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public Domain.RelayKind RelayKind { get; set; } = Domain.RelayKind.Generic;
|
||||
public List<DeviceRelayRuleDto> Rules { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// گروههای شرط رله. گروههای همعمل (روشن یا خاموش) با OR ترکیب میشوند
|
||||
/// و شرایط داخل هر گروه با AND.
|
||||
/// </summary>
|
||||
public List<DeviceRelayRuleGroupDto> RuleGroups { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// قانون روشن/خاموش شدن رله
|
||||
/// یک گروه شرط برای روشن یا خاموش شدن رله
|
||||
/// </summary>
|
||||
public sealed class DeviceRelayRuleDto
|
||||
public sealed class DeviceRelayRuleGroupDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Domain.SensorType SensorType { get; set; }
|
||||
public Domain.ComparisonType ComparisonType { get; set; }
|
||||
public decimal Value1 { get; set; }
|
||||
public decimal? Value2 { get; set; }
|
||||
|
||||
/// <summary>اقدام: روشن (On) یا خاموش (Off)</summary>
|
||||
public Domain.RelayAction Action { get; set; } = Domain.RelayAction.On;
|
||||
public Domain.AlertTimeType TimeType { get; set; } = Domain.AlertTimeType.Always;
|
||||
|
||||
/// <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; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user