123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using DBHelper;
- using Newtonsoft.Json;
- using ServiceCenter.Helpers;
- using System.ComponentModel;
- using WCS.Core;
- using WCS.Entity;
- using WCS.Entity.Protocol.Station;
- using WCS.Service.Worlds;
- using WCS.WorkEngineering.Extensions;
- namespace WCS.Service.Systems
- {
- /// <summary>
- /// 数据采集系统
- /// </summary>
- [BelongTo(typeof(DataCollectionWorld))]
- [Description("数据采集系统")]
- public class DataCollectionSysyem : ServiceSystem<bool, bool>
- {
- public List<Device<IStation520, IStation521>> ConvList;
- public DataCollectionSysyem()
- {
- ConvList = World.Devices.Where(v => v.IsConv()).Select(v => new Device<IStation520, IStation521>(v)).ToList();
- }
- protected override bool Do(bool obj)
- {
- Db.Do(db =>
- {
- //byte[] bytes = System.Text.Encoding.Default.GetBytes(JsonConvert.SerializeObject(ConvList, null, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));
- var plcData = new WCS_PlcData()
- {
- UPDATETIME = DateTime.Now,
- WAREHOUSE = "111",
- CONTENT = JsonConvert.SerializeObject(ConvList, null, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }),
- };
- var a = TypeConversionHelper.SerializeRedisValue(ConvList);
- //对bytes进行数据压缩
- //plcData.CONTENT = bytes.Compress();
- db.Default.Insertable(plcData).ExecuteCommand(); ;
- });
- return true;
- }
- }
- }
|