Пример #1
0
 /// <summary>
 /// This event edit a selected node.
 /// </summary>
 /// <param name="sender">
 /// Name of the object.
 /// </param>
 /// <param name="e">
 /// This class contains no event data; it is used by events that do not pass state information to an event
 /// handler when an event is raised. If the event handler requires state information, the application must
 /// derive a class from this class to hold the data.
 /// </param>
 private void EditOption_Click(object sender, EventArgs e)
 {
     OpenSCL.Object sCL = new OpenSCL.Object();
     sCL.Configuration = (SCL)this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Tag;
     if (treeSCL.Tag is tPrivate)
     {
         PrivateDialog windowsPrivate = new PrivateDialog(treeSCL.Tag as tPrivate);
         if (windowsPrivate.ShowDialog() == DialogResult.OK)
         {
             Changed(this, EventArgs.Empty);
         }
     }
     else if (treeSCL.Tag is tAnyLN)
     {
         WindowTreeViewLNType windowTreeViewLNType = new WindowTreeViewLNType(this.treeSCL, sCL.Configuration, this.treeSCL.Tag, "Edit");
         windowTreeViewLNType.ReloadLNType();
         if (windowTreeViewLNType.ShowDialog() == DialogResult.OK)
         {
             Changed(this, EventArgs.Empty);
         }
     }
     else if (treeSCL.Tag is tDataSet)
     {
         DataSetDialog windowDataSet = new DataSetDialog();
         windowDataSet.ReloadDataSet(treeSCL, sCL.Configuration);
         if (windowDataSet.ShowDialog() == DialogResult.OK)
         {
             Changed(this, EventArgs.Empty);
         }
     }
     else if (treeSCL.Tag is tGSEControl)
     {
         tGSEControl  cgse   = (tGSEControl)this.treeSCL.TreeView.SelectedNode.Tag;
         tLDevice     ld     = (tLDevice)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Tag;
         tAccessPoint ap     = (tAccessPoint)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Tag;
         tIED         ied    = (tIED)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Tag;
         GSEDialog    gseDlg = new GSEDialog(this.treeViewSCL,
                                             this.treeSCL.TreeView.SelectedNode,
                                             ied, ap, ld, cgse);
         if (gseDlg.ShowDialog() == DialogResult.OK)
         {
             Changed(this, EventArgs.Empty);
         }
     }
     else if (treeSCL.Tag is tSampledValueControl)
     {
         object opt = null;
         if (this.treeSCL.TreeView.SelectedNode.FirstNode != null)
         {
             opt = this.treeSCL.TreeView.SelectedNode.FirstNode.Tag;
         }
         if (this.treeViewSCL.getDataset(this.treeSCL).Count == 0)
         {
             MessageBox.Show("The SCL file should have at least one DataSet configured on this Device",
                             "Warnning",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
         }
         else
         {
             SMVDialog smvDlg = new SMVDialog(this.treeSCL, this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Tag, "name").ToString(),
                                              this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Tag, "name").ToString(),
                                              this.treeSCL.TreeView.SelectedNode.Tag, opt,
                                              this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Tag, "inst").ToString());             //victor
             if (smvDlg.ShowDialog() == DialogResult.OK)
             {
                 Changed(this, EventArgs.Empty);
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Event that will be used when an option of the insert submenu is selected.
        /// </summary>
        /// <param name="sender">
        /// Name of the object.
        /// </param>
        /// <param name="e">
        /// This class contains no event data; it is used by events that do not pass state information to an event
        /// handler when an event is raised. If the event handler requires state information, the application must
        /// derive a class from this class to hold the data.
        /// </param>
        private void clickInsertSCL(object sender, EventArgs e)
        {
            ToolStripMenuItem    ts = (ToolStripMenuItem)sender;
            WindowTreeViewLNType windowTreeViewLNType;

            OpenSCL.Object sCL = this.scl;
            string         apName;
            string         iedName;
            TreeNode       objectFound = null;

            // FIXME:  Add modified
            switch (ts.Name)
            {
            case "Communication":
                apName = this.objectManagement.FindVariable(this
                                                            .treeSCL.TreeView.SelectedNode
                                                            .Parent.Tag, "name").ToString();
                iedName = this.objectManagement.FindVariable(this
                                                             .treeSCL.TreeView.SelectedNode
                                                             .Parent.Parent.Parent.Tag, "name").ToString();
                if (sCL.Configuration.Communication != null && sCL.Configuration.Communication.SubNetwork != null)
                {
                    objectFound = this.treeViewSCL.SeekAssociation(this.treeSCL.TreeView
                                                                   .Nodes["root"].Nodes["SCL"]
                                                                   .Nodes["tCommunication"]
                                                                   .Nodes["tSubNetwork[]"].Nodes, apName, iedName);
                }
                CommunicationDialog comm = new CommunicationDialog(this
                                                                   .treeSCL.TreeView.SelectedNode,
                                                                   sCL.Configuration, iedName,
                                                                   apName, objectFound);
                if (comm.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            case  "tGSEControl":
            {
                tLDevice     ld  = (tLDevice)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Tag;
                tAccessPoint ap  = (tAccessPoint)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Tag;
                tIED         ied = (tIED)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Tag;

                GSEDialog gSEDlg = new GSEDialog(this.treeViewSCL,
                                                 this.treeSCL.TreeView.SelectedNode,
                                                 ied, ap, ld);
                if (gSEDlg.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
            }
            break;

            case  "tGSEControl[]":
                if (this.treeViewSCL.getDataset(this.treeSCL).Count == 0)                     //victor
                {
                    MessageBox.Show("The SCL file should have at least one DataSet configured on this Device",
                                    "Adding a New GOOSE",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    break;
                }
                tLDevice     ld       = (tLDevice)this.treeSCL.TreeView.SelectedNode.Parent.Tag;
                tAccessPoint ap       = (tAccessPoint)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Tag;
                tIED         ied      = (tIED)this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Tag;
                int          iedindex = this.scl.GetIED(ied.name);
                var          lcap     = this.scl.GetIEDConnectedAP(iedindex);
                if (lcap.Count == 0)
                {
                    MessageBox.Show("You mast have at least one connection to a subnetwork\n"
                                    + "Try to add one at tServer of this IED",
                                    "Adding a New GOOSE",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    break;
                }

                GSEDialog gSEDlg = new GSEDialog(this.treeViewSCL,
                                                 this.treeSCL.TreeView.SelectedNode,
                                                 ied, ap, ld);
                if (gSEDlg.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            case  "tSampledValueControl":
                if (this.treeViewSCL.getDataset(this.treeSCL).Count == 0)                     //victor
                {
                    MessageBox.Show("The SCL file should have at least one DataSet configured on this Device",
                                    "Adding a new SampleValue stream", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    break;
                }
                SMVDialog smvDlg = new SMVDialog(this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Tag, "inst").ToString(),
                                                 this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Tag, "name").ToString(),
                                                 this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Tag, "name").ToString(),
                                                 this.treeSCL.TreeView.SelectedNode.Parent);
                if (smvDlg.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            case  "tSampledValueControl[]":
                if (this.treeViewSCL.getDataset(this.treeSCL).Count == 0)
                {
                    MessageBox.Show("The SCL file should have at least one DataSet configured on this Device");
                    break;
                }
                smvDlg = new SMVDialog(this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Tag, "inst").ToString(),
                                       this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Tag, "name").ToString(),
                                       this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Parent.Parent.Parent.Parent.Parent.Parent.Tag, "name").ToString(),
                                       this.treeSCL.TreeView.SelectedNode);
                if (smvDlg.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            case "tDOI[]":
                windowTreeViewLNType = new WindowTreeViewLNType(this.treeSCL.TreeView.SelectedNode,
                                                                sCL.Configuration,
                                                                this.treeSCL.TreeView.SelectedNode.Tag,
                                                                "New");
                if (windowTreeViewLNType.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            case "tDataSet[]":
            case "tDataSet":
                DataSetDialog dataSetDlg = new DataSetDialog();
                dataSetDlg.CreateDataSet(this.treeSCL.TreeView.SelectedNode, sCL.Configuration);
                if (dataSetDlg.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            case "tIED":
                Utils utils = new Utils();
                utils.CreateIED(sCL.Configuration, this.treeSCL);
                Changed(this, EventArgs.Empty);
                break;

            case "tLNode[]":
            case "tLNode":
                LNodeDialog LNodeDlg = new LNodeDialog();
                LNodeDlg.CreatetLNode(this.treeSCL.TreeView.SelectedNode, sCL.Configuration);
                if (LNodeDlg.ShowDialog() == DialogResult.OK)
                {
                    Changed(this, EventArgs.Empty);
                }
                break;

            default:
                if (this.treeViewSCL.Insert(this.treeSCL.TreeView.SelectedNode, ts.Text, ts.Name))
                {
                    Changed(this, EventArgs.Empty);
                }
                break;
            }
        }