Пример #1
0
        public void CreateIED(SCL sCL, TreeNode nodeSCL)
        {
            tIED iED = new tIED();

            iED.configVersion = "0";
            this.objectManagement.AddObjectToArrayObjectOfParentObject(iED, sCL);
            tAccessPoint accessPoint = new tAccessPoint();

            this.objectManagement.AddObjectToArrayObjectOfParentObject(accessPoint, iED);
            accessPoint.Server = new tServer();
            accessPoint.Server.Authentication = new tServerAuthentication();
            tLDevice lDevice = new tLDevice();

            this.objectManagement.AddObjectToArrayObjectOfParentObject(lDevice, accessPoint.Server);
            lDevice.LN0 = new LN0();
            tLN lN = new tLN();

            lN.lnType  = "LPHD1";
            lN.inst    = 1;
            lN.lnClass = tLNClassEnum.LPHD.ToString();
            lDevice.AddLN(lN);

            this.treeViewSCL.GetNodesItemOfArray(sCL.IED, sCL.GetType(),
                                                 nodeSCL.TreeView.Nodes["root"].Nodes["SCL"]);
            this.CreatingDependenciesLN(sCL, sCL.IED[sCL.IED.Length - 1].AccessPoint[0].Server
                                        .LDevice[0].LN0, nodeSCL.TreeView.Nodes["root"].Nodes["SCL"]
                                        .Nodes["tIED[]"].Nodes[sCL.IED.Length - 1].Nodes["tAccessPoint[]"]
                                        .Nodes[0].Nodes["tServer"].Nodes["tLDevice[]"].Nodes[0].Nodes["LN0"]);
            this.CreatingDependenciesLN(sCL, sCL.IED[sCL.IED.Length - 1].AccessPoint[0].Server
                                        .LDevice[0].LN[0], nodeSCL.TreeView.Nodes["root"].Nodes["SCL"]
                                        .Nodes["tIED[]"].Nodes[sCL.IED.Length - 1].Nodes["tAccessPoint[]"]
                                        .Nodes[0].Nodes["tServer"].Nodes["tLDevice[]"].Nodes[0].Nodes["tLN[]"].Nodes[0]);
        }
Пример #2
0
 /// <summary>
 /// This method sets and gets the FCDA of an LN0.
 /// </summary>
 /// <param name="ldInst">
 /// Attribute "inst" that belongs to LDevice class, it is used on the FCDA class.
 /// </param>
 /// <param name="lN">
 /// Logical node selected where FCDA will be assigned.
 /// </param>
 /// <param name="dataTypeTemplates">
 /// DataTypeTemplates Node of the SCL project. This node is used to create and assign the information
 /// to the Logical Node.
 /// </param>
 /// <returns>
 /// It returns the FCDA of the logical Node selected.
 /// </returns>
 public tDataSet GetLN0FCDAs(tLDevice ld, LN0 lN, tDataTypeTemplates dataTypeTemplates)
 {
     this.ldevice = ld;
     this.ldInst  = ld.inst;
     //this.objectManagement = new ObjectManagement();
     this.lnClass = lN.lnClass.ToString();
     this.lnInst  = lN.inst;
     this.lnType  = lN.lnType;
     this.CreateFCDAs(lN, dataTypeTemplates);
     return(this.dataSet);
 }
Пример #3
0
        public LogicalDeviceNode(tLDevice ld)
        {
            if (ld == null)
            {
                return;
            }

            Tag = ld;
            update_name();
            update_nodes();
            ld.PropertyChanged += new PropertyChangedEventHandler(on_changed);
        }
Пример #4
0
 public LogicalNodeNode(int index, tLDevice d)
 {
     if (d == null)
     {
         return;
     }
     ld         = d;
     this.index = index;
     Tag        = d.LN[index];
     update_name();
     d.LN[index].PropertyChanged += new PropertyChangedEventHandler(on_changed);
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenSCL.UI.GSEDialog"/> class.
        /// </summary>
        /// <param name='tvscl'>
        /// Tvscl.
        /// </param>
        /// <param name='node'>
        /// Node.
        /// </param>
        /// <param name='scl'>
        /// Scl.
        /// </param>
        /// <param name='ied'>
        /// Ied.
        /// </param>
        /// <param name='ap'>
        /// Ap.
        /// </param>
        /// <param name='ld'>
        /// Ld.
        /// </param>
        public GSEDialog(TreeViewSCL tvscl, TreeNode node,
                         tIED ied, tAccessPoint ap, tLDevice ld)
        {
            this.scl   = tvscl.scl;
            this.ied   = ied;
            this.ap    = ap;
            this.ld    = ld;
            this.node  = node;
            this.tvscl = tvscl;

            // The InitializeComponent() call is required for Windows Forms designer support.
            InitializeComponent();
            this.IdInst.Text = ld.inst;
            this.Text        = "New GOOSE";
        }
Пример #6
0
        /// <summary>
        /// This method shows a dialog box that allows to edit a GOOSE or GSE configuration
        /// </summary>
        /// <param name="gseSelected">
        /// GOOSE or GSE that was selected for Edit his configuration.
        /// </param>
        /// <param name="treeSCL">
        /// TreeNode reference
        /// </param>
        /// <param name="apParentName">
        /// Name of Access point where configuration will be edited according to the LN0 selected.
        /// </param>
        /// <param name="iedParentName">
        /// Name of IED where configuration will be edited according to the LN0 selected.
        /// </param>
        public GSEDialog(TreeViewSCL tvscl, TreeNode node, tIED ied, tAccessPoint ap,
                         tLDevice ld, tGSEControl gc)
        {
            this.editWindow = true;
            this.tvscl      = tvscl;
            this.scl        = tvscl.scl;
            this.ld         = ld;
            this.ied        = ied;
            this.ap         = ap;
            this.node       = node;
            this.gsec       = gc;
            InitializeComponent();
            this.datSet.SelectedItem = gc.datSet;
            this.oldGSEName          = gc.name;
            this.IdInst.Text         = this.ld.inst;

            var hgse = this.scl.Configuration.GetGSE(ied.name, ap.name, ld.inst, gc.name);

            if (hgse["gse"] is tGSE)
            {
                this.gse         = (tGSE)hgse["gse"];
                this.cbName.Text = gse.cbName;
                this.desc.Text   = gse.desc;
                if (gse.Address != null && gse.Address.P != null)
                {
                    for (int i = 0; i < gse.Address.P.Length; i++)
                    {
                        if (gse.Address.P[i].typeEnum == tPTypeEnum.MAC_Address)
                        {
                            this.mac.Text = gse.Address.P[i].Value;
                        }
                        if (gse.Address.P[i].typeEnum == tPTypeEnum.APPID)
                        {
                            this.appId.Text = gse.Address.P[i].Value;
                        }
                        if (gse.Address.P[i].typeEnum == tPTypeEnum.VLAN_PRIORITY)
                        {
                            this.vLANP.Text = gse.Address.P[i].Value;
                        }
                        if (gse.Address.P[i].typeEnum == tPTypeEnum.VLAN_ID)
                        {
                            this.vLANI.Text = gse.Address.P[i].Value;
                        }
                    }
                }
            }
            this.Text = "Edit GOOSE";
        }
        public TopLogicalNodeNode(tLDevice ld)
        {
            if (ld == null)
            {
                return;
            }

            Name    = "Logical Nodes";
            this.ld = ld;
            Tag     = ld.LN;
            var cxm     = new System.Windows.Forms.ContextMenuStrip();
            var add_dta = new System.Windows.Forms.ToolStripMenuItem("Add Logical Node",
                                                                     null, on_add_ln);

            cxm.Items.Add(add_dta);
            base.ContextMenuStrip = cxm;
            update_nodes();
        }
Пример #8
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);
             }
         }
     }
 }
Пример #9
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;
            }
        }