完成设备的启用和停用并更新界面
This commit is contained in:
45
DMS.Application/Events/DeviceConnectChangedEventArgs.cs
Normal file
45
DMS.Application/Events/DeviceConnectChangedEventArgs.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
namespace DMS.Application.Events;
|
||||
|
||||
public class DeviceConnectChangedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
public int DeviceId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string DeviceName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 旧状态
|
||||
/// </summary>
|
||||
public bool OldStatus { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 新状态
|
||||
/// </summary>
|
||||
public bool NewStatus { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态改变时间
|
||||
/// </summary>
|
||||
public DateTime ChangeTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始化DeviceStatusChangedEventArgs类的新实例
|
||||
/// </summary>
|
||||
/// <param name="deviceId">设备ID</param>
|
||||
/// <param name="deviceName">设备名称</param>
|
||||
/// <param name="oldStatus">旧状态</param>
|
||||
/// <param name="newStatus">新状态</param>
|
||||
public DeviceConnectChangedEventArgs(int deviceId, string deviceName, bool oldStatus, bool newStatus)
|
||||
{
|
||||
DeviceId = deviceId;
|
||||
DeviceName = deviceName;
|
||||
OldStatus = oldStatus;
|
||||
NewStatus = newStatus;
|
||||
ChangeTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
@@ -55,4 +55,16 @@ public interface IEventService
|
||||
void RaiseMqttConnectionChanged(object sender, MqttConnectionChangedEventArgs e);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 设备运行改变事件
|
||||
/// </summary>
|
||||
event EventHandler<DeviceConnectChangedEventArgs> OnDeviceConnectChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 触发设备状态改变事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">设备状态改变事件参数</param>
|
||||
void RaiseDeviceConnectChanged(object sender, DeviceConnectChangedEventArgs e);
|
||||
}
|
||||
@@ -22,6 +22,12 @@ public class EventService : IEventService
|
||||
/// 设备状态改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<DeviceActiveChangedEventArgs> OnDeviceActiveChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 设备运行改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<DeviceConnectChangedEventArgs> OnDeviceConnectChanged;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触发设备状态改变事件
|
||||
@@ -40,6 +46,17 @@ public class EventService : IEventService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发设备状态改变事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">设备状态改变事件参数</param>
|
||||
public void RaiseDeviceConnectChanged(object sender, DeviceConnectChangedEventArgs e)
|
||||
{
|
||||
OnDeviceConnectChanged?.Invoke(sender, e);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 变量事件
|
||||
|
||||
Reference in New Issue
Block a user