From 7f42a3ef9bc83bdc199317d12c1905d8696dac4f Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期三, 20 八月 2025 17:23:05 +0800 Subject: [PATCH] 代码提交 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs | 38 ++++++++++++++++++++++++++++++++++---- 1 files changed, 34 insertions(+), 4 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs" index 7b047c0..fe706e0 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs" @@ -20,6 +20,7 @@ using Newtonsoft.Json; using SixLabors.ImageSharp.ColorSpaces; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -231,7 +232,14 @@ { CommonStackerCrane commonStackerCrane = (CommonStackerCrane)device; - commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(2)); + //commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(2)); + DeviceProDTO? devicePro = commonStackerCrane.DeviceProDTOs.Where(x => x.DeviceChildCode == commonStackerCrane.DeviceCode && x.DeviceProParamName == "WorkType").FirstOrDefault(); + + byte valueToWrite = 2; + + byte[] buffer = new byte[] { valueToWrite }; + + commonStackerCrane.Communicator.Write(devicePro.DeviceProAddress, buffer); return content.OK(); } else @@ -257,7 +265,14 @@ { CommonStackerCrane commonStackerCrane = (CommonStackerCrane)device; - commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(4)); + //commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(4)); + DeviceProDTO? devicePro = commonStackerCrane.DeviceProDTOs.Where(x => x.DeviceChildCode == commonStackerCrane.DeviceCode && x.DeviceProParamName == "WorkType").FirstOrDefault(); + + byte valueToWrite = 4; + + byte[] buffer = new byte[] { valueToWrite }; + + commonStackerCrane.Communicator.Write(devicePro.DeviceProAddress, buffer); return content.OK(); } else @@ -563,7 +578,7 @@ { InStock = structs[2] == true ? "鏈夎揣" : "绌洪棽", TaskNum = ConveyorLineTaskNum.ToString(), - Alarm = AlarmInfo(ConveyorLineAlarm) + Alarm = GetAlarm(ConveyorLineAlarm) }; return content.OK(data:obj); } @@ -755,7 +770,22 @@ } } - string AlarmInfo(uint Alarm) => Alarm switch + public string GetAlarm(uint value) + { + byte[] bytes = BitConverter.GetBytes(value); + BitArray bits = new BitArray(bytes); + + for (int i = 0; i < bits.Length; i++) + { + if (bits[i]) + { + return AlarmInfo(i); + } + } + return ""; + } + + string AlarmInfo(int Alarm) => Alarm switch { 0 => "鎬ュ仠", 1 => "鍙橀鍣ㄦ姤璀�1", -- Gitblit v1.9.3