qiuyao
2025-03-24 45045dab394abe534fa5221a1e09a90c1eebf835
更新通讯源码
已修改2个文件
43 ■■■■ 文件已修改
项目代码/WIDESEAWCS_Server 正式/SerialPortService/ProcessServer.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/SerialPortService/ProcessServer.cs
@@ -478,7 +478,8 @@
                var maxproce = process.Max(x => x.SetpNum);
                int num = setpDTO.setnum - 1;
                var nex = process.Where(x => x.CraftType == setpDTO.group && x.SetpNum == num).FirstOrDefault();
                return new WebResponseContent { Status = true, Message = $"上一步{setpDTO.setnum}", Data = new { nex, maxproce } };
                var finish = process.Where(x => x.SetpNum < num).ToList();
                return new WebResponseContent { Status = true, Message = $"上一步{setpDTO.setnum}", Data = new { nex, maxproce, finish } };
            }
            catch (Exception ex)
            {
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using HslCommunication.WebSocket;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using Quartz;
using SqlSugar;
using StackExchange.Profiling.Internal;
@@ -82,7 +83,9 @@
                                #endregion
                                item.DeviceProParamName = CommandType.Set.ToString();
                                //原代码
                                //serialPortDevice.Communicator.Write(item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue.Replace("[setNum]", (4.5 * 1000).ToString().PadLeft(7, '0')) + "\r");//打开串口时先设值
                                //item.DeviceProParamName = CommandType.Set.ToString();
                            }
                        }
@@ -121,10 +124,6 @@
                                    if (deviceProtocolDetail != null && receiveData.Contains(item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue))
                                    {
                                        item.DeviceProParamName = CommandType.Get.ToString();
                                    }
                                }
                                else if (item.DeviceProParamName == CommandType.Get.ToString())
@@ -140,27 +139,26 @@
                                            item.DeviceProParamName = CommandType.Set.ToString();
                                        }
                                        else if (item.DeviceProParamName == CommandType.Get.ToString())
                                        {
                                            //DeviceProtocolDetailDTO? deviceProtocolDetail = serialPortDevice.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CommandResult) && x.ProtocolDetailType == nameof(CommandResult.GetError));
                                            //if (deviceProtocolDetail != null && receiveData.Contains(item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue))
                                            //{
                                            //    item.DeviceProParamName = CommandType.Set.ToString();
                                            //}
                                        }
                                        //原代码
                                        //item.DeviceProParamName = CommandType.Set.ToString();
                                    }
                                }
                                else if (item.DeviceProParamName == CommandType.Get.ToString())
                                {
                                    DeviceProtocolDetailDTO? deviceProtocolDetail = serialPortDevice.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CommandResult) && x.ProtocolDetailType == nameof(CommandResult.GetError));
                                    if (deviceProtocolDetail != null && receiveData.Contains(item.DeviceChildCode + deviceProtocolDetail.ProtocalDetailValue))
                                    {
                                        item.DeviceProParamName = CommandType.Set.ToString();
                                    }
                                }
                                //建一个对象将其传给前端
                                string data = JsonConvert.SerializeObject(serialPortDevice);//这里serialPortDevice是假设有这个对象
                                _webSocketContext.PublishAllClientPayload(data);
                            }
                            //建一个对象将其传给前端
                            string data = JsonConvert.SerializeObject(serialPortDevice);//这里serialPortDevice是假设有这个对象
                            _webSocketContext.PublishAllClientPayload(data);
                        }
                    }
                }
            }