public DerForecastDayAhead CalculateSubRegion(SubGeographicalRegion subGeographicalRegion)
        {
            List <Substation> substations = new List <Substation>();

            foreach (KeyValuePair <DMSType, Dictionary <long, IdentifiedObject> > kvp in networkModel.Insert)
            {
                foreach (KeyValuePair <long, IdentifiedObject> kvpDic in kvp.Value)
                {
                    var type = kvpDic.Value.GetType();
                    if (type.Name.Equals("Substation"))
                    {
                        var substation = (Substation)kvpDic.Value;
                        substations.Add(substation);
                    }
                }
            }
            DerForecastDayAhead subGeographicalRegionForecast = new DerForecastDayAhead(subGeographicalRegion.GlobalId);

            foreach (Substation substation in substations)
            {
                if (subGeographicalRegion.Substations.Contains(substation.GlobalId))
                {
                    subGeographicalRegionForecast.Production += substationsForecast[substation.GlobalId].Production;

                    subGeographicalRegionsForecast[subGeographicalRegion.GlobalId] = subGeographicalRegionForecast;
                }
            }
            return(subGeographicalRegionForecast);
        }
        private void SetTreeOnMap()
        {
            if (_tree == null)
            {
                return;
            }

            _map.Children.Clear();

            List <TreeNode <NodeData> > energySources = _tree.Where(x => x.Data.Type == FTN.Common.DMSType.ENEGRYSOURCE).ToList();

            foreach (TreeNode <NodeData> node in energySources)
            {
                StringBuilder stringBuilder          = new StringBuilder();
                StringBuilder stringBuilderUniversal = new StringBuilder();
                EnergySource  energySource           = (EnergySource)node.Data.IdentifiedObject;

                Substation            substation            = (Substation)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == energySource.Container).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;

                stringBuilderUniversal.AppendFormat("Geographical Region: {0}{1}", geographicalRegion.Name, Environment.NewLine);
                stringBuilderUniversal.AppendFormat("SubGeographical Region: {0}{1}", subGeographicalRegion.Name, Environment.NewLine);
                stringBuilderUniversal.AppendFormat("Substation: {0}{1}", substation.Name, Environment.NewLine);
                stringBuilderUniversal.AppendFormat("----------------------------------------{0}", Environment.NewLine);

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

                stringBuilder.Append(stringBuilderUniversal.ToString());
                stringBuilder.AppendFormat("Name: {0}{1}", energySource.Name, Environment.NewLine);
                stringBuilder.AppendFormat("Description: {0}{1}", energySource.Description, Environment.NewLine);
                stringBuilder.AppendFormat("Nominal Voltage: {0} kW", energySource.NominalVoltage);
                string toolTip = stringBuilder.ToString();

                Pushpin pushpin = new Pushpin();
                pushpin.Uid      = energySource.GlobalId.ToString();
                pushpin.Location = pinLocation;
                pushpin.ToolTip  = toolTip;
                pushpin.Cursor   = Cursors.Hand;
                pushpin.Template = (ControlTemplate)Application.Current.Resources["EnergySourceTemplate"];

                if (VisibilityOfElements["EnergySource"])
                {
                    _map.Children.Add(pushpin);
                }

                StartDrowingOnMap(node.Children.ToList(), stringBuilderUniversal.ToString());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates entity for specified global ID 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.REGION:
                io = new GeographicalRegion(globalId);
                break;

            case DMSType.SUBREGION:
                io = new SubGeographicalRegion(globalId);
                break;

            case DMSType.SUBSTATION:
                io = new Substation(globalId);
                break;

            case DMSType.SYNCMACHINE:
                io = new SynchronousMachine(globalId);
                dersCopy.Add(io.GlobalId, io as SynchronousMachine);
                break;

            case DMSType.ANALOGVALUE:
                io = new AnalogValue(globalId);
                analogPointsCopy.Add(io as AnalogValue);
                break;

            case DMSType.DISCRETEVALUE:
                io = new DiscreteValue(globalId);
                discretPointsCopy.Add(io as DiscreteValue);
                break;

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

            return(io);
        }
        public SubGeographicalRegionViewModel(SubGeographicalRegion subGeographicalRegion, GeographicalRegionViewModel parentRegion, ObservableCollection <TableSMItem> ders)
            : base(parentRegion, true)
        {
            ReactiveVisibility = Visibility.Collapsed;

            foreach (SynchronousMachine der in rdAdapter.GetDERs(subGeographicalRegion.GlobalId))
            {
                if (der.FuelType == FTN.Common.FuelType.Wind)
                {
                    ReactiveVisibility = Visibility.Visible;
                    break;
                }
            }

            _subGeographicalRegion = subGeographicalRegion;
            ActivePowerCommand     = new RelayCommand(() => ExecuteActivePowerCommand());
            ReactivePowerCommand   = new RelayCommand(() => ExecuteReactivePowerCommand());
            _ders = ders;
            _ders.Clear();
        }
Exemplo n.º 5
0
        public void GeneratorOn(long generatorGid, Dictionary <long, DerForecastDayAhead> prod)
        {
            networkModel = CalculationEngineCache.Instance.GetNMSModel();
            foreach (long gid in networkModel.Keys)
            {
                IdentifiedObject io = networkModel[gid];
                var type            = io.GetType();

                if (type.Name.Equals("Substation"))
                {
                    Substation substation = (Substation)networkModel[gid];
                    if (substation.Equipments.Contains(generatorGid))
                    {
                        prod[gid].Production += prod[generatorGid].Production;
                        SubGeographicalRegion subgr = (SubGeographicalRegion)networkModel[substation.SubGeoReg];
                        prod[subgr.GlobalId].Production += prod[generatorGid].Production;
                        prod[subgr.GeoReg].Production   += prod[generatorGid].Production;
                    }
                }
            }
        }
Exemplo n.º 6
0
        public List <SubGeographicalRegion> GetSubRegionsForRegion(long regionGid)
        {
            List <SubGeographicalRegion> resultIds = new List <SubGeographicalRegion>();

            int         numberOfResources = 500;
            Association association       = new Association(ModelCode.REGION_SUBREGIONS, 0, false);

            try
            {
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.SUBREGION);

                int iteratorId    = GdaQueryProxy.GetRelatedValues(regionGid, properties, association);
                int resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                    foreach (ResourceDescription rd in rds)
                    {
                        SubGeographicalRegion subRegion = new SubGeographicalRegion(rd.Id);
                        resultIds.Add(subRegion.ConvertFromRD(rd));
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);

                CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
            }
            catch (Exception e)
            {
                string message = string.Format("Getting related values method  failed for sourceGlobalId = {0} and association (propertyId = {1}, type = {2}). Reason: {3}", regionGid, association.PropertyId, association.Type, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(resultIds);
        }
Exemplo n.º 7
0
        public SubGeographicalRegion GetSubRegionByGid(long gid)
        {
            SubGeographicalRegion syncMachine = null;

            try
            {
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.SUBREGION);

                ResourceDescription rd = GdaQueryProxy.GetValues(gid, properties);
                syncMachine = new SubGeographicalRegion(rd.Id);
                syncMachine.ConvertFromRD(rd);
                CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
            }
            catch (Exception e)
            {
                string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", ModelCode.SUBREGION, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(syncMachine);
        }
        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());
        }