using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Xml.Serialization; namespace Aitex.Core.Util { /// /// 下降沿信号检测类 /// /// 设计目的: /// 用于信号下降沿事件检测 /// /// 使用场合: /// 系统输入数字信号,1->0跳变检测 /// public class F_TRIG { /// /// 构造函数 /// public F_TRIG() { Q = false; M = true; } /// /// 检测信号输入 /// public bool CLK { set { if (M != value && !value) Q = true; else Q = false; M = value; } get { return M; } } //clear public bool RST { set { Q = false; M = true; } } /// /// 检测结果输出 /// [XmlIgnore] public bool Q { get; private set; } /// /// 记录上一次输入信号值 /// [XmlIgnore] public bool M { get; private set; } } /// /// 上升沿信号检测类 /// /// 设计目的: /// 用于信号上升沿事件检测 /// /// 使用场合: /// 系统输入数字信号,0->1跳变检测 /// public class R_TRIG { /// /// 构造函数 /// public R_TRIG() { Q = false; M = false; } /// /// 检测信号输入 /// public bool CLK { set { if (M != value && value) Q = true; else Q = false; M = value; } get { return M; } } public bool RST { set { Q = false; M = false; } } /// /// 检测结果输出 /// [XmlIgnore] public bool Q { get; private set; } /// /// 记录上一次输入信号值 /// [XmlIgnore] public bool M { get; private set; } } /// /// 边沿信号检测类 /// /// 设计目的: /// 用于信号上升沿/下降沿事件检测 /// /// 使用场合: /// 初始值为0 /// 系统输入数字信号,0->1跳变检测 Q 触发 /// 1->0 R /// public class RD_TRIG { /// /// 构造函数 /// public RD_TRIG() { R = false; T = false; M = false; } /// /// 检测信号输入 /// public bool CLK { set { if (M != value) { R = value; T = !value; } else { R = false; T = false; } M = value; } get { return M; } } public bool RST { set { R = false; T = false; M = false; } } /// /// 检测结果输出, 上升沿触发 rising edge /// [XmlIgnore] public bool R { get; private set; } /// /// 检测结果输出, 下降沿触发 trailing edge /// [XmlIgnore] public bool T { get; private set; } /// /// 记录上一次输入信号值 /// [XmlIgnore] public bool M { get; private set; } } }