林豪 左 2 жил өмнө
parent
commit
6b38545296

+ 1 - 1
WCS.Entity.Protocol/Station/IStation520.cs

@@ -35,7 +35,7 @@ namespace WCS.Entity.Protocol.Station
         /// 指令类型
         /// </summary>
         [Description("指令类型")]
-        CmdTypeEnum CmdType { get; set; }
+        short CmdType { get; set; }
 
         /// <summary>
         /// 凭证号 每次累加

+ 1 - 1
WCS.Entity.Protocol/Station/IStation521.cs

@@ -35,7 +35,7 @@ namespace WCS.Entity.Protocol.Station
         /// 指令回复
         /// </summary>
         [Description("指令回复")]
-        CmdReplyEnum CmdType { get; set; }
+        short CmdType { get; set; }
 
         /// <summary>
         /// 凭证号 每次累加

+ 1 - 174
WCS.Entity.Protocol/Station/StationEnum.cs

@@ -2,180 +2,7 @@
 
 namespace WCS.Entity.Protocol.Station
 {
-    /// <summary>
-    /// 指令类型
-    /// </summary>
-    [Flags]
-    public enum CmdTypeEnum : ushort
-    {
-        /// <summary>
-        /// AGV放货请求
-        /// </summary>
-        AGV_PUT_ASK = 1 << 0,
-
-        /// <summary>
-        /// AGV放货运行
-        /// </summary>
-        AGV_PUT_RUN = 1 << 1,
-
-        /// <summary>
-        /// AGV放货完成
-        /// </summary>
-        AGV_PUT_OK = 1 << 2,
-
-        /// <summary>
-        /// AGV取货请求
-        /// </summary>
-        AGV_GET_ASK = 1 << 3,
-
-        /// <summary>
-        /// AGV取货运行
-        /// </summary>
-        AGV_GET_RUN = 1 << 4,
-
-        /// <summary>
-        /// AGV取货完成
-        /// </summary>
-        AGV_GET_OK = 1 << 5,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES1 = 1 << 6,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES2 = 1 << 7,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES3 = 1 << 8,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES4 = 1 << 9,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES5 = 1 << 10,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES6 = 1 << 11,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES7 = 1 << 12,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES8 = 1 << 13,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES9 = 1 << 14,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES10 = 1 << 15,
-    }
-
-    /// <summary>
-    /// 指令回复
-    /// </summary>
-    [Flags]
-    public enum CmdReplyEnum : ushort
-    {
-        /// <summary>
-        /// CONV允许接货
-        /// </summary>
-        CONV_PUT_ALLOW = 1 << 0,
-
-        /// <summary>
-        /// CONV接货完成
-        /// </summary>
-        CONV_PUT_ACK = 1 << 1,
-
-        /// <summary>
-        /// CONV运行取货
-        /// </summary>
-        CONV_GET_ALLOW = 1 << 2,
-
-        /// <summary>
-        /// CONV取货完成确认
-        /// </summary>
-        CONV_GET_ACK = 1 << 3,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES11 = 1 << 4,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES12 = 1 << 5,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES1 = 1 << 6,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES2 = 1 << 7,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES3 = 1 << 8,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES4 = 1 << 9,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES5 = 1 << 10,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES6 = 1 << 11,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES7 = 1 << 12,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES8 = 1 << 13,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES9 = 1 << 14,
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        RES10 = 1 << 15,
-    }
-
+    
     /// <summary>
     /// 输送机模式
     /// </summary>

+ 0 - 54
WCS.Entity.Protocol/Station/WCS_Station520.cs

@@ -1,54 +0,0 @@
-using System.ComponentModel;
-using System.Runtime.Serialization;
-
-namespace WCS.Entity.Protocol.Station
-{
-    /// <summary>
-    /// 站台交互信号 写记录表
-    /// </summary>
-    [DataContract]
-    public class WCS_Station520 : WCS_PROTOCOLDATA, IStation520
-    {
-        /// <summary>
-        /// 任务号
-        /// </summary>
-        [Description("任务号")]
-        [DataMember(Order = 0)]
-        public int TaskNumber { get; set; }
-
-        /// <summary>
-        /// 起始地址
-        /// </summary>
-        [Description("起始地址")]
-        [DataMember(Order = 1)]
-        public short GoodsStart { get; set; }
-
-        /// <summary>
-        /// 目标地址
-        /// </summary>
-        [Description("目标地址")]
-        [DataMember(Order = 2)]
-        public short GoodsEnd { get; set; }
-
-        /// <summary>
-        /// 运行模式
-        /// </summary>
-        [Description("运行模式")]
-        [DataMember(Order = 3)]
-        public ModeEunm Mode { get; set; }
-
-        /// <summary>
-        /// 指令类型
-        /// </summary>
-        [Description("指令类型")]
-        [DataMember(Order = 4)]
-        public CmdTypeEnum CmdType { get; set; }
-
-        /// <summary>
-        /// 凭证号
-        /// </summary>
-        [Description("凭证号")]
-        [DataMember(Order = 5)]
-        public short VoucherNo { get; set; }
-    }
-}

+ 0 - 58
WCS.Entity.Protocol/Station/WCS_Station521.cs

@@ -1,58 +0,0 @@
-using System.ComponentModel;
-using System.Runtime.Serialization;
-
-namespace WCS.Entity.Protocol.Station
-{
-    [DataContract]
-    public class WCS_Station521 : WCS_PROTOCOLDATA, IStation521
-    {
-        /// <summary>
-        /// 任务号
-        /// </summary>
-        [Description("任务号")]
-        [DataMember(Order = 0)]
-        public int TaskNumber { get; set; }
-
-        /// <summary>
-        /// 起始地址
-        /// </summary>
-        [Description("起始地址")]
-        [DataMember(Order = 1)]
-        public short GoodsStart { get; set; }
-
-        /// <summary>
-        /// 目标地址
-        /// </summary>
-        [Description("目标地址")]
-        [DataMember(Order = 2)]
-        public short GoodsEnd { get; set; }
-
-        /// <summary>
-        /// 运行模式
-        /// </summary>
-        [Description("运行模式")]
-        [DataMember(Order = 3)]
-        public ModeEunm Mode { get; set; }
-
-        /// <summary>
-        /// 指令回复
-        /// </summary>
-        [Description("指令回复")]
-        [DataMember(Order = 4)]
-        public CmdReplyEnum CmdType { get; set; }
-
-        /// <summary>
-        /// 凭证号
-        /// </summary>
-        [Description("凭证号")]
-        [DataMember(Order = 5)]
-        public short VoucherNo { get; set; }
-
-        /// <summary>
-        /// 请求
-        /// </summary>
-        [Description("请求")]
-        [DataMember(Order = 6)]
-        short IStation521.Request { get; set; }
-    }
-}

+ 0 - 35
WCS.Entity.Protocol/Station/WCS_Station523.cs

@@ -1,35 +0,0 @@
-using System.Runtime.Serialization;
-
-namespace WCS.Entity.Protocol.Station
-{
-    /// <summary>
-    /// 站台状态读取记录表
-    /// </summary>
-    [DataContract]
-    public class WCS_Station523 : WCS_PROTOCOLDATA, IStation523
-    {
-        /// <summary>
-        /// 警报
-        /// </summary>
-        [DataMember(Order = 0)]
-        public AlarmEunm Alarm { get; set; }
-
-        /// <summary>
-        /// 备用
-        /// </summary>
-        [DataMember(Order = 1)]
-        public short RES { get; set; }
-
-        /// <summary>
-        /// 状态
-        /// </summary>
-        [DataMember(Order = 2)]
-        public StatusEunm Status { get; set; }
-
-        /// <summary>
-        /// 运行时间
-        /// </summary>
-        [DataMember(Order = 3)]
-        public float RunTime { get; set; }
-    }
-}

+ 0 - 35
WCS.Entity.Protocol/Station/WCS_Station91.cs

@@ -1,35 +0,0 @@
-using System.Runtime.Serialization;
-
-namespace WCS.Entity.Protocol.Station
-{
-    /// <summary>
-    /// 外检读取数据
-    /// </summary>
-    [DataContract]
-    public class WCS_Station91 : WCS_PROTOCOLDATA, IStation91
-    {
-        /// <summary>
-        /// 外检故障
-        /// </summary>
-        [DataMember(Order = 0)]
-        public ShapeAlarmEunm ShapeAlarm { get; set; }
-
-        /// <summary>
-        /// 重量
-        /// </summary>
-        [DataMember(Order = 1)]
-        public float Weight { get; set; }
-
-        /// <summary>
-        /// 长度
-        /// </summary>
-        [DataMember(Order = 2)]
-        public float Length { get; set; }
-
-        /// <summary>
-        /// 宽度
-        /// </summary>
-        [DataMember(Order = 3)]
-        public float Width { get; set; }
-    }
-}

+ 13 - 13
WCS.Service/Worker.cs

@@ -114,19 +114,19 @@ namespace WCS.Service
                             break;
 
                         case "WCSDlog"://WCSÈÕÖ¾Êý¾Ý¿â
-                            SqlSugarHelper.SetDlog(connectionString.Key);
-                            _db.DbMaintenance.CreateDatabase();
-                            _db.CodeFirst.InitTables(typeof(WCS_BCR80));
-                            //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV520));
-                            //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV521));
-                            //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV523));
-                            //_db.CodeFirst.InitTables(typeof(WCS_SRM520));
-                            //_db.CodeFirst.InitTables(typeof(WCS_SRM521));
-                            //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_SRM537));
-                            _db.CodeFirst.InitTables(typeof(WCS_Station520));
-                            _db.CodeFirst.InitTables(typeof(WCS_Station521));
-                            _db.CodeFirst.InitTables(typeof(WCS_Station523));
-                            _db.CodeFirst.InitTables(typeof(WCS_Station91));
+                            //SqlSugarHelper.SetDlog(connectionString.Key);
+                            //_db.DbMaintenance.CreateDatabase();
+                            //_db.CodeFirst.InitTables(typeof(WCS_BCR80));
+                            ////db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV520));
+                            ////db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV521));
+                            ////db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV523));
+                            ////_db.CodeFirst.InitTables(typeof(WCS_SRM520));
+                            ////_db.CodeFirst.InitTables(typeof(WCS_SRM521));
+                            ////db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_SRM537));
+                            //_db.CodeFirst.InitTables(typeof(WCS_Station520));
+                            //_db.CodeFirst.InitTables(typeof(WCS_Station521));
+                            //_db.CodeFirst.InitTables(typeof(WCS_Station523));
+                            //_db.CodeFirst.InitTables(typeof(WCS_Station91));
 
                             break;
 

+ 42 - 0
WCS.WorkEngineering/Extensions/FlagExtension.cs

@@ -0,0 +1,42 @@
+using WCS.Core;
+
+namespace WCS.WorkEngineering.Extensions
+{
+    /// <summary>
+    ///  设备标签扩展
+    /// </summary>
+    public static class DeviceFlagExtension
+    {
+        /// <summary>
+        ///  获取指定设备标签的值
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="device"></param>
+        /// <param name="key"></param>
+        /// <returns></returns>
+        public static T GetFlag<T>(this Device device, string key)
+        {
+            if (!device.HasFlag(key))
+            {
+                if (typeof(T) == typeof(int)) device.AddFlag(key, default(int).ToString());
+                else if (typeof(T) == typeof(short)) device.AddFlag(key, default(bool).ToString());
+                else if (typeof(T) == typeof(bool)) device.AddFlag(key, default(bool).ToString());
+            }
+            var valeu = device.GetFlags(key).FirstOrDefault();
+
+            return (T)Convert.ChangeType(valeu, typeof(T));
+        }
+
+        /// <summary>
+        ///  设置指定设备标签的值
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="device"></param>
+        /// <param name="key"></param>
+        /// <returns></returns>
+        public static void SetFlag<T>(this Device device, string key, T value)
+        {
+            device.SetFlag(key, value.ToString());
+        }
+    }
+}

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

@@ -6,6 +6,7 @@ using System.ComponentModel;
 using WCS.Core;
 using WCS.Entity;
 using WCS.Entity.Protocol.DataStructure;
+using WCS.Entity.Protocol.Station;
 using WCS.Service.Worlds;
 using WCS.WorkEngineering.Extensions;
 
@@ -22,7 +23,7 @@ namespace WCS.Service.Systems
 
         public DataCollectionSysyem()
         {
-            ConvList = Device.All.Where(v => v.IsConv()).Select(v => new Station(v, this.World)).ToList();
+            ConvList = Device.All.Where(v => v.HasProtocol(typeof(IStation520))).Select(v => new Station(v, this.World)).ToList();
         }
 
         protected override bool Do(bool obj)

+ 62 - 13
WCS.WorkEngineering/Systems/SrmSystems.cs

@@ -1,4 +1,4 @@
-using ServiceCenter;
+using PlcSiemens.Core.Extension;
 using ServiceCenter.Extensions;
 using ServiceCenter.SqlSugars;
 using System.ComponentModel;
@@ -35,19 +35,18 @@ namespace WCS.WorkEngineering.Systems
 
         public SrmSystems()
         {
-            var devices = Device.All.Where(v => v.HasFlag(DeviceFlags.巷道口));
-            PickUpDevices = devices.Where(v => v.HasFlag(DeviceFlags.入库)).Select(v => new Station(v, this.World)).ToList();
             //获取所有的巷道集合
+            var devices = Device.All.Where(v => v.HasFlag(DeviceFlags.巷道));
 
             //开始分配
             foreach (var item in devices)
             {
                 //取货设备
-                var deviceCode = item;
-                PickUpDevices.Add(item.NextRoutes.First().DeviceCode, Device.All.Where(v => deviceCode.Contains(v.Code)).Select(v => new Station(v, this.World)).ToList());
+                var srm = item.Targets.Where(v => v.HasFlag(DeviceFlags.堆垛机)).FirstOrDefault();
+                PickUpDevices.Add(srm.Code, item.Targets.Where(v => v.HasFlag(DeviceFlags.输送机)).Select(v => new Station(v, this.World)).ToList());
                 //放货设备
-                deviceCode = ServiceHub.deviceInfos.First(x => item.NextRoutes.First().DeviceCode == x.Code).NextRoutes.Select(v => v.NextCode).ToList();
-                PutDevices.Add(item.NextRoutes.First().DeviceCode, Device.All.Where(v => deviceCode.Contains(v.Code)).Select(v => new Station(v, this.World)).ToList());
+                srm = item.Sources.Where(v => v.HasFlag(DeviceFlags.堆垛机)).FirstOrDefault();
+                PutDevices.Add(srm.Code, item.Sources.Where(v => v.HasFlag(DeviceFlags.堆垛机)).Select(v => new Station(v, this.World)).ToList());
             }
         }
 
@@ -181,16 +180,16 @@ namespace WCS.WorkEngineering.Systems
             #region 出入库
 
             //上一个周期是不是出库任务 第一次获取返回结果会是false
-            var lastIsOut = obj.Entity.GetFlag("LastIsOut").ToInt();
-            obj.Entity.Set("LastIsOut", !lastIsOut);
+            var lastIsOut = obj.Entity.GetFlag<bool>("LastIsOut");
+            obj.Entity.SetFlag("LastIsOut", !lastIsOut);
 
             //入库任务优先 或 上一个周期是出库任务并且出库任务无优先
             if (enterOrOut == 2 || (lastIsOut && enterOrOut == 1)) //入库任务
             {
                 //判断本次优先执行楼层,并设置下次执行时优先楼层
-                var floor = obj.Entity.Get<int>("FloorIn");
+                var floor = obj.Entity.GetFlag<int>("FloorIn");
                 floor = floor % 2 + 1;
-                obj.Entity.Set("FloorIn", floor);
+                obj.Entity.SetFlag("FloorIn", floor);
 
                 //获取当前堆垛机所有的取货站台
                 var arrIn = PickUpDevices.First(v => v.Key == obj.Entity.Code).Value;
@@ -234,9 +233,9 @@ namespace WCS.WorkEngineering.Systems
             else if (enterOrOut == 3 || !lastIsOut) //出库任务
             {
                 //判断本次优先执行楼层,并设置下次执行时优先楼层
-                var floor = obj.Entity.Get<int>("FloorOut");
+                var floor = obj.Entity.GetFlag<int>("FloorOut");
                 floor = floor % 2 + 1;
-                obj.Entity.Set("FloorOut", floor);
+                obj.Entity.SetFlag("FloorOut", floor);
 
                 //获取当前堆垛机所有的取货站台
                 var arrOut = PickUpDevices.First(v => v.Key == obj.Entity.Code).Value;
@@ -289,4 +288,54 @@ namespace WCS.WorkEngineering.Systems
             return dev.Code.Contains("SRM");
         }
     }
+
+    ///// <summary>
+
+    ///// 用于检查IP地址或域名是否可以使用TCP/IP协议访问(使用Ping命令),true表示Ping成功,false表示Ping失败
+
+    ///// </summary>
+
+    ///// <param name="strIpOrDName">输入参数,表示IP地址或域名</param>
+
+    ///// <returns></returns>
+
+    //public static bool PingIpOrDomainName(string strIpOrDName)
+
+    //{
+    //    try
+
+    //    {
+    //        Ping objPingSender = new Ping();
+
+    //        PingOptions objPinOptions = new PingOptions();
+
+    //        objPinOptions.DontFragment = true;
+
+    //        string data = "";
+
+    //        byte[] buffer = Encoding.UTF8.GetBytes(data);
+
+    //        int intTimeout = 120;
+
+    //        PingReply objPinReply = objPingSender.Send(strIpOrDName, intTimeout, buffer, objPinOptions);
+
+    //        string strInfo = objPinReply.Status.ToString();
+
+    //        if (strInfo == "Success")
+
+    //        {
+    //            return true;
+    //        }
+    //        else
+
+    //        {
+    //            return false;
+    //        }
+    //    }
+    //    catch (Exception)
+
+    //    {
+    //        return false;
+    //    }
+    //}
 }

+ 2 - 1
WCS.WorkEngineering/Systems/StorageSysyem.cs

@@ -1,5 +1,6 @@
 using System.ComponentModel;
 using WCS.Core;
+using WCS.Entity.Protocol.BCR;
 using WCS.WorkEngineering.Extensions;
 using WCS.WorkEngineering.WebApi.Controllers;
 using WCS.WorkEngineering.Worlds;
@@ -21,7 +22,7 @@ namespace WCS.WorkEngineering.Systems
 
         public StorageSysyem()
         {
-            BCRS = Device.All.Where(v => v.IsBCR()).Select(v => new BCR(v, World)).ToList() as BCRList;
+            BCRS = Device.All.Where(v => v.HasProtocol(typeof(IBCR81))).Select(v => new BCR(v, World)).ToList() as BCRList;
         }
 
         public override void Do(Station obj)

+ 1 - 1
WCS.WorkEngineering/WorkStart.cs

@@ -28,7 +28,7 @@ namespace WCS.WorkEngineering
 
             foreach (var item in segmentInfo)
             {
-                for (int i = item.Start; i < item.End; i++)
+                for (int i = item.Start; i <= item.End; i++)
                 {
                     var conv = new Device(i.ToString());
                     conv.AddFlag(DeviceFlags.输送机);

+ 10 - 10
WCS.WorkEngineering/Worlds/NoInteractionWorld.cs

@@ -40,16 +40,16 @@ namespace WCS.WorkEngineering.Worlds
                 }
                 tasks.ForEach(task =>
                 {
-                    //获取堆垛机到目标地址的路径信息
-                    var path = ServiceHub.deviceInfos.First(v => v.Code == task.Device).Paths?
-                                                     .First(v => v.EndCode == task.AddrTo).Path?
-                                                     .Split("-");
-                    //开始处理
-                    task.SrmStation = path[1];
-                    task.AddrNext = path[2];
-                    task.Status = Entity.TaskStatus.WaitingToExecute;
-                    task.AddWCS_TASK_DTL(db, task.Device, $"初始化出库任务信息,放货站台:{task.SrmStation}、放货后下一个地址:{task.AddrNext}");
-                    db.Default.Updateable(task).AddQueue();
+                    ////获取堆垛机到目标地址的路径信息
+                    //var path = ServiceHub.deviceInfos.First(v => v.Code == task.Device).Paths?
+                    //                                 .First(v => v.EndCode == task.AddrTo).Path?
+                    //                                 .Split("-");
+                    ////开始处理
+                    //task.SrmStation = path[1];
+                    //task.AddrNext = path[2];
+                    //task.Status = Entity.TaskStatus.WaitingToExecute;
+                    //task.AddWCS_TASK_DTL(db, task.Device, $"初始化出库任务信息,放货站台:{task.SrmStation}、放货后下一个地址:{task.AddrNext}");
+                    //db.Default.Updateable(task).AddQueue();
                 });
                 db.Default.SaveQueues();
             });