Esempio n. 1
0
        bool HandleTopologyChange(TopologyChanged m)
        {
            TopologyDownload download = new TopologyDownload();

            if (!download.Download())
            {
                return(false);
            }

            topology.Update(download);

            Notify(new ObservableMessage(EObservableMessageType.TopologyChanged));
            return(true);
        }
Esempio n. 2
0
        public void Update(TopologyDownload download)
        {
            List <Tuple <long, List <Tuple <long, long> >, List <Tuple <long, long> > > > topology = download.Topology;

            HashSet <Tuple <long, long> > unknownLines   = new HashSet <Tuple <long, long> >();
            HashSet <Tuple <long, long> > energizedLines = new HashSet <Tuple <long, long> >();
            HashSet <long> unknownNodes   = new HashSet <long>();
            HashSet <long> energizedNodes = new HashSet <long>();

            if (topology == null)
            {
                return;
            }

            for (int i1 = 0; i1 < topology.Count; ++i1)
            {
                Tuple <long, List <Tuple <long, long> >, List <Tuple <long, long> > > source = topology[i1];

                for (int i2 = 0; i2 < source.Item2.Count; ++i2)
                {
                    Tuple <long, long> energizedLine = source.Item2[i2];

                    energizedLines.Add(energizedLine);
                    unknownLines.Remove(energizedLine);

                    energizedNodes.Add(energizedLine.Item1);
                    unknownNodes.Remove(energizedLine.Item1);

                    energizedNodes.Add(energizedLine.Item2);
                    unknownNodes.Remove(energizedLine.Item2);
                }

                for (int i3 = 0; i3 < source.Item3.Count; ++i3)
                {
                    Tuple <long, long> unknownLine = source.Item3[i3];

                    if (!energizedLines.Contains(unknownLine))
                    {
                        unknownLines.Add(unknownLine);
                    }

                    if (!energizedNodes.Contains(unknownLine.Item1))
                    {
                        unknownNodes.Add(unknownLine.Item1);
                    }

                    if (!energizedNodes.Contains(unknownLine.Item2))
                    {
                        unknownNodes.Add(unknownLine.Item2);
                    }
                }
            }

            rwLock.EnterWriteLock();
            {
                this.unknownLines   = unknownLines;
                this.energizedLines = energizedLines;
                this.unknownNodes   = unknownNodes;
                this.energizedNodes = energizedNodes;
            }
            rwLock.ExitWriteLock();
        }