Esempio n. 1
0
        /// <summary>
        /// 软触发
        /// </summary>
        /// <param name="TrigChnName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public int SWPosTrig(string[] TrigChnName, out string errMsg)
        {
            IJFInitializable dev = null;
            JFDevCellInfo    ci  = null;

            errMsg = "";

            if (TrigChnName.Length == 0)
            {
                errMsg = "触发通道名称为空";
                return((int)ErrorDef.InvokeFailed);
            }

            int[] trigChns = new int[TrigChnName.Length];
            for (int i = 0; i < TrigChnName.Length; i++)
            {
                if (!JFCMFunction.CheckDevCellName(JFCMFunction.CmpTrig, TrigChnName[i], out dev, out ci, out errMsg))
                {
                    return((int)ErrorDef.InvokeFailed);
                }
                trigChns[i] = ci.ChannelIndex;
            }

            IJFModule_CmprTrigger md = (dev as IJFDevice_MotionDaq).GetCompareTrigger(ci.ModuleIndex);
            int errCode = md.SoftTrigge(trigChns);

            if (errCode != (int)ErrorDef.Success)
            {
                errMsg = md.GetErrorInfo(errCode);
                return(errCode);
            }
            return((int)ErrorDef.Success);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        public void AdjustView()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(AdjustView));
                return;
            }
            if (null == _module)
            {
                lbID.Text          = "空对象";
                tbEnc.Text         = "";
                tbTrigCount.Text   = "";
                btResetCnt.Enabled = false;
                cbMode.Text        = "";//cbMode.SelectedIndex = 0;
                cbMode.Enabled     = false;
                btSoftTrig.Enabled = false;
                btCfg.Enabled      = false;
                btSync.Enabled     = false;
                return;
            }
            lbID.Text = _id;
            double dVal = 0;
            int    err  = _module.GetEncoderCurrPos(_encChn, out dVal);

            if (err != 0)
            {
                tbEnc.Text = "Err:" + _module.GetErrorInfo(err);
            }
            else
            {
                tbEnc.Text = dVal.ToString();
            }
            int nVal = 0;

            int[] trigChns = null;
            err = _module.GetEncoderTrigBind(_encChn, out trigChns);//一个编码器输入可能会绑定多个触发输出
            if (err != 0)
            {
                tbTrigCount.Text = "Err:" + _module.GetErrorInfo(err);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < trigChns.Length; i++)
                {
                    int trigChn = trigChns[i];
                    err = _module.GetTriggedCount(trigChn, out nVal);
                    if (err != 0)
                    {
                        sb.Append("Err");
                    }
                    else
                    {
                        sb.Append(nVal.ToString());
                    }
                    if (i < trigChns.Length - 1)
                    {
                        sb.Append("|");
                    }
                }
                tbTrigCount.Text = sb.ToString();
            }
            btSync.Enabled     = true;
            btResetCnt.Enabled = true;
            cbMode.Enabled     = true;
            JFCompareTrigMode trigMode = JFCompareTrigMode.disable;

            err = _module.GetTrigMode(_encChn, out trigMode);
            if (err != 0)
            {
                cbMode.Text = "Err";
            }
            else
            {
                cbMode.SelectedIndex = (int)trigMode;
            }
            btSoftTrig.Enabled = true;
            btCfg.Enabled      = true;
        }
Esempio n. 3
0
        bool isChkEnableSetting = false; //主动更新CheckBox控件值
        //根据通道数量布置界面
        void AdjustUI()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(AdjustUI));
                return;
            }
            gbChns.Controls.Clear();
            gbTrigs.Controls.Clear();
            //lstTrigIdLbs.Clear();
            lstTrigEnableChks.Clear();
            lstTrigTimeTbs.Clear();
            lstResetTimeBts.Clear();
            lstSwTrigBts.Clear();
            if (null == _module)
            {
                ShowTips("模块对象为空");
                return;
            }
            int err = 0;
            int locX = 3, locY = 30;

            for (int i = 0; i < _module.EncoderChannels; i++)
            {
                UcCmprTrgChn ucChn = new UcCmprTrgChn();
                ucChn.OnTxtMsg += ShowTips;
                ucChn.Location  = new Point(locX, locY);
                string encName = _encChnIDs == null ? null : (_encChnIDs.Length > i ? _encChnIDs[i] : null);
                ucChn.SetModuleChn(_module, i, encName, _trigChnIDs);
                locY += ucChn.Height + 3;
                gbChns.Controls.Add(ucChn);
            }
            locY = 30;
            for (int i = 0; i < _module.TrigChannels; i++)
            {
                ///通道ID标签
                Label lbTrigID = new Label();
                lbTrigID.Text     = _trigChnIDs != null && (_trigChnIDs.Length > i) ? _trigChnIDs[i] : ("通道_" + i.ToString());
                lbTrigID.Location = new Point(3, locY + 5);
                lbTrigID.Width    = 100;
                gbTrigs.Controls.Add(lbTrigID);
                ///通道使能
                CheckBox chkEnable = new CheckBox();
                chkEnable.Text     = "使能";
                chkEnable.Location = new Point(lbTrigID.Right + 3, locY);
                gbTrigs.Controls.Add(chkEnable);
                lstTrigEnableChks.Add(chkEnable);
                chkEnable.CheckedChanged += OnTrigEnableCheckedChange;
                bool isEnable = false;
                err = _module.GetTrigEnable(i, out isEnable);
                isChkEnableSetting = true;
                if (err != 0)
                {
                    ShowTips("获取 " + lbTrigID.Text + " 使能状态失败,错误信息:" + _module.GetErrorInfo(err));
                    chkEnable.Checked = false;
                }
                else
                {
                    chkEnable.Checked = isEnable;
                }
                isChkEnableSetting = false;
                ///触发次数
                Label lbTrigTimes = new Label();
                lbTrigTimes.Text     = "次数";
                lbTrigTimes.Location = new Point(chkEnable.Right + 3, locY + 5);
                gbTrigs.Controls.Add(lbTrigTimes);
                TextBox tbTrigTimes = new TextBox();
                tbTrigTimes.ReadOnly  = true;
                tbTrigTimes.BackColor = SystemColors.Control;
                tbTrigTimes.Location  = new Point(lbTrigTimes.Right + 3, locY);
                gbTrigs.Controls.Add(tbTrigTimes);
                lstTrigTimeTbs.Add(tbTrigTimes);
                Button btResetTimes = new Button();
                btResetTimes.Location = new Point(tbTrigTimes.Right + 3, locY);
                btResetTimes.Text     = "置0";
                gbTrigs.Controls.Add(btResetTimes);
                lstResetTimeBts.Add(btResetTimes);
                btResetTimes.Click += OnResetTrigTimesButtonClick;
                ///软触发
                Button btSoftwareTrig = new Button();
                btSoftwareTrig.Location = new Point(btResetTimes.Right + 3, locY);
                btSoftwareTrig.Text     = "软触发";
                gbTrigs.Controls.Add(btSoftwareTrig);
                lstSwTrigBts.Add(btSoftwareTrig);
                btSoftwareTrig.Click += OnSoftwareTrigButtonClick;
                locY += btSoftwareTrig.Height + 3;
            }
            UpdateModuleStatus();
        }