| | |
| | | private int GetCurrentTaskNum() |
| | | { |
| | | DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CurrentTaskNum)); |
| | | return devicePro == null ? throw new Exception() : (int)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType); |
| | | return devicePro == null ? throw new Exception($"读取当前任务号错误,未获取到协议信息,请检查配置参数名称是否配置,且配置为为{nameof(CurrentTaskNum)}") : (int)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | for (int i = 0; i < devicePros.Count; i++) |
| | | { |
| | | object readStatus = Communicator.ReadAsObj(devicePros[i].DeviceProAddress, devicePros[i].DeviceDataType); |
| | | //todo 协议明细信息未获取到时抛出异常 |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePros[i].DeviceProParamName) ?? throw new Exception(); |
| | | deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePros[i].DeviceProParamType && x.ProtocalDetailValue.Equals(readStatus.ToString())); |
| | | if (deviceProtocolDetail != null) |
| | |
| | | } |
| | | //todo 通讯未连接时抛出异常 |
| | | return StackerCraneStatus.Unkonw.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 比较两个值是否相等。 |
| | | /// </summary> |
| | | /// <param name="value">第一个值。</param> |
| | | /// <param name="paramValue">第二个值。</param> |
| | | /// <returns>返回比较结果。</returns> |
| | | private bool Compare(object value, object paramValue) |
| | | { |
| | | return value.Equals(paramValue); |
| | | } |
| | | |
| | | private void CheckConnect() |
| | |
| | | /// <returns></returns> |
| | | public bool SendCommand<T>(T command) where T : IDataTransfer, new() |
| | | { |
| | | if(Communicator is SiemensS7) |
| | | if (Communicator is SiemensS7) |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |