Пример #1
0
        public int AddIED(string name)
        {
            int index = -1;

            if (dataTypeTemplatesField == null)
            {
                dataTypeTemplatesField = new tDataTypeTemplates();
            }
            int i;

            tIED ied = new tIED();

            if (name == null)
            {
                i = GetIED("TEMPLATE");
                if (i >= 0)
                {
                    SCL.nied++;
                }
                string n = "";
                if (SCL.nied == 0)
                {
                    SCL.nied++;
                }
                else
                {
                    n += (SCL.nied++).ToString();
                }
                ied.name = "TEMPLATE" + n;
            }
            else
            {
                i = GetIED(name);
                if (i >= 0)
                {
                    return(-1);
                }
                ied.name = name;
            }

            ied.configVersion = "0";
            int iap = ied.AddAP(null);

            ied.AddLDevice(null, ied.AccessPoint[iap].name, this.DataTypeTemplates);

            if (iEDField == null)
            {
                iEDField     = new tIED[1];
                iEDField [0] = ied;
                index        = 0;
            }
            else
            {
                System.Array.Resize <tIED> (ref this.iEDField,
                                            this.iEDField.GetLength(0) + 1);
                index = this.iEDField.GetLength(0) - 1;
                this.iEDField [index] = ied;
            }
            return(index);
        }
Пример #2
0
        public int AddLDevice(string inst, string ap, tDataTypeTemplates tpl)
        {
            if (tpl == null)
            {
                return(-1);
            }
            if (accessPointField == null)
            {
                AddAP(ap);
            }

            var ld = new tLDevice();

            if (inst == null)
            {
                ld.inst = "TEMPLATE_LD" + (++tIED.nld).ToString();
            }
            else
            {
                ld.inst = inst;
            }

            tLNodeType tln0;
            int        lnt0 = tpl.GetLNType("TEMPLATE.LLN0");

            if (lnt0 != -1)
            {
                tln0 = tpl.LNodeType [lnt0];
            }
            else
            {
                tln0 = new tLNodeType(name, "LLN0", name + ".LLN0");
                tpl.AddLNodeType(tln0);
            }

            tLNodeType tln;
            int        lnt = tpl.GetLNType("TEMPLATE.LPHD");

            if (lnt != -1)
            {
                tln = tpl.LNodeType [lnt];
            }
            else
            {
                tln = new tLNodeType(name, "LPHD", name + ".LPHD");
                tpl.AddLNodeType(tln);
            }

            var ln0 = new LN0();

            ln0.lnType = tln0.id;
            ld.LN0     = ln0;

            var ln = new tLN();

            ln.inst    = 1;
            ln.lnType  = tln.id;
            ln.lnClass = tln.lnClass;
            ld.AddLN(ln);

            int api = this.GetAP(ap);

            if (api == -1)
            {
                api = this.AddAP(ap);
            }
            return(this.AccessPoint[api].Server.AddLDevice(ld));
        }