| | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using Quartz; |
| | | using SqlSugar; |
| | | using StackExchange.Profiling.Internal; |
| | |
| | | SerialPortDevice serialPortDevice = (SerialPortDevice)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (serialPortDevice != null) |
| | | { |
| | | |
| | | List<DeviceProDTO> deviceProDTOs = serialPortDevice.DeviceProDTOs; |
| | | foreach (var item in deviceProDTOs) |
| | | { |
| | |
| | | //æ ¼å¼åææ´æ° |
| | | |
| | | serialPortDevice.Communicator.Write(com); |
| | | WriteDebug("åå
¥", com); |
| | | } |
| | | //第äºç§ï¼ç¬¬ä¸ä¸ªå¼æå®äºï¼ç¬¬äºä¸ªæ²¡ææå® |
| | | if (oponecount==onequantity&& optowcount < towquantity&& torquetwo!=0) |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | item.DeviceProParamName = CommandType.Set.ToString(); |
| | | |
| | | |
| | | item.DeviceProParamName = CommandType.None.ToString(); |
| | | } |
| | | } |
| | | |
| | |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | serialPortDevice.Communicator.Write(item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue, "\r");//æå¼ä¸²å£æ¶å
è®¾å¼ |
| | | |
| | | WriteDebug("åå
¥", item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue); |
| | | } |
| | | } |
| | | else if (CommandType.Set.ToString() == item.DeviceProParamName) |
| | | { |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = serialPortDevice.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CommandType) && x.ProtocolDetailType == nameof(CommandType.Set)); |
| | | //è®¾å¼ |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | serialPortDevice.Communicator.Write(item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue, "\r");//æå¼ä¸²å£æ¶å
è®¾å¼ |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | if (serialPortDevice.Communicator.Buffers.Count > 0) |
| | | { |
| | | string? receiveData = serialPortDevice.Communicator.ToString(Encoding.Default); |
| | | if (!string.IsNullOrEmpty(receiveData)) |
| | | { |
| | | Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + receiveData); |
| | | Console.WriteLine("serialPortDevice:" + DateTime.Now.ToString("HH:mm:ss.fff") + receiveData); |
| | | |
| | | if (item.DeviceProParamName == CommandType.Set.ToString()) |
| | | if (item.DeviceProParamName == CommandType.Set.ToString() || item.DeviceProParamName == CommandType.None.ToString()) |
| | | { |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = serialPortDevice.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CommandResult) && x.ProtocolDetailType == nameof(CommandResult.SetOK)); |
| | | //parseok |
| | |
| | | string group = item.DeviceProDataBlock; // è®¾å¤æå±ç»å« |
| | | string devicecode = item.DeviceChildCode;//设å¤ç¼å· |
| | | string torqueValue = ExtractTorqueValue(receiveData); |
| | | |
| | | |
| | | if (group == "çµæ°") |
| | | { |
| | | #region |
| | |
| | | }; |
| | | } |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | item.DeviceProParamName = CommandType.Set.ToString(); |
| | | |
| | | #endregion |
| | | |
| | | item.DeviceProParamName = CommandType.None.ToString(); |
| | | } |
| | | |
| | | } |
| | | |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail2 = serialPortDevice.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CommandResult) && x.ProtocolDetailType == nameof(CommandResult.GetError)); |
| | | if (deviceProtocolDetail2 != null && receiveData.Contains(item.DeviceChildCode + deviceProtocolDetail2.ProtocalDetailValue)) |
| | | { |
| | | item.DeviceProParamName = CommandType.None.ToString(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //建ä¸ä¸ªå¯¹è±¡å°å
¶ä¼ ç»å端 |
| | | string data = JsonConvert.SerializeObject(serialPortDevice);//è¿éserialPortDeviceæ¯å设æè¿ä¸ªå¯¹è±¡ |
| | | _webSocketContext.PublishAllClientPayload(data); |
| | | //string data = JsonConvert.SerializeObject(serialPortDevice);//è¿éserialPortDeviceæ¯å设æè¿ä¸ªå¯¹è±¡ |
| | | //_webSocketContext.PublishAllClientPayload(data); |
| | | } |
| | | |
| | | } |