终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

44 Zeilen
1.1 KiB

  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. }