林豪 左 1 жил өмнө
parent
commit
7fb5989ac4

+ 23 - 17
ServiceCenter/Logs/LogHub.cs

@@ -17,27 +17,33 @@ namespace ServiceCenter.Logs
         {
             if (logs.Count > 0)
             {
-                //每一条数据存入redis
-                foreach (var log in logs)
+                try
                 {
-                    var dir = $"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\{log.Channel.World}\\{log.Channel.System}\\{log.Channel.Item}\\";
-                    var msg = $"{log.Time.yyyyMMddhhmmssf()}--[{Thread.CurrentThread.ManagedThreadId}]--{log}\n";
-                    RedisHub.Default.RPush("LogHub", JsonConvert.SerializeObject(new LogModel
+                    //每一条数据存入redis
+                    foreach (var log in logs)
+                    {
+                        var dir = $"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\{log.Channel.World}\\{log.Channel.System}\\{log.Channel.Item}\\";
+                        var msg = $"{log.Time.yyyyMMddhhmmssf()}--[{Thread.CurrentThread.ManagedThreadId}]--{log}\n";
+                        RedisHub.Default.RPush("LogHub", JsonConvert.SerializeObject(new LogModel
+                        {
+                            path = dir,
+                            Title = $"{log.Log.Message.Split(":")[0]}.txt",
+                            Con = msg
+                        }));
+                    }
+                    //存入业务报警内容
+                    List<BusinessAlarm> businesses = logs.Where(v => v.Log.Level > LogLevelEnum.Low && v.Log.LogUpLoad == LogUpLoadEnum.UpLoadWMS).Select(v => new BusinessAlarm()
                     {
-                        path = dir,
-                        Title = $"{log.Log.Message.Split(":")[0]}.txt",
-                        Con = msg
-                    }));
+                        BusinessName = v.Channel.System,
+                        DevNo = v.Channel.Item,
+                        Con = v.ToString(),
+                        Time = DateTime.Now
+                    }).ToList();
+                    RedisHub.WMS.Set($"{nameof(BusinessAlarm)}:{World}", JsonConvert.SerializeObject(businesses));
                 }
-                //存入业务报警内容
-                List<BusinessAlarm> businesses = logs.Where(v => v.Log.Level > LogLevelEnum.Low && v.Log.LogUpLoad == LogUpLoadEnum.UpLoadWMS).Select(v => new BusinessAlarm()
+                catch
                 {
-                    BusinessName = v.Channel.System,
-                    DevNo = v.Channel.Item,
-                    Con = v.ToString(),
-                    Time = DateTime.Now
-                }).ToList();
-                RedisHub.WMS.Set($"{nameof(BusinessAlarm)}:{World}", JsonConvert.SerializeObject(businesses));
+                }
             }
         }
 

+ 4 - 1
WCS.Core/DataBlock.cs

@@ -33,7 +33,6 @@ namespace WCS.Core
         {
             try
             {
-
                 Start = (ushort)ProxyList.Min(v => v.Info.Position);
                 var last = ProxyList.OrderBy(v => v.Info.Position).Last();
                 Length = (ushort)(last.Info.Position + last.BytesCount);
@@ -41,6 +40,10 @@ namespace WCS.Core
                 lock (Entity.PLCInfo.Ex())
                 {
                     data = Entity.PLCInfo.Ex().Accessor.ReadBytes(Entity.No, Start, (ushort)(Length - Start));
+                    if (Entity.No == 83)
+                    {
+                        var a = 0;
+                    }
                 }
                 if (!Data.SequenceEqual(data))
                 {

+ 1 - 1
WCS.Entity.Protocol/BCR/BCR81.cs

@@ -10,7 +10,7 @@ namespace WCS.Entity.Protocol.BCR
         /// <summary>
         /// 内容
         /// </summary>
-        [StringLength(130)]
+        [StringLength(20)]
         string Content { get; set; }
     }
 }

+ 41 - 3
WCS.WorkEngineering/Extensions/BCRExtension.cs

@@ -11,7 +11,7 @@ namespace WCS.WorkEngineering.Extensions
     public class BCR : Device<IBCR81>
     {
         /// <summary>
-        ///  BCR扩展
+        ///   BCR扩展
         /// </summary>
         /// <param name="device"></param>
         /// <param name="world"></param>
@@ -33,6 +33,34 @@ namespace WCS.WorkEngineering.Extensions
         }
     }
 
+    /// <summary>
+    ///  BCR83
+    /// </summary>
+    public class BCR83 : Device<IBCR83>
+    {
+        /// <summary>
+        ///   BCR扩展
+        /// </summary>
+        /// <param name="device"></param>
+        /// <param name="world"></param>
+        public BCR83(Device device, World world) : base(device, world)
+        {
+        }
+
+        /// <summary>
+        ///  获取BCR码
+        /// </summary>
+        /// <returns></returns>
+        public string GetBCRCode()
+        {
+            var barcode = Data.BcrCode.Trim('\0');
+
+            if (barcode.IsNullOrWhiteSpace()) throw new KnownException($"{Entity.Code}--扫码失败,内容为空", LogLevelEnum.High);
+
+            return barcode;
+        }
+    }
+
     /// <summary>
     ///  BCR扩展
     /// </summary>
@@ -44,11 +72,21 @@ namespace WCS.WorkEngineering.Extensions
         /// <param name="bs"></param>
         /// <param name="code">BCR对应站点设备号</param>
         /// <returns></returns>
-        public static string GetBCRCode(this List<BCR> bs, string code)
+        public static string GetBCRCode(this List<BCR> bc, string code)
         {
             code = "BCR" + code;
-            var bcr = bs.FirstOrDefault(p => p.Entity.Code == code) ?? throw new KnownException($"未找到扫码器{code}", LogLevelEnum.High);
+            var bcr = bc.FirstOrDefault(p => p.Entity.Code == code) ?? throw new KnownException($"未找到扫码器{code}", LogLevelEnum.High);
             return bcr.GetBCRCode();
         }
+
+        ///// <summary>
+        /////  获取BCR83码集合
+        ///// </summary>
+        ///// <param name="bc"></param>
+        ///// <returns></returns>
+        //public static string GetBCRCodeList(this BCR83 bc)
+        //{
+
+        //}
     }
 }

+ 5 - 2
WCS.WorkEngineering/Extensions/StationExtension.cs

@@ -48,9 +48,12 @@ namespace WCS.WorkEngineering.Extensions
             if (!Data3.Status.HasFlag(StationStatus.OT_Status)) throw new KnownException("站台货物信息与实际占用不一致", LogLevelEnum.Low);
         }
 
-
-        public void GetBarCode()
+        public string GetBarCode(World world)
         {
+            var code = "BCR" + Entity.Code;
+            var bcrdev = Device.All.FirstOrDefault(v => v.Code == code) ?? throw new KnownException($"未找到扫码器{code}", LogLevelEnum.High);
+            var bcr = new BCR(bcrdev, world);
+            return bcr.GetBCRCode();
         }
     }
 }

+ 58 - 0
WCS.WorkEngineering/Protocol/BCR/IBCR83.cs

@@ -0,0 +1,58 @@
+using System.ComponentModel.DataAnnotations;
+using WCS.Entity;
+
+namespace WCS.WorkEngineering.Protocol.BCR
+{
+    /// <summary>
+    ///  满轮主线读取
+    /// </summary>
+    public interface IBCR83 : IProtocol
+    {
+        public short index { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode1 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode2 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode3 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode4 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode5 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode6 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode7 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode8 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode9 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode10 { get; set; }
+
+        [StringLength(50)]
+        public string BcrCode11 { get; set; }
+
+        ///// <summary>
+        /////  获取历史扫码记录
+        ///// </summary>
+        ///// <returns></returns>
+        //public List<string> GetBcrCodeList()
+        //{
+        //    return new List<string>() { BcrCode1, BcrCode2, BcrCode3, BcrCode4, BcrCode5, BcrCode6, BcrCode7, BcrCode8, BcrCode9, BcrCode10, BcrCode11 };
+        //}
+    }
+}

+ 1 - 1
WCS.WorkEngineering/Systems/DataCollectionSysyem.cs

@@ -16,7 +16,7 @@ namespace WCS.Service.Systems
     /// <summary>
     ///  数据采集系统
     /// </summary>
-    [BelongTo(typeof(DataCollectionWorld))]
+    //[BelongTo(typeof(DataCollectionWorld))]
     [Description("数据采集系统")]
     public class DataCollectionSysyem : DeviceSystem<SRM>
     {

+ 1 - 1
WCS.WorkEngineering/Systems/DeviceWriteSystem.cs

@@ -9,7 +9,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  设备信息写入接口
     /// </summary>
-    [BelongTo(typeof(MainWorld))]
+    //[BelongTo(typeof(MainWorld))]
     public class DeviceWriteSystem : ServiceSystem<DeviceWriteInfo>
     {
         /// <summary>

+ 1 - 1
WCS.WorkEngineering/Systems/GetDeviceSystem.cs

@@ -29,7 +29,7 @@ namespace WCS.WorkEngineering.Systems
         /// </summary>
         public GetDeviceSystem()
         {
-            Convs = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Station(v, this.World)).ToList();
+            //Convs = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Station(v, this.World)).ToList();
             Srms = Device.All.Where(v => v.HasProtocol<ISRM520>()).Select(v => new SRM(v, this.World)).ToList();
             Bcrs = Device.All.Where(v => v.HasProtocol<IBCR81>()).Select(v => new BCR(v, this.World)).ToList();
             Device91 = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Device<IStation523>(v, this.World)).ToList();

+ 58 - 2
WCS.WorkEngineering/Systems/主线分流点.cs

@@ -1,4 +1,7 @@
-using System.ComponentModel;
+using Newtonsoft.Json;
+using ServiceCenter.Extensions;
+using ServiceCenter.Redis;
+using System.ComponentModel;
 using WCS.Core;
 using WCS.WorkEngineering.Extensions;
 using WCS.WorkEngineering.Worlds;
@@ -19,7 +22,44 @@ namespace WCS.WorkEngineering.Systems
         public override void Do(Station obj)
         {
             obj.入库站点是否满足执行条件();
-            obj.
+            //获取条码
+            var bcr = obj.GetBarCode(World);
+
+            //获取到仓库Id
+            var mainlineDiversion = JsonConvert.DeserializeObject<MainlineDiversion>(RedisHub.WMS.Get($"MainlineDiversion{bcr}"));
+            //更具仓库ID来分配目标地址
+            int nextAdd = 0;
+            switch (mainlineDiversion.WarehouseId)
+            {
+                case 1:
+                    nextAdd = 0;
+                    break;
+
+                case 2:
+                    nextAdd = 0;
+                    break;
+
+                case 3:
+                    nextAdd = 0;
+                    break;
+
+                case 4:
+                    nextAdd = 0;
+                    break;
+
+                case 5:
+                    nextAdd = 0;
+                    break;
+
+                case 6:
+                    nextAdd = 0;
+                    break;
+            }
+
+            obj.Data.GoodsStart = obj.Entity.Code.ToShort();
+            obj.Data.GoodsEnd = nextAdd.ToShort();
+            obj.Data.TaskNumber = mainlineDiversion.TaskId;
+            obj.Data.VoucherNo++;
         }
 
         public override bool Select(Device dev)
@@ -27,4 +67,20 @@ namespace WCS.WorkEngineering.Systems
             return dev.HasFlag(Extensions.DeviceFlags.主线分流点);
         }
     }
+
+    /// <summary>
+    ///  主线分流
+    /// </summary>
+    public class MainlineDiversion
+    {
+        /// <summary>
+        ///  任务号
+        /// </summary>
+        public int TaskId { get; set; }
+
+        /// <summary>
+        ///  仓库号
+        /// </summary>
+        public int WarehouseId { get; set; }
+    }
 }

+ 5 - 0
WCS.WorkEngineering/Systems/湿拉满轮帘线芯股第一次扫码.cs

@@ -1,6 +1,7 @@
 using System.ComponentModel;
 using WCS.Core;
 using WCS.WorkEngineering.Extensions;
+using WCS.WorkEngineering.Protocol.BCR;
 using WCS.WorkEngineering.WebApi.Controllers;
 using WCS.WorkEngineering.Worlds;
 using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
@@ -20,6 +21,10 @@ namespace WCS.WorkEngineering.Systems
 
         public override void Do(Station obj)
         {
+            var dev = Device.All.FirstOrDefault(v => v.Code == obj.Entity.Code);
+            var bcr = new Device<IBCR83>(dev, World);
+
+            var bcrCode = bcr.Data.BcrCode1.Trim('\0');
             //获取当前站台对应的编码信息
             WmsApi.EnteMainLine(new List<string>());
         }

+ 71 - 4
WCS.WorkEngineering/WorkStart.cs

@@ -32,12 +32,14 @@ namespace WCS.WorkEngineering
 
             #region 基本信息
 
+            #region 托盘线输送线
+
             List<StationSegmentInfo> segmentInfo = new List<StationSegmentInfo>
             {
                 new StationSegmentInfo(2701, 2734, "10.30.37.89"),
                 new StationSegmentInfo(2501, 2534, "10.30.37.89"),
                 new StationSegmentInfo(1611, 1616, "10.30.37.89"),
-                new StationSegmentInfo(1601, 1606, "10.30.37.89")
+                new StationSegmentInfo(1601, 1606, "10.30.37.89"),
             };
 
             foreach (var item in segmentInfo)
@@ -46,15 +48,78 @@ namespace WCS.WorkEngineering
                 {
                     var conv = new Device(i.ToString());
                     conv.AddFlag(DeviceFlags.输送机);
+
                     conv.AddProtocol<IStation520>((i - item.Start) * 14, 520, item.IP);
                     conv.AddProtocol<IStation521>((i - item.Start) * 16, 521, item.IP);
                     conv.AddProtocol<IStation523>((i - item.Start) * 12, 523, item.IP);
                 }
             }
 
+            #endregion 托盘线输送线
+
+            #region 满轮输送线
+
+            #region DB523,所有线体都会有DB523
+
+            List<StationSegmentInfo> segmentInfo1 = new List<StationSegmentInfo>
+            {
+                new StationSegmentInfo(1, 100, "10.30.37.166"),
+                new StationSegmentInfo(401, 586, "10.30.37.166"),
+            };
+
+            foreach (var item in segmentInfo1)
+            {
+                for (int i = item.Start; i <= item.End; i++)
+                {
+                    var conv = new Device(i.ToString());
+                    conv.AddFlag(DeviceFlags.输送机);
+                    conv.AddProtocol<IStation523>((i - item.Start) * 12, 523, item.IP);
+                }
+            }
+
+            #endregion DB523,所有线体都会有DB523
+
+            #region 520、521 交互线体会有520、521
+
+            var list = new List<Tuple<List<int>, string, DeviceFlags>>()
+            {
+                new Tuple<List<int>, string,DeviceFlags>(new List<int>(){1 },"10.30.37.166",DeviceFlags.满轮主线第一次扫码),
+                new Tuple<List<int>, string,DeviceFlags>(new List<int>(){22, 41, 61 },"10.30.37.166",DeviceFlags.主线分流点),
+                new Tuple<List<int>, string,DeviceFlags>(new List<int>(){418, },"10.30.37.166",DeviceFlags.主线分流点)
+            };
+            var db520523 = new List<int>() { 1, 22, 41, 61, };
+            for (int i = 0; i < db520523.Count; i++)
+            {
+                var device = Device.All.FirstOrDefault(v => v.Code == db520523[i].ToString());
+                device.AddProtocol<IStation520>(i * 14, 520, "10.30.37.166");
+                device.AddProtocol<IStation521>(i * 16, 521, "10.30.37.166");
+                device.AddProtocol<IBCR83>(i * 602, 83, "10.30.37.166");
+            }
+
+            #endregion 520、521 交互线体会有520、521
+
+            #region 满轮扫码器
+
+            var list1 = new List<Tuple<List<int>, string, DeviceFlags>>()
+            {
+                new Tuple<List<int>, string,DeviceFlags>(new List<int>(){1 },"10.30.37.166",DeviceFlags.满轮主线第一次扫码),
+                new Tuple<List<int>, string,DeviceFlags>(new List<int>(){22, 41, 61 },"10.30.37.166",DeviceFlags.主线分流点)
+            };
+            for (int i = 0; i < db520523.Count; i++)
+            {
+                var device = Device.All.FirstOrDefault(v => v.Code == db520523[i].ToString());
+                device.AddProtocol<IStation520>(i * 14, 520, "10.30.37.166");
+                device.AddProtocol<IStation521>(i * 16, 521, "10.30.37.166");
+                device.AddProtocol<IBCR83>(i * 602, 83, "10.30.37.166");
+            }
+
+            #endregion 满轮扫码器
+
+            #endregion 满轮输送线
+
             #endregion 基本信息
 
-            #region 扫码器
+            #region 托盘线扫码器
 
             List<BcrInfo> bcrInfo = new List<BcrInfo>
             {
@@ -72,7 +137,7 @@ namespace WCS.WorkEngineering
                 }
             }
 
-            #endregion 扫码器
+            #endregion 托盘线扫码器
 
             #region 外检信息
 
@@ -209,7 +274,9 @@ namespace WCS.WorkEngineering
                 //{ DeviceFlags.二楼入库口, new List<string>() { "1603", "1613" } },
                 { DeviceFlags.一列堆垛机, new List<string>() { "SRM1"/*, "SRM3", "SRM5"*/} },
                 { DeviceFlags.二列堆垛机, new List<string>() { "SRM2"/*, "SRM4", "SRM6"*/ } },
-                {  DeviceFlags.一楼扫码,new List<string>(){ "2532","2732"} }
+                {  DeviceFlags.一楼扫码,new List<string>(){ "2532","2732"} },
+                //{  DeviceFlags.满轮主线第一次扫码,new List<string>(){ "1"} },
+                //{  DeviceFlags.主线分流点,new List<string>(){ "22","41","61"} }
                 //{ DeviceFlags.称重, new List<string>() { "1011", "1013", "1015", "1025" } }
             };