From 8e49faa42ff419efa0641478702ce7d5f8455bd9 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 30 七月 2025 20:47:56 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs |  446 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 443 insertions(+), 3 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 c96806a..b01298a 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"
@@ -18,6 +18,7 @@
 using AutoMapper;
 using HslCommunication;
 using Newtonsoft.Json;
+using SixLabors.ImageSharp.ColorSpaces;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -625,7 +626,7 @@
                     {
                         CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                         conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(3), stationManager.stationChildCode);
-                        return content.OK("鍋滄鎴愬姛");
+                        return content.OK("閫�鍥炴垚鍔�");
                     }
                 }
                 return content.Error("鏈壘鍒拌澶囦俊鎭鑱旂郴IT");
@@ -648,7 +649,7 @@
                     {
                         CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                         conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(4), stationManager.stationChildCode);
-                        return content.OK("鍋滄鎴愬姛");
+                        return content.OK("鍙栨秷鎴愬姛");
                     }
                 }
                 return content.Error("鏈壘鍒拌澶囦俊鎭鑱旂郴IT");
@@ -671,7 +672,7 @@
                     {
                         CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                         conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(6), stationManager.stationChildCode);
-                        return content.OK("鍋滄鎴愬姛");
+                        return content.OK("鍒濆鍖栨垚鍔�");
                     }
                 }
                 return content.Error("鏈壘鍒拌澶囦俊鎭鑱旂郴IT");
@@ -725,7 +726,446 @@
         #endregion
 
         #region  RGV鎵嬪姩鍛戒护
+        public WebResponseContent RGVHandTask(HandTask RGVhand)
+        {
+            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 (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(RGVhand.TaskType),
+                                };
+                                SendCommandFirstFloor(RGVcommand, command);
+                                return content.OK($"{device.DeviceName}閫�鍛戒护涓嬪彂鎴愬姛");
+                            }
+                            else
+                            {
+                                return content.Error($"{device.DeviceName}閫�鍥炲懡浠ゆ斁璐т綅涓嶈兘涓虹┖");
+                            }
+                        }
+                        else
+                        {
+                            return content.Error($"{device.DeviceName}鏈煡浠诲姟鍛戒护");
+                        }
+                    }
+                    else
+                    {
+                        CommonRGV RGVcommand = (CommonRGV)device;
+                        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}鏈煡浠诲姟鍛戒护");
+                        }
+                    }
+                }
+                return content.Error("鏈壘鍒拌澶囦俊鎭鑱旂郴IT");
+            }
+            catch (Exception ex)
+            {
+                return content.Error(ex.Message);
+            }
+        }
+
+        public WebResponseContent RGVReset(string DeviceCode)
+        {
+            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(9));
+                    }
+                    else
+                    {
+                        CommonRGV commonRGV = (CommonRGV)device;
+                        commonRGV.SetValue(StackerCraneDBName.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)
+        {
+            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)
+        {
+            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(9));
+                    }
+                    else
+                    {
+                        CommonRGV commonRGV = (CommonRGV)device;
+                        commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(9));
+                    }
+                    return content.OK($"{device.DeviceName}涓柇鎴愬姛");
+                }
+                return content.Error("鏈壘鍒拌澶囦俊鎭鑱旂郴IT");
+            }
+            catch (Exception ex)
+            {
+                return content.Error(ex.Message);
+            }
+        }
+        public WebResponseContent RGVInitialize(string DeviceCode)
+        {
+            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(9));
+                    }
+                    else
+                    {
+                        CommonRGV commonRGV = (CommonRGV)device;
+                        commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(9));
+                    }
+                    return content.OK($"{device.DeviceName}鍒濆鍖栨垚鍔�");
+                }
+                return content.Error("鏈壘鍒拌澶囦俊鎭鑱旂郴IT");
+            }
+            catch (Exception ex)
+            {
+                return content.Error(ex.Message);
+            }
+        }
+
+        public WebResponseContent RGVPause(string DeviceCode)
+        {
+            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>
+        }
 
         #endregion
     }

--
Gitblit v1.9.3