| | |
| | | |
| | | namespace WIDESEAWCS_QuartzJob |
| | | { |
| | | /// <summary> |
| | | /// 输送线实现对象 |
| | | /// </summary> |
| | | [Description("输送线")] |
| | | public class CommonConveyorLine : IConveyorLine |
| | | { |
| | |
| | | /// 读取PLC协议地址的数据 |
| | | /// </summary> |
| | | /// <typeparam name="TEnum">协议信息的枚举对象信息。</typeparam> |
| | | /// <typeparam name="TRsult">读取数据的类型对象信息。</typeparam> |
| | | /// <typeparam name="TResult">读取数据的类型对象信息。</typeparam> |
| | | /// <param name="value">枚举值</param> |
| | | /// <param name="deviceChildCode">设备子编号</param> |
| | | /// <returns>读取到的数据</returns> |
| | | public TRsult GetValue<TEnum, TRsult>(TEnum value, string deviceChildCode) where TEnum : Enum |
| | | public TResult GetValue<TEnum, TResult>(TEnum value, string deviceChildCode) where TEnum : Enum |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == value.ToString() && x.DeviceChildCode == deviceChildCode); |
| | | return devicePro == null ? throw new Exception() : (TRsult)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType); |
| | | return devicePro == null ? throw new Exception($"读取数据错误,未在协议信息里面找到参数{value.ToString()}") : (TResult)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == @enum.ToString() && x.DeviceChildCode == deviceChildCode); |
| | | return devicePro == null ? throw new Exception() : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value); |
| | | return devicePro == null ? throw new Exception($"写入数据错误,未在协议信息里面找到参数{value.ToString()}") : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 是否占位 |
| | | /// </summary> |
| | | /// <param name="deviceChildCode"></param> |
| | | /// <param name="deviceChildCode">设备子编号</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public bool IsOccupied(string deviceChildCode) |
| | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 释放对象 |
| | | /// </summary> |
| | | public void Dispose() |
| | | { |
| | | // 设置心跳状态为false |
| | | _heartStatr = false; |
| | | // 释放通信器资源 |
| | | _communicator.Dispose(); |
| | | // 告诉垃圾回收器不再调用终结器 |
| | | GC.SuppressFinalize(this); |
| | | } |
| | | #endregion |