Пример #1
0
        bool Get(INetworkModelGDAContract nms)
        {
            Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap     = ModelResourcesDesc.GetTypeToPropertiesMap();
            Dictionary <DMSType, List <ModelCode> > typeToPropertiesMapMeas = new Dictionary <DMSType, List <ModelCode> >(2)
            {
                { DMSType.Analog, typeToPropertiesMap[DMSType.Analog] }, { DMSType.Discrete, typeToPropertiesMap[DMSType.Discrete] }
            };

            List <IdentifiedObject> inserted = new List <IdentifiedObject>(insertedGids.Count);
            List <IdentifiedObject> updated  = new List <IdentifiedObject>(updatedGids.Count);

            List <ResourceDescription> result;
            int iterator = nms.GetMultipleValues(insertedGids, typeToPropertiesMapMeas, true);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, true);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    inserted.Add(IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);
            iterator = nms.GetMultipleValues(updatedGids, typeToPropertiesMapMeas, true);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, true);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    updated.Add(IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);

            Inserted = inserted;
            Updated  = updated;
            Deleted  = deletedGids;

            return(true);
        }
Пример #2
0
        public PropertiesView(Func <IdentifiedObject> ioGetter, PubSubClient pubSub) : base()
        {
            this.ioGetter = ioGetter;
            this.pubSub   = pubSub;
            typeToProps   = ModelResourcesDesc.GetTypeToPropertiesMap();
            panel         = new StackPanel();

            StackPanel propPanel = new StackPanel();
            Border     border    = new Border()
            {
                BorderThickness = new Thickness(1), BorderBrush = Brushes.LightGray, Margin = new Thickness(1), Padding = new Thickness(1)
            };
            Grid propsGrid = new Grid();

            propsGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                MinWidth = 0
            });
            propsGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(5)
            });
            propsGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                MinWidth = 0
            });
            propsGrid.RowDefinitions.Add(new RowDefinition());

            AddToGrid(propsGrid, new TextBlock()
            {
                Text = "Name", FontWeight = FontWeights.Bold, HorizontalAlignment = HorizontalAlignment.Center
            }, 0, 0);
            AddToGrid(propsGrid, new TextBlock()
            {
                Text = "Value", FontWeight = FontWeights.Bold, HorizontalAlignment = HorizontalAlignment.Center
            }, 0, 2);

            AddToGrid(propsGrid, new GridSplitter()
            {
                ResizeDirection = GridResizeDirection.Columns, HorizontalAlignment = HorizontalAlignment.Stretch, Background = Brushes.Black, Margin = new Thickness(0), Padding = new Thickness(0), ResizeBehavior = GridResizeBehavior.PreviousAndNext, BorderThickness = new Thickness(2, 0, 2, 0), BorderBrush = Brushes.Transparent
            }, 0, 1);

            border.Child = propsGrid;
            propPanel.Children.Add(border);
            panel.Children.Add(new TextBlock()
            {
                Margin = new Thickness(2), Text = "Properties", FontWeight = FontWeights.Bold, FontSize = 14
            });
            panel.Children.Add(propPanel);
        }
Пример #3
0
        bool Get(INetworkModelGDAContract nms)
        {
            Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap();

            DMSType[] types = ModelResourcesDesc.TypeIdsInInsertOrder;
            Dictionary <DMSType, Dictionary <long, IdentifiedObject> > containers = new Dictionary <DMSType, Dictionary <long, IdentifiedObject> >(types.Length);

            foreach (DMSType type in types)
            {
                Dictionary <long, IdentifiedObject> container = new Dictionary <long, IdentifiedObject>();

                int iterator = nms.GetExtentValues(type, typeToPropertiesMap[type], false);

                if (iterator < 0)
                {
                    return(false);
                }

                List <ResourceDescription> result;

                do
                {
                    result = nms.IteratorNext(iteratorCount, iterator, false);

                    if (result == null)
                    {
                        return(false);
                    }

                    foreach (ResourceDescription rd in result)
                    {
                        IdentifiedObject io = rd == null ? null : IdentifiedObject.Create(rd, true);
                        container.Add(io.GID, io);
                    }
                }while(result.Count >= iteratorCount);

                nms.IteratorClose(iterator);
                containers.Add(type, container);
            }

            Containers = containers;
            return(true);
        }
        bool Get(INetworkModelGDAContract nms)
        {
            Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap();

            if (insertedGids == null || updatedGids == null || deletedGids == null)
            {
                List <IdentifiedObject> inserted = new List <IdentifiedObject>();
                DMSType[] types = ModelResourcesDesc.TypeIdsInInsertOrder;

                foreach (DMSType type in types)
                {
                    int iterator = nms.GetExtentValues(type, typeToPropertiesMap[type], false);

                    if (iterator < 0)
                    {
                        return(false);
                    }

                    List <ResourceDescription> result;

                    do
                    {
                        result = nms.IteratorNext(iteratorCount, iterator, false);

                        if (result == null)
                        {
                            return(false);
                        }

                        foreach (ResourceDescription rd in result)
                        {
                            if (rd == null)
                            {
                                continue;
                            }

                            inserted.Add(IdentifiedObject.Create(rd, true));
                        }
                    }while(result.Count >= iteratorCount);

                    nms.IteratorClose(iterator);

                    Inserted = inserted;
                    Updated  = new List <IdentifiedObject>(0);
                    Deleted  = new List <long>(0);
                }
            }
            else
            {
                List <IdentifiedObject> inserted = new List <IdentifiedObject>(insertedGids.Count);
                List <IdentifiedObject> updated  = new List <IdentifiedObject>(updatedGids.Count);

                List <ResourceDescription> result;
                int iterator = nms.GetMultipleValues(insertedGids, typeToPropertiesMap, true);

                do
                {
                    result = nms.IteratorNext(iteratorCount, iterator, true);

                    if (result == null)
                    {
                        return(false);
                    }

                    foreach (ResourceDescription rd in result)
                    {
                        if (rd == null)
                        {
                            continue;
                        }

                        inserted.Add(IdentifiedObject.Create(rd, true));
                    }
                }while(result.Count >= iteratorCount);

                nms.IteratorClose(iterator);
                iterator = nms.GetMultipleValues(updatedGids, typeToPropertiesMap, true);

                do
                {
                    result = nms.IteratorNext(iteratorCount, iterator, true);

                    if (result == null)
                    {
                        return(false);
                    }

                    foreach (ResourceDescription rd in result)
                    {
                        if (rd == null)
                        {
                            continue;
                        }

                        updated.Add(IdentifiedObject.Create(rd, true));
                    }
                }while(result.Count >= iteratorCount);

                nms.IteratorClose(iterator);

                Inserted = inserted;
                Updated  = updated;
                Deleted  = deletedGids;
            }

            return(true);
        }
Пример #5
0
        bool Get(INetworkModelGDAContract nms)
        {
            Dictionary <long, Analog>         analogs         = new Dictionary <long, Analog>();
            Dictionary <long, Discrete>       discretes       = new Dictionary <long, Discrete>();
            Dictionary <long, Recloser>       reclosers       = new Dictionary <long, Recloser>();
            Dictionary <long, Terminal>       terminals       = new Dictionary <long, Terminal>();
            Dictionary <long, EnergyConsumer> energyConsumers = new Dictionary <long, EnergyConsumer>();

            Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap();

            List <ResourceDescription> result;
            int iterator = nms.GetExtentValues(DMSType.Analog, typeToPropertiesMap[DMSType.Analog], false);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, false);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    analogs.Add(rd.Id, (Analog)IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);
            iterator = nms.GetExtentValues(DMSType.Discrete, typeToPropertiesMap[DMSType.Discrete], false);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, false);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    discretes.Add(rd.Id, (Discrete)IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);
            iterator = nms.GetExtentValues(DMSType.EnergyConsumer, typeToPropertiesMap[DMSType.EnergyConsumer], false);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, false);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    energyConsumers.Add(rd.Id, (EnergyConsumer)IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);
            iterator = nms.GetExtentValues(DMSType.Recloser, typeToPropertiesMap[DMSType.Recloser], false);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, false);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    reclosers.Add(rd.Id, (Recloser)IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);

            List <long> terminalGIDs = new List <long>(reclosers.Count * 2);

            foreach (Recloser r in reclosers.Values)
            {
                for (int i = 0; i < r.Terminals.Count; ++i)
                {
                    terminalGIDs.Add(r.Terminals[i]);
                }
            }

            iterator = nms.GetMultipleValues(terminalGIDs, typeToPropertiesMap, false);

            do
            {
                result = nms.IteratorNext(iteratorCount, iterator, false);

                if (result == null)
                {
                    return(false);
                }

                foreach (ResourceDescription rd in result)
                {
                    if (terminals.ContainsKey(rd.Id))
                    {
                        continue;
                    }

                    terminals.Add(rd.Id, (Terminal)IdentifiedObject.Create(rd, true));
                }
            }while(result.Count >= iteratorCount);

            nms.IteratorClose(iterator);

            Analogs         = analogs;
            Discretes       = discretes;
            Reclosers       = reclosers;
            Terminals       = terminals;
            EnergyConsumers = energyConsumers;

            return(true);
        }