Exemple #1
0
        public void DeactivateNVL(NodeVL vl)
        {
            Iec61850State iecs = vl.GetIecs();

            if (iecs != null)
            {
                if (vl.urcb != null)
                {
                    NodeData        d    = (NodeData)vl.urcb.Parent;
                    List <NodeData> ndar = new List <NodeData>();
                    NodeBase        b;
                    if ((b = d.FindChildNode("RptEna")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = false;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("GI")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = false;
                        ndar.Add(n);
                    }
                    iecs.Send(ndar.ToArray(), d.CommAddress, ActionRequested.Write);
                    vl.Activated = false;
                    vl.urcb      = null;
                }
            }
            else
            {
                Logger.getLogger().LogError("Basic structure not found!");
            }
        }
Exemple #2
0
        /// <summary>
        /// Reads through a data set subtree and creates a data set node from it
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="nodeName"></param>
        /// <param name="deviceName"></param>
        /// <returns> a VL node </returns>
        private NodeVL CreateDataSet(XmlReader reader, string nodeName, string deviceName, Iec61850Model _dataModel)
        {
            reader.Read();

            var nodeVL = new NodeVL(String.Concat(nodeName, "$", reader.GetAttribute("name")));
            var test   = reader.GetAttribute("name");

            while (reader.Read())
            {
                if (reader.IsStartElement() && reader.Name.Equals("FCDA"))
                {
                    var prefix   = reader.GetAttribute("prefix");
                    var lnClass  = reader.GetAttribute("lnClass");
                    var lnInst   = reader.GetAttribute("lnInst");
                    var fullName = String.Concat(prefix, lnClass, lnInst);
                    var ldInst   = reader.GetAttribute("ldInst");
                    var doName   = reader.GetAttribute("doName");
                    var fc       = reader.GetAttribute("fc");

                    var nodeData = _dataModel.ied.AddChildNode(new NodeLD(String.Concat(_dataModel.ied.Name, ldInst)))
                                   .AddChildNode(new NodeLN(fullName))
                                   .AddChildNode(new NodeFC(fc)).AddChildNode(new NodeData(doName));

                    nodeVL.ForceLinkChildNode(nodeData);
                }
            }
            return(nodeVL);
        }
Exemple #3
0
        void OnDeleteNVLClick(object sender, EventArgs e)
        {
            NodeVL        nvl  = (NodeVL)(sender as ToolStripItem).Tag;
            Iec61850State iecs = nvl.GetIecs();

            NodeBase[] ndarr = new NodeBase[1];
            ndarr[0] = nvl;
            iecs.Send(ndarr, nvl.CommAddress, ActionRequested.DefineNVL);
        }
Exemple #4
0
        public void DefineNVL(NodeVL nvl)
        {
            List <NodeBase> ndar = new List <NodeBase>();

            foreach (NodeBase n in nvl.GetChildNodes())
            {
                ndar.Add(n);
            }
            iecs.Send(ndar.ToArray(), nvl.CommAddress, ActionRequested.DefineNVL);
        }
Exemple #5
0
        void OnAddNVLClick(object sender, EventArgs e)
        {
            NodeBase lists   = (NodeBase)(sender as ToolStripItem).Tag;
            NodeVL   newnode = new NodeVL("NewNamedVariableList");

            newnode.Parent = lists;
            AddNVLDialog d = new AddNVLDialog(newnode, lists, listsNode, OnNVListChanged);

            d.Show();
        }
Exemple #6
0
 void createVL(NodeVL vl, LogicalNode ln)
 {
     IEC61850.Server.DataSet dataSet = new IEC61850.Server.DataSet(vl.Name, ln);
     vl.SCLServerModelObject = dataSet;
     foreach (NodeVLM vlm in vl.GetChildNodes())
     {
         DataSetEntry dse = new DataSetEntry(dataSet, vlm.SCL_ServerLink, -1, null);
         vlm.SCLServerModelObject = dse;
     }
 }
Exemple #7
0
        void OnDefineNVLClick(object sender, EventArgs e)
        {
            NodeVL          nvl  = (NodeVL)(sender as ToolStripItem).Tag;
            Iec61850State   iecs = nvl.GetIecs();
            List <NodeBase> ndar = new List <NodeBase>();

            foreach (NodeBase n in nvl.GetChildNodes())
            {
                ndar.Add(n);
            }
            iecs.Send(ndar.ToArray(), nvl.CommAddress, ActionRequested.DefineNVL);
        }
Exemple #8
0
        internal AddNVLView(NodeVL list, NodeBase lists, TreeNode listsNode, EventHandler onNVListChanged)
        {
            InitializeComponent();
            this.list = list;
            this.lists = lists;
            this.listsNode = listsNode;
            this.OnNVListChanged += onNVListChanged;

            this.textBox1.Text = list.Name;
            foreach (NodeBase b in list.GetChildNodes())
            {
                ListViewItem it = this.listView1.Items.Add(new ListViewItem(b.IecAddress));
                it.Tag = b;
            }
        }
Exemple #9
0
        private void CreateDataSets(NodeLN logicalNode, IEnumerable <XElement> elements, XNamespace ns)
        {
            XAttribute a;
            NodeBase   ld = logicalNode.Parent;

            foreach (XElement el in elements)
            {
                NodeVL nodeVL = new NodeVL(el.Attribute("name").Value);
                logicalNode.AddChildNode(nodeVL);
                foreach (XElement dsMember in el.Elements(ns + "FCDA"))
                {
                    try
                    {
                        a = dsMember.Attribute("prefix");
                        string prefix2 = a != null ? a.Value : "";
                        a = dsMember.Attribute("lnClass");
                        string lnClass2 = a != null ? a.Value : "";
                        a = dsMember.Attribute("lnInst");
                        string lnInst   = a != null ? a.Value : "";
                        string fullName = String.Concat(prefix2, lnClass2, lnInst);
                        a = dsMember.Attribute("ldInst");
                        string ldInst = a != null ? a.Value : "";
                        a = dsMember.Attribute("doName");
                        string doName = a != null ? a.Value : "";
                        a = dsMember.Attribute("fc");
                        string fc = a != null ? a.Value : "";

                        // We are at the LN level, up 2 levels is an ied
                        //NodeIed iec = ld.Parent as NodeIed;

                        string serverLink = ld.Name + "/" + fullName + "." + fc + "." + doName;
                        serverLink = serverLink.Replace('.', '$');
                        string memberName = ld.Name + "/" + fullName + "." + doName;

                        // Cannot be done directly, the data are not yet present (instantiated)
                        // instead, add a temporary object
                        NodeVLM vlm = new NodeVLM(memberName);
                        vlm.SCL_FCDesc     = fc;
                        vlm.SCL_ServerLink = serverLink;
                        nodeVL.AddChildNode(vlm);
                    }
                    catch (Exception e)
                    {
                        Logger.getLogger().LogError("CreateDataSets IEC: " + e.Message);
                    }
                }
            }
        }
Exemple #10
0
        private void processDataSet(XmlNode LNNodeCn, NodeBase NLNb, Iec61850State iecf, string IEDName, string LNNodeName)
        {
            NodeVL VL = new NodeVL(LNNodeName + "$" + getStringAttribute(LNNodeCn, "name"));

            VL.Defined = true;
            NodeBase VLNb = NLNb.AddChildNode(VL);

            foreach (XmlNode DataSetCn in LNNodeCn.ChildNodes)
            {
                if (DataSetCn.Name == "FCDA")
                {
                    string addr = getAddrFromFCDA(DataSetCn);

                    NodeBase Nb = (iecf.DataModel.ied as NodeIed).FindNodeByAddress(IEDName + getStringAttribute(DataSetCn, "ldInst"), getAddrFromFCDA(DataSetCn));

                    if (Nb != null)
                    {
                        VLNb.LinkChildNode(Nb);
                    }
                }
            }
        }
Exemple #11
0
        void OnDeactivateNVLClick(object sender, EventArgs e)
        {
            NodeVL        vl   = (NodeVL)(sender as ToolStripItem).Tag;
            Iec61850State iecs = vl.GetIecs();

            if (iecs != null)
            {
                if (vl.urcb != null)
                {
                    NodeData        d    = (NodeData)vl.urcb.Parent;
                    List <NodeData> ndar = new List <NodeData>();
                    NodeBase        b;
                    if ((b = d.FindChildNode("RptEna")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = false;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("GI")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = false;
                        ndar.Add(n);
                    }
                    iecs.Send(ndar.ToArray(), d.CommAddress, ActionRequested.Write);
                    vl.Activated = false;
                    vl.urcb      = null;
                }
            }
            else
            {
                MessageBox.Show("Basic structure not found!");
            }
        }
Exemple #12
0
        private void toolStripButtonOK_Click(object sender, EventArgs e)
        {
            NodeVL existingNode = (NodeVL)lists.FindChildNode(this.textBox1.Text);
            if ( null != existingNode)
            {
                // List name already exist
                if (existingNode.Defined)
                {
                    MessageBox.Show("Cannot change the NVL " + existingNode.Name + ", already defined on the server. Change the name.");
                    return;
                }
            }
            if (this.textBox1.Text == "")
            {
                MessageBox.Show("Empty NVL Name, cannot add it to the local tree. Change the name.");
                return;
            }
            NodeVL newlist = new NodeVL(textBox1.Text);
            newlist.Tag = list.Tag;
            if (newlist.Tag != null && newlist.Tag is TreeNode && (newlist.Tag as TreeNode).Tag == list)
                (newlist.Tag as TreeNode).Tag = newlist;
            newlist.urcb = list.urcb;
            newlist.Parent = list.Parent;
            newlist.Deletable = true;
            foreach (ListViewItem it in listView1.Items)
            {
                newlist.LinkChildNodeByAddress(it.Tag as NodeBase);
            }
            list = newlist;
            if (OnNVListChanged != null)
            {
                OnNVListChanged(this, new EventArgs());
            }
            this.Close();

        }
Exemple #13
0
        public void ActivateNVL(NodeVL vl)
        {
            //Logger.getLogger().LogError("Function not active, try to configure an RCB!");
            //return;

            NodeBase      ur   = null;
            Iec61850State iecs = vl.GetIecs();
            bool          retry;

            if (iecs != null)
            {
                do
                {
                    ur = (NodeData)iecs.DataModel.ied.FindNodeByValue(scsm_MMS_TypeEnum.visible_string, vl.IecAddress, ref ur);
                    if (ur == null || ur.Parent == null)
                    {
                        Logger.getLogger().LogError("Suitable URCB not found, list cannot be activated!");
                        return;
                    }
                    retry   = !ur.Parent.Name.ToLower().Contains("rcb");
                    vl.urcb = (NodeData)ur;
                    NodeData d = (NodeData)vl.urcb.Parent;
                    NodeData b;
                    if ((b = (NodeData)d.FindChildNode("Resv")) != null)
                    {
                        // Resv is always a boolean
                        // If true then the rcb is occupied and we need to find another one
                        if ((bool)b.DataValue)
                        {
                            retry = true;
                        }
                    }
                } while (retry);

                if (vl.urcb != null)
                {
                    NodeData        d    = (NodeData)vl.urcb.Parent;
                    List <NodeData> ndar = new List <NodeData>();
                    NodeBase        b;
                    if ((b = d.FindChildNode("Resv")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = true;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("DatSet")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = ((NodeData)b).DataValue;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("OptFlds")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = new byte[] { 0x7c, 0x00 };
                        n.DataParam = 6;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("TrgOps")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = new byte[] { 0x74 };
                        n.DataParam = 2;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("RptEna")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = true;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("GI")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = true;
                        ndar.Add(n);
                    }
                    iecs.Send(ndar.ToArray(), d.CommAddress, ActionRequested.Write);
                    vl.Activated = true;
                }
            }
            else
            {
                Logger.getLogger().LogError("Basic structure not found!");
            }
        }
Exemple #14
0
 public void DeleteNVL(NodeVL nvl)
 {
     NodeBase[] ndarr = new NodeBase[1];
     ndarr[0] = nvl;
     iecs.Send(ndarr, nvl.CommAddress, ActionRequested.DeleteNVL);
 }
Exemple #15
0
        void OnActivateNVLClick(object sender, EventArgs e)
        {
            NodeVL        vl   = (NodeVL)(sender as ToolStripItem).Tag;
            NodeBase      ur   = null;
            Iec61850State iecs = vl.GetIecs();

            if (iecs != null)
            {
                do
                {
                    ur = (NodeData)iecs.ied.FindNodeByValue(scsm_MMS_TypeEnum.visible_string, vl.Address, ref ur);
                    if (ur == null)
                    {
                        MessageBox.Show("Suitable URCB not found, list cannot be activated!");
                        return;
                    }
                } while (!ur.Parent.Name.ToLower().Contains("rcb"));
                vl.urcb = (NodeData)ur;

                if (vl.urcb != null)
                {
                    NodeData        d    = (NodeData)vl.urcb.Parent;
                    List <NodeData> ndar = new List <NodeData>();
                    NodeBase        b;
                    if ((b = d.FindChildNode("Resv")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = true;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("DatSet")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = ((NodeData)b).DataValue;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("OptFlds")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = new byte[] { 0x7c, 0x00 };
                        n.DataParam = 6;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("TrgOps")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = new byte[] { 0x74 };
                        n.DataParam = 2;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("RptEna")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = true;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("GI")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = true;
                        ndar.Add(n);
                    }
                    iecs.Send(ndar.ToArray(), d.CommAddress, ActionRequested.Write);
                    vl.Activated = true;
                }
            }
            else
            {
                MessageBox.Show("Basic structure not found!");
            }
        }