Пример #1
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);
                }
            }
        }
Пример #2
0
        protected override ScadaResult IOSendCommand(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, IO_PARA para, string value)
        {
            ScadaResult res = new ScadaResult();

            if (device == null)
            {
                res = new ScadaResult(false, "设备对象不存在");
            }

            //用户发送一条命令后要及时获取最新的数据,主要是因为有些命令需要及时判断命令是否成功,
            if (ResponseData(server, comm, device, para, value))
            {
                RealData realData = this.RealDevices.Find(x => x.Device == device);
                string   error    = "";
                if (RequestData(realData.Device, realData, out error, realData.Fragment))
                {
                    res = new ScadaResult(true, "请求数据成功");
                }
            }
            DataSended(server, comm, device, para, value, res.Result);
            return(res);
        }
Пример #3
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;
        }