| | |
| | | /// <returns>读取到的数据</returns> |
| | | public TRsult GetValue<TEnum, TRsult>(TEnum value, string deviceChildCode) where TEnum : Enum |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【 {DeviceName} 】"); |
| | | 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); |
| | | } |
| | |
| | | /// <exception cref="Exception"></exception> |
| | | public bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new() |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【{DeviceName}】"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (devicePro == null) |
| | | { |
| | |
| | | /// <exception cref="Exception"></exception> |
| | | public T ReadCustomer<T>(string deviceChildCode) where T : IDataTransfer, new() |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【{DeviceName}】"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == "ReadDeviceCommand" && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | if (devicePro == null) |
| | |
| | | /// <exception cref="Exception"></exception> |
| | | public T ReadCustomer<T>(string deviceChildCode, string deviceProParamType) where T : IDataTransfer, new() |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络:" + DeviceName); |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【{DeviceName}】"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == deviceProParamType && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | if (devicePro == null) |
| | |
| | | where TEnum : Enum |
| | | where TValue : notnull |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【 {DeviceName} 】"); |
| | | 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); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 检测站台是否有货 |
| | | /// </summary> |
| | | /// <param name="deviceChildCode"></param> |
| | | /// <returns></returns> |
| | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测站台是否有货 |
| | | /// </summary> |
| | | /// <param name="deviceChildCode"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public bool IsOccupiedx(string deviceChildCode) |
| | | { |
| | | if (Communicator.IsConnected) |
| | | { |
| | | var device = _deviceProDTOs.Where(x => x.DeviceChildCode == deviceChildCode && x.DeviceProParamName == "InteractiveSignal").FirstOrDefault(); |
| | | |
| | | object readStatus = Communicator.ReadAsObj(device.DeviceProAddress, device.DeviceDataType); |
| | | |
| | | //todo 协议明细信息未获取到时抛出异常 |
| | | if (readStatus.ToString() != "2") |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | //todo 通讯未连接时抛出异常 |
| | | return false; |
| | | } |
| | | |
| | | public void Dispose() |
| | | { |
| | | _heartStatr = false; |