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