using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Text; namespace BPASmartClient.Helper { /// /// 下降沿操作 /// public class TTrig { private volatile static ConcurrentDictionary _Instance; public static TTrig GetInstance(string name) { if (_Instance == null) _Instance = new ConcurrentDictionary(); if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new TTrig()); return _Instance[name]; } private TTrig() { } private bool flag1; public bool Q { get; private set; } private bool IN1 { set { Q = !value && flag1; flag1 = value; } } public bool Start(bool IN) { IN1 = IN; return Q; } } }