public GseControlNode(tGSEControl gsec) { if (gsec == null) { return; } Name = gsec.name + "[" + gsec.type.ToString() + "]"; Tag = gsec; }
/// <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"; }
/// <summary> /// This method Adds a new Node. shows the information to edit all values pre-configured for GSE and GSEControl classes. /// </summary> /// <param name="treeSCL"> /// TreeNode reference. /// </param> /// <param name="gsc"> /// Array of GSEControl values /// </param> public void AddGSE() { // Add a GSEControl to IED tGSEControl cgse = new tGSEControl(); cgse.name = this.cbName.Text; cgse.appID = this.appId.Text; cgse.desc = this.desc.Text; cgse.type = tGSEControlTypeEnum.GOOSE; cgse.datSet = this.datSet.SelectedItem.ToString(); ld.LN0.AddGSEControl(cgse); if (!this.tvscl.AddGSEControlNode(ied.name, ap.name, ld.inst, cgse)) { MessageBox.Show("Can't update Tree for new GSEControl", "Adding a New GOOSE", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Add a GSE to Network tGSE gse = new tGSE(); gse.cbName = cgse.name; gse.desc = cgse.desc; gse.ldInst = ld.inst; gse.InitAddess(); 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) { gse.Address.P[i].Value = this.mac.Text; } if (gse.Address.P[i].typeEnum == tPTypeEnum.APPID) { gse.Address.P[i].Value = this.appId.Text; } if (gse.Address.P[i].typeEnum == tPTypeEnum.VLAN_PRIORITY) { gse.Address.P[i].Value = this.vLANP.Text; } if (gse.Address.P[i].typeEnum == tPTypeEnum.VLAN_ID) { gse.Address.P[i].Value = this.vLANI.Text; } } } int iedindex = this.scl.GetIED(ied.name); var lcap = this.scl.GetIEDConnectedAP(iedindex); for (int i = 0; i < lcap.Count; i++) { IEDConnectedAP iap = (IEDConnectedAP)lcap[i]; tConnectedAP cap = this.scl.GetConnectedAP(iap.subnetwork, iap.connectedap); if (cap.apName.Equals(ap.name) && cap.iedName.Equals(ied.name)) { cap.AddGSE(gse); System.Console.WriteLine("Adding a new GSE Node..."); if (!this.tvscl.AddGSENode(ied.name, ap.name, ld.inst, gse)) { MessageBox.Show("Can't update Tree new GSE", "Adding a New GOOSE", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <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); } } } }