Пример #1
0
        public void UpdateChannelsInfo(string devID, int moduleIndex)
        {
            //int nBottom = 0;
            pnAi.Controls.Clear();
            pnAo.Controls.Clear();
            JFDevCellNameManeger mgr = JFHubCenter.Instance.MDCellNameMgr;
            IJFModule_AIO        md  = null;
            IJFDevice_MotionDaq  dev = JFHubCenter.Instance.InitorManager.GetInitor(devID) as IJFDevice_MotionDaq;

            if (dev != null && dev.DioCount > moduleIndex)
            {
                md = dev.GetAio(moduleIndex);
            }
            int AiCount = mgr.GetAiChannelCount(devID, moduleIndex);

            for (int i = 0; i < AiCount; i++)
            {
                Label lbIndex = new Label();
                lbIndex.Text     = i.ToString("D2");
                lbIndex.Location = new Point(2, 10 + i * 33 + 2);
                lbIndex.Width    = 30;
                pnAi.Controls.Add(lbIndex);
                UcAIOChn ucAi = new UcAIOChn();
                pnAi.Controls.Add(ucAi);
                ucAi.Location = new Point(32, 2 + i * 33);
                ucAi.Width    = pnAi.Width - 34;
                ucAi.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                ucAi.SetIOInfo(md, i, false, mgr.GetAiName(devID, moduleIndex, i));
                //nBottom = ucAi.Bottom;
            }
            int aoCount = mgr.GetAoChannelCount(devID, moduleIndex);

            for (int i = 0; i < aoCount; i++)
            {
                Label lbIndex = new Label();
                lbIndex.Text     = i.ToString("D2");
                lbIndex.Location = new Point(2, 10 + i * 33 + 2);
                lbIndex.Width    = 30;
                pnAo.Controls.Add(lbIndex);
                UcAIOChn ucAo = new UcAIOChn();
                pnAo.Controls.Add(ucAo);
                ucAo.Location = new Point(32, 2 + i * 33);
                ucAo.Width    = pnAi.Width - 34;
                ucAo.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                ucAo.SetIOInfo(md, i, true, mgr.GetAoName(devID, moduleIndex, i));
                //if (nBottom < ucAo.Bottom)
                //    nBottom = ucAo.Bottom;
            }

            //rtTips.Top = nBottom + 10;
        }
Пример #2
0
        void AdjustUI()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(AdjustUI));
                return;
            }

            while (tabControlCF1.TabCount > 1)
            {
                tabControlCF1.TabPages.RemoveAt(tabControlCF1.TabCount - 1);
            }

            gbInitParams.Controls.Clear();

            if (null == _dev)
            {
                lbModel.Text        = "空";
                lbID.Text           = "空";
                lbOpend.Text        = "空";
                btOpenClose.Enabled = false;
                btOpenClose.Text    = "空设备";
                return;
            }
            else //更新设备信息
            {
                lbModel.Text = _dev.DeviceModel;
                lbID.Text    = _id;
                //UpdateDevice();

                int   locY      = 20;
                int   locX      = 5;
                Label lbDevInit = new Label();
                lbDevInit.Text     = _dev.IsInitOK?"初始化完成":"初始化失败";
                lbDevInit.Location = new Point(locX, locY);
                gbInitParams.Controls.Add(lbDevInit);
                locY += 28;
                for (int i = 0; i < _dev.InitParamNames.Length; i++)
                {
                    UcJFParamEdit ucParam = new UcJFParamEdit();
                    ucParam.SetParamDesribe(_dev.GetInitParamDescribe(_dev.InitParamNames[i]));
                    ucParam.SetParamValue(_dev.GetInitParamValue(_dev.InitParamNames[i]));
                    ucParam.Enabled  = false;
                    ucParam.Location = new Point(locX, locY);
                    gbInitParams.Controls.Add(ucParam);
                    ucParam.Width = gbInitParams.Width - 20;
                    locY          = ucParam.Bottom + 2;
                }

                if (_dev.DioCount > 0)
                {
                    ///fmDios = new FormDios();
                    for (int i = 0; i < _dev.DioCount; i++)
                    {
                        fmDios.AddModule(_dev.GetDio(i), "模块_" + i.ToString());
                    }

                    TabPage tabPage = new TabPage(); //创建一个TabControl 中的单个选项卡页。
                    tabPage.Text      = "DIO模块";
                    tabPage.Name      = "DioModules";
                    tabPage.BackColor = fmDios.BackColor;

                    tabControlCF1.TabPages.Add(tabPage);   //添加tabPage选项卡到tab控件

                    fmDios.TopLevel        = false;
                    fmDios.FormBorderStyle = FormBorderStyle.None;
                    fmDios.Dock            = DockStyle.Fill;
                    fmDios.Parent          = tabPage;
                    fmDios.Visible         = true;
                    tabPage.Controls.Add(fmDios);  //tabPage选项卡添加一个窗体对象
                }

                if (_dev.McCount > 0)
                {
                    //fmMotions = new FormMotions();
                    for (int i = 0; i < _dev.McCount; i++)
                    {
                        fmMotions.AddModule(_dev.GetMc(i), "模块_" + i.ToString());
                    }

                    TabPage tabPage = new TabPage(); //创建一个TabControl 中的单个选项卡页。
                    tabPage.Text      = "Motion模块";
                    tabPage.Name      = "MotionModules";
                    tabPage.BackColor = fmMotions.BackColor;

                    tabControlCF1.TabPages.Add(tabPage);   //添加tabPage选项卡到tab控件

                    fmMotions.TopLevel        = false;
                    fmMotions.FormBorderStyle = FormBorderStyle.None;
                    fmMotions.Dock            = DockStyle.Fill;
                    fmMotions.Parent          = tabPage;
                    fmMotions.Visible         = true;
                    tabPage.Controls.Add(fmMotions);  //tabPage选项卡添加一个窗体对象
                }

                if (_dev.CompareTriggerCount > 0)
                {
                    for (int i = 0; i < _dev.CompareTriggerCount; i++)
                    {
                        fmCmprTrigs.AddModule(_dev.GetCompareTrigger(i), "模块_" + i.ToString());
                    }

                    TabPage tabPage = new TabPage(); //创建一个TabControl 中的单个选项卡页。
                    tabPage.Text      = "CmprTrig模块";
                    tabPage.Name      = "CmprTrigModule";
                    tabPage.BackColor = fmCmprTrigs.BackColor;

                    tabControlCF1.TabPages.Add(tabPage);   //添加tabPage选项卡到tab控件

                    fmCmprTrigs.TopLevel        = false;
                    fmCmprTrigs.FormBorderStyle = FormBorderStyle.None;
                    fmCmprTrigs.Dock            = DockStyle.Fill;
                    fmCmprTrigs.Parent          = tabPage;
                    fmCmprTrigs.Visible         = true;
                    tabPage.Controls.Add(fmCmprTrigs);  //tabPage选项卡添加一个窗体对象
                }

                if (_dev.AioCount > 0)
                {
                    for (int i = 0; i < _dev.AioCount; i++)
                    {
                        fmAios.AddModule(_dev.GetAio(i), "模块_" + i.ToString());
                    }

                    TabPage tabPage = new TabPage(); //创建一个TabControl 中的单个选项卡页。
                    tabPage.Text      = "AIO模块";
                    tabPage.Name      = "AioModules";
                    tabPage.BackColor = fmAios.BackColor;

                    tabControlCF1.TabPages.Add(tabPage);   //添加tabPage选项卡到tab控件

                    fmAios.TopLevel        = false;
                    fmAios.FormBorderStyle = FormBorderStyle.None;
                    fmAios.Dock            = DockStyle.Fill;
                    fmAios.Parent          = tabPage;
                    fmAios.Visible         = true;
                    tabPage.Controls.Add(fmAios);  //tabPage选项卡添加一个窗体对象
                }
            }

            tabControlCF1.SelectedIndex = 0;
            UpdateModuleStatus();
        }