| | |
| | | |
| | | namespace WIDESEAWCS_QuartzJob |
| | | { |
| | | /// <summary> |
| | | /// 静态变脸存储区,可使用静态变量,也可注入使用 |
| | | /// </summary> |
| | | public class Storage |
| | | { |
| | | /// <summary> |
| | | /// 已连接设备对象集合 |
| | | /// </summary> |
| | | public static List<IDevice> Devices = new List<IDevice>(); |
| | | |
| | | /// <summary> |
| | | /// 设备对象 |
| | | /// </summary> |
| | | public List<IDevice> Pro_Devices { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | public Storage() |
| | | { |
| | | Pro_Devices = new List<IDevice>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取设备 |
| | | /// </summary> |
| | | /// <param name="deviceCode"></param> |
| | | /// <returns></returns> |
| | | public IDevice? GetDevice(string deviceCode) |
| | | { |
| | | return Pro_Devices.FirstOrDefault(x => x.DeviceCode == deviceCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取设备 |
| | | /// </summary> |
| | | /// <param name="deviceCodes"></param> |
| | | /// <returns></returns> |
| | | public List<IDevice> GetDevices(List<string> deviceCodes) |
| | | { |
| | | return Pro_Devices.Where(x => deviceCodes.Contains(x.DeviceCode)).ToList(); |
| | | } |
| | | |
| | | public BaseCommunicator? GetCommunicator(string deviceCode) |
| | | { |
| | | return Devices.FirstOrDefault(x => x.DeviceCode == deviceCode)?.Communicator; |
| | | } |
| | | } |
| | | } |