huangxiaoqiang
4 天以前 7f42a3ef9bc83bdc199317d12c1905d8696dac4f
ÏîÄ¿´úÂë/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",