初步添加报警功能
This commit is contained in:
30
DMS.Core/Enums/AlarmRule.cs
Normal file
30
DMS.Core/Enums/AlarmRule.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace DMS.Core.Enums
|
||||
{
|
||||
public enum AlarmRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 超过上限报警
|
||||
/// </summary>
|
||||
AboveMax,
|
||||
|
||||
/// <summary>
|
||||
/// 低于下限报警
|
||||
/// </summary>
|
||||
BelowMin,
|
||||
|
||||
/// <summary>
|
||||
/// 超出范围报警(同时检查上限和下限)
|
||||
/// </summary>
|
||||
OutOfRange,
|
||||
|
||||
/// <summary>
|
||||
/// 死区报警
|
||||
/// </summary>
|
||||
Deadband,
|
||||
|
||||
/// <summary>
|
||||
/// 布尔值变化报警
|
||||
/// </summary>
|
||||
BooleanChange
|
||||
}
|
||||
}
|
||||
27
DMS.Core/Events/AlarmEventArgs.cs
Normal file
27
DMS.Core/Events/AlarmEventArgs.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace DMS.Core.Events
|
||||
{
|
||||
public class AlarmEventArgs : EventArgs
|
||||
{
|
||||
public int VariableId { get; }
|
||||
public string VariableName { get; }
|
||||
public double CurrentValue { get; }
|
||||
public double ThresholdValue { get; }
|
||||
public string Message { get; }
|
||||
public DateTime Timestamp { get; }
|
||||
public string AlarmType { get; } // 可以是 "High", "Low", "Change" 等
|
||||
|
||||
public AlarmEventArgs(int variableId, string variableName, double currentValue,
|
||||
double thresholdValue, string message, string alarmType)
|
||||
{
|
||||
VariableId = variableId;
|
||||
VariableName = variableName;
|
||||
CurrentValue = currentValue;
|
||||
ThresholdValue = thresholdValue;
|
||||
Message = message;
|
||||
Timestamp = DateTime.Now;
|
||||
AlarmType = alarmType;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
DMS.Core/Interfaces/Repositories/IAlarmHistoryRepository.cs
Normal file
16
DMS.Core/Interfaces/Repositories/IAlarmHistoryRepository.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using DMS.Core.Models;
|
||||
|
||||
namespace DMS.Core.Interfaces.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警历史记录仓库接口
|
||||
/// </summary>
|
||||
public interface IAlarmHistoryRepository : IBaseRepository<AlarmHistory>
|
||||
{
|
||||
// 可以添加特定于报警历史记录的查询方法
|
||||
// 例如:
|
||||
// Task<IEnumerable<AlarmHistory>> GetUnacknowledgedAlarmsAsync();
|
||||
// Task<IEnumerable<AlarmHistory>> GetAlarmsByVariableIdAsync(int variableId);
|
||||
// Task AcknowledgeAlarmAsync(int alarmId, string acknowledgedBy);
|
||||
}
|
||||
}
|
||||
71
DMS.Core/Models/AlarmHistory.cs
Normal file
71
DMS.Core/Models/AlarmHistory.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DMS.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警历史记录实体
|
||||
/// </summary>
|
||||
public class AlarmHistory
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量ID
|
||||
/// </summary>
|
||||
public int VariableId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量名称
|
||||
/// </summary>
|
||||
[MaxLength(100)]
|
||||
public string VariableName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前值
|
||||
/// </summary>
|
||||
public double CurrentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 阈值
|
||||
/// </summary>
|
||||
public double ThresholdValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警类型 (High, Low, Deadband, BooleanChange)
|
||||
/// </summary>
|
||||
[MaxLength(50)]
|
||||
public string AlarmType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警消息
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警触发时间
|
||||
/// </summary>
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已确认
|
||||
/// </summary>
|
||||
public bool IsAcknowledged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 确认时间
|
||||
/// </summary>
|
||||
public DateTime? AcknowledgedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 确认人
|
||||
/// </summary>
|
||||
[MaxLength(100)]
|
||||
public string AcknowledgedBy { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user