|
@@ -1,5 +1,6 @@
|
|
|
using Newtonsoft.Json;
|
|
|
using ServiceCenter;
|
|
|
+using ServiceCenter.Extensions;
|
|
|
using ServiceCenter.Helpers;
|
|
|
using ServiceCenter.SqlSugars;
|
|
|
using System.ComponentModel;
|
|
@@ -20,10 +21,12 @@ namespace WCS.Service.Systems
|
|
|
public class DataCollectionSysyem : DeviceSystem<SRM>
|
|
|
{
|
|
|
public List<Station> ConvList;
|
|
|
+ public List<Device<IStation91>> Conv91List;
|
|
|
|
|
|
public DataCollectionSysyem()
|
|
|
{
|
|
|
ConvList = Device.All.Where(v => v.HasProtocol(typeof(IStation523))).Select(v => new Station(v, this.World)).ToList();
|
|
|
+ Conv91List = Device.All.Where(v => v.HasProtocol(typeof(IStation91))).Select(v => new Device<IStation91>(v, this.World)).ToList();
|
|
|
}
|
|
|
|
|
|
protected override bool ParallelDo => true;
|
|
@@ -40,22 +43,27 @@ namespace WCS.Service.Systems
|
|
|
SqlSugarHelper.Do(db =>
|
|
|
{
|
|
|
DeviceDataPack pack = new DeviceDataPack();
|
|
|
- pack.StationDatas = new DeviceDataCollection<StationData>();
|
|
|
- pack.StationDatas.Frame = DateTime.Now;
|
|
|
-
|
|
|
+ List<StationData> DevList = new List<StationData>();
|
|
|
foreach (var item in ConvList)
|
|
|
{
|
|
|
var dev = new StationData()
|
|
|
{
|
|
|
Code = item.Entity.Code,
|
|
|
Frame = DateTime.Now,
|
|
|
- D520 = item.Data as WCS_Station520,
|
|
|
- D521 = item.Data2 as WCS_Station521,
|
|
|
- D523 = item.Data3 as WCS_Station523,
|
|
|
-
|
|
|
+ D520 = TypeExtension.Mapper<WCS_Station520, IStation520>(item.Data),
|
|
|
+ D521 = TypeExtension.Mapper<WCS_Station521, IStation521>(item.Data2),
|
|
|
+ D523 = TypeExtension.Mapper<WCS_Station523, IStation523>(item.Data3),
|
|
|
+ D91 = new WCS_Station91()
|
|
|
};
|
|
|
- pack.StationDatas.Datas.Append(dev);
|
|
|
+ if (Conv91List.Any(v => v.Entity.Code == item.Entity.Code))
|
|
|
+ {
|
|
|
+ var d91 = Conv91List.First(v => v.Entity.Code == item.Entity.Code);
|
|
|
+ dev.D91 = TypeExtension.Mapper<WCS_Station91, IStation91>(d91.Data);
|
|
|
+ }
|
|
|
+ DevList.Add(dev);
|
|
|
}
|
|
|
+ pack.StationDatas = new DeviceDataCollection<StationData>(DateTime.Now, DevList.ToArray());
|
|
|
+
|
|
|
pack.Frame = DateTime.Now;
|
|
|
//pack.
|
|
|
|