/// <summary> /// 修改设备所属的模块数量 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItemResetDevsModuleCount_Click(object sender, EventArgs e) { TreeNode currNode = tvDevs.SelectedNode; DevNodeInfo nodeInfo = currNode.Tag as DevNodeInfo; JFDevCellNameManeger mgr = JFHubCenter.Instance.MDCellNameMgr; if (nodeInfo.Categoty == DevNodeCategory.MotionDaqDev) //更改运动控制器模块数量 { FormDevModuleInfo fm = new FormDevModuleInfo(); fm.DevID = nodeInfo.DevID; fm.MotionCount = mgr.GetAxisModuleCount(nodeInfo.DevID); fm.DioCount = mgr.GetDioModuleCount(nodeInfo.DevID); fm.AioCount = mgr.GetAioModuleCount(nodeInfo.DevID); fm.TrigCount = mgr.GetCmpTrigModuleCount(nodeInfo.DevID); fm.SettingMode = DevModuleSettingMode.Set; if (DialogResult.OK == fm.ShowDialog()) { mgr.SetAxisModuleCount(nodeInfo.DevID, fm.MotionCount); mgr.SetDioModuleCount(nodeInfo.DevID, fm.DioCount); mgr.SetAioModuleCount(nodeInfo.DevID, fm.AioCount); mgr.SetCmpTrigModuleCount(nodeInfo.DevID, fm.TrigCount); _UpdateModuleNode(currNode);//_UpdateCfg2UI(); } } else if (nodeInfo.Categoty == DevNodeCategory.TrigCtrlDev)//更改触发控制器通道数量 { FormAddMChnDev fm = new FormAddMChnDev(); fm.Text = "修改触发器通道数量"; string[] devIDs = JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_TrigController)); //所有触发控制设备ID,过滤掉其中的光源控制器 List <string> trigDevIDs = new List <string>(); fm.SetDeviceID(nodeInfo.DevID); fm.SettingMode = DevModuleSettingMode.Set; fm.SetChannelTypes(new string[] { "触发通道数量:" }); int nCurrChns = JFHubCenter.Instance.MDCellNameMgr.GetTrigCtrlChannelCount(nodeInfo.DevID); fm.ChannelCount = new int[] { nCurrChns }; if (DialogResult.OK != fm.ShowDialog()) { return; } JFHubCenter.Instance.MDCellNameMgr.SetTrigCtrlChannelCount(fm.DeviceID, fm.ChannelCount[0]); _UpdateModuleNode(currNode); } else if (nodeInfo.Categoty == DevNodeCategory.LightCtrlTDev) //更改光源控制器通道数量 { FormAddMChnDev fm = new FormAddMChnDev(); fm.Text = "修改光源通道数量"; // string[] devIDs = JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_TrigController)); //所有触发控制设备ID,过滤掉其中的光源控制器 //List<string> trigDevIDs = new List<string>(); fm.SetDeviceID(nodeInfo.DevID); fm.SettingMode = DevModuleSettingMode.Set; fm.SetChannelTypes(new string[] { "开关通道数量", "触发通道数量:" }); int lightChnCount = JFHubCenter.Instance.MDCellNameMgr.GetLightCtrlChannelCount(nodeInfo.DevID); int trigChnCount = JFHubCenter.Instance.MDCellNameMgr.GetTrigCtrlChannelCount(nodeInfo.DevID); fm.ChannelCount = new int[] { lightChnCount, trigChnCount }; if (DialogResult.OK != fm.ShowDialog()) { return; } JFHubCenter.Instance.MDCellNameMgr.SetLightCtrlChannelCount(fm.DeviceID, fm.ChannelCount[0]); JFHubCenter.Instance.MDCellNameMgr.SetTrigCtrlChannelCount(fm.DeviceID, fm.ChannelCount[1]); _UpdateModuleNode(currNode); } }
/// <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); } }