终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TTrig.cs 1.1 KiB

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