public IODeviceNode FindDeviceTreeNode(Scada.Model.IO_SERVER Server, Scada.Model.IO_COMMUNICATION Communication, Scada.Model.IO_DEVICE Device) { for (int i = 0; i < this.IoTree.Nodes.Count; i++) { if (this.IoTree.Nodes[i] is IOServerNode) { IOServerNode sNode = this.IoTree.Nodes[i] as IOServerNode; if (sNode.Server == Server) { for (int j = 0; j < sNode.Nodes.Count; j++) { if (sNode.Nodes[j] is IOCommunicationNode) { IOCommunicationNode commNode = sNode.Nodes[j] as IOCommunicationNode; if (commNode.Communication == Communication) { for (int c = 0; c < commNode.Nodes.Count; c++) { if (commNode.Nodes[c] is IODeviceNode) { IODeviceNode deviceNode = commNode.Nodes[c] as IODeviceNode; if (deviceNode.Device == Device) { return(deviceNode); } } } } } } } } } return(null); }
private void 修改设备ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.mediator.IOTreeForm.SelectedNode is IODeviceNode) { IODeviceNode deviceNode = this.mediator.IOTreeForm.SelectedNode as IODeviceNode; FormManager.EditIODeviceNode(deviceNode); } }
private void 编辑点表ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.mediator.IOTreeForm.SelectedNode is IODeviceNode) { IODeviceNode devNode = this.mediator.IOTreeForm.SelectedNode as IODeviceNode; IOCommunicationNode comNode = devNode.Parent as IOCommunicationNode; IOServerNode sNode = comNode.Parent as IOServerNode; FormManager.OpenDeviceParas(sNode.Server, comNode.Communication, devNode.Device); } }
private void 除设备ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.mediator.IOTreeForm.SelectedNode is IODeviceNode) { IODeviceNode deviceNode = this.mediator.IOTreeForm.SelectedNode as IODeviceNode; if (MessageBox.Show(this, "是否要删除" + deviceNode.Device.IO_DEVICE_LABLE + "设备?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.mediator.IOTreeForm.SelectedNode.Remove(); } } }
private void wizardTabControl_ButtonOK(object sender, EventArgs e) { if (cb_Driver.SelectedItem == null) { MessageBox.Show("请选择设备驱动"); return; } if (this.txtLabel.Text.Trim() == "") { MessageBox.Show("请输入中文标识"); return; } if (this.txtName.Text.Trim() == "") { MessageBox.Show("请输入设备名称"); return; } IOCommunicationNode commNode = FormManager.mediator.IOTreeForm.IoTree.GetCommunicationNode(Server, Communication); if (commNode != null) { for (int i = 0; i < commNode.Nodes.Count; i++) { IODeviceNode deviceNode = commNode.Nodes[i] as IODeviceNode; if (deviceNode.Device.IO_DEVICE_ADDRESS.Trim() == Device.IO_DEVICE_ADDRESS.Trim() && deviceNode.Device != Device) { MessageBox.Show("设备地址与" + deviceNode.Device.IO_DEVICE_LABLE + " 的设备地址重复!"); return; } } } if (DriverKernel != null) { ScadaResult res = DriverKernel.DeviceCtrl.IsValidParameter(); if (res.Result) { Scada.Model.SCADA_DEVICE_DRIVER driver = cb_Driver.SelectedItem as Scada.Model.SCADA_DEVICE_DRIVER; Device.DEVICE_DRIVER_ID = driver.Id; Device.IO_DEVICE_LABLE = this.txtLabel.Text.Trim(); Device.IO_DEVICE_NAME = this.txtName.Text.Trim(); Device.IO_DEVICE_REMARK = this.txtRemark.Text; Device.IO_DEVICE_STATUS = 1; Device.IO_DEVICE_ADDRESS = this.txtAddress.Text.Trim(); Device.IO_SERVER_ID = Server.SERVER_ID; Device.IO_COMM_ID = Communication.IO_COMM_ID; Device.IO_DEVICE_UPDATECYCLE = Convert.ToInt32(this.nd_updatecycle.Value); Device.IO_DEVICE_OVERTIME = Convert.ToInt32(this.nd_timeout.Value); Device.IO_DEVICE_PARASTRING = DriverKernel.DeviceCtrl.GetUIParameter(); FormManager.InsertIODeviceNode(this.Server, this.Communication, this.Device); this.DialogResult = DialogResult.OK; } else { MessageBox.Show(res.Message); } } this.txtID.Text = Device.IO_DEVICE_ID; this.txtLabel.Text = Device.IO_DEVICE_LABLE; this.txtName.Text = Device.IO_DEVICE_NAME; this.txtRemark.Text = Device.IO_DEVICE_REMARK; this.nd_timeout.Value = Device.IO_DEVICE_OVERTIME; this.nd_updatecycle.Value = Device.IO_DEVICE_UPDATECYCLE; }