林豪 左 hai 1 ano
pai
achega
2279235b8b

+ 6 - 17
WCS.WorkEngineering/Systems/DataCollectionSysyem.cs

@@ -27,7 +27,7 @@ namespace WCS.WorkEngineering.Systems
     /// </summary>
     [BelongTo(typeof(DataWorld))]
     [Description("数据采集系统")]
-    public class DataCollectionSysyem : DeviceSystem<Device<IStation520>>
+    public class DataCollectionSysyem : SystemBase
     {
         public static DeviceDataPack pack = new DeviceDataPack();
 
@@ -47,23 +47,12 @@ namespace WCS.WorkEngineering.Systems
             }
         }
 
-        /// <summary>
-        ///  所有设备数据
-        ///  Key 是不同设备所使用的类型 例如DeviceDataCollection<SRMData>
-        ///  value 不同设备的具体数据
-        /// </summary>
-        public static ConcurrentDictionary<string, DeviceData> AllDatas = new ConcurrentDictionary<string, DeviceData>();
-
-        protected override bool ParallelDo => true;
-
-        protected override bool SaveLogsToFile => true;
-
-        public override bool Select(Device dev)
+        public override List<object> GetObjects()
         {
-            return dev.Code == "1";
+            return new List<object>();
         }
 
-        public override void Do(Device<IStation520> objDev)
+        public override void Update(List<WorkTimes> list)
         {
             try
             {
@@ -100,7 +89,7 @@ namespace WCS.WorkEngineering.Systems
                                 {
                                     protObj.Frame = frame;
                                 }
-                                if (protObj.Db.failed)
+                                if (protObj.Db.Failed)
                                 {
                                     return;
                                 }
@@ -141,7 +130,7 @@ namespace WCS.WorkEngineering.Systems
 
                 //开始存储设备信息
                 RedisHub.Monitor.RPush("Packs", pack);
-                if (RedisHub.Monitor.LLen("Packs") > 100000)
+                if (RedisHub.Monitor.LLen("Packs") > 70000)
                 {
                     RedisHub.Monitor.LTrim("Packs", 5000, -1);
                 }

+ 19 - 16
WCS.WorkEngineering/Systems/MainSysyem.cs

@@ -27,22 +27,9 @@ namespace WCS.WorkEngineering.Systems
     /// </summary>
     [BelongTo(typeof(MainWorld))]
     [Description("数据处理")]
-    public class MainSysyem : DeviceSystem<Device<IStation520>>
+    public class MainSysyem : SystemBase
     {
-        public MainSysyem()
-        {
-        }
-
-        protected override bool ParallelDo => true;
-
-        protected override bool SaveLogsToFile => true;
-
-        public override bool Select(Device dev)
-        {
-            return dev.Code == "1";
-        }
-
-        public override void Do(Device<IStation520> objDev)
+        public override void Update(List<WorkTimes> list)
         {
             var sql = new StringBuilder();
             try
@@ -315,10 +302,21 @@ namespace WCS.WorkEngineering.Systems
                             {
                                 if (pack.Truss523.Any())
                                 {
-                                    var value = pack.Truss523.Select(x => x.Data).ToList();
+
+                                    var value = pack.Truss523.Select(x => new QuestDb_Truss523()
+                                    {
+                                        Alarm = Convert.ToString(x.Data.Alarm),
+                                        Code = x.Data.Code,
+                                        Frame = x.Data.Frame.ToLocalTime()
+                                    }).ToList();
                                     var sql = db.Insertable(value).ToSqlString();
                                     db.Ado.ExecuteCommand(sql);
                                     typeName = typeof(WCS_Truss523).Name;
+
+                                    //var value = pack.Truss523.Select(x => x.Data).ToList();
+                                    //var sql = db.Insertable(value).ToSqlString();
+                                    //db.Ado.ExecuteCommand(sql);
+                                    //typeName = typeof(WCS_Truss523).Name;
                                 }
                             }
                             else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss530>[]))
@@ -386,5 +384,10 @@ namespace WCS.WorkEngineering.Systems
                 .Replace("\0", "")
                 .Replace("(N'", "('") + "\r";
         }
+
+        public override List<object> GetObjects()
+        {
+            return new List<object>();
+        }
     }
 }

+ 3 - 4
WCS.WorkEngineering/WorkStart.cs

@@ -326,7 +326,7 @@ namespace WCS.WorkEngineering
                 conv.AddFlag(DeviceFlags.桁架);
                 conv.AddProtocol<ITruss520>(0, 520, item.Ip);
                 conv.AddProtocol<ITruss521>(0, 521, item.Ip);
-                conv.AddProtocol<ITruss523>(0, 523, item.Ip);
+                conv.AddProtocol<ITruss523>(0, 522, item.Ip);
             }
 
             var tuples1 = new List<Tuple<string, List<int>>>
@@ -363,7 +363,7 @@ namespace WCS.WorkEngineering
                 new("10.30.37.234",new  List<int>(){ 1696, 1691}), //库二北
                 new("10.30.37.236",new  List<int>(){ 1711, 1706}), //库二南
                 new("10.30.37.238",new  List<int>(){ 1726, 1721}), //库三北
-                new("10.30.37.240",new  List<int>(){ 1736, 1741}), //库三南
+                new("10.30.37.240",new  List<int>(){ 1741, 1736 }), //库三南
             };
 
             foreach (var item in tuples21)
@@ -470,7 +470,7 @@ namespace WCS.WorkEngineering
                             //_db.CodeFirst.InitTables<WCS_Station91>();
                             //_db.CodeFirst.InitTables<WCS_Truss520>();
                             //_db.CodeFirst.InitTables<WCS_Truss521>();
-                            //_db.CodeFirst.InitTables<WCS_Truss523>();
+                            // _db.CodeFirst.InitTables<QuestDb_Truss523>();
                             //_db.CodeFirst.InitTables<WCS_Truss530>();
                             //_db.CodeFirst.InitTables<WCS_Truss531>();
                             //_db.CodeFirst.InitTables<WCS_Robot520>();
@@ -478,7 +478,6 @@ namespace WCS.WorkEngineering
                             //_db.CodeFirst.InitTables<QuestDb_Robot522>();
                             //_db.CodeFirst.InitTables<WCS_Robot530>();
                             //_db.CodeFirst.InitTables<WCS_Robot531>();
-                            var a = false;
                             break;
 
                         default: //其他库

+ 26 - 3
WCS.WorkEngineering/Worlds/MainWorld.cs

@@ -1,6 +1,7 @@
 using ServiceCenter.Logs;
 using System.Collections.Concurrent;
 using System.ComponentModel;
+using System.Diagnostics;
 using WCS.Core;
 using LogInfo = ServiceCenter.Logs.LogInfo;
 
@@ -36,7 +37,7 @@ namespace WCS.WorkEngineering.Worlds
         ///  更新前执行,重写改方法后请自行添加执行内容
         ///  执行内容:清空日志队列
         /// </summary>
-        protected override void BeforeUpdate()
+        protected override void BeforeUpdate(List<WorkTimes> list)
         {
             // 清空日志队列,确保日志队列中只会有当前周期日志
             Logs.Clear();
@@ -46,9 +47,31 @@ namespace WCS.WorkEngineering.Worlds
         /// 更新后执行,重写改方法后请自行添加执行内容
         /// 执行内容:清空日志队列
         /// </summary>
-        protected override void AfterUpdate()
+        protected override void AfterUpdate(List<WorkTimes> list)
         {
-            LogHub.WorldPublish(Logs, this.GetType().Name);
+            ////LogHub.WorldPublish(Logs, this.GetType().Name);
+            ////通过异步处理,加快周期速度
+            //var wt = new WorkTimes
+            //{
+            //    Key = "更新后执行内容"
+            //};
+            //var sw = new Stopwatch();
+            //sw.Start();
+            //Task.Run(() =>
+            //{
+            //    try
+            //    {
+            //        LogHub.WorldPublish(Logs, this.GetType().Name);
+            //    }
+            //    catch (Exception e)
+            //    {
+            //        //Console.WriteLine(e);
+            //        //throw;
+            //    }
+            //}); //通过异步处理,加快周期速度
+            //sw.Stop();
+            //wt.Total = sw.ElapsedMilliseconds;
+            //list.AddSafe(wt);
         }
 
         /// <summary>