public void UpdateChannelsInfo(string devID, int moduleIndex)
        {
            lstTbTrigIDs.Clear();
            pnTrigs.Controls.Clear();
            JFDevCellNameManeger  mgr = JFHubCenter.Instance.MDCellNameMgr;
            IJFModule_CmprTrigger md  = null;
            IJFDevice_MotionDaq   dev = JFHubCenter.Instance.InitorManager.GetInitor(devID) as IJFDevice_MotionDaq;

            if (dev != null && dev.CompareTriggerCount > moduleIndex)
            {
                md = dev.GetCompareTrigger(moduleIndex);
            }
            int trigChannCount = mgr.GetCmpTrigCount(devID, moduleIndex);

            for (int i = 0; i < trigChannCount; i++)
            {
                Label lb = new Label();
                lb.Location = new Point(2, 2 + 5 + 33 * i);
                lb.Text     = "序号:" + i.ToString("D2") + "名称:";
                pnTrigs.Controls.Add(lb);
                TextBox tbID = new TextBox();
                tbID.Location  = new Point(lb.Right, 2 + 33 * i);
                tbID.Text      = mgr.GetCmpTrigName(devID, moduleIndex, i);
                tbID.BackColor = SystemColors.Control;
                tbID.ReadOnly  = true;
                tbID.Width     = 200;
                pnTrigs.Controls.Add(tbID);
                lstTbTrigIDs.Add(tbID);
                UcCmprTrgChn ucTrig = new UcCmprTrgChn();
                ucTrig.Location = new Point(tbID.Right, 2 + 33 * i);
                ucTrig.SetModuleChn(md, i, "", null);
                pnTrigs.Controls.Add(ucTrig);
            }
        }
예제 #2
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);
        }
예제 #3
0
        public void AddModule(IJFModule_CmprTrigger module, string moduleName)
        {
            if (null == module)
            {
                return;
            }
            if (_lstModules.Contains(module))
            {
                return;
            }

            if (null == moduleName)
            {
                moduleName = "CmprTrig";
            }
            TabPage tp = new TabPage();

            tabCtrl.TabPages.Add(tp);
            UcCmprTrig uc = new UcCmprTrig();

            uc.Dock    = DockStyle.Fill;
            uc.Parent  = tp;
            uc.Visible = true;
            uc.SetCmprTigger(module, null, null);
            tp.Text = moduleName;
            tp.Name = moduleName;
            tp.Controls.Add(uc);
            _lstModules.Add(module);
        }
예제 #4
0
 string[] _trigChnIDs = null;          //触发器输出通道的名称
 /// <summary>设置模块和编码器通道号</summary>
 public void SetModuleChn(IJFModule_CmprTrigger module, int encChn, string id, string[] trigChnIDs)
 {
     _module     = module;
     _encChn     = encChn;
     _trigChnIDs = trigChnIDs;
     if (null == _module)
     {
         id = "";
     }
     else
     {
         if (id == null)
         {
             _id = "Enc_" + _encChn.ToString("D2");
         }
         else
         {
             _id = id;
         }
     }
     if (_isFormLoaded)
     {
         AdjustView();
     }
 }
예제 #5
0
 /// <summary>设置模块</summary>
 public void SetCmprTigger(IJFModule_CmprTrigger module, string[] encChnIDs, string[] trgChnIDs)
 {
     _module     = module;
     _encChnIDs  = encChnIDs;
     _trigChnIDs = trgChnIDs;
     if (_isLoaded)
     {
         AdjustUI();
     }
 }
        /// <summary>
        /// 更新界面
        /// </summary>
        void AdjustView()
        {
            Controls.Clear();
            _lstCmpTrigInfos.Clear();
            _lstCmpTrigUcs.Clear();
            if (null == _trigNames || 0 == _trigNames.Length)
            {
                return;
            }
            Point loc = new Point(5, 5);

            for (int i = 0; i < _trigNames.Length; i++)
            {
                Label lbInfo = new Label();
                lbInfo.AutoSize = true;
                lbInfo.Text     = _trigNames[i];
                string        errInfo;
                JFDevCellInfo ci = CheckTrigDevInfo(_trigNames[i], out errInfo);
                if (null == ci)
                {
                    lbInfo.Text += " ,ErrorInfo:" + errInfo;
                }
                lbInfo.Location = loc;           //lbInfo.Top = bottom;
                loc.Y           = lbInfo.Bottom; //bottom = lbInfo.Bottom +5;
                Controls.Add(lbInfo);
                _lstCmpTrigInfos.Add(lbInfo);

                UcCmprTrgChn ucTrig = new UcCmprTrgChn();
                if (null == ci)
                {
                    ci = JFHubCenter.Instance.MDCellNameMgr.GetCmpTrigCellInfo(_trigNames[i]); //尝试使用命名表中的名称
                    if (ci == null)
                    {
                        ucTrig.SetModuleChn(null, 0, _trigNames[i] + ":无效通道名", null);
                    }
                    else
                    {
                        ucTrig.SetModuleChn(null, ci.ChannelIndex, _trigNames[i], null);
                    }
                }
                else
                {
                    IJFModule_CmprTrigger md = (JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq).GetCompareTrigger(ci.ModuleIndex);
                    ucTrig.SetModuleChn(md, ci.ChannelIndex, _trigNames[i], null);
                }
                ucTrig.Location  = loc;
                ucTrig.BackColor = SystemColors.ActiveBorder;
                Controls.Add(ucTrig);
                _lstCmpTrigUcs.Add(ucTrig);
                loc.Y = ucTrig.Bottom + 20;//bottom = ucTrig.Bottom + 10;
            }
        }
        JFDevCellInfo CheckTrigDevInfo(string trigName, out string errorInfo)
        {
            JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetCmpTrigCellInfo(trigName); //在命名表中的通道信息

            if (null == ci)
            {
                errorInfo = "未找到设备信息";
                return(null);
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;

            if (null == dev)
            {
                errorInfo = "未找到所属设备:\"" + ci.DeviceID + "\"";
                return(null);
            }
            if (!dev.IsDeviceOpen)
            {
                errorInfo = "所属设备:\"" + ci.DeviceID + "\"未打开";
                return(null);
            }
            if (ci.ModuleIndex >= dev.McCount)
            {
                errorInfo = "模块序号:\"" + ci.ModuleIndex + "\"超出限制!";
                return(null);
            }
            IJFModule_CmprTrigger md = dev.GetCompareTrigger(ci.ModuleIndex);

            if (ci.ChannelIndex >= md.EncoderChannels)
            {
                errorInfo = "通道序号:\"" + ci.ChannelIndex + "\"超出限制!";
                return(null);
            }

            errorInfo = "";
            return(ci);
        }