using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;

namespace BPASmartClient.Helper
{
    /// <summary>
    /// 下降沿操作
    /// </summary>
    public class TTrig
    {
        private volatile static ConcurrentDictionary<string, TTrig> _Instance;
        public static TTrig GetInstance(string name)
        {
            if (_Instance == null) _Instance = new ConcurrentDictionary<string, TTrig>();
            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;
        }

    }
}
