Beispiel #1
0
 public IOCommunicationNode FindCommunicationTreeNode(Scada.Model.IO_SERVER Server, Scada.Model.IO_COMMUNICATION Communication)
 {
     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)
                         {
                             return(commNode);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 private void 修改通道ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.mediator.IOTreeForm.SelectedNode is IOCommunicationNode)
     {
         IOCommunicationNode commNode = this.mediator.IOTreeForm.SelectedNode as IOCommunicationNode;
         FormManager.EditIOCommunicationNode(commNode);
     }
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
 private void  除通道ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.mediator.IOTreeForm.SelectedNode is IOCommunicationNode)
     {
         IOCommunicationNode commNode = this.mediator.IOTreeForm.SelectedNode as IOCommunicationNode;
         if (MessageBox.Show(this, "是否要删除" + commNode.Communication.IO_COMM_LABEL + "设备?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             this.mediator.IOTreeForm.SelectedNode.Remove();
         }
     }
 }
Beispiel #6
0
        private void wizardTabControl_ButtonOK(object sender, EventArgs e)
        {
            if (comboDrive.SelectedItem == null)
            {
                MessageBox.Show("请选择通讯驱动");
                return;
            }
            if (this.txtLabel.Text.Trim() == "")
            {
                MessageBox.Show("请输入中文名称");
                return;
            }
            if (this.txtName.Text.Trim() == "")
            {
                MessageBox.Show("请输入通道标识");
                return;
            }
            IOServerNode serverNode = FormManager.mediator.IOTreeForm.IoTree.GetServerNode(Server);

            if (serverNode != null)
            {
                for (int i = 0; i < serverNode.Nodes.Count; i++)
                {
                    IOCommunicationNode commNode = serverNode.Nodes[i] as IOCommunicationNode;
                    if (commNode.Communication.IO_COMM_NAME.Trim() == Comunication.IO_COMM_NAME.Trim() && commNode.Communication != Comunication)
                    {
                        MessageBox.Show("通讯通道" + commNode.Communication.IO_COMM_NAME.Trim() + " 的标识重复!");
                        return;
                    }
                }
            }
            if (DriverCom != null)
            {
                ScadaResult res = DriverCom.CommunicationControl.IsValidParameter();

                if (res.Result)
                {
                    Scada.Model.SCADA_DRIVER driver = comboDrive.SelectedItem as Scada.Model.SCADA_DRIVER;
                    Comunication.IO_COMM_DRIVER_ID  = driver.Id;
                    Comunication.IO_COMM_LABEL      = this.txtLabel.Text.Trim();
                    Comunication.IO_COMM_NAME       = this.txtName.Text.Trim();
                    Comunication.IO_COMM_REMARK     = this.txtRemark.Text;
                    Comunication.IO_COMM_STATUS     = 1;
                    Comunication.IO_SERVER_ID       = Server.SERVER_ID;
                    Comunication.IO_COMM_PARASTRING = DriverCom.GetUIParameter();
                    FormManager.InsertIOCommunicationNode(this.Server, Comunication);
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(res.Message);
                }
            }
        }
Beispiel #7
0
        public void InitForm()
        {
            FormManager.IODeviceDriveCombox(cb_Driver, Communication.IO_COMM_DRIVER_ID);
            if (Device == null)
            {
                Device = new IO_DEVICE();
                Device.IO_DEVICE_ID = GUIDTo16.GuidToLongID().ToString();
                IOCommunicationNode commNode = FormManager.mediator.IOTreeForm.IoTree.GetCommunicationNode(Server, Communication);
                if (commNode != null)
                {
                    int num = commNode.DeviceNumber;
                    Device.IO_DEVICE_NAME        = "Device" + num;
                    Device.IO_DEVICE_LABLE       = Device.IO_DEVICE_NAME;
                    Device.IO_DEVICE_OVERTIME    = 120;
                    Device.IO_DEVICE_UPDATECYCLE = 120;
                    Device.IO_DEVICE_ADDRESS     = num.ToString();
                }

                Device.IO_DEVICE_STATUS = 0;
            }
            Device.IO_COMM_ID   = Communication.IO_COMM_ID;
            Device.IO_SERVER_ID = Server.SERVER_ID;

            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.txtAddress.Text      = Device.IO_DEVICE_ADDRESS;
            this.nd_timeout.Value     = Device.IO_DEVICE_OVERTIME;
            this.nd_updatecycle.Value = Device.IO_DEVICE_UPDATECYCLE;
            for (int i = 0; i < this.cb_Driver.Items.Count; i++)
            {
                Scada.Model.SCADA_DEVICE_DRIVER driver = this.cb_Driver.Items[i] as Scada.Model.SCADA_DEVICE_DRIVER;
                if (driver.Id == Device.DEVICE_DRIVER_ID)
                {
                    this.cb_Driver.SelectedIndex = i;
                    break;
                }
            }
            if (this.cb_Driver.SelectedIndex <= 0 && this.cb_Driver.Items.Count > 0)
            {
                this.cb_Driver.SelectedIndex = 0;
            }
        }
Beispiel #8
0
        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;
        }