Example #1
0
        /// <summary>软触发按钮</summary>
        private void btSoftTrig_Click(object sender, EventArgs e)
        {
            if (null == _module)
            {
                MessageBox.Show("软触发失败!触发器对象未设置(空值)");
                return;
            }
            if (_encChn < 0 || _encChn >= _module.EncoderChannels)
            {
                MessageBox.Show(string.Format("软触发失败!编码器通道序号 ={0} 超出范围0~{1}", _encChn, _module.EncoderChannels - 1));
                return;
            }
            string errInfo = "";

            int[] trigChn = null;
            int   err     = _module.GetEncoderTrigBind(_encChn, out trigChn);

            if (err != 0)
            {
                errInfo = _id + " 软触发失败,Error:" + _module.GetErrorInfo(err);
                if (null != OnTxtMsg)
                {
                    OnTxtMsg(errInfo);
                }
                else
                {
                    MessageBox.Show(errInfo);
                }
                return;
            }
            err = _module.SoftTrigge(trigChn);
            if (err != 0)
            {
                errInfo = _id + " 软触发失败,Error:" + _module.GetErrorInfo(err);
                if (null != OnTxtMsg)
                {
                    OnTxtMsg(errInfo);
                }
                else
                {
                    MessageBox.Show(errInfo);
                }
                return;
            }
            errInfo = _id + " 软触发OK!输出通道:";
            for (int i = 0; i < trigChn.Length; i++)
            {
                errInfo = errInfo + trigChn[i].ToString();
                if (i < trigChn.Length - 1)
                {
                    errInfo = errInfo + "|";
                }
            }
            OnTxtMsg?.Invoke(errInfo);
            UpdateChnStatus();
        }