| | |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Newtonsoft.Json; |
| | | using SixLabors.ImageSharp.ColorSpaces; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Security.Claims; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.Log; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | |
| | | |
| | | public WebResponseContent StackerHandTask(HandTask stackerhand) |
| | | { |
| | | WriteLog.GetLog("å åæºæå¨ä»»å¡").Write(JsonConvert.SerializeObject(stackerhand), "å åæºæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | string[] sourceCodes = stackerhand.SourceAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0]))); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | string[] targetCodes = stackerhand.TargetAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0]))); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | string[] sourceCodes = stackerhand.SourceAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0]))); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | string[] targetCodes = stackerhand.TargetAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0]))); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | string[] sourceCodes = stackerhand.SourceAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0]))); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | string[] targetCodes = stackerhand.TargetAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0]))); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | string[] sourceCodes = stackerhand.SourceAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0]))); |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]); |
| | | |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(0); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(0); |
| | |
| | | stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(0); |
| | | stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(0); |
| | | |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0]))); |
| | | stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]); |
| | | stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | return content.Error("æªæ¾å°ä»»å¡å½ä»¤"); |
| | | } |
| | | |
| | | StackerSendCommand(stackerCraneTaskCommand, stackerhand.DeviceCode); |
| | | return content; |
| | | |
| | | return content.OK("å½ä»¤ä¸åæåï¼"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | |
| | | public WebResponseContent StackerReset(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("å åæºæå¨ä»»å¡").Write($"ãå¤ä½å½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "å åæºæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | { |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)device; |
| | | |
| | | commonStackerCrane.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(2)); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(2)); |
| | | return content.OK(); |
| | | } |
| | | else |
| | |
| | | |
| | | public WebResponseContent StackerEmergencyStop(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("å åæºæå¨ä»»å¡").Write($"ãæ¥åå½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "å åæºæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | { |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)device; |
| | | |
| | | commonStackerCrane.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(2)); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(2)); |
| | | return content.OK(); |
| | | } |
| | | else |
| | |
| | | commonStackerCrane.SetValue(StackerCraneDBName.StartColumn, command.StartColumn); |
| | | Thread.Sleep(100); |
| | | |
| | | commonStackerCrane.SetValue(StackerCraneDBName.StartColumn, command.StartLayer); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.StartLayer, command.StartLayer); |
| | | Thread.Sleep(100); |
| | | |
| | | commonStackerCrane.SetValue(StackerCraneDBName.EndRow, command.EndRow); |
| | |
| | | Thread.Sleep(100); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.EndLayer, command.EndLayer); |
| | | Thread.Sleep(100); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(command.WorkType)); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(command.WorkType)); |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("请å¨å åæºèæºæ¨¡å¼ãå¾
æºç¶æãæ æ
éçæ
åµä¸ä¸åä»»å¡"); |
| | | throw new Exception($"请å¨{commonStackerCrane.DeviceName}èæºæ¨¡å¼ãå¾
æºç¶æãæ æ
éçæ
åµä¸ä¸åä»»å¡"); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public int GetRowCode(int number) |
| | | { |
| | | if (number == 1 || number == 15 || number == 11 || number == 19) |
| | | { |
| | | return 1; |
| | | } |
| | | else if (number == 2 || number == 5 || number == 8 || number == 12 || number == 16 || number == 20) |
| | | { |
| | | return 2; |
| | | } |
| | | else if (number == 3 || number == 6 || number == 9 || number == 13 || number == 17 || number == 21) |
| | | { |
| | | return 3; |
| | | } |
| | | else if (number == 4 || number == 7 || number == 10 || number == 14 || number == 18 || number == 22) |
| | | { |
| | | return 4; |
| | | } |
| | | else |
| | | { |
| | | throw new ArgumentOutOfRangeException(nameof(number), "è¾å
¥çæ°åå¿
é¡»å¨1-16èå´å
"); |
| | | } |
| | | } |
| | | public class StackerCraneTaskCommand |
| | | { |
| | | #region <Public Menber> |
| | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | ushort x = conveyorLine.GetValue<ConveyorLineDBName, ushort>(ConveyorLineDBName.InteractiveSignal, stationManager.stationChildCode); |
| | | short x = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, stationManager.stationChildCode); |
| | | var structs = BitConverter.GetBytes(x).ToArray().ToBoolArray(); |
| | | short ConveyorLineTaskNum = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.ConveyorLineTaskNum, stationManager.stationChildCode); |
| | | int ConveyorLineAlarm = conveyorLine.GetValue<ConveyorLineDBName, int>(ConveyorLineDBName.ConveyorLineAlarm, stationManager.stationChildCode); |
| | | uint ConveyorLineAlarm = conveyorLine.GetValue<ConveyorLineDBName, uint>(ConveyorLineDBName.ConveyorLineAlarm, stationManager.stationChildCode); |
| | | ConveyorLineTaskCommand obj = new() |
| | | { |
| | | InStock = structs[2] == true ? "æè´§" : "空é²", |
| | |
| | | |
| | | public WebResponseContent ConveyorLineHandTask(HandTask ConveyorLinehand) |
| | | { |
| | | WriteLog.GetLog("è¾é线æå¨ä»»å¡").Write(JsonConvert.SerializeObject(ConveyorLinehand), "è¾é线æå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | short x = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, stationManager.stationChildCode); |
| | | var structs = BitConverter.GetBytes(x).ToArray().ToBoolArray(); |
| | | if (!structs[2]) |
| | | { |
| | | return content.Error($"请å¨{stationManager.stationChildCode}è¾é线就绪æ
åµä¸ä¸åå½ä»¤"); |
| | | } |
| | | //å
¥åº |
| | | if (ConveyorLinehand.TaskType == "1") |
| | | { |
| | |
| | | |
| | | public WebResponseContent ConveyorLineReset(string DeviceChildCode) |
| | | { |
| | | WriteLog.GetLog("è¾é线æå¨ä»»å¡").Write($"ãå¤ä½å½ä»¤ã{JsonConvert.SerializeObject(DeviceChildCode)}", "è¾é线æå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | |
| | | public WebResponseContent ConveyorLineEmergencyStop(string DeviceChildCode) |
| | | { |
| | | WriteLog.GetLog("è¾é线æå¨ä»»å¡").Write($"ãæ¥åå½ä»¤ã{JsonConvert.SerializeObject(DeviceChildCode)}", "è¾é线æå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | } |
| | | public WebResponseContent ConveyorLineReturn(string DeviceChildCode) |
| | | { |
| | | WriteLog.GetLog("è¾é线æå¨ä»»å¡").Write($"ãéåå½ä»¤ã{JsonConvert.SerializeObject(DeviceChildCode)}", "è¾é线æå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(3), stationManager.stationChildCode); |
| | | return content.OK("忢æå"); |
| | | return content.OK("éåæå"); |
| | | } |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | |
| | | } |
| | | public WebResponseContent ConveyorLineCancel(string DeviceChildCode) |
| | | { |
| | | WriteLog.GetLog("è¾é线æå¨ä»»å¡").Write($"ãåæ¶å½ä»¤ã{JsonConvert.SerializeObject(DeviceChildCode)}", "è¾é线æå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(4), stationManager.stationChildCode); |
| | | return content.OK("忢æå"); |
| | | return content.OK("åæ¶æå"); |
| | | } |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | |
| | | } |
| | | public WebResponseContent ConveyorLineInitialize(string DeviceChildCode) |
| | | { |
| | | WriteLog.GetLog("è¾é线æå¨ä»»å¡").Write($"ãåå§åå½ä»¤ã{JsonConvert.SerializeObject(DeviceChildCode)}", "è¾é线æå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(6), stationManager.stationChildCode); |
| | | return content.OK("忢æå"); |
| | | return content.OK("åå§åæå"); |
| | | } |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | |
| | | } |
| | | } |
| | | |
| | | string AlarmInfo(int Alarm) => Alarm switch |
| | | string AlarmInfo(uint Alarm) => Alarm switch |
| | | { |
| | | 0 => "æ¥å", |
| | | 1 => "åé¢å¨æ¥è¦1", |
| | |
| | | 13 => "é¢ç4", |
| | | 14 => "é¢ç5", |
| | | 15 => "é¢ç6", |
| | | _ => $"æªç¥æ¥è¦({Alarm})" |
| | | }; |
| | | |
| | | public enum ConveyorLineDBName |
| | |
| | | #endregion |
| | | |
| | | #region RGVæå¨å½ä»¤ |
| | | public WebResponseContent RGVHandTask(HandTask RGVhand) |
| | | { |
| | | WriteLog.GetLog("RGVæå¨ä»»å¡").Write(JsonConvert.SerializeObject(RGVhand), "RGVæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (RGVhand == null || RGVhand.TaskType == "") |
| | | { |
| | | return content.Error("请è¾å
¥ä»»å¡å½ä»¤"); |
| | | } |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == RGVhand.DeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (RGVhand.DeviceCode == "RGV01" || RGVhand.DeviceCode == "RGV02") |
| | | { |
| | | CommonRGV_FirstFloor RGVcommand = (CommonRGV_FirstFloor)device; |
| | | if (RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Fault) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Running)) |
| | | { |
| | | if (RGVhand.TaskType == "1") |
| | | { |
| | | if (RGVhand.SourceAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandFirstFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}åå®ä½å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}åå®ä½å½ä»¤åè´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | } |
| | | else if (RGVhand.TaskType == "2") |
| | | { |
| | | if (RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandFirstFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}æ¾å®ä½å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}æ¾å®ä½å½ä»¤æ¾è´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "3") |
| | | { |
| | | if (RGVhand.SourceAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandFirstFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}åè´§å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}åè´§å½ä»¤åè´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "4") |
| | | { |
| | | if (RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandFirstFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}æ¾è´§å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}æ¾è´§å½ä»¤æ¾è´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "5") |
| | | { |
| | | if (RGVhand.TargetAddress != null && RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress), |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandFirstFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}åæ¾è´§å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}åæ¾è´§å½ä»¤æ¾è´§ä½ååè´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "6") |
| | | { |
| | | if (RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(4), |
| | | }; |
| | | SendCommandFirstFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}éå½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}éåå½ä»¤æ¾è´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}æªç¥ä»»å¡å½ä»¤"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"请å¨èæºæ¨¡å¼ãæ æ
éãå¾
æºç¶ææ¶åä¸å{RGVcommand.DeviceName}å½ä»¤"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CommonRGV RGVcommand = (CommonRGV)device; |
| | | if (RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Fault) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Running)) |
| | | { |
| | | if (RGVhand.TaskType == "1") |
| | | { |
| | | if (RGVhand.SourceAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandSecondFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}åå®ä½å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}åå®ä½å½ä»¤åè´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | } |
| | | else if (RGVhand.TaskType == "2") |
| | | { |
| | | if (RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandSecondFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}æ¾å®ä½å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}æ¾å®ä½å½ä»¤æ¾è´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "3") |
| | | { |
| | | if (RGVhand.SourceAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandSecondFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}åè´§å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}åè´§å½ä»¤åè´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "4") |
| | | { |
| | | if (RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandSecondFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}æ¾è´§å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}æ¾è´§å½ä»¤æ¾è´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "5") |
| | | { |
| | | if (RGVhand.TargetAddress != null && RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress), |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandSecondFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}åæ¾è´§å½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("åæ¾è´§å½ä»¤æ¾è´§ä½ååè´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else if (RGVhand.TaskType == "6") |
| | | { |
| | | if (RGVhand.TargetAddress != null) |
| | | { |
| | | RGVTaskCommand command = new RGVTaskCommand() |
| | | { |
| | | PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress), |
| | | TaskType = (byte)Convert.ToSByte(RGVhand.TaskType), |
| | | }; |
| | | SendCommandSecondFloor(RGVcommand, command); |
| | | return content.OK($"{device.DeviceName}éåå½ä»¤ä¸åæå"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}éåå½ä»¤æ¾è´§ä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"{device.DeviceName}æªç¥ä»»å¡å½ä»¤"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"请å¨èæºæ¨¡å¼ãæ æ
éãå¾
æºç¶ææ¶åä¸å{RGVcommand.DeviceName}å½ä»¤"); |
| | | } |
| | | } |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent RGVReset(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("RGVæå¨ä»»å¡").Write($"ãå¤ä½å½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "RGVæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (DeviceCode == "RGV01" || DeviceCode == "RGV02") |
| | | { |
| | | CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device; |
| | | commonRGV.SetValue(RGVDBName.TaskType, Convert.ToSByte(9)); |
| | | } |
| | | else |
| | | { |
| | | CommonRGV commonRGV = (CommonRGV)device; |
| | | commonRGV.SetValue(RGVDBName.TaskType, Convert.ToSByte(9)); |
| | | } |
| | | return content.OK($"{device.DeviceName}å¤ä½æå"); |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent RGVEmergencyStop(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("RGVæå¨ä»»å¡").Write($"ãæ¥åå½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "RGVæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (DeviceCode == "RGV01" || DeviceCode == "RGV02") |
| | | { |
| | | CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device; |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(11)); |
| | | } |
| | | else |
| | | { |
| | | CommonRGV commonRGV = (CommonRGV)device; |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(11)); |
| | | } |
| | | return content.OK($"{device.DeviceName}忢æå"); |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent RGVCancel(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("RGVæå¨ä»»å¡").Write($"ãåæ¶ä»»å¡å½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "RGVæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (DeviceCode == "RGV01" || DeviceCode == "RGV02") |
| | | { |
| | | CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device; |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(7)); |
| | | } |
| | | else |
| | | { |
| | | CommonRGV commonRGV = (CommonRGV)device; |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(7)); |
| | | } |
| | | return content.OK($"{device.DeviceName}䏿æå"); |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent RGVInitialize(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("RGVæå¨ä»»å¡").Write($"ãåå§åå½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "RGVæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode); |
| | | if (device != null) |
| | | { |
| | | |
| | | if (DeviceCode == "RGV01" || DeviceCode == "RGV02") |
| | | { |
| | | CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device; |
| | | DeviceProDTO? devicePro = commonRGV.DeviceProDTOs.Where(x => x.DeviceChildCode == commonRGV.DeviceCode && x.DeviceProParamName == "TaskType").FirstOrDefault(); |
| | | //byte[] byt = Encoding.UTF8.GetBytes("08"); |
| | | byte valueToWrite = 8; |
| | | |
| | | byte[] buffer = new byte[] { valueToWrite }; |
| | | |
| | | commonRGV.Communicator.Write(devicePro.DeviceProAddress, buffer); |
| | | } |
| | | else |
| | | { |
| | | CommonRGV commonRGV = (CommonRGV)device; |
| | | DeviceProDTO? devicePro = commonRGV.DeviceProDTOs.Where(x => x.DeviceChildCode == commonRGV.DeviceCode && x.DeviceProParamName == "TaskType").FirstOrDefault(); |
| | | byte valueToWrite = 8; |
| | | |
| | | byte[] buffer = new byte[] { valueToWrite }; |
| | | commonRGV.Communicator.Write(devicePro.DeviceProAddress, buffer); |
| | | } |
| | | return content.OK($"{device.DeviceName}åå§åæå"); |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent RGVPause(string DeviceCode) |
| | | { |
| | | WriteLog.GetLog("RGVæå¨ä»»å¡").Write($"ã忢å½ä»¤ã{JsonConvert.SerializeObject(DeviceCode)}", "RGVæå¨ä»»å¡"); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (DeviceCode == "RGV01" || DeviceCode == "RGV02") |
| | | { |
| | | CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device; |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(10)); |
| | | } |
| | | else |
| | | { |
| | | CommonRGV commonRGV = (CommonRGV)device; |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(10)); |
| | | } |
| | | return content.OK($"{device.DeviceName}æåæå"); |
| | | } |
| | | return content.Error("æªæ¾å°è®¾å¤ä¿¡æ¯è¯·èç³»IT"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void SendCommandFirstFloor(CommonRGV_FirstFloor commonRGV, RGVTaskCommand? rgvTaskCommand) |
| | | { |
| | | commonRGV.SetValue(StackerCraneDBName.TaskNum, Convert.ToInt16(1)); |
| | | Thread.Sleep(100); |
| | | commonRGV.SetValue(StackerCraneDBName.PutcargoLocation, (byte)Convert.ToSByte(rgvTaskCommand.PutcargoLocation)); |
| | | Thread.Sleep(100); |
| | | commonRGV.SetValue(StackerCraneDBName.PickupLocation, (byte)Convert.ToSByte(rgvTaskCommand.PickupLocation)); |
| | | Thread.Sleep(100); |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(rgvTaskCommand.TaskType)); |
| | | |
| | | } |
| | | public void SendCommandSecondFloor(CommonRGV commonRGV, RGVTaskCommand? rgvTaskCommand) |
| | | { |
| | | commonRGV.SetValue(StackerCraneDBName.TaskNum, Convert.ToInt16(1)); |
| | | Thread.Sleep(100); |
| | | commonRGV.SetValue(StackerCraneDBName.PutcargoLocation, (byte)Convert.ToSByte(rgvTaskCommand.PutcargoLocation)); |
| | | Thread.Sleep(100); |
| | | commonRGV.SetValue(StackerCraneDBName.PickupLocation, (byte)Convert.ToSByte(rgvTaskCommand.PickupLocation)); |
| | | Thread.Sleep(100); |
| | | commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(rgvTaskCommand.TaskType)); |
| | | |
| | | } |
| | | |
| | | public class RGVTaskCommand |
| | | { |
| | | #region <Public Menber> |
| | | |
| | | /// <summary> |
| | | /// åè´§ä½ |
| | | /// </summary> |
| | | public byte PickupLocation { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¾è´§ä½ |
| | | /// </summary> |
| | | public byte PutcargoLocation { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç±»å |
| | | /// </summary> |
| | | public byte TaskType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// é¢ç |
| | | /// </summary> |
| | | public byte Spare { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å· |
| | | /// </summary> |
| | | public short TaskNum { get; set; } |
| | | |
| | | |
| | | #endregion <Public Menber> |
| | | } |
| | | |
| | | public enum RGVDBName |
| | | { |
| | | SendTask, |
| | | Automatic, |
| | | WorkCompleted, |
| | | Running, |
| | | Fault, |
| | | InStock, |
| | | RGVTargetAddress, |
| | | RGVTaskNum, |
| | | PickupLocation, |
| | | PutcargoLocation, |
| | | TaskType, |
| | | TaskNum, |
| | | LevelPoint, |
| | | CurrentTaskNum, |
| | | RGVAlarm, |
| | | } |
| | | |
| | | #endregion |
| | | } |