Пример #1
0
        /// <summary>
        /// 向树形控件添加一个运动控制设备节点
        /// </summary>
        /// <param name="devID"></param>
        void _AddDevNode(string devID, DevNodeCategory category)
        {
            TreeNode devNode = new TreeNode(devID);

            devNode.Tag = new DevNodeInfo(devID, /*DevNodeCategory.MotionDaqDev*/ category, 0);
            devNode.ContextMenuStrip = contextMenuDev;
            JFDevCellNameManeger mgr = JFHubCenter.Instance.MDCellNameMgr;

            tvDevs.Nodes[0].Nodes.Add(devNode);
            _UpdateModuleNode(devNode);
        }
Пример #2
0
        DevNodeCategory _currNodeCategory = DevNodeCategory.MotionDaqDev; //当前点击的节点类型
        private void tvDevs_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)//判断右键
            {
                Point    ClickPoint  = new Point(e.X, e.Y);
                TreeNode nodeClicked = tvDevs.GetNodeAt(ClickPoint);
                if (null == nodeClicked)
                {
                    return;
                }
                tvDevs.SelectedNode = nodeClicked;
                DevNodeInfo nodeInfo = nodeClicked.Tag as DevNodeInfo;
                if (null == nodeInfo)
                {
                    return;
                }
                if (nodeInfo.Categoty == DevNodeCategory.MotionDaqDev)
                {
                    contextMenuDev.Items["ToolStripMenuItemResetDevsModuleCount"].Text = "修改模块数量";
                    if (JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_MotionDaq)).Contains(nodeInfo.DevID))
                    {
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Enabled = true;
                        IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(nodeInfo.DevID) as IJFDevice_MotionDaq;
                        if (dev.IsDeviceOpen)
                        {
                            contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text = "关闭设备";
                        }
                        else
                        {
                            contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text = "打开设备";
                        }
                    }
                    else
                    {
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Enabled = false;
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text    = "无效设备";
                    }
                }
                else if (nodeInfo.Categoty == DevNodeCategory.LightCtrlTDev || nodeInfo.Categoty == DevNodeCategory.TrigCtrlDev)
                {
                    contextMenuDev.Items["ToolStripMenuItemResetDevsModuleCount"].Text = "修改通道数量";
                    if (JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_TrigController)).Contains(nodeInfo.DevID))
                    {
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Enabled = true;
                        IJFDevice_TrigController dev = JFHubCenter.Instance.InitorManager.GetInitor(nodeInfo.DevID) as IJFDevice_TrigController;
                        if (dev.IsDeviceOpen)
                        {
                            contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text = "关闭设备";
                        }
                        else
                        {
                            contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text = "打开设备";
                        }
                    }
                    else
                    {
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Enabled = false;
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text    = "无效设备";
                    }
                }
                else if (nodeInfo.Categoty == DevNodeCategory.LightCtrlTDev)
                {
                    contextMenuDev.Items["ToolStripMenuItemResetDevsModuleCount"].Text = "修改通道数量";
                    if (JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_LightControllerWithTrig)).Contains(nodeInfo.DevID))
                    {
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Enabled = true;
                        IJFDevice_LightControllerWithTrig dev = JFHubCenter.Instance.InitorManager.GetInitor(nodeInfo.DevID) as IJFDevice_LightControllerWithTrig;
                        if (dev.IsDeviceOpen)
                        {
                            contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text = "关闭设备";
                        }
                        else
                        {
                            contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text = "打开设备";
                        }
                    }
                    else
                    {
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Enabled = false;
                        contextMenuDev.Items["ToolStripMenuItemOpenCloseDev"].Text    = "无效设备";
                    }
                }
            }
            else if (e.Button == MouseButtons.Left) //左键
            {
                Point    ClickPoint  = new Point(e.X, e.Y);
                TreeNode nodeClicked = tvDevs.GetNodeAt(ClickPoint);
                if (null == nodeClicked)
                {
                    return;
                }
                DevNodeInfo nodeInfo = nodeClicked.Tag as DevNodeInfo;
                if (null == nodeInfo)
                {
                    return;
                }
                panel1.Controls.Clear();
                _currNodeCategory = nodeInfo.Categoty;
                switch (nodeInfo.Categoty)
                {
                case DevNodeCategory.MotionDaqDev:
                    timer1.Enabled = false;
                    break;

                case DevNodeCategory.DioModule:
                    ucDioNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex);
                    panel1.Controls.Add(ucDioNames);
                    ucDioNames.Dock = DockStyle.Fill;
                    timer1.Enabled  = true;
                    break;

                case DevNodeCategory.MotionModule:
                    timer1.Enabled = true;
                    ucAxisNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex);
                    panel1.Controls.Add(ucAxisNames);
                    ucAxisNames.Dock = DockStyle.Fill;
                    timer1.Enabled   = true;
                    break;

                case DevNodeCategory.AioModule:
                    ucAioNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex);
                    panel1.Controls.Add(ucAioNames);
                    ucAioNames.Dock = DockStyle.Fill;
                    timer1.Enabled  = true;
                    break;

                case DevNodeCategory.CmpTrigModule:
                    ucCmpTrigNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex);
                    panel1.Controls.Add(ucCmpTrigNames);
                    ucCmpTrigNames.Dock = DockStyle.Fill;
                    timer1.Enabled      = true;
                    break;

                case DevNodeCategory.TrigCtrlDev:
                    ucTrigCtrlNames.UpdateChannelsInfo(nodeInfo.DevID);
                    panel1.Controls.Add(ucTrigCtrlNames);
                    ucTrigCtrlNames.Dock = DockStyle.Fill;
                    timer1.Enabled       = true;
                    break;

                case DevNodeCategory.LightCtrlTDev:
                    ucLightCtrlNames.UpdateChannelsInfo(nodeInfo.DevID);
                    panel1.Controls.Add(ucLightCtrlNames);
                    ucLightCtrlNames.Dock = DockStyle.Fill;
                    timer1.Enabled        = true;
                    break;
                }
            }
        }
Пример #3
0
 public DevNodeInfo(string devID, DevNodeCategory category, int moduleIndex)
 {
     DevID       = devID;
     Categoty    = category;
     ModuleIndex = moduleIndex;
 }