终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
1.1 KiB

  1. using System;
  2. using System.Collections.Concurrent;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.Helper
  8. {
  9. /// <summary>
  10. /// 上升沿操作类
  11. /// </summary>
  12. public class RTrig
  13. {
  14. private volatile static ConcurrentDictionary<string, RTrig> _Instance;
  15. private static readonly object Lock = new object();
  16. public static RTrig GetInstance(string name)
  17. {
  18. lock (Lock)
  19. {
  20. if (_Instance == null) _Instance = new ConcurrentDictionary<string, RTrig>();
  21. if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new RTrig());
  22. return _Instance[name];
  23. }
  24. }
  25. private RTrig() { }
  26. private bool flag1;
  27. public bool Q { get; private set; }
  28. private bool IN1
  29. {
  30. set
  31. {
  32. Q = value && !flag1;
  33. flag1 = value;
  34. }
  35. }
  36. public bool Start(bool IN)
  37. {
  38. IN1 = IN;
  39. return Q;
  40. }
  41. }
  42. }