eqpData.cs 1013 B

1234567891011121314151617181920212223242526272829303132
  1. using FreeRedis;
  2. using System;
  3. using WCS.Entity.Protocol;
  4. namespace WCS_Client
  5. {
  6. public static class eqpData
  7. {
  8. public static DeviceDataPack deviceDataPack { get; set; } = null;
  9. private static System.Timers.Timer _timer;
  10. public static RedisClient Redis = null;
  11. public static void init(RedisClient redis)
  12. {
  13. Redis = redis;
  14. _timer = new System.Timers.Timer(5000);
  15. _timer.Elapsed += new System.Timers.ElapsedEventHandler(GetData);//到达时间的时候执行事件;
  16. _timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
  17. _timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
  18. }
  19. public static void GetData(object sender, EventArgs e)
  20. {
  21. try
  22. {
  23. deviceDataPack = Redis.Get<DeviceDataPack>("DeviceDataPack");
  24. }
  25. catch (Exception ex) {
  26. }
  27. }
  28. }
  29. }