DataCollectionSysyem.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using DBHelper;
  2. using Newtonsoft.Json;
  3. using System.ComponentModel;
  4. using WCS.Core;
  5. using WCS.Entity;
  6. using WCS.Entity.Protocol.Station;
  7. using WCS.Service.Worlds;
  8. using WCS.WorkEngineering.Extensions;
  9. namespace WCS.Service.Systems
  10. {
  11. /// <summary>
  12. /// 数据采集系统
  13. /// </summary>
  14. [BelongTo(typeof(DataCollectionWorld))]
  15. [Description("数据采集系统")]
  16. public class DataCollectionSysyem : ServiceSystem<bool, bool>
  17. {
  18. public List<Device<IStation520, IStation521>> ConvList;
  19. public DataCollectionSysyem()
  20. {
  21. ConvList = World.Devices.Where(v => v.IsConv()).Select(v => new Device<IStation520, IStation521>(v)).ToList();
  22. }
  23. protected override bool Do(bool obj)
  24. {
  25. Db.Do(db =>
  26. {
  27. var plcData = new WCS_PlcData()
  28. {
  29. UPDATETIME = DateTime.Now,
  30. WAREHOUSE = "111",
  31. CONTENT = JsonConvert.SerializeObject(ConvList),
  32. };
  33. db.Default.Insertable<WCS_PlcData>(plcData).ExecuteCommand(); ;
  34. });
  35. return true;
  36. }
  37. }
  38. }