Browse Source

新增机械臂

xsd 5 months ago
parent
commit
694588ed49

+ 142 - 0
SourceGen/ExampleSourceGenerator.cs

@@ -0,0 +1,142 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Text;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace SourceGen
+{
+    [Generator]
+    public class ExampleSourceGenerator : ISourceGenerator
+    {
+        public void Execute(GeneratorExecutionContext context)
+        {
+            //Debugger.Launch();
+            var assemblies = context.Compilation.SourceModule.ReferencedAssemblySymbols.ToArray();
+            var flag = assemblies.Any(v => v.Name == "UnityEngine");
+            var types = assemblies.SelectMany(a =>
+            {
+                try
+                {
+                    var main = a.Identity.Name.Split('.').Aggregate(a.GlobalNamespace, (s, c) => s.GetNamespaceMembers().Single(m => m.Name.Equals(c)));
+
+                    return GetAllTypes(main);
+                }
+                catch
+                {
+                    return Enumerable.Empty<ITypeSymbol>();
+                }
+            }).ToArray();
+            types = types.Where(t => t.TypeKind == TypeKind.Interface && t.DeclaredAccessibility == Accessibility.Public)
+                .Where(v => v.AllInterfaces.Any(d => d.Name == "IProtocol")).ToArray();
+
+
+            var code = @"#nullable disable
+using System;
+using System.Runtime.Serialization;
+namespace SourceGen
+{ 
+    #content
+}
+";
+
+            var str = "";
+
+            foreach (var model in types)
+            {
+                str += "\n[DataContract]";
+                str += $"\npublic struct {model.Name}Data:{model.ContainingNamespace}.{model.Name}";
+                str += "\n{";
+                var i = 0;
+                foreach (var member in model.GetMembers())
+                {
+                    if (member is IPropertySymbol p)
+                    {
+                        str += $"\n    [DataMember(Order = {i})]";
+                        str += $"\n    public {p.Type} {p.Name}{{get;set;}}";
+                        i++;
+                    }
+                }
+                str += "\n}";
+            }
+
+            code = code.Replace("#content", str);
+            context.AddSource("Structs.cs", SourceText.From(code, Encoding.UTF8));
+
+        }
+
+        public void Initialize(GeneratorInitializationContext context)
+        { 
+            //context.RegisterForSyntaxNotifications(() => new CustomSyntaxReceiver());
+
+        }
+
+        private static IEnumerable<ITypeSymbol> GetAllTypes(INamespaceSymbol root)
+        {
+            foreach (var namespaceOrTypeSymbol in root.GetMembers())
+            {
+                if (namespaceOrTypeSymbol is INamespaceSymbol @namespace)
+                {
+                    foreach (var nested in GetAllTypes(@namespace))
+                        yield return nested;
+                }
+                else if (namespaceOrTypeSymbol is ITypeSymbol type)
+                    yield return type;
+            }
+        }
+    }
+
+    internal class CustomSyntaxReceiver : ISyntaxReceiver
+    {
+        public List<InterfaceDeclarationSyntax> Models { get; } = new List<InterfaceDeclarationSyntax>();
+
+        public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
+        {
+            //Debugger.Launch();
+            if (syntaxNode.ToString().Contains("IStation520"))
+            { 
+            
+            }
+            return;
+            if (syntaxNode is InterfaceDeclarationSyntax it)
+            {
+                if (it.BaseList.Types.Any(v => v.Type.ToString() == "IProtocol"))
+                {
+                    Models.Add(it);
+                }
+            }
+            
+        }
+    }
+
+    public class myReceiver : SourceReferenceResolver
+    {
+        public override bool Equals(object other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public override int GetHashCode()
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public override string NormalizePath(string path, string baseFilePath)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public override Stream OpenRead(string resolvedPath)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public override string ResolveReference(string path, string baseFilePath)
+        {
+            throw new System.NotImplementedException();
+        }
+    }
+}

+ 12 - 0
SourceGen/SourceGen.csproj

@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.0</TargetFramework>
+    <UserSecretsId>5ab668e8-bab8-4956-be18-4087bb6e8bea</UserSecretsId>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.CodeAnalysis" Version="3.8.0" /> 
+  </ItemGroup>
+
+</Project>

+ 6 - 6
WcsFramework.sln

@@ -29,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.WorkEngineering", "业
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WCS.DebugTool", "WCS.DebugTool\WCS.DebugTool.csproj", "{6E83138E-F92B-40FB-BEB4-F5E02383B823}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGen", "..\test\WCS\WCS\SourceGen\SourceGen.csproj", "{24DFD839-45C9-4CA1-ABF1-3580B3677A26}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGen", "SourceGen\SourceGen.csproj", "{B2B5A371-9367-46A8-BA0D-0E1FDA41794A}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -73,10 +73,10 @@ Global
 		{6E83138E-F92B-40FB-BEB4-F5E02383B823}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{6E83138E-F92B-40FB-BEB4-F5E02383B823}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{6E83138E-F92B-40FB-BEB4-F5E02383B823}.Release|Any CPU.Build.0 = Release|Any CPU
-		{24DFD839-45C9-4CA1-ABF1-3580B3677A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{24DFD839-45C9-4CA1-ABF1-3580B3677A26}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{24DFD839-45C9-4CA1-ABF1-3580B3677A26}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{24DFD839-45C9-4CA1-ABF1-3580B3677A26}.Release|Any CPU.Build.0 = Release|Any CPU
+		{B2B5A371-9367-46A8-BA0D-0E1FDA41794A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{B2B5A371-9367-46A8-BA0D-0E1FDA41794A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{B2B5A371-9367-46A8-BA0D-0E1FDA41794A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{B2B5A371-9367-46A8-BA0D-0E1FDA41794A}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -92,7 +92,7 @@ Global
 		{A492ECC8-9874-4D75-A279-79F908803B25} = {5C319C8D-9EC2-4C1E-9924-437DB3239AE1}
 		{CD308645-A4F6-4AC4-891B-B7AE0547EA08} = {5C319C8D-9EC2-4C1E-9924-437DB3239AE1}
 		{6E83138E-F92B-40FB-BEB4-F5E02383B823} = {C783651F-7EB6-40BA-8E68-525F93B8FCED}
-		{24DFD839-45C9-4CA1-ABF1-3580B3677A26} = {C783651F-7EB6-40BA-8E68-525F93B8FCED}
+		{B2B5A371-9367-46A8-BA0D-0E1FDA41794A} = {C783651F-7EB6-40BA-8E68-525F93B8FCED}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {2C009DED-1CDE-4D15-A895-5013ED32E8FC}

+ 10 - 8
业务工程/时效库/WCS.WorkEngineering/Systems/装箱码垛/入缓存扫码.cs

@@ -70,7 +70,7 @@ namespace WCS.WorkEngineering.Systems.装箱码垛
                         Circling(obj, 5038, 5173, bcrCode);
                         continue;
                     }
-                    if (item.AddrTo != "8090" && item.AddrTo != "8092" && item.AddrTo != "8096" && item.AddrTo != "8098")
+                    if (item.AddrTo != "8090" && item.AddrTo != "8092" && item.AddrTo != "8096" && item.AddrTo != "8098" && item.AddrTo != "5434" && item.AddrTo != "8307")
                     {
                         var error = new BaseErrorinfoWcs()
                         {
@@ -111,14 +111,15 @@ namespace WCS.WorkEngineering.Systems.装箱码垛
 
                         var cacheList = new List<string>();
 
-                        if (task.Robot is "Robot1" or "")
+                        cacheList = obj.Entity.Code switch
                         {
-                            cacheList = new List<string>() { /*"5100",*/ "5086", "5070", "5056" };
-                        }
-                        else if (task.Robot is "Robot2" or "")
-                        {
-                            cacheList = new List<string>() { "5310", "5295", "5280", "5265" };
-                        }
+                            "Robot1" => new List<string> { "5100", "5086", "5070", "5056" },
+                            "Robot2" => new List<string> { "5310", "5295", "5280", "5265" },
+                            "Robot3" => new List<string> { "5392", "5377", "5362", "5347" },
+                            "Robot10" => new List<string> { "5392", "5377", "5362", "5347" }, //表示人工码垛位
+                            _ => new List<string>()  // 默认情况,可根据需要处理
+                        };
+
                         //当前任务是否正在码垛
                         var isPallet = db.Default.Queryable<Palletizing>().Any(v => v.PalletizState == 0 && v.ID == task.PalletizingID);
 
@@ -305,6 +306,7 @@ namespace WCS.WorkEngineering.Systems.装箱码垛
                 if (taskInfo == null) continue;
                 if (string.IsNullOrEmpty(next))
                     continue;
+
                 //开始赋值
                 obj.Data2.GetType().GetProperty($"TaskNumber{obj.Data2.NextIndex}").SetValue(obj.Data2, taskInfo.ID);
                 obj.Data2.GetType().GetProperty($"TaskNumber{obj.Data2.NextIndex}").SetValue(obj.Data2, taskInfo.ID);

+ 1 - 1
业务工程/时效库/WCS.WorkEngineering/Systems/装箱码垛/机器人抓取.cs

@@ -216,7 +216,7 @@ namespace WCS.WorkEngineering.Systems
 
         public override bool Select(Device dev)
         {
-            return dev.Code is "Robot1" or "Robot2";
+            return dev.Code is "Robot1" or "Robot2" or "Robot3";
         }
     }
 }

+ 2 - 5
业务工程/时效库/WCS.WorkEngineering/Systems/装箱码垛/码垛位.cs

@@ -33,10 +33,7 @@ namespace WCS.WorkEngineering.Systems
            
             if (obj.Data.VoucherNo != obj.Data2.VoucherNo)
                 return;
-            if (obj.Entity.Code == "8090" && obj.Data.PalletID == 485161 && obj.Data.VoucherNo == -32601 && obj.Data.Cmd != 0)
-            {
-                obj.Data.Cmd = 0;
-            }
+            
             if (obj.Data2.Rqst == RobotStationRqst.完成码垛)
             {
                 World.Log($"码垛位{obj.Entity.Code}整垛完成交互开始时间: " + DateTime.Now.ToString("yyyyMMddHHmmss"));
@@ -164,7 +161,7 @@ namespace WCS.WorkEngineering.Systems
 
         public override bool Select(Device dev)
         {
-            return true;// "" dev.Code == "8090" || dev.Code == "8092"||dev.Code=="8096";
+            return dev.Code== "8098"|| dev.Code == "8090" || dev.Code == "8092"||dev.Code=="8096"||dev.Code=="8307";
         }
     }
 }

+ 37 - 0
业务工程/时效库/WCS.WorkEngineering/Systems/装箱码垛/码垛抓取扫码.cs

@@ -79,6 +79,19 @@ namespace WCS.WorkEngineering.Systems
                 case "5160":
                     addrPick = 5169;
                     break;
+                case "5405":
+                    addrPick = 5143;
+                    break;
+                case "5408":
+                    addrPick = 5418;
+                    break;
+            }
+
+            if (addrPick==5143) 
+            {
+                World.Log("人工码垛位暂停使用");
+                MainWorld.Redis.Set($"Sx:WCSErrorInfo:{obj.Entity.Code}", JsonConvert.SerializeObject(new RedisError() { Equip = obj.Entity.Code, Con = $"人工码垛位暂时禁用", Time = DateTime.Now }));
+                return;
             }
 
             var arr = Device.All.Where(v => v.HasProtocol<IStation521>())
@@ -205,6 +218,30 @@ namespace WCS.WorkEngineering.Systems
                         //throw new Exception($"扫码器{obj.Entity.Code},任务目标地址不对");
                     }
                 }
+                if (task.AddrTo == "5435")
+                {
+                    if (obj.Entity.Code != "5405")
+                    {
+                        obj.Data.TaskNumber = int.Parse(obj.Entity.Code);
+                        obj.Data.GoodsEnd = 5173;
+                        obj.Data.VoucherNo++;
+                        return;
+                        //MainWorld.Redis.Set($"Sx:WCSErrorInfo:{obj.Entity.Code}", JsonConvert.SerializeObject(new RedisError() { Equip = obj.Entity.Code, Con = $"扫码器{obj.Entity.Code},任务目标地址不对", Time = DateTime.Now }));
+                        //throw new Exception($"扫码器{obj.Entity.Code},任务目标地址不对");
+                    }
+                }
+                if (task.AddrTo == "8307")
+                {
+                    if (obj.Entity.Code != "5408")
+                    {
+                        obj.Data.TaskNumber = int.Parse(obj.Entity.Code);
+                        obj.Data.GoodsEnd = 5173;
+                        obj.Data.VoucherNo++;
+                        return;
+                        //MainWorld.Redis.Set($"Sx:WCSErrorInfo:{obj.Entity.Code}", JsonConvert.SerializeObject(new RedisError() { Equip = obj.Entity.Code, Con = $"扫码器{obj.Entity.Code},任务目标地址不对", Time = DateTime.Now }));
+                        //throw new Exception($"扫码器{obj.Entity.Code},任务目标地址不对");
+                    }
+                }
                 task.Status = Entity.TaskStatus.码垛抓取扫码;
                 task.EditTime = DateTime.Now;
                 try

+ 25 - 17
业务工程/时效库/WCS.WorkEngineering/Systems/装箱码垛/码垛缓存放行.cs

@@ -1,23 +1,15 @@
-using ServiceCenter.SqlSugars;
-using System;
-using System.Collections.Generic;
+using Newtonsoft.Json;
+using ServiceCenter.Extensions;
+using ServiceCenter.SqlSugars;
+using SqlSugar;
 using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using WCS.Core;
 using WCS.Entity;
-using WCS.Entity.Protocol.BCR;
 using WCS.Entity.Protocol.Station;
-using WCS.WorkEngineering.Worlds;
 using WCS.WorkEngineering.Extensions;
-using ServiceCenter.Redis;
 using WCS.WorkEngineering.WebApi.Models.WCS.Request;
-using Newtonsoft.Json;
-using ServiceCenter.Extensions;
+using WCS.WorkEngineering.Worlds;
 using TaskStatus = WCS.Entity.TaskStatus;
-using Autofac.Core;
-using SqlSugar;
 
 namespace WCS.WorkEngineering.Systems
 {
@@ -41,7 +33,6 @@ namespace WCS.WorkEngineering.Systems
             }
             World.Log($"码垛放行{obj.Entity.Code}交互开始时间:任务号 {obj.Data2.TaskNumber}  | " + DateTime.Now.ToString("yyyyMMddHHmmss"));
 
-
             SqlSugarHelper.Do(db =>
             {
                 var task1 = db.Default.Queryable<WCS_TaskInfo>().Where(v => v.ID == obj.Data2.TaskNumber).First();
@@ -67,7 +58,24 @@ namespace WCS.WorkEngineering.Systems
                     }
                 }
 
-                var devCodeList = Device.All.Where(x => x.Code is "5100" or "5086" or "5070" or "5056" or "5310" or "5295" or "5280" or "5265").Select(x => new Device<IStation521>(x, World)).Where(x => x.Data.Request == 1).Select(x => x.Entity.Code).ToList();
+                // 定义所有设备组
+                var codeGroups = new List<HashSet<string>>
+                {
+                    new HashSet<string> { "5100", "5086", "5070", "5056" },
+                    new HashSet<string> { "5310", "5295", "5280", "5265" },
+                    new HashSet<string> { "5392", "5377", "5362", "5347" }
+                };
+
+                // 查找包含当前代码的组
+                var codes = codeGroups.FirstOrDefault(group => group.Contains(obj.Entity.Code))?
+                             .ToList() ?? new List<string>();
+
+                var devCodeList = Device.All
+                    .Where(x => codes.Contains(x.Code))
+                    .Select(x => new Device<IStation521>(x, World))
+                    .Where(x => x.Data.Request == 1)
+                    .Select(x => x.Entity.Code)
+                    .ToList();
 
                 //检查当前线体缓存是不是当前箱中最少的
                 var addrNextGroup = db.Default.Queryable<WCS_TaskInfo>().With(SqlWith.NoLock).Where(x =>
@@ -152,7 +160,7 @@ namespace WCS.WorkEngineering.Systems
                         device.Data.TaskNumber = task.ID;
                         device.Data.GoodsEnd = short.Parse(addrScan.Code);
                         MainWorld.Redis.Decr($"stockOperateNum{task.AddrTo}");
-                        World.Log("码垛缓存放行:" + device.Data.TaskNumber + "," + device.Data.GoodsEnd+",之前凭证号:"+ obj.Data.VoucherNo);
+                        World.Log("码垛缓存放行:" + device.Data.TaskNumber + "," + device.Data.GoodsEnd + ",之前凭证号:" + obj.Data.VoucherNo);
                     }
                     obj.Data.VoucherNo++;
                 }
@@ -165,4 +173,4 @@ namespace WCS.WorkEngineering.Systems
             return dev.HasFlag("装箱码垛") && dev.HasFlag("位置", "缓存");
         }
     }
-}
+}

+ 57 - 18
业务工程/时效库/WCS.WorkEngineering/WorkStart.cs

@@ -1,22 +1,13 @@
 using PlcSiemens.Core.Extension;
-using PlcSiemens.ProtocolHandle;
 using ServiceCenter;
 using ServiceCenter.SqlSugars;
-using SqlSugar;
 using WCS.Core;
-using WCS.Entity;
 using WCS.Entity.Protocol.BCR;
-using WCS.Entity.Protocol.DataStructure;
 using WCS.Entity.Protocol.QT;
-using WCS.Entity.Protocol.RGV;
 using WCS.Entity.Protocol.Robot;
 using WCS.Entity.Protocol.SRM;
 using WCS.Entity.Protocol.Station;
-using WCS.Entity.Protocol.Truss;
 using WCS.WorkEngineering.Extensions;
-using WCS.WorkEngineering.Systems;
-using WCS.WorkEngineering.Systems.扭转检测;
-using wms.sqlsugar.model.fj;
 using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
 
 namespace WCS.WorkEngineering
@@ -88,7 +79,6 @@ namespace WCS.WorkEngineering
             SetPath(3752, 3753, 3755, 3756, 3757, 3758, 3759);
             SetPath(3753, 3760, 3761, 3763, 3764, 3765, 3766, 3767);
             SetPath(3761, 3771, 3772, 3774, 3775, 3776, 3777, 3778);
-             
 
             AddDevices(3301, 3506, "{0:d}", (dev, i) =>
             {
@@ -148,7 +138,7 @@ namespace WCS.WorkEngineering
 
             var sCode = 3020;
             for (int f = 0; f < 3; f++)
-            { 
+            {
                 for (int i = 0; i < 8; i++)
                 {
                     var code = sCode + 16 * i;
@@ -156,7 +146,6 @@ namespace WCS.WorkEngineering
 
                     Device.Find($"{code + 5}").AddFlag("位置", "堆垛机放货工位").AddFlag("Tunnel", $"{i + 1}");
                     Device.Find($"{code + 4}").AddFlag("位置", "堆垛机放货工位").AddFlag("Tunnel", $"{i + 1}");
-
                 }
                 sCode += 300;
             }
@@ -194,13 +183,22 @@ namespace WCS.WorkEngineering
                 dev.SetFlag("装箱码垛");
             });
 
+            AddDevices(5331, 5434, "{0:d}", (dev, i) =>
+            {
+                var index = i + 330;
+                dev.AddProtocol<IStation520>(index * 14, 520, "10.30.39.220");
+                dev.AddProtocol<IStation521>(index * 16, 521, "10.30.39.220");
+                dev.AddProtocol<IStation523>(index * 12, 523, "10.30.39.220");
+                dev.AddFlag(DeviceFlags.输送机);
+                dev.SetFlag("装箱码垛");
+            });
+
             Device.Find("5032").AddProtocol<IStation23>(8, 23, "10.30.39.220");
             Device.Find("5038").AddProtocol<IBCR81>(2560, 81, "10.30.39.220");
             Device.Find("5251").AddProtocol<IStation525>(0, 525, "10.30.39.220");
             Device.Find("5251").AddProtocol<IBCR83>(0, 83, "10.30.39.220");
             Device.Find("5038").AddProtocol<IBCR83>(2796, 83, "10.30.39.220");
 
-
             Device.Find("5056").AddFlag("码垛工位", "8090").AddFlag("位置", "缓存");
             Device.Find("5070").AddFlag("码垛工位", "8090").AddFlag("位置", "缓存");
             Device.Find("5086").AddFlag("码垛工位", "8092").AddFlag("位置", "缓存");
@@ -211,6 +209,11 @@ namespace WCS.WorkEngineering
             Device.Find("5280").AddFlag("码垛工位", "8098").AddFlag("位置", "缓存");
             Device.Find("5265").AddFlag("码垛工位", "8098").AddFlag("位置", "缓存");
 
+            Device.Find("5392").AddFlag("码垛工位", "5434").AddFlag("位置", "缓存");
+            Device.Find("5377").AddFlag("码垛工位", "5434").AddFlag("位置", "缓存");
+            Device.Find("5362").AddFlag("码垛工位", "8307").AddFlag("位置", "缓存");
+            Device.Find("5347").AddFlag("码垛工位", "8307").AddFlag("位置", "缓存");
+
             Device.Find("5135").AddFlag("码垛工位", "8090").AddFlag("位置", "抓取");
             "5213,5214,5215".Split(',').For((dev, i) =>
             {
@@ -235,6 +238,12 @@ namespace WCS.WorkEngineering
                 dev.AddFlag("Parent", "5169");
             });
 
+            Device.Find("5418").AddFlag("码垛工位", "8307").AddFlag("位置", "抓取");
+            "5448,5449,5450".Split(',').For((dev, i) =>
+            {
+                dev.AddFlag("Parent", "5418");
+            });
+
             //Device.Find("5134").AddFlag("码垛工位", "8090").AddFlag("位置","扫码");
             //Device.Find("5145").AddFlag("码垛工位", "8092").AddFlag("位置","扫码");
             //Device.Find("5157").AddFlag("码垛工位", "8096").AddFlag("位置","扫码");
@@ -250,6 +259,8 @@ namespace WCS.WorkEngineering
             Device.Find("5137").AddProtocol<IBCR81>(3050, 81, "10.30.39.220").AddFlag("码垛工位", "8092").AddFlag("位置", "扫码");
             Device.Find("5149").AddProtocol<IBCR81>(3306, 81, "10.30.39.220").AddFlag("码垛工位", "8096").AddFlag("位置", "扫码");
             Device.Find("5160").AddProtocol<IBCR81>(3562, 81, "10.30.39.220").AddFlag("码垛工位", "8098").AddFlag("位置", "扫码");
+            Device.Find("5405").AddProtocol<IBCR81>(4328, 81, "10.30.39.220").AddFlag("码垛工位", "5434").AddFlag("位置", "扫码");
+            Device.Find("5408").AddProtocol<IBCR81>(4584, 81, "10.30.39.220").AddFlag("码垛工位", "8307").AddFlag("位置", "扫码");
 
             #endregion 成品码垛
 
@@ -260,14 +271,13 @@ namespace WCS.WorkEngineering
                 dev.AddProtocol<IStation520>(i * 14, 520, "10.30.39.190");
                 if (short.Parse(dev.Code) >= 4280)
                 {
-                    dev.AddProtocol<IStation521>((i+12) * 16, 521, "10.30.39.190");
+                    dev.AddProtocol<IStation521>((i + 12) * 16, 521, "10.30.39.190");
                 }
                 else
                     dev.AddProtocol<IStation521>(i * 16, 521, "10.30.39.190");
                 dev.AddProtocol<IStation523>(i * 12, 523, "10.30.39.190");
                 dev.SetFlag("扭转检测");
-            }); 
-
+            });
 
             AddDevices(5186, 5197, "{0:d}", (dev, i) =>
             {
@@ -349,13 +359,27 @@ namespace WCS.WorkEngineering
 
             #region 机械手
 
-            AddDevices(1, 2, "Robot{0:d}", (dev, i) =>
+            AddDevices(3, 3, "Robot{0:d}", (dev, i) =>
             {
                 dev.AddProtocol<IRobot520>(i * 24, 520, "10.30.43.117");
                 dev.AddProtocol<IRobot521>(i * 34, 521, "10.30.43.117");
                 dev.AddProtocol<IRobot522>(i * 4, 522, "10.30.43.117");
             });
 
+            #region 新增第三个机械臂
+            AddDevices(1, 2, "Robot{0:d}", (dev, i) =>
+            {
+                dev.AddProtocol<IRobot520>(i * 24, 520, "10.30.43.118");
+                dev.AddProtocol<IRobot521>(i * 34, 521, "10.30.43.118");
+                dev.AddProtocol<IRobot522>(i * 4, 522, "10.30.43.118");
+            });
+            //var dev = new Device(string.Format("{0:d}", 8307));
+            //dev.AddProtocol<IRobot520>(0 * 24, 520, "10.30.43.118");
+            //dev.AddProtocol<IRobot521>(0 * 34, 521, "10.30.43.118");
+            //dev.AddProtocol<IRobot522>(0 * 4, 522, "10.30.43.118");
+
+            #endregion 新增第三个机械臂
+
             AddDevices("{0:d}", (dev, code, i) =>
             {
                 dev.AddProtocol<IStation521>((code - 8001) * 16, 521, "10.30.43.73");
@@ -367,6 +391,21 @@ namespace WCS.WorkEngineering
                 dev.SetFlag("装箱码垛");
             }, 8090, 8092, 8096, 8098);
 
+            #region 新增第三个机械臂的码垛位
+
+            AddDevices("{0:d}", (dev, code, i) =>
+            {
+                dev.AddProtocol<IStation521>((code - 8001) * 16, 521, "10.30.43.73");
+                dev.AddProtocol<IRobot530>(i * 12, 530, "10.30.43.118");
+                dev.AddProtocol<IRobot531>(i * 334, 531, "10.30.43.118");
+                var rbcode = $"Robot{(i + 4) / 2 + 1}";
+                dev.AddFlag("Robot", rbcode);
+                dev.AddFlag("位置", "码垛");
+                dev.SetFlag("装箱码垛");
+            }, 8307);
+
+            #endregion 新增第三个机械臂的码垛位
+
             #endregion 机械手
 
             new Device("SXOut");
@@ -467,4 +506,4 @@ namespace WCS.WorkEngineering
             }
         }
     }
-}
+}