/// <summary> /// 更新模块的通道信息 /// </summary> /// <param name="nodeChannel"></param> void _UpdateChannelNode(TreeNode nodeChannel) { DevNodeInfo nodeInfo = nodeChannel.Tag as DevNodeInfo; JFDevCellNameManeger mgr = JFHubCenter.Instance.MDCellNameMgr; if (nodeInfo.Categoty == DevNodeCategory.DioModule) { nodeChannel.Text = "序号_" + nodeInfo.ModuleIndex + ",DI数:" + mgr.GetDiChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex) + ",DO数:" + mgr.GetDoChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex); ucDioNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex); } else if (nodeInfo.Categoty == DevNodeCategory.MotionModule) { nodeChannel.Text = "序号_" + nodeInfo.ModuleIndex + ",轴数:" + mgr.GetAxisCount(nodeInfo.DevID, nodeInfo.ModuleIndex); ucAxisNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex); } else if (nodeInfo.Categoty == DevNodeCategory.CmpTrigModule) { nodeChannel.Text = "序号_" + nodeInfo.ModuleIndex + ",通道数:" + mgr.GetCmpTrigCount(nodeInfo.DevID, nodeInfo.ModuleIndex); ucCmpTrigNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex); } else if (nodeInfo.Categoty == DevNodeCategory.AioModule) { nodeChannel.Text = "序号_" + nodeInfo.ModuleIndex + ",AI数:" + mgr.GetAiChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex) + ",AO数:" + mgr.GetAoChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex); ucAioNames.UpdateChannelsInfo(nodeInfo.DevID, nodeInfo.ModuleIndex); } }
/// <summary> /// 修改Module所属的通道数量 轴/Dio/Aio/Trig等等 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItemResetChannelCount_Click(object sender, EventArgs e) { TreeNode currNode = tvDevs.SelectedNode; DevNodeInfo nodeInfo = currNode.Tag as DevNodeInfo; JFDevCellNameManeger mgr = JFHubCenter.Instance.MDCellNameMgr; FormSetModuleChnCount fm = new FormSetModuleChnCount(); if (nodeInfo.Categoty == DevNodeCategory.MotionModule) { fm.Category = FormSetModuleChnCount.ModuleCategory.Motion; fm.ChannelCount1 = mgr.GetAxisCount(nodeInfo.DevID, nodeInfo.ModuleIndex); if (fm.ShowDialog() == DialogResult.OK) { mgr.SetAxisCount(nodeInfo.DevID, nodeInfo.ModuleIndex, fm.ChannelCount1); _UpdateChannelNode(currNode);//_UpdateCfg2UI(); } } else if (nodeInfo.Categoty == DevNodeCategory.CmpTrigModule) { fm.Category = FormSetModuleChnCount.ModuleCategory.Trig; fm.ChannelCount1 = mgr.GetCmpTrigCount(nodeInfo.DevID, nodeInfo.ModuleIndex); if (fm.ShowDialog() == DialogResult.OK) { mgr.SetCmpTrigCount(nodeInfo.DevID, nodeInfo.ModuleIndex, fm.ChannelCount1); _UpdateChannelNode(currNode);//_UpdateCfg2UI(); } } else if (nodeInfo.Categoty == DevNodeCategory.DioModule) { fm.Category = FormSetModuleChnCount.ModuleCategory.Dio; fm.ChannelCount1 = mgr.GetDiChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex); fm.ChannelCount2 = mgr.GetDoChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex); if (fm.ShowDialog() == DialogResult.OK) { mgr.SetDiChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex, fm.ChannelCount1); mgr.SetDoChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex, fm.ChannelCount2); _UpdateChannelNode(currNode);////_UpdateCfg2UI(); } } else if (nodeInfo.Categoty == DevNodeCategory.AioModule) { fm.Category = FormSetModuleChnCount.ModuleCategory.Aio; fm.ChannelCount1 = mgr.GetAiChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex); fm.ChannelCount2 = mgr.GetAoChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex); if (fm.ShowDialog() == DialogResult.OK) { mgr.SetAiChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex, fm.ChannelCount1); mgr.SetAoChannelCount(nodeInfo.DevID, nodeInfo.ModuleIndex, fm.ChannelCount2); _UpdateChannelNode(currNode);// _UpdateCfg2UI(); } } }
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; }
/// <summary> /// 更新控制卡的模块数量信息 /// </summary> /// <param name="nodeModule"></param> void _UpdateModuleNode(TreeNode nodeModule) { JFDevCellNameManeger mgr = JFHubCenter.Instance.MDCellNameMgr; DevNodeInfo nodeInfo = nodeModule.Tag as DevNodeInfo; if (nodeInfo.Categoty == DevNodeCategory.MotionDaqDev) //更新运动控制设备节点 { nodeModule.Nodes.Clear(); int motionModuleCount = mgr.GetAxisModuleCount(nodeInfo.DevID);//轴模块 if (motionModuleCount > 0) { TreeNode motionsNode = new TreeNode("轴模块"); motionsNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.Module, 0); nodeModule.Nodes.Add(motionsNode); for (int i = 0; i < motionModuleCount; i++) { TreeNode motionNode = new TreeNode("序号_" + i + ",轴数:" + mgr.GetAxisCount(nodeInfo.DevID, i)); motionNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.MotionModule, i); motionsNode.Nodes.Add(motionNode); motionNode.ContextMenuStrip = contextMenuModule; } } int dioModuleCount = mgr.GetDioModuleCount(nodeInfo.DevID);//数字IO模块 if (dioModuleCount > 0) { TreeNode diosNode = new TreeNode("Dio模块"); diosNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.Module, 0); nodeModule.Nodes.Add(diosNode); for (int i = 0; i < dioModuleCount; i++) { TreeNode dioNode = new TreeNode("序号_" + i + ",DI数:" + mgr.GetDiChannelCount(nodeInfo.DevID, i) + ",DO数:" + mgr.GetDoChannelCount(nodeInfo.DevID, i)); dioNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.DioModule, i); diosNode.Nodes.Add(dioNode); dioNode.ContextMenuStrip = contextMenuModule; } } int trigModuleCount = mgr.GetCmpTrigModuleCount(nodeInfo.DevID);//位置比较触发 if (trigModuleCount > 0) { TreeNode trigsNode = new TreeNode("位置比较触发模块"); trigsNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.Module, 0); nodeModule.Nodes.Add(trigsNode); for (int i = 0; i < trigModuleCount; i++) { TreeNode trigNode = new TreeNode("序号_" + i + ",通道数:" + mgr.GetCmpTrigCount(nodeInfo.DevID, i)); trigNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.CmpTrigModule, i); trigsNode.Nodes.Add(trigNode); trigNode.ContextMenuStrip = contextMenuModule; } } int aioModuleCount = mgr.GetAioModuleCount(nodeInfo.DevID); if (aioModuleCount > 0) { TreeNode aiosNode = new TreeNode("Aio模块"); aiosNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.Module, 0); nodeModule.Nodes.Add(aiosNode); for (int i = 0; i < aioModuleCount; i++) { TreeNode aioNode = new TreeNode("序号_" + i + ",AI数:" + mgr.GetAiChannelCount(nodeInfo.DevID, i) + ",AO数:" + mgr.GetAoChannelCount(nodeInfo.DevID, i)); aioNode.Tag = new DevNodeInfo(nodeInfo.DevID, DevNodeCategory.AioModule, i); aiosNode.Nodes.Add(aioNode); aioNode.ContextMenuStrip = contextMenuModule; } } } else if (nodeInfo.Categoty == DevNodeCategory.LightCtrlTDev) //光源控制器设备节点 { ucLightCtrlNames.UpdateChannelsInfo(nodeInfo.DevID); } else if (nodeInfo.Categoty == DevNodeCategory.TrigCtrlDev) //触发控制器设备节点 { ucTrigCtrlNames.UpdateChannelsInfo(nodeInfo.DevID); } }