using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HBLConsole.Service { /// /// 上升沿操作类 /// public class RTrig { private volatile static ConcurrentDictionary _Instance; public static RTrig GetInstance(string name) { if (_Instance == null) _Instance = new ConcurrentDictionary(); if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new RTrig()); return _Instance[name]; } private RTrig() { } 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; } } }