private double getLatitude(TreeNode <NodeData> node)
        {
            if (node.Data.Type == DMSType.ACLINESEGMENT)
            {
                //+
                ACLineSegment acLineSegment = (ACLineSegment)node.Data.IdentifiedObject;
                return(acLineSegment.Latitude);
            }
            else if (node.Data.Type == DMSType.BREAKER)
            {
                //+
                Breaker breaker = (Breaker)node.Data.IdentifiedObject;
                return(breaker.Latitude);
            }
            else if (node.Data.Type == DMSType.ENEGRYSOURCE)
            {
                //+
                EnergySource source = (EnergySource)node.Data.IdentifiedObject;
                return(source.Latitude);
            }
            else if (node.Data.Type == DMSType.ENERGYCONSUMER)
            {
                //+
                EnergyConsumer consumer = (EnergyConsumer)node.Data.IdentifiedObject;
                return(consumer.Latitude);
            }
            else if (node.Data.Type == DMSType.GENERATOR)
            {
                //+
                Generator generator = (Generator)node.Data.IdentifiedObject;
                return(generator.Latitude);
            }

            return(0);
        }
Пример #2
0
        double CalculateVoltageForACLineSegment(Node node, Dictionary <long, LoadFlowResult> lf, Dictionary <long, Complex> currents)
        {
            Complex current;

            if (!currents.TryGetValue(node.IO.GID, out current))
            {
                return(double.MaxValue);
            }

            ACLineSegment segment = node.IO as ACLineSegment;

            List <Node> nodes = new List <Node>(2);

            for (int i = node.AdjacentOffset; i < node.AdjacentOffset + node.AdjacentCount; ++i)
            {
                Node n = adjacency[i];

                if (!nodes.Contains(n) && ModelCodeHelper.GetTypeFromGID(n.IO.GID) == DMSType.ConnectivityNode)
                {
                    nodes.Add(n);
                }
            }

            if (nodes.Count != 2)
            {
                return(0);
            }

            LoadFlowResult lfr1;

            if (!lf.TryGetValue(nodes[0].IO.GID, out lfr1))
            {
                return(0);
            }

            Complex u1 = new Complex(lfr1.Get(LoadFlowResultType.UR), lfr1.Get(LoadFlowResultType.UI));
            Complex u2 = u1.Subtract(new Complex(segment.PerLengthPhaseResistance * segment.Length, segment.PerLengthPhaseReactance * segment.Length).Multiply(current));

            LoadFlowResult lfr2;
            double         relDelta = double.MaxValue;

            if (!lf.TryGetValue(nodes[1].IO.GID, out lfr2))
            {
                lfr2 = new LoadFlowResult();
                lf[nodes[1].IO.GID] = lfr2;
            }
            else
            {
                relDelta = GetVoltageRelativeDifference(new Complex(lfr2.Get(LoadFlowResultType.UR), lfr2.Get(LoadFlowResultType.UI)), u2);
            }

            lfr2.Remove(LoadFlowResultType.UR);
            lfr2.Remove(LoadFlowResultType.UI);

            lfr2.Add(new LoadFlowResultItem(u2.X, LoadFlowResultType.UR));
            lfr2.Add(new LoadFlowResultItem(u2.Y, LoadFlowResultType.UI));

            return(relDelta);
        }
Пример #3
0
 public override void Izvrsi()
 {
     line      = (ACLineSegment)line.Clone();
     line.mRID = ID;
     line.terminali.Add(terminal1);
     line.terminali.Add(terminal2);
     Singleton.Instance().AClines.Add(line);
 }
        private void Brisi(object sender, RoutedEventArgs e)
        {
            ACLineSegment acs = dataGrid.SelectedItem as ACLineSegment;
            BrisiLiniju   bl  = new BrisiLiniju(acs.mRID);

            Singleton.Instance().inv.DodajIzvrsi(bl);
            serializer.SerializeObject <BindingList <ACLineSegment> >(Singleton.Instance().AClines, "../../doc/konekcije.xml");
            Singleton.Instance().NotifyObservers();
        }
Пример #5
0
        Complex CalculateCurrentForACLineSegment(Node node, IEnumerable <Complex> childCurrents, Dictionary <long, LoadFlowResult> lf)
        {
            Complex result = CalculateCurrentDefault(node, childCurrents, lf);

            LoadFlowResult lfr;

            if (!lf.TryGetValue(node.IO.GID, out lfr))
            {
                lfr             = new LoadFlowResult();
                lf[node.IO.GID] = lfr;
            }

            lfr.Remove(LoadFlowResultType.IR);
            lfr.Remove(LoadFlowResultType.II);

            lfr.Add(new LoadFlowResultItem(result.X, LoadFlowResultType.IR));
            lfr.Add(new LoadFlowResultItem(result.Y, LoadFlowResultType.II));

            List <Node> nodes = new List <Node>(2);

            for (int i = node.AdjacentOffset; i < node.AdjacentOffset + node.AdjacentCount; ++i)
            {
                Node n = adjacency[i];

                if (!nodes.Contains(n) && ModelCodeHelper.GetTypeFromGID(n.IO.GID) == DMSType.ConnectivityNode)
                {
                    nodes.Add(n);
                }
            }

            if (nodes.Count != 2)
            {
                return(result);
            }

            LoadFlowResult lfr1;
            LoadFlowResult lfr2;

            if (!lf.TryGetValue(nodes[0].IO.GID, out lfr1) || !lf.TryGetValue(nodes[1].IO.GID, out lfr2))
            {
                return(result);
            }

            ACLineSegment segment = node.IO as ACLineSegment;
            Complex       u1      = new Complex(lfr1.Get(LoadFlowResultType.UR), lfr1.Get(LoadFlowResultType.UI));
            Complex       u2      = new Complex(lfr2.Get(LoadFlowResultType.UR), lfr2.Get(LoadFlowResultType.UI));
            Complex       s       = u1.Subtract(u2).Multiply(new Complex(result.X, -result.Y));

            lfr.Remove(LoadFlowResultType.SR);
            lfr.Remove(LoadFlowResultType.SI);

            lfr.Add(new LoadFlowResultItem(s.X, LoadFlowResultType.SR));
            lfr.Add(new LoadFlowResultItem(s.Y, LoadFlowResultType.SI));

            return(result);
        }
 private void KlonirajLiniju(object sender, RoutedEventArgs e)
 {
     if (dataGrid.SelectedItem != null)
     {
         ACLineSegment ac = dataGrid.SelectedItem as ACLineSegment;
         CloneLine     cl = new CloneLine(ac.mRID);
         Singleton.Instance().inv.DodajIzvrsi(cl);
         Singleton.Instance().NotifyObservers();
     }
 }
        /// <summary>
        /// Creates entity for specified global inside the container.
        /// </summary>
        /// <param name="globalId">Global id of the entity for insert</param>
        /// <returns>Created entity (identified object).</returns>
        public IdentifiedObject CreateEntity(long globalId)
        {
            short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);

            IdentifiedObject io = null;

            switch ((DMSType)type)
            {
            case DMSType.BASEVOLTAGE:
                io = new BaseVoltage(globalId);
                break;

            case DMSType.CONNECTIVITYNODE:
                io = new ConnectivityNode(globalId);
                break;

            case DMSType.ENERGYCONSUMER:
                io = new EnergyConsumer(globalId);
                break;

            case DMSType.ENERGYSOURCE:
                io = new EnergySource(globalId);
                break;

            case DMSType.POWERTRANSFORMER:
                io = new PowerTransformer(globalId);
                break;

            case DMSType.PTRANSFORMEREND:
                io = new PowerTransformerEnd(globalId);
                break;

            case DMSType.SWITCH:
                io = new Switch(globalId);
                break;

            case DMSType.ACLINESEGMENT:
                io = new ACLineSegment(globalId);
                break;

            case DMSType.TERMINAL:
                io = new Terminal(globalId);
                break;

            default:
                string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type);
                Logger.LogError(message);
                throw new Exception(message);
            }

            // Add entity to map
            this.AddEntity(io);

            return(io);
        }
        private ResourceDescription CreateACLineSegmentResourceDecription(ACLineSegment cimACLineSegment)
        {
            ResourceDescription rd = null;

            if (cimACLineSegment != null)
            {
                long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.ACLINESEGMENT, importHelper.CheckOutIndexForDMSType(DMSType.ACLINESEGMENT));
                rd = new ResourceDescription(gid);
                importHelper.DefineIDMapping(cimACLineSegment.ID, gid);

                ////populate ResourceDescription
                LoadFlowConverter.PopulateACLineSegmentProperties(cimACLineSegment, rd, importHelper, report);
            }
            return(rd);
        }
Пример #9
0
        private ResourceDescription CreateACLineSegmentResourceDescription(ACLineSegment acline)
        {
            ResourceDescription rd = null;

            if (acline != null)
            {
                long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.ACLINESEGMENT, importHelper.CheckOutIndexForDMSType(DMSType.ACLINESEGMENT));
                rd = new ResourceDescription(gid);
                importHelper.DefineIDMapping(acline.ID, gid);

                ////populate ResourceDescription
                PowerTransformerConverter.PopulateACLineSegmentProperties(acline, rd, importHelper, report);
            }
            return(rd);
        }
        //ovu metodu treba jos doraditi kada se uvuce pravilan xml fajl sa vise kordinata za AcLine
        private void DrowOnMapAcLineSegment(TreeNode <NodeData> acLine, string stringBuilderUniversal)
        {
            StringBuilder stringBuilder = new StringBuilder();
            ACLineSegment acLineSegment = (ACLineSegment)acLine.Data.IdentifiedObject;

            stringBuilder.Append(stringBuilderUniversal);
            stringBuilder.AppendFormat("Name: {0}{1}", acLineSegment.Name, Environment.NewLine);
            stringBuilder.AppendFormat("Description: {0}{1}", acLineSegment.Description, Environment.NewLine);
            stringBuilder.AppendFormat("Type: {0}", acLineSegment.Type.ToString());
            string toolTip = stringBuilder.ToString();

            Location pinLocation = new Location(acLineSegment.Longitude, acLineSegment.Latitude);

            MapPolygon  polygon = new MapPolygon();
            MapPolyline line    = new MapPolyline();

            line.ToolTip = toolTip;

            if (acLine.Data.Energized == Enums.Energized.FromEnergySRC)
            {
                line.Stroke = new SolidColorBrush(Colors.Green);
            }
            else if (acLine.Data.Energized == Enums.Energized.FromIsland)
            {
                line.Stroke = new SolidColorBrush(Colors.Blue);
            }
            else
            {
                line.Stroke = new SolidColorBrush(Colors.Red);
            }

            line.Uid             = acLineSegment.GlobalId.ToString();
            line.StrokeThickness = 2;
            line.Opacity         = 0.9;
            line.Cursor          = Cursors.Hand;
            line.Locations       = new LocationCollection();


            foreach (long item in acLineSegment.Points)
            {
                TreeNode <NodeData> data = acLine.Children.Where(X => X.Data.IdentifiedObject.GlobalId == item).First();
                DERMSCommon.DataModel.Core.Point point1 = (DERMSCommon.DataModel.Core.Point)(data.Data.IdentifiedObject);
                //polygon.Locations.Add(new Location(point1.Longitude, point1.Latitude));
                line.Locations.Add(new Location(point1.Longitude, point1.Latitude));
            }

            _map.Children.Add(line);
        }
Пример #11
0
        void PopulateACLineSegmentProperties(ACLineSegment x, ResourceDescription rd)
        {
            PopulateConductorProperties(x, rd);

            if (x.RatedCurrentHasValue)
            {
                rd.AddProperty(new FloatProperty(ModelCode.ACLINESEGMENT_RATEDCURRENT, x.RatedCurrent));
            }

            if (x.PerLengthPhaseResistanceHasValue)
            {
                rd.AddProperty(new FloatProperty(ModelCode.ACLINESEGMENT_PERLENGTHPHASERESISTANCE, x.PerLengthPhaseResistance));
            }

            if (x.PerLengthPhaseReactanceHasValue)
            {
                rd.AddProperty(new FloatProperty(ModelCode.ACLINESEGMENT_PERLENGTHPHASEREACTANCE, x.PerLengthPhaseReactance));
            }
        }
Пример #12
0
        public DodajACLine(ConnectivityNode node1, ConnectivityNode node2, String ime, float duzina, float gch, float bch, float r, float x)
        {
            als = new ACLineSegment();
            Random rand = new Random();

            als.name   = ime;//linija ime
            als.length = duzina;
            als.mRID   = rand.Next(1000).ToString();
            als.gch    = gch;
            als.bch    = bch;
            als.r      = r;
            als.x      = x;

            term1 = new Terminal()
            {
                name                = "Terminal 1",
                ConnectivityNode    = node1,
                ConductingEquipment = new ConductingEquipment(),
                phases              = PhaseCode.AB,
                sequenceNumber      = 1,
                connected           = false,
                mRID                = rand.Next(100).ToString(),
                aliasName           = "A_Terminal 1",
                description         = "opis"
            };

            term2 = new Terminal()
            {
                name                = "Terminal 2",
                ConnectivityNode    = node2,
                ConductingEquipment = new ConductingEquipment(),
                phases              = PhaseCode.ABCN,
                sequenceNumber      = 1,
                connected           = false,
                mRID                = rand.Next(100).ToString(),
                aliasName           = "A_Terminal 2",
                description         = "opis"
            };

            als.terminali.Add(term1);
            als.terminali.Add(term2);
        }
Пример #13
0
        public static void PopulateACLineSegmentProperties(ACLineSegment cimACLineSegment, ResourceDescription rd)
        {
            if ((cimACLineSegment != null) && (rd != null))
            {
                IES21Converter.PopulateConductorProperties(cimACLineSegment, rd);

                if (cimACLineSegment.B0chHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_B0CH, cimACLineSegment.B0ch));
                }
                if (cimACLineSegment.BchHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_BCH, cimACLineSegment.Bch));
                }
                if (cimACLineSegment.G0chHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_G0CH, cimACLineSegment.G0ch));
                }
                if (cimACLineSegment.GchHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_GCH, cimACLineSegment.Gch));
                }
                if (cimACLineSegment.R0HasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_R0, cimACLineSegment.R0));
                }
                if (cimACLineSegment.RHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_R, cimACLineSegment.R));
                }
                if (cimACLineSegment.X0HasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_X0, cimACLineSegment.X0));
                }
                if (cimACLineSegment.XHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEG_X, cimACLineSegment.X));
                }
            }
        }
Пример #14
0
        public static void PopulateACLineSegmentProperties(ACLineSegment acline, ResourceDescription rd, ImportHelper importHelper, TransformAndLoadReport report)
        {
            if ((acline != null) && (rd != null))
            {
                PowerTransformerConverter.PopulateConductorProperties(acline, rd, importHelper, report);
                if (acline.B0chHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_B0CH, acline.B0ch));
                }
                if (acline.BchHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_BCH, acline.Bch));
                }
                if (acline.GchHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_GCH, acline.Gch));
                }
                if (acline.G0chHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_G0CH, acline.G0ch));
                }

                if (acline.XHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_X, acline.X));
                }
                if (acline.X0HasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_X0, acline.X0));
                }
                if (acline.RHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_R, acline.R));
                }
                if (acline.R0HasValue)
                {
                    rd.AddProperty(new Property(ModelCode.ACLINESEGMENT_R0, acline.R0));
                }
            }
        }
        private void ImportACLineSegments()
        {
            SortedDictionary <string, object> cimACLineSegments = concreteModel.GetAllObjectsOfType("FTN.ACLineSegment");

            if (cimACLineSegments != null)
            {
                foreach (KeyValuePair <string, object> cimACLineSegmentPair in cimACLineSegments)
                {
                    ACLineSegment cimACLineSegment = cimACLineSegmentPair.Value as ACLineSegment;

                    ResourceDescription rd = CreateACLineSegmentResourceDescription(cimACLineSegment);
                    if (rd != null)
                    {
                        delta.AddDeltaOperation(DeltaOpType.Insert, rd, true);
                        report.Report.Append("ACLineSegment ID = ").Append(cimACLineSegment.ID).Append(" SUCCESSFULLY converted to GID = ").AppendLine(rd.Id.ToString());
                    }
                    else
                    {
                        report.Report.Append("ACLineSegment ID = ").Append(cimACLineSegment.ID).AppendLine(" FAILED to be converted");
                    }
                }
                report.Report.AppendLine();
            }
        }
Пример #16
0
 public BrisiLiniju(String id)
 {
     line      = new ACLineSegment();
     line.mRID = id;
 }
Пример #17
0
        public Dictionary <Type, Dictionary <string, IdentifiedObject> > CreateObjectModel(Dictionary <string, DataVertex> globalVertices, Dictionary <string, List <DataEdge> > globalEdges, Dictionary <string, CableConfiguration> globalCableConfiguration, Dictionary <string, SpotLoad> globalSpotLoads)
        {
            globalComponentDictionary   = new Dictionary <Type, Dictionary <string, IdentifiedObject> >();
            terminalPairsContainer      = new List <TerminalPair>();
            perLengthImpedanceContainer = new Dictionary <string, PerLengthImpedance>();
            wireInfoContainer           = new Dictionary <string, WireInfo>();
            usagePointContainer         = new Dictionary <string, SpotLoad>();
            powerTransformerEnding      = new Dictionary <string, DataVertexTransformer>();

            PSRType local_psr_pt = new PSRType();

            circuit = new Circuit();
            string  mrid           = Guid.NewGuid().ToString();
            PSRType psrTypeCircuit = new PSRType()
            {
                MRID = "Feeder", Name = "Feeder"
            };

            circuit.PSRType = psrTypeCircuit;

            circuit.ID   = mrid;
            circuit.MRID = mrid;
            circuit.Name = "Feeder_36";

            addComponentToGlobalDictionary(circuit, circuit.GetType());
            addComponentToGlobalDictionary(psrTypeCircuit, psrTypeCircuit.GetType());

            Dictionary <string, ConnectivityNode> connectivityNodeContainer = new Dictionary <string, ConnectivityNode>();



            foreach (DataVertex dataVertex in globalVertices.Values)
            {
                if (dataVertex.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX)
                {
                    PowerTransformer powerTransformer = new PowerTransformer();

                    DataVertexTransformer dvt = (DataVertexTransformer)dataVertex;

                    string power_transformer_mrid = Guid.NewGuid().ToString();
                    powerTransformer.ID   = power_transformer_mrid;
                    powerTransformer.MRID = power_transformer_mrid;
                    powerTransformer.Name = "2 winding power transformer";
                    local_psr_pt          = new PSRType()
                    {
                        Name = "Consumer Transformer", MRID = "Consumer Transformer"
                    };
                    powerTransformer.PSRType            = local_psr_pt;
                    powerTransformer.EquipmentContainer = circuit;
                    addComponentToGlobalDictionary(local_psr_pt, local_psr_pt.GetType());



                    ConnectivityNode w1T_cn = new ConnectivityNode();
                    string           connectivity_node_mrid = Guid.NewGuid().ToString();
                    w1T_cn.ID   = connectivity_node_mrid;
                    w1T_cn.MRID = connectivity_node_mrid;
                    w1T_cn.ConnectivityNodeContainer = circuit;
                    if ((dataVertex as DataVertexTransformer).Line_from == null)
                    {
                        continue;
                    }
                    ;
                    w1T_cn.Name = (dataVertex as DataVertexTransformer).Line_from;
                    connectivityNodeContainer.Add((dataVertex as DataVertexTransformer).Line_from, w1T_cn);
                    addComponentToGlobalDictionary(w1T_cn, w1T_cn.GetType());

                    ConnectivityNode w2T_cn = new ConnectivityNode();
                    connectivity_node_mrid = Guid.NewGuid().ToString();
                    w2T_cn.ID   = connectivity_node_mrid;
                    w2T_cn.MRID = connectivity_node_mrid;
                    w2T_cn.ConnectivityNodeContainer = circuit;
                    w2T_cn.Name = (dataVertex as DataVertexTransformer).Line_to;
                    connectivityNodeContainer.Add((dataVertex as DataVertexTransformer).Line_to, w2T_cn);
                    if ((dataVertex as DataVertexTransformer).Line_to == null)
                    {
                        continue;
                    }
                    ;
                    addComponentToGlobalDictionary(w2T_cn, w2T_cn.GetType());

                    Terminal w1T = new Terminal();
                    w1T.MRID                = power_transformer_mrid + ".W1.T";
                    w1T.ID                  = power_transformer_mrid + ".W1.T";
                    w1T.SequenceNumber      = 1;
                    w1T.ConductingEquipment = powerTransformer;
                    w1T.ConnectivityNode    = w1T_cn;
                    w1T.Phases              = PhaseCode.s2N;
                    w1T.Name                = "Transformer end terminal 1";



                    Terminal w2T = new Terminal();
                    w2T.MRID                = power_transformer_mrid + ".W2.T";
                    w2T.ID                  = power_transformer_mrid + ".W2.T";
                    w2T.SequenceNumber      = 2;
                    w2T.ConductingEquipment = powerTransformer;
                    w2T.ConnectivityNode    = w2T_cn;
                    w2T.Phases              = PhaseCode.s2N;
                    w2T.Name                = "Transformer end terminal 2";

                    terminalPairsContainer.Add(new TerminalPair()
                    {
                        terminalA = w1T, terminalB = w2T
                    });



                    addComponentToGlobalDictionary(w1T, w1T.GetType());
                    addComponentToGlobalDictionary(w2T, w2T.GetType());


                    PowerTransformerEnd powerTransformerEnd1 = new PowerTransformerEnd();

                    powerTransformerEnd1.ID               = power_transformer_mrid + ".W1";
                    powerTransformerEnd1.MRID             = power_transformer_mrid + ".W1";
                    powerTransformerEnd1.Name             = dvt.NameA;
                    powerTransformerEnd1.Terminal         = w1T;
                    powerTransformerEnd1.Grounded         = false;
                    powerTransformerEnd1.EndNumber        = 1;
                    powerTransformerEnd1.PowerTransformer = powerTransformer;
                    powerTransformerEnd1.ConnectionKind   = WindingConnection.D;
                    powerTransformerEnd1.PhaseAngleClock  = 0;
                    powerTransformerEnd1.RatedS           = (float)dvt._kVA_A;
                    powerTransformerEnd1.RatedU           = (float)dvt._kV_LowA;


                    PowerTransformerEnd powerTransformerEnd2 = new PowerTransformerEnd();

                    powerTransformerEnd2.ID               = power_transformer_mrid + ".W2";
                    powerTransformerEnd2.MRID             = power_transformer_mrid + ".W2";
                    powerTransformerEnd2.Name             = dvt.NameB;
                    powerTransformerEnd2.Terminal         = w2T;
                    powerTransformerEnd2.Grounded         = false;
                    powerTransformerEnd2.EndNumber        = 1;
                    powerTransformerEnd2.PowerTransformer = powerTransformer;
                    powerTransformerEnd2.ConnectionKind   = WindingConnection.D;
                    powerTransformerEnd2.PhaseAngleClock  = 0;
                    powerTransformerEnd2.RatedS           = (float)dvt._kVA_B;
                    powerTransformerEnd2.RatedU           = (float)dvt._kV_LowB;

                    addComponentToGlobalDictionary(powerTransformer, powerTransformer.GetType());
                    addComponentToGlobalDictionary(powerTransformerEnd1, powerTransformerEnd1.GetType());
                    addComponentToGlobalDictionary(powerTransformerEnd2, powerTransformerEnd2.GetType());
                }


                if (dataVertex.typeOfVertex == DataVertex.TypeOfVertex.REGULATOR_VERTEX)
                {
                    string  sync_machine     = Guid.NewGuid().ToString();
                    PSRType psr_sync_machine = new PSRType()
                    {
                        MRID = "Generator",
                        Name = "Generator"
                    };
                    SynchronousMachine sm = new SynchronousMachine()
                    {
                        Name = dataVertex.Text,
                        MRID = sync_machine,
                        ID   = sync_machine,
                        EquipmentContainer = circuit
                    };
                    addComponentToGlobalDictionary(sm, sm.GetType());
                    addComponentToGlobalDictionary(psr_sync_machine, psr_sync_machine.GetType());
                }
            }


            foreach (List <DataEdge> dataEdgeCollection in globalEdges.Values)
            {
                foreach (DataEdge dataEdge in dataEdgeCollection)
                {
                    string acLineSegment_mrid = Guid.NewGuid().ToString();


                    ConnectivityNode T1_cn = new ConnectivityNode();
                    string           connectivity_node_mrid = Guid.NewGuid().ToString();
                    T1_cn.ID   = connectivity_node_mrid;
                    T1_cn.MRID = connectivity_node_mrid;
                    T1_cn.ConnectivityNodeContainer = circuit;
                    T1_cn.Name = (dataEdge.Source as DataVertex).Element_id;
                    if (connectivityNodeContainer.ContainsKey((dataEdge.Source as DataVertex).Element_id) == false)
                    {
                        connectivityNodeContainer.Add(dataEdge.Source.Element_id, T1_cn);
                        addComponentToGlobalDictionary(T1_cn, T1_cn.GetType());
                    }



                    ConnectivityNode T2_cn = new ConnectivityNode();
                    connectivity_node_mrid = Guid.NewGuid().ToString();
                    T2_cn.ID   = connectivity_node_mrid;
                    T2_cn.MRID = connectivity_node_mrid;
                    T2_cn.ConnectivityNodeContainer = circuit;
                    T2_cn.Name = (dataEdge.Target as DataVertex).Element_id;
                    if (connectivityNodeContainer.ContainsKey((dataEdge.Target as DataVertex).Element_id) == false)
                    {
                        connectivityNodeContainer.Add(dataEdge.Target.Element_id, T2_cn);
                        addComponentToGlobalDictionary(T2_cn, T2_cn.GetType());
                    }



                    Terminal T1 = new Terminal();
                    //string terminal_mrid = Guid.NewGuid().ToString();
                    T1.ID     = acLineSegment_mrid + ".T1";
                    T1.MRID   = acLineSegment_mrid + ".T1";
                    T1.Name   = dataEdge.Source.Element_id;
                    T1.Phases = PhaseCode.ABC;
                    ACDCTerminal acdc_terminal = new ACDCTerminal()
                    {
                        SequenceNumber = 1
                    };
                    T1.SequenceNumber   = acdc_terminal.SequenceNumber;
                    T1.ConnectivityNode = T1_cn;



                    Terminal T2 = new Terminal();
                    T2.ID     = acLineSegment_mrid + ".T2";
                    T2.MRID   = acLineSegment_mrid + ".T2";
                    T2.Name   = dataEdge.Target.Element_id;
                    T2.Phases = PhaseCode.ABC;
                    ACDCTerminal acdc_terminal2 = new ACDCTerminal()
                    {
                        SequenceNumber = 2
                    };
                    T2.SequenceNumber   = acdc_terminal2.SequenceNumber;
                    T2.ConnectivityNode = T2_cn;

                    string             perLengthImpedance_mrid = Guid.NewGuid().ToString();
                    PerLengthImpedance pli = createPerLengthImpedanceObject(dataEdge.Configuration, perLengthImpedance_mrid);
                    AssetInfo          wi  = createWireInfoObject(dataEdge.Configuration, perLengthImpedance_mrid);

                    PSRType acPSRType = new PSRType()
                    {
                        MRID = "Section",
                        Name = "Section"
                    };
                    if (!globalComponentDictionary[acPSRType.GetType()].ContainsKey(acPSRType.Name))
                    {
                        addComponentToGlobalDictionary(acPSRType, acPSRType.GetType());
                    }



                    ACLineSegment acLineSegment = new ACLineSegment()
                    {
                        ID                 = acLineSegment_mrid,
                        MRID               = acLineSegment_mrid,
                        Name               = T1.Name.Split(' ').Last() + "-" + T2.Name.Split(' ').Last(),
                        PSRType            = acPSRType,
                        EquipmentContainer = circuit,
                        Length             = (float)feetsToMeters(dataEdge.Length),
                        PerLengthImpedance = pli,
                        AssetDatasheet     = wi
                    };

                    addComponentToGlobalDictionary(acLineSegment, acLineSegment.GetType());


                    TerminalPair terminalPair = new TerminalPair()
                    {
                        terminalA = T1,
                        terminalB = T2
                    };


                    terminalPairsContainer.Add(terminalPair);

                    addComponentToGlobalDictionary(T1, T1.GetType());
                    addComponentToGlobalDictionary(T2, T2.GetType());
                }
            }

            UsagePoint usagePoint = new UsagePoint();


            foreach (DataVertex dv in globalVertices.Values)
            {
                if (dv.typeOfVertex == DataVertex.TypeOfVertex.SPOT_LOAD_VERTEX)
                {
                    SpotLoad sl = (SpotLoad)dv;
                    usagePoint = CreateSpotLoad(sl);
                    addComponentToGlobalDictionary(usagePoint, usagePoint.GetType());
                }
            }



            return(globalComponentDictionary);
        }
Пример #18
0
        private void addComponentToGlobalDictionary(IdentifiedObject component, Type type)
        {
            if (!globalComponentDictionary.ContainsKey(type))
            {
                globalComponentDictionary.Add(type, new Dictionary <string, IdentifiedObject>());
            }


            if (type.Equals(typeof(ACLineSegment)))
            {
                ACLineSegment acl = (ACLineSegment)component;

                globalComponentDictionary[type].Add(acl.MRID, acl);
            }
            else if (type.Equals(typeof(Terminal)))
            {
                Terminal tp = (Terminal)component;

                globalComponentDictionary[tp.GetType()].Add(tp.MRID, tp);
            }
            else if (type.Equals(typeof(Circuit)))
            {
                Circuit cr = (Circuit)component;

                globalComponentDictionary[cr.GetType()].Add(cr.MRID, cr);
            }
            else if (type.Equals(typeof(WireInfo)))
            {
                WireInfo wi = (WireInfo)component;
                globalComponentDictionary[wi.GetType()].Add(wi.MRID, wi);
            }
            else if (type.Equals(typeof(PerLengthSequenceImpedance)))
            {
                PerLengthSequenceImpedance pli = (PerLengthSequenceImpedance)component;
                globalComponentDictionary[pli.GetType()].Add(pli.MRID, pli);
            }
            else if (type.Equals(typeof(ConnectivityNode)))
            {
                ConnectivityNode cn = (ConnectivityNode)component;
                globalComponentDictionary[cn.GetType()].Add(cn.MRID, cn);
            }
            else if (type.Equals(typeof(PowerTransformer)))
            {
                PowerTransformer pt = (PowerTransformer)component;
                globalComponentDictionary[pt.GetType()].Add(pt.MRID, pt);
            }
            else if (type.Equals(typeof(PowerTransformerEnd)))
            {
                PowerTransformerEnd pt = (PowerTransformerEnd)component;
                globalComponentDictionary[pt.GetType()].Add(pt.MRID, pt);
            }
            else if (type.Equals(typeof(UsagePoint)))
            {
                UsagePoint us = (UsagePoint)component;
                globalComponentDictionary[us.GetType()].Add(us.MRID, us);
            }
            else if (type.Equals(typeof(PSRType)))
            {
                PSRType psr = (PSRType)component;
                globalComponentDictionary[psr.GetType()].Add(psr.Name, psr);
            }
            else if (type.Equals(typeof(SynchronousMachine)))
            {
                SynchronousMachine sm = (SynchronousMachine)component;
                globalComponentDictionary[sm.GetType()].Add(sm.Name, sm);
            }
        }
Пример #19
0
        public CloneLine(string id)
        {
            foreach (ACLineSegment ac in Singleton.Instance().AClines)
            {
                if (ac.mRID.Equals(id))
                {
                    line = ac;
                    break;
                }
            }

            ID = Guid.NewGuid().ToString().Substring(0, 8);

            foreach (ACLineSegment l in Singleton.Instance().AClines)
            {
                if (id.Equals(l.mRID))
                {
                    foreach (Terminal t in l.terminali)
                    {
                        foreach (CIM.IEC61970.Base.Core.Substation s in Singleton.Instance().Substations)
                        {
                            foreach (ConnectivityNode cn in s.connectivityNodes)
                            {
                                if (t.ConnectivityNode.mRID.Equals(cn.mRID))
                                {
                                    if (terminal1 == null)
                                    {
                                        terminal1 = new Terminal()
                                        {
                                            aliasName           = "Terminal",
                                            ConductingEquipment = new ConductingEquipment(),
                                            connected           = false,
                                            ConnectivityNode    = cn,
                                            description         = "something",
                                            mRID           = Guid.NewGuid().ToString().Substring(0, 8),
                                            name           = "Terminal",
                                            phases         = PhaseCode.A,
                                            sequenceNumber = 1
                                        };
                                    }
                                    else
                                    {
                                        terminal2 = new Terminal()
                                        {
                                            aliasName           = "Terminal",
                                            ConductingEquipment = new ConductingEquipment(),
                                            connected           = false,
                                            ConnectivityNode    = cn,
                                            description         = "something",
                                            mRID           = Guid.NewGuid().ToString().Substring(0, 8),
                                            name           = "Terminal",
                                            phases         = PhaseCode.A,
                                            sequenceNumber = 1
                                        };
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #20
0
        /// <summary>
        /// Creates entity for specified global inside the container.
        /// </summary>
        /// <param name="globalId">Global id of the entity for insert</param>
        /// <returns>Created entity (identified object).</returns>
        public IdentifiedObject CreateEntity(long globalId)
        {
            short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);

            IdentifiedObject io = null;

            switch ((DMSType)type)
            {
            case DMSType.BASEVOLTAGE:
            {
                io = new BaseVoltage(globalId);
                break;
            }

            case DMSType.TERMINAL:
            {
                io = new Terminal(globalId);
                break;
            }

            case DMSType.CONNECTIVITYNODE:
            {
                io = new ConnectivityNode(globalId);
                break;
            }

            case DMSType.POWERTRANSFORMER:
            {
                io = new PowerTransformer(globalId);
                break;
            }

            case DMSType.ENERGYSOURCE:
            {
                io = new EnergySource(globalId);
                break;
            }

            case DMSType.ENERGYCONSUMER:
            {
                io = new EnergyConsumer(globalId);
                break;
            }

            case DMSType.TRANSFORMERWINDING:
            {
                io = new TransformerWinding(globalId);
                break;
            }

            case DMSType.FUSE:
            {
                io = new Fuse(globalId);
                break;
            }

            case DMSType.DISCONNECTOR:
            {
                io = new Disconnector(globalId);
                break;
            }

            case DMSType.BREAKER:
            {
                io = new Breaker(globalId);
                break;
            }

            case DMSType.LOADBREAKSWITCH:
            {
                io = new LoadBreakSwitch(globalId);
                break;
            }

            case DMSType.ACLINESEGMENT:
            {
                io = new ACLineSegment(globalId);
                break;
            }

            case DMSType.DISCRETE:
            {
                io = new Discrete(globalId);
                break;
            }

            case DMSType.ANALOG:
            {
                io = new Analog(globalId);
                break;
            }

            case DMSType.SYNCHRONOUSMACHINE:
            {
                io = new SynchronousMachine(globalId);
                break;
            }

            default:
            {
                string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type);
                Logger.LogError(message);
                throw new Exception(message);
            }
            }

            // Add entity to map
            this.AddEntity(io);

            return(io);
        }
        private string BuildToolTipOnClick(TreeNode <NodeData> selected)
        {
            StringBuilder stringBuilderFinal = new StringBuilder();
            StringBuilder stringBuilder      = new StringBuilder();

            stringBuilder.AppendFormat("GID: {0}{1}", selected.Data.IdentifiedObject.GlobalId, Environment.NewLine);
            stringBuilder.AppendFormat("Name: {0}{1}", selected.Data.IdentifiedObject.Name, Environment.NewLine);
            stringBuilder.AppendFormat("Description: {0}{1}", selected.Data.IdentifiedObject.Description, Environment.NewLine);
            stringBuilder.AppendFormat("{0}", Environment.NewLine);
            stringBuilder.AppendFormat("{0}{1}", selected.Data.Type.ToString(), Environment.NewLine);
            stringBuilder.AppendFormat("Energized: {0}{1}", selected.Data.Energized.ToString(), Environment.NewLine);

            long        substationGID   = 0;
            List <long> measurementGIDs = new List <long>();

            switch (selected.Data.Type)
            {
            case FTN.Common.DMSType.ACLINESEGMENT:
                ACLineSegment lineSegment = (ACLineSegment)selected.Data.IdentifiedObject;
                stringBuilder.AppendFormat("Current Flow: {0}{1}", lineSegment.CurrentFlow, Environment.NewLine);
                stringBuilder.AppendFormat("Type of AC Line Segment: {0}{1}", lineSegment.Type.ToString(), Environment.NewLine);
                substationGID   = lineSegment.Container;
                measurementGIDs = lineSegment.Measurements;
                break;

            case FTN.Common.DMSType.BREAKER:
                Breaker breaker = (Breaker)selected.Data.IdentifiedObject;

                if (breaker.NormalOpen)
                {
                    stringBuilder.AppendFormat("Normal open state: true (0) {1}", breaker.NormalOpen.ToString(), Environment.NewLine);
                }
                else
                {
                    stringBuilder.AppendFormat("Normal open state: false (1) {1}", breaker.NormalOpen.ToString(), Environment.NewLine);
                }
                substationGID   = breaker.Container;
                measurementGIDs = breaker.Measurements;
                break;

            case FTN.Common.DMSType.ENEGRYSOURCE:
                EnergySource energySource = (EnergySource)selected.Data.IdentifiedObject;
                stringBuilder.AppendFormat("Type: {0}{1}", energySource.Type.ToString(), Environment.NewLine);
                stringBuilder.AppendFormat("Nominal Voltage: {0}     ", energySource.NominalVoltage);
                stringBuilder.AppendFormat("Magnitude Voltage: {0}     ", energySource.MagnitudeVoltage);
                stringBuilder.AppendFormat("Active Power: {0}{1}", energySource.ActivePower, Environment.NewLine);
                substationGID   = energySource.Container;
                measurementGIDs = energySource.Measurements;
                break;

            case FTN.Common.DMSType.ENERGYCONSUMER:
                EnergyConsumer energyConsumer = (EnergyConsumer)selected.Data.IdentifiedObject;
                stringBuilder.AppendFormat("P Fixed: {0}     ", energyConsumer.PFixed);
                stringBuilder.AppendFormat("Q Fixed: {0}{1}", energyConsumer.QFixed, Environment.NewLine);
                substationGID   = energyConsumer.Container;
                measurementGIDs = energyConsumer.Measurements;
                break;

            case FTN.Common.DMSType.GENERATOR:
                Generator generator = (Generator)selected.Data.IdentifiedObject;
                stringBuilder.AppendFormat("Type: {0}{1}", generator.GeneratorType.ToString(), Environment.NewLine);
                stringBuilder.AppendFormat("Consider P: {0}{1}", generator.ConsiderP, Environment.NewLine);
                substationGID   = generator.Container;
                measurementGIDs = generator.Measurements;
                break;

            default:
                break;
            }

            Substation            substation            = (Substation)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == substationGID).FirstOrDefault().Data.IdentifiedObject;
            SubGeographicalRegion subGeographicalRegion = (SubGeographicalRegion)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == substation.SubGeoReg).FirstOrDefault().Data.IdentifiedObject;
            GeographicalRegion    geographicalRegion    = (GeographicalRegion)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == subGeographicalRegion.GeoReg).FirstOrDefault().Data.IdentifiedObject;

            stringBuilderFinal.AppendFormat("Geographical Region: {0}     ", geographicalRegion.Name);
            stringBuilderFinal.AppendFormat("SubGeographical Region: {0}     ", subGeographicalRegion.Name);
            stringBuilderFinal.AppendFormat("Substation: {0}{1}", substation.Name, Environment.NewLine);
            stringBuilderFinal.AppendFormat("{0}", Environment.NewLine);
            stringBuilderFinal.Append(stringBuilder.ToString());
            stringBuilderFinal.AppendFormat("{0}Measurements {1}", Environment.NewLine, Environment.NewLine);
            int i = 0;

            if (measurementGIDs.Count == 0)
            {
                stringBuilderFinal.AppendFormat("NaN");
            }

            foreach (long gid in measurementGIDs)
            {
                stringBuilderFinal.AppendFormat("[{0}]{1}", i++, Environment.NewLine);
                TreeNode <NodeData> treeNode = _tree.Where(x => x.Data.IdentifiedObject.GlobalId == gid).FirstOrDefault();

                if (treeNode.Data.Type == FTN.Common.DMSType.ANALOG)
                {
                    Analog analog = (Analog)treeNode.Data.IdentifiedObject;
                    stringBuilderFinal.AppendFormat("Name: {0}{1}", analog.Name, Environment.NewLine);
                    stringBuilderFinal.AppendFormat("Measurement Type: {0}{1}", analog.MeasurementType, Environment.NewLine);
                    stringBuilderFinal.AppendFormat("Min Value: {0}     ", analog.MinValue);
                    stringBuilderFinal.AppendFormat("Max Value: {0}     ", analog.MaxValue);
                    stringBuilderFinal.AppendFormat("Normal Value: {0}{1}", analog.NormalValue, Environment.NewLine);
                }
                else
                {
                    Discrete discrete = (Discrete)treeNode.Data.IdentifiedObject;
                    stringBuilderFinal.AppendFormat("Name: {0}{1}", discrete.Name, Environment.NewLine);
                    stringBuilderFinal.AppendFormat("Measurement Type: {0}{1}", discrete.MeasurementType, Environment.NewLine);
                    stringBuilderFinal.AppendFormat("Min Value: {0}     ", discrete.MinValue);
                    stringBuilderFinal.AppendFormat("Max Value: {0}     ", discrete.MaxValue);
                    if (discrete.NormalValue == 1)
                    {
                        stringBuilderFinal.AppendFormat("Normal Value: OPEN({0}){1}", discrete.NormalValue, Environment.NewLine);
                    }
                    else
                    {
                        stringBuilderFinal.AppendFormat("Normal Value: CLOSED({0}){1}", discrete.NormalValue, Environment.NewLine);
                    }
                }
            }

            return(stringBuilderFinal.ToString());
        }