Пример #1
0
        /// <summary>触发次数置0</summary>
        void OnResetTrigTimesButtonClick(object sender, EventArgs e)
        {
            if (null == _module)
            {
                MessageBox.Show("无效操作,模块对象未设置(空值)");
                return;
            }

            for (int i = 0; i < _module.TrigChannels; i++)
            {
                if (sender == lstResetTimeBts[i])
                {
                    int err = _module.ResetTriggedCount(i);
                    if (0 != err)
                    {
                        MessageBox.Show(string.Format("触发通道{0} 次数置0失败,错误信息:{1}", i, _module.GetErrorInfo(err)));
                        return;
                    }
                    else
                    {
                        ShowTips(string.Format("触发通道{0} 次数置0完成", i));
                    }
                }
            }
            UpdateModuleStatus();
        }
Пример #2
0
        /// <summary>将触发次数置0</summary>
        private void btResetCnt_Click(object sender, EventArgs e)
        {
            if (null == _module)
            {
                MessageBox.Show("触发次数归0失败!触发器对象未设置(空值)");
                return;
            }
            if (_encChn < 0 || _encChn >= _module.EncoderChannels)
            {
                MessageBox.Show(string.Format("触发次数归0失败!编码器通道序号 ={0} 超出范围0~{1}", _encChn, _module.EncoderChannels - 1));
                return;
            }
            string errInfo = "";

            int[] trigChns = null;
            int   err      = _module.GetEncoderTrigBind(_encChn, out trigChns);//一个编码器输入可能会绑定多个触发输出

            if (err != 0)
            {
                errInfo = _id + " 触发次数归0失败,Error:" + _module.GetErrorInfo(err);
                if (null != OnTxtMsg)
                {
                    OnTxtMsg(errInfo);
                }
                else
                {
                    MessageBox.Show(errInfo);
                }
                return;
            }
            bool isErrorHappend = false;

            for (int i = 0; i < trigChns.Length; i++)
            {
                err = _module.ResetTriggedCount(trigChns[i]);
                if (err != 0)
                {
                    isErrorHappend = true;
                    errInfo       += string.Format("TrigChan = {0} 次数置0失败:{1}", trigChns[i], _module.GetErrorInfo(err));
                }
            }
            UpdateChnStatus();
            if (!isErrorHappend)
            {
                OnTxtMsg?.Invoke(_id + "置0 完成");
                return;
            }
            else
            {
                if (null != OnTxtMsg)
                {
                    OnTxtMsg(_id + "置0失败! " + errInfo);
                }
                else
                {
                    MessageBox.Show(_id + "置0失败! " + errInfo);
                }
            }
        }