| | |
| | | using Newtonsoft.Json; |
| | | using SixLabors.ImageSharp.ColorSpaces; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Security.Claims; |
| | |
| | | { |
| | | 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 |
| | |
| | | { |
| | | 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 |
| | |
| | | { |
| | | InStock = structs[2] == true ? "æè´§" : "空é²", |
| | | TaskNum = ConveyorLineTaskNum.ToString(), |
| | | Alarm = AlarmInfo(ConveyorLineAlarm) |
| | | Alarm = GetAlarm(ConveyorLineAlarm) |
| | | }; |
| | | return content.OK(data:obj); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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", |