Пример #1
0
        public static int Initialize(CounterMode mode, out int index)
        {
            int idx = 0;
            var ret = lowLevel.HAL_InitializeCounter(mode, &idx);

            index = idx;
            return(ret);
        }
Пример #2
0
 public void SetMode(CounterMode mode)
 {
     if (State == CounterState.Working)
     {
         throw new Exception("Нельзя изменить способ подсчёта во время работы счётчика");
     }
     Mode = mode;
 }
Пример #3
0
        /// <summary>
        /// 创建时间计数器.
        /// </summary>
        /// <param name="iMaxValue">计数器最大值.</param>
        /// <param name="iOnCountOver">超过计时回调函数.</param>
        /// <param name="iMode">模式(默认为:倒计时).</param>
        public static TimeCounter Create(
            float iMaxValue,
            System.Action <float, float> iOnCountOver = null,
            CounterMode iMode = CounterMode.CountDown)
        {
            var objRet = new TimeCounter();

            objRet.InitCounter(iMaxValue, CounterType.TimeCounter, iMode);
            if (iOnCountOver != null)
            {
                objRet.OnCounterUpdated += iOnCountOver;
            }
            return(objRet);
        }
Пример #4
0
        /// <summary>
        /// Initialize a new <see cref="Counter"/> instance with the given parameters.
        /// </summary>
        /// <param name="name">The name of the counter.</param>
        /// <param name="description">The description of the counter.</param>
        /// <param name="mode">The mode of the counter sampling.</param>
        /// <param name="displayType">The default display mode for the counter.</param>
        public Counter(string name, string description, CounterMode mode, CounterDisplayType displayType)
        {
            this.Mode        = mode;
            this.Name        = name;
            this.Description = description;

            // HACK
            this.Mode = CounterMode.Historical;

            if (this.Mode == CounterMode.Historical)
            {
                this.History = new CircularList <double>(CounterHistorySize, true);
            }
            this.DisplayType = displayType;
        }
Пример #5
0
        public Counter(int number, CounterMode mode, string file, int speed1 = 250, int speed2 = 500)
        {
            State           = CounterState.Ready;
            Mode            = mode;
            Number          = number;
            File            = file;
            sw              = new StreamWriter(File);
            OddThreadSpeed  = speed1;
            EvenThreadSpeed = speed2;

            oddThread     = new Thread(new ThreadStart(Odd));
            evenThread    = new Thread(new ThreadStart(Even));
            oddThreadNum  = 1;
            evenThreadNum = 2;
            firstTurn     = true;
        }
Пример #6
0
        public CTSetup(CTChannel AIMyPanel)
        {
            m_CTPanel = AIMyPanel;
            InitializeComponent();
            rbIncremental.Enabled = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.INCREMENTALCOUNTER);
            rbIncExtFlow.Enabled  = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.INCEEXTFLOWRATE);
            rbIncExtTime.Enabled  = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.INCEEXTTIMESTAMP);


            rbImpulse.Enabled    = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.IMPULSECOUNTER);
            rbFreq.Enabled       = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.FREQUENCYCOUNTER);
            rbPeriod.Enabled     = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.PERIODCOUNTER);
            rbPulsewidth.Enabled = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.PULSEWIDTHCOUNTER);


            rbUpDown.Enabled         = m_CTPanel.Channel.IsCounterModeAvailable(CounterMode.UPDOWNCOUNTER);
            checkBoxSyncToAD.Enabled = m_CTPanel.Channel.MyDevice.IsDSPDevice;
            Mode = m_CTPanel.Mode;
            checkBoxSyncToAD.Checked = m_CTPanel.ADSync;
        }
Пример #7
0
 /// <summary>
 /// 初始化计数器.
 /// </summary>
 /// <param name="iMaxValue">最大值.</param>
 /// <param name="iType">类型.</param>
 /// <param name="iMode">模式.</param>
 /// <param name="iInterval">更新时间间隔(单位:100毫微秒).</param>
 public abstract void InitCounter(
     T iMaxValue, CounterType iType,
     CounterMode iMode = CounterMode.CountDown,
     long iInterval    = 0L);
Пример #8
0
 /// <summary>
 /// Initialize a new <see cref="Counter"/> instance with the given parameters.
 /// </summary>
 /// <param name="name">The name of the counter.</param>
 /// <param name="description">The description of the counter.</param>
 /// <param name="mode">The mode of the counter sampling.</param>
 public Counter(string name, string description, CounterMode mode)
     : this(name, description, mode, CounterDisplayType.LastValue)
 {
 }
Пример #9
0
 private void rbGrouShuffle_CheckedChanged(object sender, EventArgs e) => _currentMode = CounterMode.GroupShuffle;
Пример #10
0
 private void rbReverseQueue_CheckedChanged(object sender, EventArgs e) => _currentMode = CounterMode.ReverseQueue;
Пример #11
0
 private void rbAll_CheckedChanged(object sender, EventArgs e) => _currentMode = CounterMode.All;
Пример #12
0
        /// <summary>
        /// Initialize a new <see cref="Counter"/> instance with the given parameters.
        /// </summary>
        /// <param name="name">The name of the counter.</param>
        /// <param name="description">The description of the counter.</param>
        /// <param name="mode">The mode of the counter sampling.</param>
        /// <param name="displayType">The default display mode for the counter.</param>
        public Counter( string name, string description, CounterMode mode, CounterDisplayType displayType )
        {
            this.Mode = mode;
            this.Name = name;
            this.Description = description;

            // HACK
            this.Mode = CounterMode.Historical;

            if( this.Mode == CounterMode.Historical )
                this.History = new CircularList<double>( CounterHistorySize, true );
            this.DisplayType = displayType;
        }
Пример #13
0
 /// <summary>
 /// Initialize a new <see cref="Counter"/> instance with the given parameters.
 /// </summary>
 /// <param name="name">The name of the counter.</param>
 /// <param name="description">The description of the counter.</param>
 /// <param name="mode">The mode of the counter sampling.</param>
 public Counter( string name, string description, CounterMode mode )
     : this(name, description, mode, CounterDisplayType.LastValue)
 {
 }