添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using MainShell.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MainShell.EventArgsFolder
|
||||
{
|
||||
public class DeviceIoChangedEventArgs : EventArgs
|
||||
{
|
||||
public DeviceIoChangedEventArgs(IReadOnlyList<DeviceIoPointState> changedPoints, IReadOnlyDictionary<string, DeviceIoPointState> allPoints)
|
||||
{
|
||||
ChangedPoints = changedPoints ?? new List<DeviceIoPointState>();
|
||||
AllPoints = allPoints ?? new Dictionary<string, DeviceIoPointState>();
|
||||
}
|
||||
|
||||
public IReadOnlyList<DeviceIoPointState> ChangedPoints { get; private set; }
|
||||
|
||||
public IReadOnlyDictionary<string, DeviceIoPointState> AllPoints { get; private set; }
|
||||
|
||||
public bool TryGetById(int id, out DeviceIoPointState point)
|
||||
{
|
||||
point = AllPoints.Values.FirstOrDefault(x => x.Id == id);
|
||||
return point != null;
|
||||
}
|
||||
|
||||
public bool TryGetByPointKey(string pointKey, out DeviceIoPointState point)
|
||||
{
|
||||
return AllPoints.TryGetValue(pointKey, out point);
|
||||
}
|
||||
|
||||
public DeviceIoPointState FindByName(string name)
|
||||
{
|
||||
return AllPoints.Values.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public IReadOnlyList<DeviceIoPointState> FindByModule(string module)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(module))
|
||||
{
|
||||
return new List<DeviceIoPointState>();
|
||||
}
|
||||
|
||||
return AllPoints.Values
|
||||
.Where(x => string.Equals(x.Module, module, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user