Exemplo n.º 1
0
        public void TestHumidToHigh()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.HumidityLevel = 60;
            ad.ProcessData();
            Assert.Equal(61, ad.TempControlBafflePosition);
        }
Exemplo n.º 2
0
        public void TestHumidityWithinAcceptableLowerDeviance()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.HumidityLevel = 35;
            ad.ProcessData();
            Assert.Equal(60, ad.TempControlBafflePosition);
        }
Exemplo n.º 3
0
        public void TestTempToHot()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.Temperature = 19.6;
            ad.ProcessData();
            Assert.Equal(61, ad.TempControlBafflePosition);
        }
Exemplo n.º 4
0
        public void TestUnCrewedToCold()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.Temperature = 2;
            ad.ProcessData();
            Assert.Equal(59, ad.TempControlBafflePosition);
        }
Exemplo n.º 5
0
        public void TestTempWithinAcceptableLowerDeviance()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.Temperature = 18.5;
            ad.ProcessData();
            Assert.Equal(60, ad.TempControlBafflePosition);
        }
Exemplo n.º 6
0
        public void TestNewTempValueGenerated()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            AtmosphereData newad = new AtmosphereData(ad);

            Assert.NotEqual(newad.Temperature, ad.Temperature);
        }
Exemplo n.º 7
0
        public void TestSeperatorOffWhileUncrewed()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            AtmosphereData newad = new AtmosphereData(ad);

            Assert.Equal(0, newad.SeperatorSpeed);
        }
Exemplo n.º 8
0
        public void TestLiquidInOutflow()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.LiquidInOutflow = true;
            ad.ProcessData();
            Assert.Equal(DiverterValvePositions.Reprocess, ad.ReprocessBafflePosition);
        }
Exemplo n.º 9
0
        public void TestCrewedToDry()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.HumidityLevel = 34;
            ad.ProcessData();
            Assert.Equal(59, ad.TempControlBafflePosition);
        }
Exemplo n.º 10
0
        public void TestLiquidInOutflowCleared()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.ReprocessBafflePosition = DiverterValvePositions.Reprocess;
            ad.LiquidInOutflow         = false;
            ad.ProcessData();
            Assert.Equal(DiverterValvePositions.Accept, ad.ReprocessBafflePosition);
        }
Exemplo n.º 11
0
        public void TestCrewedToCold()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.CabinStatus = Modes.Crewed;
            ad.Temperature = 15;
            ad.ProcessData();
            Assert.Equal(59, ad.TempControlBafflePosition);
        }
Exemplo n.º 12
0
        public void TestZeroedTempControlBaffle()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.TempControlBafflePosition = 0;
            ad.Temperature = 18.4;
            ad.ProcessData();
            Assert.Equal(0, ad.TempControlBafflePosition);
        }
Exemplo n.º 13
0
        public void TestMaxedTempControlBaffle()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.TempControlBafflePosition = 100;
            ad.Temperature = 19.6;
            ad.ProcessData();
            Assert.Equal(100, ad.TempControlBafflePosition);
        }
Exemplo n.º 14
0
        public void TestSeperatorOnWhileCrewed()
        {
            AtmosphereData ad = new AtmosphereData();

            ad.SeedData();
            ad.CabinStatus = Modes.Crewed;
            AtmosphereData newad = new AtmosphereData(ad);

            newad.SeperatorSpeed.Should().BeGreaterThan(1000);
        }
Exemplo n.º 15
0
    // ---- METHODS ----
    #region

    // Generate Planet
    public GameObject GeneratePlanet()
    {
        planet = new GameObject(name);
        planet.AddComponent <MeshFilter>();
        planet.AddComponent <MeshRenderer>();
        planet.AddComponent <MeshCollider>();
        PlanetScript ps = planet.AddComponent <PlanetScript>();

        // Add planet script
        PlanetScript planetScript = planet.GetComponent <PlanetScript>();

        //planetScript.planetData = this; // <--------------------<----------------------<---------------------<------------------<-------- Jos käytät tätä scriptiä niin muista tää ------<------------------<

        if (hasAtmosphere)
        {
            atmosphere = AtmosphereGenerator.GenerateAtmosphere(planet.transform, planetSize / 2f + 15f, 0.25f);
        }

        return(planet);
    }
Exemplo n.º 16
0
    // ---- METHODS ----
    #region

    // Generate Planet
    public GameObject GeneratePlanet(Vector3 position)
    {
        planet     = new GameObject(name);
        planet.tag = "Planet";
        planet.AddComponent <MeshFilter>();
        planet.AddComponent <MeshRenderer>();

        PlanetScript ps = planet.AddComponent <PlanetScript>();

        ps.planetData = this;
        GravityAttractor ga = planet.AddComponent <GravityAttractor>();

        if (hasAtmosphere)
        {
            atmosphere = AtmosphereGenerator.GenerateAtmosphere(planet.transform, planetSize / 2f, 0.1f);
            //atmosphere = AtmosphereGenerator.GenerateAtmosphere(planet.transform, planetSize / 2f + 12f, 0.1f);
        }

        planet.transform.position = position;

        return(planet);
    }
Exemplo n.º 17
0
        /// <summary>
        /// cstor which extracts the data from the XML feed and push it into
        /// the strongly typed class which is then available in the razor script
        /// files
        /// </summary>
        /// <param name="xmlData"></param>
        public WeatherModel(string xmlData)
        {
            data = xmlData;

            //load all the data
            using (var reader = new StringReader(data))
            {
                var xPath = new XPathDocument(reader);
                var nav   = xPath.CreateNavigator();

                XmlNamespaceManager ns = new XmlNamespaceManager(nav.NameTable);
                ns.AddNamespace("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0");
                ns.AddNamespace("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#");

                Title       = nav.SelectSingleNode("//item/title").Value;
                PublishDate = nav.SelectSingleNode("//lastBuildDate").Value;

                var location = new LocationData()
                {
                    City    = nav.SelectSingleNode("//yweather:location/@city", ns).Value,
                    Region  = nav.SelectSingleNode("//yweather:location/@region", ns).Value,
                    Country = nav.SelectSingleNode("//yweather:location/@country", ns).Value,
                    Lat     = decimal.Parse(nav.SelectSingleNode("//geo:lat", ns).Value),
                    Long    = decimal.Parse(nav.SelectSingleNode("//geo:long", ns).Value)
                };
                Location = location;


                var units = new UnitData()
                {
                    Temperature = nav.SelectSingleNode("//yweather:units/@temperature", ns).Value,
                    Distance    = nav.SelectSingleNode("//yweather:units/@distance", ns).Value,
                    Pressure    = nav.SelectSingleNode("//yweather:units/@pressure", ns).Value,
                    Speed       = nav.SelectSingleNode("//yweather:units/@speed", ns).Value
                };
                Units = units;


                var wind = new WindData()
                {
                    Chill     = decimal.Parse(nav.SelectSingleNode("//yweather:wind/@chill", ns).Value),
                    Direction = int.Parse(nav.SelectSingleNode("//yweather:wind/@direction", ns).Value),
                    Speed     = decimal.Parse(nav.SelectSingleNode("//yweather:wind/@speed", ns).Value)
                };
                Wind = wind;


                var atmos = new AtmosphereData()
                {
                    Humidity   = decimal.Parse(nav.SelectSingleNode("//yweather:atmosphere/@humidity", ns).Value),
                    Visibility = decimal.Parse(nav.SelectSingleNode("//yweather:atmosphere/@visibility", ns).Value),
                    Pressure   = decimal.Parse(nav.SelectSingleNode("//yweather:atmosphere/@pressure", ns).Value),
                    Rising     = decimal.Parse(nav.SelectSingleNode("//yweather:atmosphere/@rising", ns).Value)
                };
                Atmosphere = atmos;


                var astro = new AstronomyData()
                {
                    SunRise = DateTime.Parse(nav.SelectSingleNode("//yweather:astronomy/@sunrise", ns).Value),
                    SunSet  = DateTime.Parse(nav.SelectSingleNode("//yweather:astronomy/@sunset", ns).Value)
                };
                Astronomy = astro;


                var conditions = new ConditionData()
                {
                    Caption     = nav.SelectSingleNode("//yweather:condition/@text", ns).Value,
                    Code        = int.Parse(nav.SelectSingleNode("//yweather:condition/@code", ns).Value),
                    Temperature = int.Parse(nav.SelectSingleNode("//yweather:condition/@temp", ns).Value),
                    Date        = DateTime.Parse(nav.SelectSingleNode("//yweather:condition/@date", ns).Value.Substring(0, nav.SelectSingleNode("//yweather:condition/@date", ns).Value.Length - 3))
                };
                CurrentCondition = conditions;

                var forecasts = new List <ForecastData>();
                foreach (XPathNavigator item in nav.Select("//yweather:forecast", ns))
                {
                    forecasts.Add(new ForecastData()
                    {
                        Day      = item.SelectSingleNode("@day", ns).Value,
                        Date     = DateTime.Parse(item.SelectSingleNode("@date", ns).Value),
                        TempLow  = int.Parse(item.SelectSingleNode("@low", ns).Value),
                        TempHigh = int.Parse(item.SelectSingleNode("@high", ns).Value),
                        Code     = int.Parse(item.SelectSingleNode("@code", ns).Value),
                        Caption  = item.SelectSingleNode("@text", ns).Value
                    });
                }
                Forecast = forecasts;
            }
        }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     planet     = transform;
     atmosphere = AtmosphereGenerator.GenerateAtmosphere(planet, radius, 0.25f);
 }
Exemplo n.º 19
0
        /// <summary>
        /// This method simulates generating real-world data and inserting it into the database.
        /// </summary>
        /// <returns> </returns>
        private void SimulateDataGeneration()
        {
            CancellationToken token = _cancellationTokenSource.Token;

            this.Started?.Invoke(this, EventArgs.Empty);
            bool isFirst = true;

            while (!token.IsCancellationRequested)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));

                if (token.IsCancellationRequested)
                {
                    break;
                }

                using var scope = ServiceProvider.CreateScope();
                using var db    = scope.ServiceProvider.GetRequiredService <OrbitDbContext>();

                if (isFirst)
                {
                    db.InsertSeedData();
                    isFirst = false;
                    db.SaveChanges();
                    continue;
                }

                #region Get data from context

                WasteWaterStorageTankData wasteTank      = db.WasteWaterStorageTankData.Last();
                UrineSystemData           urineSystem    = db.UrineProcessorData.Last();
                WaterProcessorData        waterProcessor = db.WaterProcessorData.Last();
                PowerSystemData           power          = db.PowerSystemData.Last();
                AtmosphereData            atmo           = db.AtmosphereData.Last();
                CarbonDioxideRemediation  co2            = db.CarbonDioxideRemoverData.Last();
                ExternalCoolantLoopData   eloop          = db.ExternalCoolantLoopData.Last();
                InternalCoolantLoopData   iloop          = db.InternalCoolantLoopData.Last();
                OxygenGenerator           o2             = db.OxygenGeneratorData.Last();
                WaterGeneratorData        h20            = db.WaterGeneratorData.Last();

                #endregion Get data from context


                #region Process the data

                urineSystem.ProcessData(wasteTank.Level);
                wasteTank.ProcessData(urineSystem.Status, waterProcessor.SystemStatus);
                waterProcessor.ProcessData(wasteTank.Level);
                power.ProcessData();
                atmo.ProcessData();
                co2.ProcessData();
                eloop.ProcessData();
                iloop.ProcessData();
                o2.ProcessData();
                h20.ProcessData();

                #endregion Process the data


                #region Generate new data sets

                var nextUrineSystem = new UrineSystemData(urineSystem);
                var nextWasteTank   = new WasteWaterStorageTankData {
                    Level = wasteTank.Level
                };
                var nextWaterProcessor = new WaterProcessorData(waterProcessor);
                var nextPower          = new PowerSystemData(power);
                var nextAtmo           = new AtmosphereData(atmo);
                var nextCo2            = new CarbonDioxideRemediation(co2);
                var nextEloop          = new ExternalCoolantLoopData(eloop);
                var nextIloop          = new InternalCoolantLoopData(iloop);
                var nextO2             = new OxygenGenerator(o2);
                var nextH20            = new WaterGeneratorData(h20);

                #endregion Generate new data sets


                #region Save new data sets to context

                db.UrineProcessorData.Add(nextUrineSystem);
                db.WasteWaterStorageTankData.Add(nextWasteTank);
                db.WaterProcessorData.Add(nextWaterProcessor);
                db.PowerSystemData.Add(nextPower);
                db.AtmosphereData.Add(nextAtmo);
                db.CarbonDioxideRemoverData.Add(nextCo2);
                db.ExternalCoolantLoopData.Add(nextEloop);
                db.InternalCoolantLoopData.Add(nextIloop);
                db.OxygenGeneratorData.Add(nextO2);
                db.WaterGeneratorData.Add(nextH20);

                db.SaveChanges();

                #endregion Save new data sets to context
            }

            this.Stopped?.Invoke(this, EventArgs.Empty);
        }