|
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.Helper
- {
- /// <summary>
- /// 上升沿操作类
- /// </summary>
- public class RTrig
- {
- private volatile static ConcurrentDictionary<string, RTrig> _Instance;
- private static readonly object Lock = new object();
- public static RTrig GetInstance(string name)
- {
- lock (Lock)
- {
- if (_Instance == null) _Instance = new ConcurrentDictionary<string, RTrig>();
- 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;
- }
- }
- }
|