|
12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace HBLConsole.Service
- {
- /// <summary>
- /// 上升沿操作类
- /// </summary>
- public class RTrig
- {
- private volatile static ConcurrentDictionary<string, RTrig> _Instance;
- public static RTrig GetInstance(string name)
- {
- 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;
- }
- }
- }
|