public JFRealtimeUI GetRealtimeUI()
        {
            JFRealtimeUI ret = new JFRealtimeUI();

            if (!IsDeviceOpen)
            {
                return(ret);
            }
            ret.AutoScroll = true;

            UcMotionDaq ui = new UcMotionDaq();

            ui.AutoScroll = true;
            string cardType  = DeviceModel;
            int    cardIndex = 0;
            object obj       = GetInitParamValue(_initParamNames[0]);

            if (null != obj && (CardType)obj != CardType.PCI_Unknown)
            {
                cardType = ((CardType)obj).ToString();
            }
            obj = GetInitParamValue(_initParamNames[0]);
            if (null != obj)
            {
                cardIndex = (int)obj;
            }
            ui.SetDevice(this, cardType + " ID:" + cardIndex);
            return(ui);
        }
        public JFRealtimeUI GetRealtimeUI()
        {
            JFRealtimeUI ret = new JFRealtimeUI();
            if (!IsDeviceOpen)
                return ret;
            ret.AutoScroll = true;

            UcMotionDaq ui = new UcMotionDaq();
            ui.AutoScroll = true;
            ui.SetDevice(this, "APS168MD BoardID = " + _boardID.ToString());
            return ui;

        }
Beispiel #3
0
        /// <summary>调试所选设备</summary>
        private void btDebug_Click(object sender, EventArgs e)
        {
            if (null == dgvDevs.SelectedRows || 0 == dgvDevs.SelectedRows.Count)
            {
                MessageBox.Show("请先选择需要调试的" + InitorCaption + "对象");
                return;
            }
            IJFInitializable initor  = JFHubCenter.Instance.InitorManager[dgvDevs.SelectedRows[0].Cells[0].Value.ToString()];
            Type             devType = initor.GetType();

            if (chkSelfUI.Checked)
            {
                if (!typeof(IJFRealtimeUIProvider).IsAssignableFrom(devType))
                {
                    MessageBox.Show(InitorCaption + "对象未提供自带调试界面,请取消\"自带界面\"后重试!");
                    return;
                }

                if (typeof(IJFStation).IsAssignableFrom(devType))
                {
                    Form fmStationDebug = (initor as IJFStation).GenForm();
                    if (null == fmStationDebug) //工站自身未提供界面
                    {
                        if (DialogResult.Cancel == MessageBox.Show("工站对象未提供调试界面,是否使用通用界面?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
                        {
                            return;
                        }
                        if (typeof(JFStationBase).IsAssignableFrom(devType))
                        {
                            FormStationBaseDebug fmSB = new FormStationBaseDebug();
                            fmSB.Text = (initor as JFStationBase).Name + " Debug";
                            fmSB.SetStation(initor as JFStationBase);
                            fmSB.TopMost = true;
                            fmSB.Show();
                            return;
                        }
                        else
                        {
                            //JFRealtimeUI ucST = (initor as IJFRealtimeUIProvider).GetRealtimeUI();
                            //ucST.Dock = DockStyle.Fill;
                            UcStationRealtimeUI ucST = new UcStationRealtimeUI();
                            ucST.Dock = DockStyle.Fill;
                            ucST.AllowedStartStopCmd = true;
                            ucST.SetStation(initor as IJFStation);
                            FormJFRealTimeUI fmST = new FormJFRealTimeUI();
                            fmST.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug";
                            fmST.Size = ucST.Size;
                            fmST.SetRTUI(ucST);
                            //fm.Controls.Add(uc);
                            fmST.Show();
                            return;
                        }
                    }
                    else
                    {
                        fmStationDebug.FormBorderStyle = FormBorderStyle.Sizable;
                        fmStationDebug.TopMost         = true;
                        fmStationDebug.Show();
                        return;
                    }
                }

                JFRealtimeUI uc = (initor as IJFRealtimeUIProvider).GetRealtimeUI();
                uc.Dock = DockStyle.Fill;
                FormJFRealTimeUI fm = new FormJFRealTimeUI();
                fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug";
                fm.Size = uc.Size;
                fm.SetRTUI(uc);
                //fm.Controls.Add(uc);
                fm.Show();
            }
            else
            {
                if (typeof(IJFDevice_Camera).IsAssignableFrom(devType) ||
                    typeof(IJFDevice_LightController).IsAssignableFrom(devType) ||
                    typeof(IJFDevice_MotionDaq).IsAssignableFrom(devType) ||
                    typeof(IJFDevice_TrigController).IsAssignableFrom(devType) ||
                    typeof(IJFStation).IsAssignableFrom(devType))
                {
                    if (typeof(JFStationBase).IsAssignableFrom(devType))
                    {
                        FormStationBaseDebug fmSB = new FormStationBaseDebug();
                        fmSB.Text = (initor as JFStationBase).Name + " Debug";
                        fmSB.SetStation(initor as JFStationBase);
                        fmSB.Show();
                        return;
                    }
                    if (typeof(IJFStation).IsAssignableFrom(devType))
                    {
                        UcStationRealtimeUI ucST = new UcStationRealtimeUI();
                        ucST.Dock = DockStyle.Fill;
                        ucST.AllowedStartStopCmd = true;
                        ucST.SetStation(initor as IJFStation);
                        FormJFRealTimeUI fmST = new FormJFRealTimeUI();
                        fmST.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug";
                        fmST.Size = ucST.Size;
                        fmST.SetRTUI(ucST);
                        //fm.Controls.Add(uc);
                        fmST.Show();
                        return;
                    }


                    FormJFRealTimeUI fm = new FormJFRealTimeUI();
                    fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug" + "待实现!!";
                    if (typeof(IJFDevice_MotionDaq).IsAssignableFrom(devType))
                    {
                        UcMotionDaq uc = new UcMotionDaq();
                        fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口";
                        //uc.Parent = fm;
                        uc.SetDevice(initor as IJFDevice_MotionDaq, dgvDevs.SelectedRows[0].Cells[0].Value.ToString());
                        //fm.Size = new Size(uc.Width + 20, uc.Height + 20);
                        //fm.Controls.Add(uc);
                        fm.SetRTUI(uc);
                    }
                    else if (typeof(IJFDevice_TrigController).IsAssignableFrom(devType))//HTM触发板控制器,一进多出(控制触发强度/时间)
                    {
                        fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口";
                        if (typeof(IJFDevice_LightController).IsAssignableFrom(devType))//带触发功能的光源控制器
                        {
                            UcLightCtrl_T uc = new UcLightCtrl_T();
                            uc.SetModule(initor as IJFDevice_LightControllerWithTrig, null, null);
                            uc.Dock = DockStyle.Fill;
                            fm.SetRTUI(uc);
                        }
                        else //单纯的触发控制器
                        {
                            UcTrigCtrl uc = new UcTrigCtrl();
                            uc.SetModuleInfo(initor as IJFDevice_TrigController);
                            fm.SetRTUI(uc);
                        }
                    }
                    else if (typeof(IJFDevice_LightController).IsAssignableFrom(devType)) //光源控制器
                    {
                        fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口";
                        UcLightCtrl uc = new UcLightCtrl();
                        uc.SetModuleInfo(initor as IJFDevice_LightController);
                        fm.SetRTUI(uc);
                    }
                    else if (typeof(IJFDevice_Camera).IsAssignableFrom(devType))
                    {
                        fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口";
                        UcCmr uc = new UcCmr();
                        uc.SetCamera(initor as IJFDevice_Camera);
                        fm.SetRTUI(uc);
                    }
                    fm.Show();
                }
                else
                {
                    MessageBox.Show("无法为" + InitorCaption + "类型的对象提供调试界面");
                    return;
                }
            }
        }