feat: add device relay and telemetry support
This commit is contained in:
120
src/GreenHome.Domain/DeviceRelay.cs
Normal file
120
src/GreenHome.Domain/DeviceRelay.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
namespace GreenHome.Domain;
|
||||
|
||||
/// <summary>
|
||||
/// نوع مصرفکننده متصل به رله
|
||||
/// </summary>
|
||||
public enum RelayKind
|
||||
{
|
||||
/// <summary>سایر / نامشخص</summary>
|
||||
Generic = 0,
|
||||
|
||||
/// <summary>فن</summary>
|
||||
Fan = 1,
|
||||
|
||||
/// <summary>هیتر / بخاری</summary>
|
||||
Heater = 2,
|
||||
|
||||
/// <summary>پمپ آب</summary>
|
||||
WaterPump = 3,
|
||||
|
||||
/// <summary>مهپاش / رطوبتساز</summary>
|
||||
Humidifier = 4,
|
||||
|
||||
/// <summary>روشنایی</summary>
|
||||
Light = 5,
|
||||
|
||||
/// <summary>شیر برقی</summary>
|
||||
Valve = 6
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// حالت عملکرد رله
|
||||
/// </summary>
|
||||
public enum RelayMode
|
||||
{
|
||||
/// <summary>خودکار (بر اساس قوانین)</summary>
|
||||
Auto = 0,
|
||||
|
||||
/// <summary>دستی (قوانین خودکار نادیده گرفته میشوند)</summary>
|
||||
Manual = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نوع اقدام یک قانون رله
|
||||
/// </summary>
|
||||
public enum RelayAction
|
||||
{
|
||||
/// <summary>روشن کردن</summary>
|
||||
On = 0,
|
||||
|
||||
/// <summary>خاموش کردن</summary>
|
||||
Off = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// رله دستگاه به همراه تنظیمات آن
|
||||
/// </summary>
|
||||
public sealed class DeviceRelay
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int DeviceSettingsId { get; set; }
|
||||
public DeviceSettings DeviceSettings { get; set; } = null!;
|
||||
|
||||
/// <summary>شماره رله (۱ تا RelayCount)</summary>
|
||||
public int RelayIndex { get; set; }
|
||||
|
||||
/// <summary>نام نمایشی رله (مثلاً فن، هیتر)</summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>آیا این رله فعال است؟</summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>نوع مصرفکننده متصل به رله</summary>
|
||||
public RelayKind RelayKind { get; set; } = RelayKind.Generic;
|
||||
|
||||
/// <summary>حالت عملکرد: خودکار یا دستی</summary>
|
||||
public RelayMode Mode { get; set; } = RelayMode.Auto;
|
||||
|
||||
/// <summary>حداقل زمان روشن ماندن (دقیقه) - برای جلوگیری از قطع و وصل مکرر</summary>
|
||||
public int MinOnMinutes { get; set; } = 0;
|
||||
|
||||
/// <summary>حداقل زمان خاموش ماندن (دقیقه) - برای محافظت از تجهیزات</summary>
|
||||
public int MinOffMinutes { get; set; } = 0;
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>قوانین روشن/خاموش شدن رله</summary>
|
||||
public ICollection<RelayRule> Rules { get; set; } = new List<RelayRule>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// یک قانون برای روشن یا خاموش کردن رله بر اساس سنسورها
|
||||
/// </summary>
|
||||
public sealed class RelayRule
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int DeviceRelayId { get; set; }
|
||||
public DeviceRelay DeviceRelay { get; set; } = null!;
|
||||
|
||||
/// <summary>نوع سنسور: دما، رطوبت، خاک، گاز، نور</summary>
|
||||
public SensorType SensorType { get; set; }
|
||||
|
||||
/// <summary>نوع مقایسه: بزرگتر، کوچکتر، بین، خارج از محدوده</summary>
|
||||
public ComparisonType ComparisonType { get; set; }
|
||||
|
||||
/// <summary>مقدار عددی اول</summary>
|
||||
public decimal Value1 { get; set; }
|
||||
|
||||
/// <summary>مقدار عددی دوم (برای بین و خارج از محدوده)</summary>
|
||||
public decimal? Value2 { get; set; }
|
||||
|
||||
/// <summary>اقدام: روشن یا خاموش کردن رله</summary>
|
||||
public RelayAction Action { get; set; } = RelayAction.On;
|
||||
|
||||
/// <summary>زمان اعمال: روز، شب، همیشه</summary>
|
||||
public AlertTimeType TimeType { get; set; } = AlertTimeType.Always;
|
||||
|
||||
/// <summary>ترتیب قوانین</summary>
|
||||
public int Order { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user