コード例 #1
0
ファイル: FormRecipeMgr.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>
        /// 新建/重置配方管理器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItemReset_Click(object sender, EventArgs e)
        {
            IJFRecipeManager recipeMgr = JFHubCenter.Instance.RecipeManager;
            FormCreateInitor fm        = new FormCreateInitor();

            fm.MatchType = typeof(IJFRecipeManager);
            fm.SetFixedID("JF配方管理器");
            if (null == recipeMgr)
            {
                fm.Text = "新建配方管理器";
            }
            else
            {
                fm.Text = "重建配方管理器";
            }
            if (DialogResult.OK != fm.ShowDialog())
            {
                return;
            }
            if (null != recipeMgr)
            {
                JFHubCenter.Instance.InitorManager.Remove("JF配方管理器");//先删除当前RecipeMgr
            }
            recipeMgr = fm.Initor as IJFRecipeManager;
            JFHubCenter.Instance.InitorManager.Add(fm.ID, recipeMgr);
            AdjustManagerView2UI();
        }
コード例 #2
0
ファイル: FormInitorMgr.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>添加新设备</summary>
        private void btAdd_Click(object sender, EventArgs e)
        {
            FormCreateInitor fm = new FormCreateInitor();

            fm.Text      = "创建" + InitorCaption + "对象";
            fm.MatchType = InitorType;
            if (DialogResult.OK == fm.ShowDialog())
            {
                IJFInitializable newDevice = fm.Initor;
                string           devID     = fm.ID;
                JFHubCenter.Instance.InitorManager.Add(devID, newDevice);


                DataGridViewRow         row    = new DataGridViewRow();
                DataGridViewTextBoxCell cellID = new DataGridViewTextBoxCell();
                cellID.Value = devID;
                row.Cells.Add(cellID);

                DataGridViewTextBoxCell cellModel = new DataGridViewTextBoxCell();
                cellModel.Value = JFinitializerHelper.DispalyTypeName(newDevice.GetType());
                row.Cells.Add(cellModel);
                DataGridViewTextBoxCell cellType = new DataGridViewTextBoxCell();
                cellType.Value = newDevice.GetType().Name;
                row.Cells.Add(cellType);
                dgvDevs.Rows.Add(row);
                newDevice.Initialize();
                if (!newDevice.IsInitOK)
                {
                    btInit.Enabled = true;
                    row.DefaultCellStyle.ForeColor = Color.Red;
                }
                else
                {
                    btInit.Enabled = false;
                }



                /// 更新参数到界面
                dgvDevs.Rows[dgvDevs.Rows.Count - 1].Selected = true;
                RemoveAllPEs();
                string[] iniParamNames = newDevice.InitParamNames;
                if (null == iniParamNames)
                {
                    btEditSave.Enabled = false;
                    return;
                }
                btEditSave.Enabled = true;
                int locY = btInit.Location.Y + btInit.Size.Height + 5;
                foreach (string ipName in iniParamNames)
                {
                    UcJFParamEdit pe = new UcJFParamEdit();
                    pe.Width    = gbParams.Width - 1;
                    pe.Location = new Point(4, locY);
                    pe.SetParamDesribe(newDevice.GetInitParamDescribe(ipName));
                    locY += pe.Height;
                    pe.SetParamValue(newDevice.GetInitParamValue(ipName));
                    pe.IsValueReadOnly = true;
                    gbParams.Controls.Add(pe);
                }

                Type devType = newDevice.GetType();
                if (typeof(IJFDevice_Camera).IsAssignableFrom(devType) ||
                    typeof(IJFDevice_LightController).IsAssignableFrom(devType) ||
                    typeof(IJFDevice_MotionDaq).IsAssignableFrom(devType) ||
                    typeof(IJFDevice_TrigController).IsAssignableFrom(devType) ||
                    typeof(IJFRealtimeUIProvider).IsAssignableFrom(devType)) //提供调试界面
                {
                    btDebug.Enabled = true;
                    if (typeof(IJFRealtimeUIProvider).IsAssignableFrom(devType))
                    {
                        chkSelfUI.Enabled = true;
                    }
                    else
                    {
                        chkSelfUI.Checked = false;
                        chkSelfUI.Enabled = false;
                    }
                }
                else
                {
                    btDebug.Enabled = false;
                }

                if (typeof(IJFConfigUIProvider).IsAssignableFrom(devType))
                {
                    btCfg.Enabled = true;
                }
                else
                {
                    btCfg.Enabled = false;
                }
            }
        }