Beispiel #1
0
 public void AddWind(WindDirection dir, float ammount)
 {
     unsafe
     {
         wind[(int)dir] = ammount;
     }
 }
Beispiel #2
0
 public float GetWind(WindDirection dir)
 {
     unsafe
     {
         return(wind[(int)dir]);
     }
 }
Beispiel #3
0
        public async Task LoadWeatherForModels(ObservableCollection <CityTableCellViewModel> citiesModels)
        {
            using (var httpClient = new HttpClient())
            {
                foreach (var cityModel in citiesModels)
                {
                    try
                    {
                        string url  = UrlResolver.ResolveWeatherApiUrl(cityModel.WeatherId);
                        string json = await httpClient.GetStringAsync(url);

                        var data         = JObject.Parse(json);
                        int temp         = data["main"]["temp"].Value <int>();
                        var selectedCity = Cities.First((item) => item.WeatherId == cityModel.WeatherId);
                        selectedCity.CurrentWeather = Convert.ToString(temp) + " °C";
                        selectedCity.WindDegree     = data["wind"]["deg"].Value <int>();
                        cityModel.Weather           = selectedCity.CurrentWeather;
                        var wind = WindDirection.GetWindDirection(selectedCity.WindDegree);
                        cityModel.WindDirectionImageSource = WindDirection.GetWindImageDirection(wind);
                        cityModel.UpdateWeather();
                    }
                    catch
                    {
                        if (cityModel.WindDirectionImageSource == null)
                        {
                            cityModel.WindDirectionImageSource = WindDirection.GetNotLoadedImageDirection();
                            cityModel.UpdateWeather();
                        }
                    }
                }
            }
            WeatherUpdated(this, new EventArgs());
        }
        public void Create_ValidTopLevelSubMechanismIllustrationPoint_ReturnsEntityWithSubMechanismIllustrationPointEntity()
        {
            // Setup
            var random            = new Random(21);
            var illustrationPoint = new SubMechanismIllustrationPoint("Illustration point name",
                                                                      random.NextDouble(),
                                                                      Enumerable.Empty <SubMechanismIllustrationPointStochast>(),
                                                                      Enumerable.Empty <IllustrationPointResult>());

            var windDirection = new WindDirection("WindDirection Name", random.NextDouble());
            var topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection,
                                                                                                  "Just a situation",
                                                                                                  illustrationPoint);
            int order = random.Next();

            // Call
            TopLevelSubMechanismIllustrationPointEntity entity =
                topLevelSubMechanismIllustrationPoint.Create(order);

            // Assert
            TestHelper.AssertAreEqualButNotSame(topLevelSubMechanismIllustrationPoint.ClosingSituation, entity.ClosingSituation);
            Assert.AreEqual(order, entity.Order);

            TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
            Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());

            SubMechanismIllustrationPointEntity subMechanismIllustrationPointEntity = entity.SubMechanismIllustrationPointEntity;

            TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, subMechanismIllustrationPointEntity.Name);
            Assert.AreEqual(illustrationPoint.Beta, subMechanismIllustrationPointEntity.Beta, illustrationPoint.Beta.GetAccuracy());
            CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.IllustrationPointResultEntities);
            CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.SubMechanismIllustrationPointStochastEntities);
        }
Beispiel #5
0
        public static string ToText(this WindDirection direction)
        {
            switch (direction)
            {
            case WindDirection.E:
                return("В");

            case WindDirection.NE:
                return("С-В");

            case WindDirection.N:
                return("С");

            case WindDirection.NW:
                return("С-З");

            case WindDirection.W:
                return("З");

            case WindDirection.SW:
                return("Ю-З");

            case WindDirection.S:
                return("Ю");

            case WindDirection.SE:
                return("Ю-В");

            case WindDirection.Calm:
                return("ШТЛ");

            default:
                return(string.Empty);
            }
        }
        private List <TileValue> GetFlowerTileValue(WindDirection wd)
        {
            List <TileValue> ret = new List <TileValue>();

            if (wd == WindDirection.East)
            {
                ret.Add(TileValue.FlowerRomanOne);
                ret.Add(TileValue.FlowerNumericOne);
            }

            if (wd == WindDirection.South)
            {
                ret.Add(TileValue.FlowerRomanTwo);
                ret.Add(TileValue.FlowerNumericTwo);
            }

            if (wd == WindDirection.West)
            {
                ret.Add(TileValue.FlowerRomanThree);
                ret.Add(TileValue.FlowerNumericThree);
            }

            if (wd == WindDirection.North)
            {
                ret.Add(TileValue.FlowerRomanFour);
                ret.Add(TileValue.FlowerNumericFour);
            }

            return(ret);
        }
Beispiel #7
0
        public void Constructor_StochastNamesNotUnique_ThrowArgumentException()
        {
            // Setup
            var           random        = new Random(21);
            WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection();
            var           stochasts     = new[]
            {
                new Stochast("unique", random.NextDouble(), random.NextDouble()),
                new Stochast("non-unique", random.NextDouble(), random.NextDouble()),
                new Stochast("non-unique", random.NextDouble(), random.NextDouble()),
                new Stochast("nonunique", random.NextDouble(), random.NextDouble()),
                new Stochast("nonunique", random.NextDouble(), random.NextDouble())
            };
            IEnumerable <TopLevelIllustrationPointBase> topLevelIllustrationPoints =
                Enumerable.Empty <TopLevelIllustrationPointBase>();

            // Call
            TestDelegate test = () => new GeneralResult <TopLevelIllustrationPointBase>(windDirection,
                                                                                        stochasts,
                                                                                        topLevelIllustrationPoints);

            // Assert
            const string expectedMessage = "Een of meerdere stochasten hebben dezelfde naam.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(test, expectedMessage);
        }
Beispiel #8
0
        private static void ParseXForecast(XElement xForecast, List <AbstractParameter> parameters)
        {
            parameters.Add(Temperature.FromDouble(
                               xForecast.Element("temperature").Attribute("value").Value));

            parameters.Add(Pressure.FromHpa(
                               xForecast.Element("pressure").Attribute("value").Value));

            var xPrecipVal = xForecast.Element("precipitation").Attribute("value");

            if (xPrecipVal != null)
            {
                parameters.Add(new PrecipitationAmount(
                                   xPrecipVal.Value));
            }
            else
            {
                parameters.Add(new PrecipitationAmount(0));
            }

            parameters.Add(new Humidity(
                               xForecast.Element("humidity").Attribute("value").Value));

            parameters.Add(new Cloudiness(
                               xForecast.Element("clouds").Attribute("all").Value));

            parameters.Add(WindDirection.FromDouble(
                               xForecast.Element("windDirection").Attribute("deg").Value));

            parameters.Add(WindSpeed.FromDouble(
                               xForecast.Element("windSpeed").Attribute("mps").Value));
        }
Beispiel #9
0
        public void Constructor_ChildStochastsNotEqualToTopLevelIllustrationPointStochasts_ThrowArgumentException()
        {
            // Setup
            WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection();

            var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint(new[]
            {
                new Stochast("Stochast 2", 0, 0)
            }));

            IEnumerable <TopLevelIllustrationPointBase> topLevelIllustrationPoints = new List <TopLevelIllustrationPointBase>
            {
                new TopLevelFaultTreeIllustrationPoint(windDirection, "closing", illustrationPointNode)
            };

            IEnumerable <Stochast> stochasts = new[]
            {
                new Stochast("Stochast 1", 0, 0)
            };

            // Call
            TestDelegate test = () => new GeneralResult <TopLevelIllustrationPointBase>(windDirection,
                                                                                        stochasts,
                                                                                        topLevelIllustrationPoints);

            // Assert
            const string expectedMessage = "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als in de onderliggende illustratiepunten.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(test, expectedMessage);
        }
        public static RoundPlayer GetNextPlayer(ICollection <RoundPlayer> players, WindDirection currentPlayerWind)
        {
            RoundPlayer ret;

            switch (currentPlayerWind)
            {
            case WindDirection.East:
                ret = players.First(p => p.Wind == WindDirection.South);
                break;

            case WindDirection.South:
                ret = players.First(p => p.Wind == WindDirection.West);
                break;

            case WindDirection.West:
                ret = players.First(p => p.Wind == WindDirection.North);
                break;

            case WindDirection.North:
                ret = players.First(p => p.Wind == WindDirection.East);
                break;

            default:
                throw new Exception("Error when getting next player");
            }

            return(ret);
        }
 private static void AssertWindDirection(WindDirection expectedWindDirection,
                                         IGeneralResultEntity entity)
 {
     TestHelper.AssertAreEqualButNotSame(expectedWindDirection.Name, entity.GoverningWindDirectionName);
     Assert.AreEqual(expectedWindDirection.Angle, entity.GoverningWindDirectionAngle,
                     expectedWindDirection.Angle.GetAccuracy());
 }
Beispiel #12
0
    private Vector3 GetWindFlowDirectiond(WindDirection direction)
    {
        Vector3 windDirection = Vector3.zero;

        switch (direction)
        {
        case WindDirection.North:
            windDirection = Vector3.forward * Time.deltaTime * windSpeed;
            break;

        case WindDirection.East:
            windDirection = Vector3.right * Time.deltaTime * windSpeed;
            break;

        case WindDirection.South:
            windDirection = Vector3.back * Time.deltaTime * windSpeed;
            break;

        case WindDirection.West:
            windDirection = Vector3.left * Time.deltaTime * windSpeed;
            break;

        default:
            Debug.Log("This direction does not exist!");
            break;
        }
        return(windDirection);
    }
Beispiel #13
0
 public void CalculateNextFrame(Tree[] treesAround, WindDirection direction)
 {
     if (!Burned)
     {
         calculateChance(treesAround, direction);
     }
 }
Beispiel #14
0
        public async Task <DancerResponse> Dancing(float latitude, float longitude)
        {
            var weather = await GetWeather(latitude, longitude);


            var random      = new Random();
            var randomBirds = random.Next(100) < 10;

            var dancer = new DancerResponse()
            {
                Lat      = latitude,
                Lng      = longitude,
                HasBirds = randomBirds,
                Weather  = new WeatherResponse()
                {
                    WindDirection = WindDirection.WindDegreesToDirection(weather.Wind.Deg),
                    WindDegree    = weather.Wind.Deg,
                    WindSpeed     = weather.Wind.Speed
                },
                HasDangerDanger = IsDangerDanger(weather),
                HasNoFlyZone    = await _noFlyingBusiness.IsInNoFlyZone(latitude, longitude),
                MaxHeight       = 1000,
            };

            return(dancer);
        }
Beispiel #15
0
        internal static WindDirection Clone(this WindDirection original) //דרך ראשונה
        {
            WindDirection target = new WindDirection();

            target.direction = original.direction;
            return(target);
        }
        public ForestFireSimulator(int treesNumber, WindDirection windDirection, int threads = 1, bool showUsage = false)
        {
            this.treesNumber = treesNumber;
            this.threads     = threads;
            this.showUsage   = showUsage;
            xSize            = (int)Math.Sqrt(treesNumber);
            ySize            = xSize + (int)Math.Ceiling((decimal)(treesNumber - (xSize * xSize)) / xSize);
            direction        = windDirection;
            trees            = new Tree[xSize, ySize];
            for (int i = 0; i < ySize; ++i)
            {
                for (int j = 0; j < xSize; ++j)
                {
                    if ((i * xSize + j) < treesNumber)
                    {
                        trees[j, i] = new Tree();
                    }
                    else
                    {
                        trees[j, i] = null;
                    }
                }
            }

            //Console.WriteLine("Trees: " + treesNumber + " | " + xSize + "x" + ySize + " | Free: " + free + Environment.NewLine);
        }
        /// <summary>
        /// Parses <see cref="WindDirection"/> objects from the <paramref name="reader"/>.
        /// </summary>
        /// <param name="reader">The database reader.</param>
        /// <exception cref="HydraRingFileParserException">Thrown when the read <see cref="IllustrationPointsDatabaseConstants.WindDirectionAngle"/>
        /// is <see cref="DBNull"/> or when no governing wind direction is found.</exception>
        private void ParseWindDirections(HydraRingDatabaseReader reader)
        {
            windDirections = new Dictionary <int, WindDirection>();

            foreach (Dictionary <string, object> readWindDirection in GetIterator(reader))
            {
                int    key   = Convert.ToInt32(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionId]);
                string name  = Convert.ToString(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionName]);
                double angle = ConvertToDouble(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionAngle],
                                               IllustrationPointsDatabaseConstants.WindDirectionAngle);
                bool isGoverning = Convert.ToBoolean(readWindDirection[IllustrationPointsDatabaseConstants.IsGoverning]);

                var windDirection = new WindDirection(name, angle);
                windDirections[key] = windDirection;

                if (isGoverning)
                {
                    governingWindDirection = windDirection;
                }
            }

            if (governingWindDirection == null)
            {
                throw new HydraRingFileParserException(Resources.IllustrationPointsParser_Parse_No_governing_wind_direction_found);
            }
        }
Beispiel #18
0
 public WeatherConditions(double windSpeed, WindDirection windDirection, double temperatureC, double precipitationIntensity)
 {
     this.WindSpeed              = windSpeed;
     this.WindDirection          = windDirection;
     this.TemperatureC           = temperatureC;
     this.PrecipitationIntensity = precipitationIntensity;
 }
Beispiel #19
0
            private WindDirection NextWindClockWise(WindDirection wind)
            {
                WindDirection ret;

                switch (wind)
                {
                case WindDirection.East:
                    ret = WindDirection.South;
                    break;

                case WindDirection.South:
                    ret = WindDirection.West;
                    break;

                case WindDirection.West:
                    ret = WindDirection.North;
                    break;

                case WindDirection.North:
                    ret = WindDirection.East;
                    break;

                default:
                    ret = WindDirection.East;
                    break;
                }
                return(ret);
            }
Beispiel #20
0
        private void calculateChance(Tree[] treesAround, WindDirection direction)
        {
            BurningChance = 0f;
            for (int i = 0; i < treesAround.Length; ++i)
            {
                if (treesAround[i] != null)
                {
                    if (treesAround[i].Burning)
                    {
                        BurningChance += .05f;
                    }
                }
            }

            try
            {
                if ((direction == WindDirection.N && treesAround[7].Burning) ||
                    (direction == WindDirection.S && treesAround[3].Burning) ||
                    (direction == WindDirection.W && treesAround[1].Burning) ||
                    (direction == WindDirection.E && treesAround[5].Burning))
                {
                    BurningChance += .5f;
                }
            }
            catch (NullReferenceException ex) { }
        }
Beispiel #21
0
        protected override void Update(GameTime gameTime)
        {
            InputManager.Update();

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (InputManager.OnKeyUp(Keys.N))
            {
                _windDirection = WindDirection.None;
            }
            else if (InputManager.OnKeyUp(Keys.Left))
            {
                _windDirection = WindDirection.Left;
            }
            else if (InputManager.OnKeyUp(Keys.Right))
            {
                _windDirection = WindDirection.Right;
            }
            else if (InputManager.OnKeyUp(Keys.Up))
            {
                IncreaseFireSource();
            }
            else if (InputManager.OnKeyUp(Keys.Down))
            {
                DecreaseFireSource();
            }

            CalculateFirePropagation();

            base.Update(gameTime);
        }
 public WeatherTelemetryEvent(DateTime measurementStartTime,
                              DateTime measurementEndTime,
                              double temperature,
                              double pressure,
                              double humidity,
                              int lightLevel,
                              WindDirection currentWindDirection,
                              WindDirection mostFrequentWindDirection,
                              double averageWindSpeed,
                              double maxWindSpeed,
                              double minWindSpeed,
                              float precipitation)
 {
     MeasurementStartTime      = measurementStartTime;
     MeasurementEndTime        = measurementEndTime;
     Temperature               = temperature;
     Pressure                  = pressure;
     Humidity                  = humidity;
     LightLevel                = lightLevel;
     CurrentWindDirection      = currentWindDirection;
     MostFrequentWindDirection = mostFrequentWindDirection;
     AverageWindSpeed          = averageWindSpeed;
     MaxWindSpeed              = maxWindSpeed;
     MinWindSpeed              = minWindSpeed;
     Precipitation             = precipitation;
 }
        public void ToString_DifferentClosingSituations_ReturnsCombinationOfWindDirectionAndClosingSituation()
        {
            // Setup
            string illustrationPointName         = string.Empty;
            var    subMechanismIllustrationPoint =
                new SubMechanismIllustrationPoint(illustrationPointName,
                                                  3,
                                                  Enumerable.Empty <SubMechanismIllustrationPointStochast>(),
                                                  Enumerable.Empty <IllustrationPointResult>());

            const string  closingSituation = "direction";
            WindDirection windDirection    = WindDirectionTestFactory.CreateTestWindDirection();
            var           context          = new TopLevelSubMechanismIllustrationPoint(windDirection,
                                                                                       closingSituation,
                                                                                       subMechanismIllustrationPoint);

            // Call
            var properties = new TopLevelSubMechanismIllustrationPointProperties(
                context,
                new[]
            {
                closingSituation,
                closingSituation,
                "Different situation"
            });

            // Assert
            string expectedStringValue = $"{windDirection.Name} ({closingSituation})";

            Assert.AreEqual(expectedStringValue, properties.ToString());
        }
        public void ConvertToGeneralResultTopLevelFaultTreeIllustrationPoint_HydraRingGeneralResultWithFaultTreeIllustrationPointsOnly_ExpectedProperties()
        {
            // Setup
            var random = new Random(21);

            const string closingSituation       = "Closing situation";
            var          hydraRingWindDirection = new HydraRingWindDirection("SSE", random.NextDouble());
            var          hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(
                hydraRingWindDirection,
                closingSituation);

            var hydraRingIllustrationPoint = new HydraRingFaultTreeIllustrationPoint(
                "IllustrationPoint",
                random.NextDouble(),
                Enumerable.Empty <HydraRingStochast>(),
                HydraRingCombinationType.Or);
            var hydraRingIllustrationTreeNode = new HydraRingIllustrationPointTreeNode(hydraRingIllustrationPoint);

            var governingHydraRingWindDirection = new HydraRingWindDirection("Name", random.NextDouble());
            var hydraRingGeneralResult          = new HydraRingGeneralResult(
                random.NextDouble(),
                governingHydraRingWindDirection,
                Enumerable.Empty <HydraRingStochast>(),
                new Dictionary <HydraRingWindDirectionClosingSituation, HydraRingIllustrationPointTreeNode>
            {
                {
                    hydraRingWindDirectionClosingSituation, hydraRingIllustrationTreeNode
                }
            });

            // Call
            GeneralResult <TopLevelFaultTreeIllustrationPoint> generalResult =
                GeneralResultConverter.ConvertToGeneralResultTopLevelFaultTreeIllustrationPoint(hydraRingGeneralResult);

            // Assert
            WindDirection generalResultGoverningWindDirection =
                generalResult.GoverningWindDirection;

            AssertWindDirection(governingHydraRingWindDirection, generalResultGoverningWindDirection);

            TopLevelFaultTreeIllustrationPoint topLevelFaultTreeIllustrationPoint =
                generalResult.TopLevelIllustrationPoints.Single();

            AssertWindDirection(hydraRingWindDirection, topLevelFaultTreeIllustrationPoint.WindDirection);
            Assert.AreEqual(closingSituation, topLevelFaultTreeIllustrationPoint.ClosingSituation);

            IllustrationPointNode faultTreeIllustrationPoint =
                topLevelFaultTreeIllustrationPoint.FaultTreeNodeRoot;

            CollectionAssert.IsEmpty(faultTreeIllustrationPoint.Children);

            var faultTreeIllustrationPointData = (FaultTreeIllustrationPoint)faultTreeIllustrationPoint.Data;

            CollectionAssert.IsEmpty(faultTreeIllustrationPointData.Stochasts);
            Assert.AreEqual(hydraRingIllustrationPoint.Name, faultTreeIllustrationPointData.Name);
            Assert.AreEqual(hydraRingIllustrationPoint.Beta, faultTreeIllustrationPointData.Beta,
                            faultTreeIllustrationPointData.Beta.GetAccuracy());
            Assert.AreEqual(CombinationType.Or, faultTreeIllustrationPointData.CombinationType);
        }
Beispiel #25
0
        public void Convert_ValidArguments_ExpectedProperties()
        {
            // Setup
            var random = new Random(21);
            var hydraRingWindDirection = new HydraRingWindDirection("Name", random.NextDouble());

            var hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(hydraRingWindDirection,
                                                                                                    "closing scenario");

            var hydraRingIllustrationPointResult = new HydraRingIllustrationPointResult("HydraIllustrationPointResult",
                                                                                        "-",
                                                                                        random.NextDouble());

            var hydraRingSubMechanismIllustrationPointStochast =
                new HydraRingSubMechanismIllustrationPointStochast("HydraSubMechanismIllustrationPointStochast",
                                                                   "-",
                                                                   random.NextDouble(),
                                                                   random.NextDouble(),
                                                                   random.NextDouble());

            var hydraRingSubMechanismIllustrationPoint = new HydraRingSubMechanismIllustrationPoint("name", new[]
            {
                hydraRingSubMechanismIllustrationPointStochast
            }, new[]
            {
                hydraRingIllustrationPointResult
            }, random.NextDouble());

            // Call
            TopLevelSubMechanismIllustrationPoint combination =
                TopLevelSubMechanismIllustrationPointConverter.Convert(
                    hydraRingWindDirectionClosingSituation, hydraRingSubMechanismIllustrationPoint);

            // Assert
            WindDirection windDirection = combination.WindDirection;

            Assert.AreEqual(hydraRingWindDirection.Angle, windDirection.Angle, windDirection.Angle.GetAccuracy());
            Assert.AreEqual(hydraRingWindDirection.Name, windDirection.Name);

            Assert.AreEqual(hydraRingWindDirectionClosingSituation.ClosingSituation, combination.ClosingSituation);

            SubMechanismIllustrationPoint subMechanismIllustrationPoint = combination.SubMechanismIllustrationPoint;

            Assert.AreEqual(hydraRingSubMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta.GetAccuracy());
            Assert.AreEqual(hydraRingSubMechanismIllustrationPoint.Name, subMechanismIllustrationPoint.Name);

            IllustrationPointResult illustrationPointResult = subMechanismIllustrationPoint.IllustrationPointResults.Single();

            Assert.AreEqual(hydraRingIllustrationPointResult.Description, illustrationPointResult.Description);
            Assert.AreEqual(hydraRingIllustrationPointResult.Value, illustrationPointResult.Value, illustrationPointResult.Value.GetAccuracy());

            SubMechanismIllustrationPointStochast stochast = subMechanismIllustrationPoint.Stochasts.Single();

            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Alpha, stochast.Alpha, stochast.Alpha.GetAccuracy());
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Duration, stochast.Duration, stochast.Duration.GetAccuracy());
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Name, stochast.Name);
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Unit, stochast.Unit);
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Realization, stochast.Realization, stochast.Realization.GetAccuracy());
        }
Beispiel #26
0
        // Wrapper for the recursion.
        private List <int> DisksToChangeForDirection(int place, Players player, WindDirection windDirection)
        {
            var result = new List <int>();

            DisksToChangeForDirection(place, player, windDirection, result);

            return(result);
        }
Beispiel #27
0
 public Reading(decimal temperature, decimal pressure,
                decimal rainfall, WindDirection windDirection)
 {
     Temperature   = temperature;
     Pressure      = pressure;
     Rainfall      = rainfall;
     WindDirection = windDirection;
 }
Beispiel #28
0
        public WindDirection GetWindDirection(int day)
        {
            WindDirection direction  = DataSource.directions.Find(d => true);
            var           directions = (WindDirections[])Enum.GetValues(typeof(WindDirections));

            direction.direction = directions[rnd.Next(0, directions.Length)];

            return(direction.Clone());
        }
Beispiel #29
0
        public void TestNorth()
        {
            string isNorth = WindDirection.GetWindDirection(0);

            Assert.IsTrue(isNorth == "N");
            string isN = WindDirection.GetWindDirection(360);

            Assert.IsTrue(isN == "N");
        }
Beispiel #30
0
        public static string GetShortDirectionString(WindDirection actualValue)
        {
            switch (actualValue)
            {
            case WindDirection.North:
                return("N");

            case WindDirection.NorthNorthEast:
                return("NNE");

            case WindDirection.NorthEast:
                return("NE");

            case WindDirection.EastNorthEast:
                return("ENE");

            case WindDirection.East:
                return("E");

            case WindDirection.EastSouthEast:
                return("ESE");

            case WindDirection.SouthEast:
                return("SE");

            case WindDirection.SouthSouthEast:
                return("SSE");

            case WindDirection.South:
                return("S");

            case WindDirection.SouthSouthWest:
                return("SSW");

            case WindDirection.SouthWest:
                return("SW");

            case WindDirection.WestSouthWest:
                return("WSW");

            case WindDirection.West:
                return("W");

            case WindDirection.WestNorthWest:
                return("WNW");

            case WindDirection.NorthWest:
                return("NW");

            case WindDirection.NorthNorthWest:
                return("NNW");

            default:
                return(String.Empty);
            }
        }
Beispiel #31
0
 public Weather(DateTime date, eWindSpeed windspeed, WindDirection direction, CloudCover cover,Precipitation precip, HourlyWeather[] temperatures,double temperatureLow, double temperatureHigh)
 {
     this.Date = date;
     this.WindSpeed = windspeed;
     this.Direction = direction;
     this.Cover = cover;
     this.Precip = precip;
     this.Temperatures = temperatures;
     this.TemperatureLow = temperatureLow;
     this.TemperatureHigh = temperatureHigh;
 }
        public void GetAvgWeatherData_CalculateAverageDirectionNearZerroWithSameSpeed_AverageDirection(
            WindDirection direction1, WindDirection direction2, WindDirection result)
        {
            // Arrange
            var weatherData = new[]
            {
                new WeatherDataDto { WindDirection = direction1, WindSpeed = 10 },
                new WeatherDataDto { WindDirection = direction2, WindSpeed = 10 }
            };

            // Act
            var averageWeatherData = this.calculator.GetAvgWeatherData(weatherData);

            // Assert
            Assert.AreEqual(averageWeatherData.WindDirection, result);
        }
        public Lane(string id, Server server, Vehicle type, settings Settings)
        {
            _id = id;
            _laneNr = Convert.ToInt32(id.Substring(1,1));
            _direction = (WindDirection) Enum.Parse(typeof(WindDirection),
                Enum.GetNames(typeof(WindDirection)).First((s) => s.StartsWith(id.Substring(0, 1))), true);

            _server = server;
            _vehicle = type;
            _state = TrafficLightState.Red;
            _orangeTime = Settings.orangeTime;
            BusDirections = new Queue<Direction>();

            int windPriority = _direction == WindDirection.North || _direction == WindDirection.South ? 10 : 0;
            switch (type)
            {
                case Vehicle.PEDESTRIAN:
                    _priority = 73;
                    break;
                case Vehicle.BICYCLE:
                    _priority = 100;
                    break;
                case Vehicle.CAR:
                    _priority = 200 + windPriority;
                    break;
                case Vehicle.BUS:
                    _priority = 300 + windPriority;
                    break;
            }

            _compatibilityList = new bool[][,] { _compatibilitySelf, _compatibilityLeft, _compatibilityStraight, _compatibilityRight };
        }
Beispiel #34
0
 private double DegToRad(WindDirection? angle)
 {
     return DegToRad(angle.HasValue ? (int)angle : 0);
 }
 public Direction GetRelativeDirection(WindDirection other)
 {
     return _W2Direction[(int)(other + 4 - _direction) % 4];
 }
        public void GetAvgWeatherData_CalculateAverageDirectionWithCrosswindAndDifferentSpeed_DirectionWhereMoreSpeed(
            WindDirection direction1, WindDirection direction2)
        {
            // Arrange
            var weatherData = new[]
            {
                new WeatherDataDto { WindDirection = direction1, WindSpeed = 10 },
                new WeatherDataDto { WindDirection = direction2, WindSpeed = 11 }
            };

            // Act
            var averageWeatherData = this.calculator.GetAvgWeatherData(weatherData);

            // Assert
            Assert.AreEqual(averageWeatherData.WindDirection, direction2);
        }
        public void GetAvgWeatherData_CalculateAverageSpeedWithCrosswindAndDifferentSpeed_AverageSpeed(
            WindDirection direction1, WindDirection direction2, double speed1, double speed2)
        {
            // Arrange
            var weatherData = new[]
            {
                new WeatherDataDto { WindDirection = direction1, WindSpeed = speed1 },
                new WeatherDataDto { WindDirection = direction2, WindSpeed = speed2 }
            };

            // Act
            var averageWeatherData = this.calculator.GetAvgWeatherData(weatherData);

            // Assert
            Assert.AreEqual(averageWeatherData.WindSpeed, Math.Round((speed1 > speed2 ? speed1 - speed2 : speed2 - speed1) / 2, MidpointRounding.AwayFromZero));
        }
 private StringBuilder SetText(WindDirection direction, StringBuilder sb)
 {
     sb.Append(direction.GetDisplayName());
     return sb;
 }
        private static string GetWindDirection(WindDirection? direction)
        {
            switch (direction)
            {
                case null:
                    return AppResource.WindDirection_Calm;

                case WindDirection.North:
                    return AppResource.WindDirection_North;

                case WindDirection.NorthEast:
                    return AppResource.WindDirection_NorthEast;

                case WindDirection.East:
                    return AppResource.WindDirection_East;

                case WindDirection.SouthEast:
                    return AppResource.WindDirection_SouthEast;

                case WindDirection.South:
                    return AppResource.WindDirection_South;

                case WindDirection.SouthWest:
                    return AppResource.WindDirection_SouthWest;

                case WindDirection.West:
                    return AppResource.WindDirection_West;

                case WindDirection.NorthWest:
                    return AppResource.WindDirection_NorthWest;
            }

            return string.Empty;
        }
 /// <summary>
 /// initForecastObjects init and allocate all forecast objects
 /// </summary>
 private void initForecastObjects()
 {
     this.location = new Location();
     this.sunRise = new SunRise();
     this.temperature = new Temperature();
     this.humidity = new Humidity();
     this.pressure = new Pressure();
     this.windSpeed = new WindSpeed();
     this.windDirection = new WindDirection();
     this.clouds = new Clouds();
     this.precipitation = new Precipitation();
     this.weather = new Weather();
     this.lastupdate = new Lastupdate();
 }
Beispiel #41
0
 public WindInfo(WindDirection direction, string speed)
 {
     this._direction = direction;
     this._speed = speed;
 }