gkj 2 년 전
부모
커밋
c8132811ee
2개의 변경된 파일17개의 추가작업 그리고 36개의 파일을 삭제
  1. 17 7
      WCS.WorkEngineering/Systems/DataCollectionSysyem.cs
  2. 0 29
      WCS.WorkEngineering/Worlds/DataCollectionWorld.cs

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

@@ -17,7 +17,7 @@ namespace WCS.Service.Systems
     /// </summary>
     [BelongTo(typeof(DataCollectionWorld))]
     [Description("数据采集系统")]
-    public class DataCollectionSysyem : ServiceSystem<bool, bool>
+    public class DataCollectionSysyem : DeviceSystem<SRM>
     {
         public List<Station> ConvList;
 
@@ -26,7 +26,16 @@ namespace WCS.Service.Systems
             ConvList = Device.All.Where(v => v.HasProtocol(typeof(IStation523))).Select(v => new Station(v, this.World)).ToList();
         }
 
-        protected override bool Do(bool obj)
+        protected override bool ParallelDo => true;
+
+        protected override bool SaveLogsToFile => true;
+
+        public override bool Select(Device dev)
+        {
+            return dev.Code == "SRM1";
+        }
+
+        public override void Do(SRM obj)
         {
             SqlSugarHelper.Do(db =>
             {
@@ -36,15 +45,16 @@ namespace WCS.Service.Systems
 
                 foreach (var item in ConvList)
                 {
-                    pack.StationDatas.Datas.Append(new StationData()
+                    var dev = new StationData()
                     {
                         Code = item.Entity.Code,
                         Frame = DateTime.Now,
                         D520 = item.Data as WCS_Station520,
-                        D521 = item.Data as WCS_Station521,
-                        D523 = item.Data as WCS_Station523,
+                        D521 = item.Data2 as WCS_Station521,
+                        D523 = item.Data3 as WCS_Station523,
 
-                    });
+                    };
+                    pack.StationDatas.Datas.Append(dev);
                 }
                 pack.Frame = DateTime.Now;
                 //pack.
@@ -65,7 +75,7 @@ namespace WCS.Service.Systems
 
                 db.Default.Insertable(plcData).ExecuteCommand();
             });
-            return true;
+
         }
     }
 }

+ 0 - 29
WCS.WorkEngineering/Worlds/DataCollectionWorld.cs

@@ -18,34 +18,5 @@ namespace WCS.Service.Worlds
         public DataCollectionWorld()
         {
         }
-
-        /// <summary>
-        /// 更新后执行,重写改方法后请自行添加执行内容
-        /// 执行内容:清空日志队列
-        /// </summary>
-        protected override void AfterUpdate()
-        {
-            #region 日志处理
-
-            //TODO:暂时仅将日志记录至文本文件
-            if (Logs.Count() > 0)
-            {
-                //var time = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:FF")}";
-                //var fst = Logs.First();
-                //var dir = $"Logs\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{fst.Channel.World}\\{fst.Channel.System}\\";
-                //if (!Directory.Exists(dir))
-                //    Directory.CreateDirectory(dir);
-
-                //foreach (var log in Logs)
-                //{
-                //    var msg = $"--------------------{log.Time}[{Thread.CurrentThread.ManagedThreadId}]--------------------\n{log}\n";
-                //    File.AppendAllText(Path.Combine(dir, $"{log.Log.Message.Split(":")[0]}.txt"), msg);
-                //}
-            }
-
-            #endregion 日志处理
-
-            World.GetSystemInstance<DataCollectionSysyem>().Invoke(true);
-        }
     }
 }