public DerForecastDayAhead CalculateGeoRegion(GeographicalRegion geographicalRegion)
        {
            List <SubGeographicalRegion> subGeographicalRegions = new List <SubGeographicalRegion>();

            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("SubGeographicalRegion"))
                    {
                        var substation = (SubGeographicalRegion)kvpDic.Value;
                        subGeographicalRegions.Add(substation);
                    }
                }
            }
            DerForecastDayAhead geoRegionForecast = new DerForecastDayAhead(geographicalRegion.GlobalId);

            foreach (SubGeographicalRegion subGeo in subGeographicalRegions)
            {
                if (geographicalRegion.Regions.Contains(subGeo.GlobalId))
                {
                    geoRegionForecast.Production += subGeographicalRegionsForecast[subGeo.GlobalId].Production;
                }
            }
            return(geoRegionForecast);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PatientAssignedArea"/> class.
 /// </summary>
 /// <param name="countyArea">The county area.</param>
 /// <param name="geographicalRegion">The geographical region.</param>
 /// <param name="postalCode">The postal code.</param>
 public PatientAssignedArea(
     CountyArea countyArea,
     GeographicalRegion geographicalRegion,
     PostalCode postalCode)
 {
     CountyArea         = countyArea;
     GeographicalRegion = geographicalRegion;
     PostalCode         = postalCode;
 }
示例#3
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (CountyArea != null ? CountyArea.GetHashCode() : 0);
         result = (result * 397) ^ (GeographicalRegion != null ? GeographicalRegion.GetHashCode() : 0);
         result = (result * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0);
         return(result);
     }
 }
示例#4
0
        private static void CreateGeographicalRegion(int depth, int x, int y, Point target, Dictionary <Point, GeographicalRegion> geographicalRegions)
        {
            var point           = new Point(x, y);
            var geologicalIndex = GeologicalIndex(point, target, geographicalRegions);
            var region          = new GeographicalRegion(point)
            {
                GeologicalIndex = geologicalIndex,
                ErosionLevel    = ErosionLevel(geologicalIndex, depth)
            };

            geographicalRegions.Add(point, region);
        }
示例#5
0
        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override int GetHashCode()
        {
            unchecked
            {
                int result = AgencyType != null?AgencyType.GetHashCode() : 0;

                result = (result * 397) ^ (AgencyName != null ? AgencyName.GetHashCode() : 0);
                result = (result * 397) ^ (EffectiveDateRange != null ? EffectiveDateRange.GetHashCode() : 0);
                result = (result * 397) ^ (WebsiteUrlName != null ? WebsiteUrlName.GetHashCode() : 0);
                result = (result * 397) ^ (GeographicalRegion != null ? GeographicalRegion.GetHashCode() : 0);
                result = (result * 397) ^ (Note != null ? Note.GetHashCode() : 0);
                return(result);
            }
        }
示例#6
0
        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override int GetHashCode()
        {
            unchecked
            {
                int result = LocationName != null?LocationName.GetHashCode() : 0;

                result = (result * 397) ^ (EffectiveDateRange != null ? EffectiveDateRange.GetHashCode() : 0);
                result = (result * 397) ^ (WebsiteUrlName != null ? WebsiteUrlName.GetHashCode() : 0);
                result = (result * 397) ^ (CountyArea != null ? CountyArea.GetHashCode() : 0);
                result = (result * 397) ^ (GeographicalRegion != null ? GeographicalRegion.GetHashCode() : 0);
                result = (result * 397) ^ (HipaaServiceLocation != null ? HipaaServiceLocation.GetHashCode() : 0);
                return(result);
            }
        }
        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());
            }
        }
示例#8
0
        //GeographicalRegion
        public List <GeographicalRegion> ListGeographicalRegion()
        {
            var list = new List <GeographicalRegion>();
            GeographicalRegion obj;

            for (int i = 0; i <= 1; i++)
            {
                obj = new GeographicalRegion();
                obj._GeographicalRegionID   = i.ToString();
                obj._GeographicalRegionName = "PCQuangNgai " + i.ToString();
                obj._SubGeographicalRegions = ListSubGeographicalRegion();
                list.Add(obj);
            }
            return(list);
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocationProfile"/> class.
        /// </summary>
        /// <param name="locationName">Name of the location.</param>
        /// <param name="effectiveDateRange">The effective date range.</param>
        /// <param name="websiteUrlName">Name of the website URL.</param>
        /// <param name="countyArea">The county area.</param>
        /// <param name="geographicalRegion">The geographical region.</param>
        /// <param name="hipaaServiceLocation">The hipaa service location.</param>
        protected internal LocationProfile(
            LocationName locationName,
            DateRange effectiveDateRange,
            string websiteUrlName,
            CountyArea countyArea,
            GeographicalRegion geographicalRegion,
            HipaaServiceLocation hipaaServiceLocation)
        {
            Check.IsNotNull(locationName, () => LocationName);

            LocationName         = locationName;
            EffectiveDateRange   = effectiveDateRange;
            WebsiteUrlName       = websiteUrlName;
            CountyArea           = countyArea;
            GeographicalRegion   = geographicalRegion;
            HipaaServiceLocation = hipaaServiceLocation;
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AgencyProfile"/> class.
        /// </summary>
        /// <param name="agencyType">Type of the agency.</param>
        /// <param name="agencyName">Name of the agency.</param>
        /// <param name="effectiveDateRange">The effective date range.</param>
        /// <param name="websiteUrlName">Name of the website URL.</param>
        /// <param name="geographicalRegion">The geographical region.</param>
        /// <param name="note">The note.</param>
        public AgencyProfile(
            AgencyType agencyType,
            AgencyName agencyName,
            DateRange effectiveDateRange,
            string websiteUrlName,
            GeographicalRegion geographicalRegion,
            string note)
        {
            Check.IsNotNull(agencyType, () => AgencyType);
            Check.IsNotNull(agencyName, () => AgencyName);

            AgencyType         = agencyType;
            AgencyName         = agencyName;
            EffectiveDateRange = effectiveDateRange;
            WebsiteUrlName     = websiteUrlName;
            GeographicalRegion = geographicalRegion;
            Note = note;
        }
示例#11
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);
        }
示例#12
0
        public List <GeographicalRegion> GetRegions()
        {
            int         iteratorId            = 0;
            List <long> ids                   = new List <long>();
            List <GeographicalRegion> regions = new List <GeographicalRegion>();

            try
            {
                int numberOfResources = 500;
                int resourcesLeft     = 0;

                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.REGION);

                iteratorId    = GdaQueryProxy.GetExtentValues(ModelCode.REGION, properties);
                resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

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

                    for (int i = 0; i < rds.Count; i++)
                    {
                        var rg = GdaQueryProxy.GetValues(rds[i].Id, properties);
                        GeographicalRegion geographicalRegion = new GeographicalRegion(rds[i].Id);
                        regions.Add(geographicalRegion.ConvertFromRD(rg));
                    }

                    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 extent values method failed for {0}.\n\t{1}", ModelCode.REGION, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(regions);
        }
示例#13
0
        public GeographicalRegionViewModel(GeographicalRegion region, NetworkRootViewModel parent, ObservableCollection <TableSMItem> ders)
            : base(parent, true)
        {
            ReactiveVisibility = Visibility.Collapsed;

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

            _region              = region;
            ActivePowerCommand   = new RelayCommand(() => ExecuteActivePowerCommand());
            ReactivePowerCommand = new RelayCommand(() => ExecuteReactivePowerCommand());
            _ders = ders;
            _ders.Clear();
        }
        public static IdentifiedObject CreateEntity(long globalId)
        {
            short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);

            IdentifiedObject io = null;

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

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

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

            case DMSType.GENERATOR:
                io = new Generator(globalId);
                break;

            case DMSType.GEOGRAFICAL_REGION:
                io = new GeographicalRegion(globalId);
                break;

            case DMSType.SUBSTATION:
                io = new Substation(globalId);
                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);
        }
示例#15
0
        public GeographicalRegion GetRegionByGid(long gid)
        {
            GeographicalRegion syncMachine = null;

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

                ResourceDescription rd = GdaQueryProxy.GetValues(gid, properties);
                syncMachine = new GeographicalRegion(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.REGION, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(syncMachine);
        }
示例#16
0
 protected bool Equals(GeographicalRegion other)
 {
     return(Location.Equals(other.Location));
 }
示例#17
0
 /// <summary>
 /// Assigns the geographical region.
 /// </summary>
 /// <param name="geographicalRegion">The geographical region.</param>
 /// <returns>An AgencyProfileBuilder.</returns>
 public AgencyProfileBuilder WithGeographicalRegion(GeographicalRegion geographicalRegion)
 {
     _geographicalRegion = geographicalRegion;
     return(this);
 }
示例#18
0
 /// <summary>
 /// Assigns the geographical region.
 /// </summary>
 /// <param name="geographicalRegion">The geographical region.</param>
 /// <returns>A LocationProfileBuilder.</returns>
 public LocationProfileBuilder WithGeographicalRegion(GeographicalRegion geographicalRegion)
 {
     _geographicalRegion = geographicalRegion;
     return this;
 }
示例#19
0
 public RegionWithEquipment(GeographicalRegion region, Equipment equipment)
 {
     Region    = region;
     Equipment = equipment;
 }
        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());
        }
示例#21
0
 /// <summary>
 /// Assigns the geographical region.
 /// </summary>
 /// <param name="geographicalRegion">The geographical region.</param>
 /// <returns>A LocationProfileBuilder.</returns>
 public LocationProfileBuilder WithGeographicalRegion(GeographicalRegion geographicalRegion)
 {
     _geographicalRegion = geographicalRegion;
     return(this);
 }