コード例 #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!");
            }
        }
コード例 #2
0
 public CommandParams PrepareSendCommand(NodeBase data)
 {
     if (data != null)
     {
         NodeData d = (NodeData)data.Parent;
         if (d != null)
         {
             NodeBase      b;//, c;
             CommandParams cPar = new CommandParams();
             cPar.CommType = CommandType.SingleCommand;
             if ((b = d.FindChildNode("ctlVal")) != null)
             {
                 cPar.DataType = ((NodeData)b).DataType;
                 cPar.Address  = b.IecAddress;
                 cPar.ctlVal   = ((NodeData)b).DataValue;
             }
             cPar.T = DateTime.MinValue;
             cPar.interlockCheck  = true;
             cPar.synchroCheck    = true;
             cPar.orCat           = OrCat.STATION_CONTROL;
             cPar.orIdent         = "IEDEXPLORER";
             cPar.CommandFlowFlag = CommandCtrlModel.Unknown;
             b = data;
             List <string> path = new List <string>();
             do
             {
                 b = b.Parent;
                 path.Add(b.Name);
             } while (!(b is NodeFC));
             path[0] = "ctlModel";
             path[path.Count - 1] = "CF";
             b = b.Parent;
             for (int i = path.Count - 1; i >= 0; i--)
             {
                 if ((b = b.FindChildNode(path[i])) == null)
                 {
                     break;
                 }
             }
             if (b != null)
             {
                 if (b is NodeData && !(b is NodeDO))
                 {
                     cPar.CommandFlowFlag = (CommandCtrlModel)((long)((b as NodeData).DataValue));
                 }
             }
             cPar.SBOrun      = false;
             cPar.SBOdiffTime = false;
             cPar.SBOtimeout  = 100;
             return(cPar);
         }
         else
         {
             Logger.getLogger().LogError("Basic structure for a command not found at " + data.IecAddress + "!");
         }
     }
     return(null);
 }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: ttgzs/iedexplorer
        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!");
            }
        }
コード例 #4
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!");
            }
        }
コード例 #5
0
        public void SendCommand(NodeBase data, CommandParams cPar, ActionRequested how)
        {
            if (data != null)
            {
                Logger.getLogger().LogInfo("Sending command " + data.IecAddress);
                NodeData d = (NodeData)data.Parent;
                if (d != null)
                {
                    NodeBase b, c;

                    List <NodeData> ndar = new List <NodeData>();
                    //char *nameo[] = {"$Oper$ctlVal", "$Oper$origin$orCat", "$Oper$origin$orIdent", "$Oper$ctlNum", "$Oper$T", "$Oper$Test", "$Oper$Check"};
                    if ((b = d.FindChildNode("ctlVal")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = cPar.ctlVal;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("origin")) != null)
                    {
                        if (how == ActionRequested.WriteAsStructure)
                        {
                            NodeData n = new NodeData(b.Name);
                            n.DataType  = scsm_MMS_TypeEnum.structure;
                            n.DataValue = 2;
                            ndar.Add(n);
                            if ((c = b.FindChildNode("orCat")) != null)
                            {
                                NodeData n2 = new NodeData(b.Name + "$" + c.Name);
                                n2.DataType  = ((NodeData)c).DataType;
                                n2.DataValue = (long)cPar.orCat;
                                n.AddChildNode(n2);
                            }
                            if ((c = b.FindChildNode("orIdent")) != null)
                            {
                                NodeData n2 = new NodeData(b.Name + "$" + c.Name);
                                n2.DataType = ((NodeData)c).DataType;
                                byte[]  bytes = new byte[cPar.orIdent.Length];
                                int     tmp1, tmp2; bool tmp3;
                                Encoder ascii = (new ASCIIEncoding()).GetEncoder();
                                ascii.Convert(cPar.orIdent.ToCharArray(), 0, cPar.orIdent.Length, bytes, 0, cPar.orIdent.Length, true, out tmp1, out tmp2, out tmp3);
                                n2.DataValue = bytes;
                                n.AddChildNode(n2);
                            }
                        }
                        else
                        {
                            if ((c = b.FindChildNode("orCat")) != null)
                            {
                                NodeData n = new NodeData(b.Name + "$" + c.Name);
                                n.DataType  = ((NodeData)c).DataType;
                                n.DataValue = (long)cPar.orCat;
                                ndar.Add(n);
                            }
                            if ((c = b.FindChildNode("orIdent")) != null)
                            {
                                NodeData n = new NodeData(b.Name + "$" + c.Name);
                                n.DataType = ((NodeData)c).DataType;
                                byte[]  bytes = new byte[cPar.orIdent.Length];
                                int     tmp1, tmp2; bool tmp3;
                                Encoder ascii = (new ASCIIEncoding()).GetEncoder();
                                ascii.Convert(cPar.orIdent.ToCharArray(), 0, cPar.orIdent.Length, bytes, 0, cPar.orIdent.Length, true, out tmp1, out tmp2, out tmp3);
                                n.DataValue = bytes;
                                ndar.Add(n);
                            }
                        }
                    }
                    if ((b = d.FindChildNode("ctlNum")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType = ((NodeData)b).DataType;
                        if (d.Name == "SBO" || d.Name == "SBOw")
                        {
                            n.DataValue = m_ctlNum;
                        }
                        else
                        {
                            n.DataValue = m_ctlNum++;
                        }
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("T")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType = ((NodeData)b).DataType;
                        byte[] btm = new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
                        n.DataValue = btm;

                        if (cPar.T != DateTime.MinValue)
                        {
                            if (d.Name == "Oper" && cPar.SBOdiffTime && cPar.SBOrun)
                            {
                                cPar.T.AddMilliseconds(cPar.SBOtimeout);
                            }
                            Scsm_MMS.ConvertToUtcTime(cPar.T, btm);
                        }
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("Test")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = cPar.Test;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("Check")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType = ((NodeData)b).DataType;
                        byte sync  = 0x80;
                        byte intl  = 0x40;
                        byte check = 0;
                        if (cPar.synchroCheck)
                        {
                            check |= sync;
                        }
                        if (cPar.interlockCheck)
                        {
                            check |= intl;
                        }
                        n.DataValue = new byte[] { check };
                        n.DataParam = ((NodeData)b).DataParam;
                        ndar.Add(n);
                    }
                    iecs.Send(ndar.ToArray(), d.CommAddress, how);
                }
                else
                {
                    Logger.getLogger().LogError("Basic structure for a command not found at " + data.IecAddress + "!");
                }
            }
        }
コード例 #6
0
        public async void PrepareSendCommand(NodeBase data, CommandParams cPar, ActionRequested how)
        {
            if (cPar.SBOrun)
            {
                string   sName = (cPar.CommandFlowFlag == CommandCtrlModel.Select_Before_Operate_With_Enhanced_Security) ? "SBOw" : "SBO";
                NodeData d = (NodeData)data.Parent;
                NodeData op = null, sel = null;
                if (d != null)
                {
                    if (d.Name == "SBOw" || d.Name == "SBO")
                    {
                        sName = "Oper";
                        sel   = (NodeData)data;
                    }
                    else
                    {
                        op = (NodeData)data;
                    }
                    NodeBase dd = d.Parent;
                    if (dd != null)
                    {
                        NodeData d2 = (NodeData)dd.FindChildNode(sName);
                        if (d2 != null)
                        {
                            NodeData d3 = (NodeData)d2.FindChildNode("ctlVal");
                            if (d3 != null)
                            {
                                if (op == null)
                                {
                                    op = d3;
                                }
                                else
                                {
                                    sel = d3;
                                }
                                SendCommand(sel, cPar, how);
                                await PutTaskDelay(cPar.SBOtimeout);

                                SendCommand(op, cPar, how);
                            }
                            else
                            {
                                Logger.getLogger().LogWarning("Cannot send SBO command sequence, ctlVal not found in " + d2.IecAddress);
                            }
                        }
                        else
                        {
                            Logger.getLogger().LogWarning("Cannot send SBO command sequence, " + sName + " not found in " + dd.IecAddress);
                        }
                    }
                    else
                    {
                        Logger.getLogger().LogWarning("Cannot send SBO command sequence, null parent of " + d.IecAddress);
                    }
                }
                else
                {
                    Logger.getLogger().LogWarning("Cannot send SBO command sequence, null parent of " + data.IecAddress);
                }
            }
            else
            {
                SendCommand(data, cPar, how);
            }
        }
コード例 #7
0
ファイル: MainWindow.cs プロジェクト: ttgzs/iedexplorer
        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!");
            }
        }
コード例 #8
0
ファイル: MainWindow.cs プロジェクト: ttgzs/iedexplorer
        private void SendCommand(NodeBase data, Iec61850State iecs, ActionRequested how)
        {
            if (data != null)
            {
                NodeData d = (NodeData)data.Parent;
                if (d != null)
                {
                    NodeBase      b, c;
                    CommandParams cPar = new CommandParams();
                    cPar.CommType = CommandType.SingleCommand;
                    if ((b = d.FindChildNode("ctlVal")) != null)
                    {
                        cPar.DataType = ((NodeData)b).DataType;
                        cPar.Address  = b.Address;
                        cPar.ctlVal   = ((NodeData)b).DataValue;
                    }
                    cPar.T = DateTime.MinValue;
                    cPar.interlockCheck = true;
                    cPar.synchroCheck   = true;
                    cPar.orCat          = OrCat.STATION_CONTROL;
                    cPar.orIdent        = "IEDEXPLORER";
                    //cPar.orIdent = "ET03: 192.168.001.001 R001 K189 Origin:128";
                    cPar.CommandFlowFlag = CommandCtrlModel.Unknown;
                    b = data;
                    List <string> path = new List <string>();
                    do
                    {
                        b = b.Parent;
                        path.Add(b.Name);
                    } while (!(b is NodeFC));
                    path[0] = "ctlModel";
                    path[path.Count - 1] = "CF";
                    b = b.Parent;
                    for (int i = path.Count - 1; i >= 0; i--)
                    {
                        if ((b = b.FindChildNode(path[i])) == null)
                        {
                            break;
                        }
                    }
                    if (b != null)
                    {
                        if (b is NodeData)
                        {
                            cPar.CommandFlowFlag = (CommandCtrlModel)((long)((b as NodeData).DataValue));
                        }
                    }

                    CommandDialog dlg = new CommandDialog(cPar);
                    DialogResult  res = dlg.ShowDialog(this);

                    if (res == DialogResult.Cancel)
                    {
                        return;
                    }

                    List <NodeData> ndar = new List <NodeData>();
                    //char *nameo[] = {"$Oper$ctlVal", "$Oper$origin$orCat", "$Oper$origin$orIdent", "$Oper$ctlNum", "$Oper$T", "$Oper$Test", "$Oper$Check"};
                    if ((b = d.FindChildNode("ctlVal")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = cPar.ctlVal;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("origin")) != null)
                    {
                        if (how == ActionRequested.WriteAsStructure)
                        {
                            NodeData n = new NodeData(b.Name);
                            n.DataType  = scsm_MMS_TypeEnum.structure;
                            n.DataValue = 2;
                            ndar.Add(n);
                            if ((c = b.FindChildNode("orCat")) != null)
                            {
                                NodeData n2 = new NodeData(b.Name + "$" + c.Name);
                                n2.DataType  = ((NodeData)c).DataType;
                                n2.DataValue = (long)cPar.orCat;
                                n.AddChildNode(n2);
                            }
                            if ((c = b.FindChildNode("orIdent")) != null)
                            {
                                NodeData n2 = new NodeData(b.Name + "$" + c.Name);
                                n2.DataType = ((NodeData)c).DataType;
                                byte[]  bytes = new byte[cPar.orIdent.Length];
                                int     tmp1, tmp2; bool tmp3;
                                Encoder ascii = (new ASCIIEncoding()).GetEncoder();
                                ascii.Convert(cPar.orIdent.ToCharArray(), 0, cPar.orIdent.Length, bytes, 0, cPar.orIdent.Length, true, out tmp1, out tmp2, out tmp3);
                                n2.DataValue = bytes;
                                n.AddChildNode(n2);
                            }
                        }
                        else
                        {
                            if ((c = b.FindChildNode("orCat")) != null)
                            {
                                NodeData n = new NodeData(b.Name + "$" + c.Name);
                                n.DataType  = ((NodeData)c).DataType;
                                n.DataValue = (long)cPar.orCat;
                                ndar.Add(n);
                            }
                            if ((c = b.FindChildNode("orIdent")) != null)
                            {
                                NodeData n = new NodeData(b.Name + "$" + c.Name);
                                n.DataType = ((NodeData)c).DataType;
                                byte[]  bytes = new byte[cPar.orIdent.Length];
                                int     tmp1, tmp2; bool tmp3;
                                Encoder ascii = (new ASCIIEncoding()).GetEncoder();
                                ascii.Convert(cPar.orIdent.ToCharArray(), 0, cPar.orIdent.Length, bytes, 0, cPar.orIdent.Length, true, out tmp1, out tmp2, out tmp3);
                                n.DataValue = bytes;
                                ndar.Add(n);
                            }
                        }
                    }
                    if ((b = d.FindChildNode("ctlNum")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = m_ctlNum++;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("T")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType = ((NodeData)b).DataType;
                        byte[] btm = new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
                        n.DataValue = btm;

                        if (cPar.T != DateTime.MinValue)
                        {
                            int    t   = (int)Scsm_MMS.ConvertToUnixTimestamp(cPar.T);
                            byte[] uib = BitConverter.GetBytes(t);
                            btm[0] = uib[3];
                            btm[1] = uib[2];
                            btm[2] = uib[1];
                            btm[3] = uib[0];
                        }
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("Test")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = false;
                        ndar.Add(n);
                    }
                    if ((b = d.FindChildNode("Check")) != null)
                    {
                        NodeData n = new NodeData(b.Name);
                        n.DataType  = ((NodeData)b).DataType;
                        n.DataValue = new byte[] { 0x40 };
                        n.DataParam = ((NodeData)b).DataParam;
                        ndar.Add(n);
                    }
                    iecs.Send(ndar.ToArray(), d.CommAddress, how);
                }
                else
                {
                    MessageBox.Show("Basic structure not found!");
                }
            }
        }