示例#1
0
        public IODeviceNode()
        {
            Device       = new IO_DEVICE();
            mContextMenu = new ContextMenu();

            mContextMenu.MenuItems.Add(new MenuItem("删除设备")
            {
                Tag = 1
            });
            mContextMenu.MenuItems.Add(new MenuItem("修改设备")
            {
                Tag = 2
            });
            mContextMenu.MenuItems.Add(new MenuItem("编辑IO表")
            {
                Tag = 3
            });
            mContextMenu.MenuItems[0].Click += DeviceNode_Click;
            mContextMenu.MenuItems[1].Click += DeviceNode_Click;
            mContextMenu.MenuItems[2].Click += DeviceNode_Click;

            this.ContextMenu        = mContextMenu;
            Device.IO_DEVICE_ID     = GUIDTo16.GuidToLongID().ToString();
            this.SelectedImageIndex = 2;
            this.StateImageIndex    = 2;
            this.ImageIndex         = 2;
            ChangedNode();
        }
示例#2
0
        public IOCommunicationNode()
        {
            Communication = new IO_COMMUNICATION();
            mContextMenu  = new ContextMenu();
            mContextMenu.MenuItems.Add(new MenuItem("删除通讯通道")
            {
                Tag = 1
            });
            mContextMenu.MenuItems.Add(new MenuItem("修改通讯通道")
            {
                Tag = 2
            });
            mContextMenu.MenuItems.Add(new MenuItem("新增设备")
            {
                Tag = 3
            });

            mContextMenu.MenuItems[0].Click += IOCommunicationNode_Click;
            mContextMenu.MenuItems[1].Click += IOCommunicationNode_Click;
            mContextMenu.MenuItems[2].Click += IOCommunicationNode_Click;
            this.ContextMenu         = mContextMenu;
            Communication.IO_COMM_ID = GUIDTo16.GuidToLongID().ToString();

            this.SelectedImageIndex = 1;
            this.StateImageIndex    = 1;
            this.ImageIndex         = 1;
            ChangedNode();
        }
示例#3
0
 public DockContent CreateWorkForm(string Title, float width, float height)
 {
     lastAdded = tabFactory.GetTab(new TabCodon("W" + GUIDTo16.GuidToLongID(), Title, TabTypes.WorkArea)
     {
         MapHeight = height, MapWidth = width
     }) as WorkForm;
     lastAdded.TabText = Title;
     lastAdded.Text    = Title;
     OnShowTab(lastAdded);
     return(lastAdded);
 }
示例#4
0
 private void 粘贴视图ToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.treeView.SelectedNode is FlowProjectNode)
         {
             GraphAbstract data       = null;
             IDataObject   dataObject = Clipboard.GetDataObject();
             if (dataObject.GetDataPresent("Scada.FlowGraphEngine.GraphicsMap.GraphSite.Copy"))
             {
                 data = dataObject.GetData("Scada.FlowGraphEngine.GraphicsMap.GraphSite.Copy") as GraphAbstract;
             }
             if (data != null)
             {
                 FlowProjectNode  selectedNode = this.treeView.SelectedNode as FlowProjectNode;
                 CreateViewDialog dialog       = new CreateViewDialog();
                 if (dialog.ShowDialog(this) == DialogResult.OK)
                 {
                     data.GID = "V_" + GUIDTo16.GuidToLongID();
                     SCADAViewNode node = new SCADAViewNode
                     {
                         Text             = dialog.ViewName,
                         ContextMenuStrip = this.contextMenuView,
                         View             = (WorkForm)this.mediator.CreateWorkForm(dialog.ViewName, (float)dialog.PageWidth, (float)dialog.PageHeight)
                     };
                     node.View.GraphControl.Abstract       = data;
                     node.View.GraphControl.Abstract.Site  = node.View.GraphControl;
                     node.View.GraphControl.BasicLayer     = data.Layers[0];
                     node.View.GraphControl.SaveViewResult = delegate(bool res, string msg) {
                         if (res)
                         {
                             this.LoadTreeViewTemplate();
                         }
                         else
                         {
                             MessageBox.Show(this, msg);
                         }
                     };
                     selectedNode.Nodes.Add(node);
                     selectedNode.Project.GraphList.Add(node.View.GraphControl.Abstract);
                 }
                 Clipboard.Clear();
             }
         }
     }
     catch (Exception exception1)
     {
         MessageBox.Show(exception1.Message);
     }
 }
示例#5
0
        private void ucBtnSend_BtnClick(object sender, EventArgs e)
        {
            if (comboIOPara.SelectedItem == null)
            {
                FrmDialog.ShowDialog(this, "请选择要设置的参数");
                return;
            }
            double dvalue = 0;

            if (tbValue.Text.Trim() == "")
            {
                FrmDialog.ShowDialog(this, "请输入下置的值");
                return;
            }
            if (!double.TryParse(tbValue.Text.Trim(), out dvalue))
            {
                FrmDialog.ShowDialog(this, "请输入下置的数值,不能是文本");
                return;
            }
            if (FrmDialog.ShowDialog(this, "您确定要下置命令吗?", "提醒", true, true, true, true) == DialogResult.OK)
            {
                IO_COMMANDS cmmd = new IO_COMMANDS();
                cmmd.COMMAND_DATE   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                cmmd.COMMAND_ID     = GUIDTo16.GuidToLongID().ToString();
                cmmd.COMMAND_RESULT = "false";
                cmmd.COMMAND_USER   = IOCenterManager.IOProject.ServerConfig.User;
                cmmd.COMMAND_VALUE  = tbValue.Text.Trim();
                cmmd.IO_COMM_ID     = Communication.IO_COMM_ID;
                cmmd.IO_DEVICE_ID   = Device.IO_DEVICE_ID;
                cmmd.IO_SERVER_ID   = Server.SERVER_ID;
                cmmd.IO_LABEL       = ((IO_PARA)comboIOPara.SelectedItem).IO_LABEL;
                cmmd.IO_NAME        = ((IO_PARA)comboIOPara.SelectedItem).IO_NAME;
                cmmd.IO_ID          = ((IO_PARA)comboIOPara.SelectedItem).IO_ID;

                Command = cmmd;
                this.ucStep.StepIndex = 0;
                try
                {
                    Scada.AsyncNetTcp.TcpData tcpData = new Scada.AsyncNetTcp.TcpData();
                    byte[] datas = tcpData.StringToTcpByte(cmmd.GetCommandString(), Scada.AsyncNetTcp.ScadaTcpOperator.置命令);
                    this.ucStep.StepIndex = 1;
                }
                catch (Exception ex)
                {
                    FrmDialog.ShowDialog(this, ex.Message);
                }
            }
        }
示例#6
0
 public IOParaNode()
 {
     this.ContextMenu = new  ContextMenu();
     this.ContextMenu.MenuItems.Add(new MenuItem("删除")
     {
     });
     this.ContextMenu.MenuItems.Add(new MenuItem("修改")
     {
     });
     this.ContextMenu.MenuItems[0].Click += IOParaNode_Click;
     this.ContextMenu.MenuItems[1].Click += IOParaNode_Click;
     IOPara.IO_ID            = GUIDTo16.GuidToLongID().ToString();
     this.SelectedImageIndex = 3;
     this.StateImageIndex    = 3;
     this.ImageIndex         = 3;
 }
示例#7
0
        public static void CreateNewProject()
        {
            CreateProjectDialog dig = new CreateProjectDialog();

            if (dig.ShowDialog(FlowDesign) == DialogResult.OK)
            {
                FlowProject Project = new FlowProject();
                Project.Title        = dig.ProjectTitle;
                Project.Password     = dig.Password;
                Project.ProjectID    = GUIDTo16.GuidToLongID().ToString();
                Project.FileFullName = dig.FileFullName;
                Mediator.ToolForm.InitTreeView(Project);
                Mediator.ToolForm.InitTreeUser(Project);
                Mediator.ToolForm.InitTreeConnections(Project);

                Projects.Add(Project);
            }
        }
示例#8
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;
            }
        }
示例#9
0
        // Methods
        public FlowProject()
        {
            this.FlowUsers        = new List <ScadaFlowUser>();
            this.ScadaConnections = new List <ScadaConnectionBase>();
            this.mTitle           = "";
            this.mCreateDate      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            this.mProjectID       = "";
            this.mGraphList       = new List <GraphAbstract>();
            this.mPassword        = "******";
            this.FileFullName     = "";
            this.mProjectID       = GUIDTo16.GuidToLongID().ToString();
            ScadaFlowUser item = new ScadaFlowUser
            {
                Nickname = "管理员",
                UserName = "******",
                Password = "******",
                Read     = 1,
                Write    = 1
            };

            this.FlowUsers.Add(item);
        }
示例#10
0
        public void InitForm()
        {
            FormManager.IOCommunicationDriveCombox(comboDrive);

            if (Comunication == null)
            {
                Comunication            = new IO_COMMUNICATION();
                Comunication.IO_COMM_ID = GUIDTo16.GuidToLongID().ToString();
                IOServerNode serverNode = FormManager.mediator.IOTreeForm.IoTree.GetServerNode(Server);
                if (serverNode != null)
                {
                    Comunication.IO_COMM_LABEL = "Communication" + serverNode.CommunicationNumber;
                    Comunication.IO_COMM_NAME  = "";
                }

                Comunication.IO_COMM_STATUS = 1;
            }
            Comunication.IO_SERVER_ID = Server.SERVER_ID;

            this.txtID.Text     = Comunication.IO_COMM_ID;
            this.txtLabel.Text  = Comunication.IO_COMM_LABEL;
            this.txtName.Text   = Comunication.IO_COMM_NAME;
            this.txtRemark.Text = Comunication.IO_COMM_REMARK;
            for (int i = 0; i < this.comboDrive.Items.Count; i++)
            {
                Scada.Model.SCADA_DRIVER driver = this.comboDrive.Items[i] as Scada.Model.SCADA_DRIVER;
                if (driver.Id == Comunication.IO_COMM_DRIVER_ID)
                {
                    this.comboDrive.SelectedIndex = i;
                    break;
                }
            }
            if (this.comboDrive.SelectedIndex <= 0 && this.comboDrive.Items.Count > 0)
            {
                this.comboDrive.SelectedIndex = 0;
            }
        }
示例#11
0
 private void GetTemplateShape(Shape shape, List <Shape> shapes)
 {
     if (shape.GetType().BaseType == typeof(SVGContainer))
     {
         SVGContainer container = (SVGContainer)shape;
         for (int c = container.Shapes.Count - 1; c >= 0; c--)
         {
             Shape existShape = shapes.Find(x => x.UID == container.Shapes[c].UID);
             if (existShape != null)
             {
                 container.Shapes[c].Shape = existShape;
                 if (container.Shapes[c].Shape != null)
                 {
                     container.Shapes[c].ChangedUid();
                     container.Shapes[c].Shape.Name = "Element" + container.Shapes[c].UID;
                     GetTemplateShape(container.Shapes[c].Shape, shapes);
                 }
                 else
                 {
                     container.Shapes.RemoveAt(c);
                 }
             }
         }
     }
     else if (shape.GetType() == typeof(SVG_TabPanelShape))//tab页面
     {
         SVG_TabPanelShape container = (SVG_TabPanelShape)shape;
         for (int c = 0; c < container.TabPages.Count; c++)
         {
             for (int s = container.TabPages[c].Shapes.Count - 1; s >= 0; s--)
             {
                 Shape existShape = shapes.Find(x => x.UID == container.TabPages[c].Shapes[s].UID);
                 if (existShape != null)
                 {
                     container.TabPages[c].Shapes[s].Shape = existShape;
                     if (container.TabPages[c].Shapes[s].Shape != null)
                     {
                         container.TabPages[c].Shapes[s].ChangedUid();
                         container.TabPages[c].Shapes[s].Shape.Name = "Element" + container.TabPages[c].Shapes[s].UID;
                         GetTemplateShape(container.TabPages[c].Shapes[s].Shape, shapes);
                     }
                 }
                 else
                 {
                     container.TabPages[c].Shapes.RemoveAt(s);
                 }
             }
         }
     }
     else if (shape.GetType() == typeof(Combination))//组合体
     {
         Combination container = (Combination)shape;
         for (int c = container.Shapes.Count - 1; c >= 0; c--)
         {
             Shape existShape = shapes.Find(x => x.UID == container.Shapes[c]);
             if (existShape != null)
             {
                 existShape.UID      = "ID" + GUIDTo16.GuidToLongID().ToString();
                 existShape.Name     = "Element" + existShape.UID;
                 container.Shapes[c] = existShape.UID;
                 GetTemplateShape(existShape, shapes);
             }
             else
             {
                 container.Shapes.RemoveAt(c);
             }
         }
     }
 }
示例#12
0
        private void wizardTabControl_ButtonOK(object sender, EventArgs e)
        {
            try
            {
                if (tb_paraname.Text.Trim() == "")
                {
                    MessageBox.Show("请输入IO参数名称");
                    return;
                }

                if (cb_paratype.SelectedItem == null)
                {
                    MessageBox.Show("请选择IO类型");
                    return;
                }
                if (cb_datatype.SelectedItem == null)
                {
                    MessageBox.Show("请选择IO模拟量数据类型");
                    return;
                }


                //量程转换输入判断
                if (this.cb_range.Checked)
                {
                    if (Convert.ToDouble(this.tb_maxrange.Text) <= Convert.ToDouble(this.tb_minrange.Text))
                    {
                        MessageBox.Show("量程范围不匹配");
                        return;
                    }
                    if (Convert.ToDouble(this.tb_valuemax.Text) <= Convert.ToDouble(this.tb_valuemin.Text))
                    {
                        MessageBox.Show("裸数据范围不匹配");
                        return;
                    }
                }
                if (cb_paratype.SelectedIndex == 5)
                {
                    cb_datatype.SelectedIndex = 8;
                }

                Para.IO_ADDRESS               = this.tb_address.Text.Trim();
                Para.IO_ALERT_ENABLE          = Convert.ToInt32(cb_alarm.Checked);
                Para.IO_COMM_ID               = Comunication.IO_COMM_ID;
                Para.IO_DATATYPE              = cb_datatype.SelectedItem.ToString();
                Para.IO_DEVICE_ID             = Device.IO_DEVICE_ID;
                Para.IO_ENABLEALARM           = Convert.ToInt32(cb_alarm.Checked);
                Para.IO_ENABLERANGECONVERSION = Convert.ToInt32(cb_range.Checked);
                Para.IO_HISTORY               = 1;
                Para.IO_INITALVALUE           = tb_initvalue.Text;
                Para.IO_LABEL    = tb_parachname.Text;
                Para.IO_MAXVALUE = tb_valuemax.Text;
                Para.IO_MINVALUE = tb_valuemin.Text;
                Para.IO_NAME     = tb_paraname.Text.Trim();
                Para.IO_ONE      = tb_one.Text.Trim();
                Para.IO_OUTLIES  = tbDecimalplace.Text.Trim();
                if (DeviceKernel != null)
                {
                    Para.IO_PARASTRING = DeviceKernel.ParaCtrl.GetUIParameter();
                }
                Para.IO_POINTTYPE = cb_paratype.SelectedItem.ToString();
                Para.IO_RANGEMAX  = tb_maxrange.Text;
                Para.IO_RANGEMIN  = tb_minrange.Text;
                Para.IO_SERVER_ID = Server.SERVER_ID;
                Para.IO_SYSTEM    = 0;
                Para.IO_UNIT      = cb_unittype.Text.Trim();
                Para.IO_ZERO      = tb_zone.Text;
                //公式配置部分
                Para.IO_FORMULA = txtFormula.Text.Trim();
                //数据源设置部分
                #region
                {
                    Para.IO_DATASOURCE  = "";
                    Para.IO_DATASOURCE  = this.txtDataSourceIP.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceName.Text;
                    Para.IO_DATASOURCE += "," + this.cbDatabaseType.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceUser.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourcePassword.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceTable.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceValueRecord.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceValueRecordType.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceDateRecord.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceDateRecordRange.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceOrderRecord.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceOrderRecordType.Text;
                    Para.IO_DATASOURCE += "," + this.txtDataSourceWhere.Text;
                }
                #endregion

                //报警部分设置
                Para.AlarmConfig.IO_SERVER_ID     = Para.IO_SERVER_ID;
                Para.AlarmConfig.IO_COMM_ID       = Para.IO_COMM_ID;
                Para.AlarmConfig.IO_DEVICE_ID     = Para.IO_DEVICE_ID;
                Para.AlarmConfig.IO_ID            = Para.IO_ID;
                Para.AlarmConfig.IO_ENABLE_MAX    = Convert.ToInt32(cb_maxenable.Checked);
                Para.AlarmConfig.IO_ENABLE_MAXMAX = Convert.ToInt32(cb_maxmaxenable.Checked);
                Para.AlarmConfig.IO_ENABLE_MIN    = Convert.ToInt32(cb_minenable.Checked);
                Para.AlarmConfig.IO_ENABLE_MINMIN = Convert.ToInt32(cb_minminenable.Checked);
                if (cbo_minmin.SelectedItem != null)
                {
                    Para.AlarmConfig.IO_MINMIN_TYPE = cbo_minmin.SelectedItem.ToString();
                }
                if (cbo_min.SelectedItem != null)
                {
                    Para.AlarmConfig.IO_MIN_TYPE = cbo_min.SelectedItem.ToString();
                }
                if (cbo_max.SelectedItem != null)
                {
                    Para.AlarmConfig.IO_MAX_TYPE = cbo_max.SelectedItem.ToString();
                }
                if (cbo_maxmax.SelectedItem != null)
                {
                    Para.AlarmConfig.IO_MAXMAX_TYPE = cbo_maxmax.SelectedItem.ToString();
                }



                Para.AlarmConfig.IO_MINMIN_VALUE = nb_minmin.Value;
                Para.AlarmConfig.IO_MIN_VALUE    = nb_min.Value;
                Para.AlarmConfig.IO_MAX_VALUE    = nb_max.Value;
                Para.AlarmConfig.IO_MAXMAX_VALUE = nb_maxmax.Value;
                Para.AlarmConfig.IO_ALARM_LEVEL  = "";

                if (this.cb_alarm.Checked)
                {
                    if (nb_maxmax.Value <= Para.AlarmConfig.IO_MIN_VALUE || nb_maxmax.Value <= Para.AlarmConfig.IO_MINMIN_VALUE || nb_maxmax.Value <= Para.AlarmConfig.IO_MAX_VALUE)
                    {
                        MessageBox.Show("超高限值不能小于等于高限、低限、超低限值");
                        return;
                    }
                    if (nb_max.Value <= Para.AlarmConfig.IO_MINMIN_VALUE || nb_max.Value <= Para.AlarmConfig.IO_MIN_VALUE)
                    {
                        MessageBox.Show("高限值不能小于等于低限、超低限值");
                        return;
                    }
                    if (nb_min.Value <= Para.AlarmConfig.IO_MINMIN_VALUE)
                    {
                        MessageBox.Show("超高限值不能小于等于高限、低限、超低限值");
                        return;
                    }
                }
                string strs = "";
                for (int i = 0; i < listCons.Items.Count; i++)
                {
                    strs += listCons.Items[i].ToString() + ",";
                }
                if (strs != "")
                {
                    strs = strs.Remove(strs.Length - 1, 1);
                }
                Para.AlarmConfig.IO_CONDITION = strs;
                if (Para.IO_ID == null || Para.IO_ID == "")//新建
                {
                    for (int i = 0; i < this.Device.IOParas.Count; i++)
                    {
                        if (this.Device.IOParas[i] != Para && Para.IO_NAME.Trim() == this.Device.IOParas[i].IO_NAME.Trim())
                        {
                            MessageBox.Show("已经存" + Para.IO_NAME.Trim() + "名称的IO点");
                            return;
                        }
                    }
                    Para.IO_ID = GUIDTo16.GuidToLongID().ToString();
                    IOListViewItem lvi = new IOListViewItem(Para);
                    this.Device.IOParas.Add(Para);
                    FormManager.mediator.IOParaForm.AddListViewItem(lvi);
                    FormManager.mediator.IOLogForm.AppendText(FormManager.mediator.IOParaForm.IOListView.IOPath + " 创建IO点" + Para.IO_NAME + "成功!");
                }
                else
                {
                    for (int i = 0; i < this.Device.IOParas.Count; i++)
                    {
                        if (this.Device.IOParas[i] != Para && Para.IO_NAME.Trim() == this.Device.IOParas[i].IO_NAME.Trim())
                        {
                            MessageBox.Show("已经存" + Para.IO_NAME.Trim() + "名称的IO点");
                            return;
                        }
                    }
                    IOListViewItem lvi = FormManager.mediator.IOParaForm.GetListViewItem(Para);
                    if (lvi != null)
                    {
                        lvi.ResetSubItems();
                        FormManager.mediator.IOLogForm.AppendText(FormManager.mediator.IOParaForm.IOListView.IOPath + " 修改IO点" + Para.IO_NAME + "成功!");
                    }
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception emx)
            {
                FormManager.DisplayException(emx);
            }
        }