Пример #1
0
        public void TestSimulateStandby()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.ProcessData();
            Assert.Equal(22, wg.H2StoreLevel); //20 start level + fill value of 2
        }
Пример #2
0
        public void TestStayInStandby()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.ProcessData();
            Assert.Equal(SystemStatus.Standby, wg.Status);
        }
Пример #3
0
        public void TestStandbyTrouble_MethaneStoreFull()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.MethaneStoreLevel = 91;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Trouble, wg.Status);
        }
Пример #4
0
        public void TestStandbyTrouble_HeaterOn()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.HeaterOn = true;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Trouble, wg.Status);
        }
Пример #5
0
        public void TestStandbyTrouble_ReactorHot()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.ReactorTemp = 426;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Trouble, wg.Status);
        }
Пример #6
0
        public void TestTurnOn_ReactorCold()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Co2StoreLevel = 76;
            wg.ProcessData();
            Assert.True(wg.HeaterOn);
        }
Пример #7
0
        public void TestH2Full_ChangeToProcessing()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.H2StoreLevel = 76;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Processing, wg.Status);
        }
Пример #8
0
        public void TestTurnOn_ReactorHot()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Co2StoreLevel = 76;
            wg.ReactorTemp   = 500;
            wg.ProcessData();
            Assert.False(wg.HeaterOn);
        }
Пример #9
0
        public void TestProcessingDecreasesCo2()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 400;
            wg.SeperatorMotorSpeed = 2000;
            wg.ProcessData();
            Assert.Equal(22, wg.Co2StoreLevel);
        }
Пример #10
0
        public void TestProcessingIncreasesMethane()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 500;
            wg.SeperatorMotorSpeed = 2000;
            wg.ProcessData();
            Assert.Equal(35, wg.MethaneStoreLevel);
        }
Пример #11
0
        public void TestProcessingTrouble_SeperatorToSlow()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 500;
            wg.SeperatorOn         = true;
            wg.SeperatorMotorSpeed = 999;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Trouble, wg.Status);
        }
Пример #12
0
        public void TestProcessingTrouble_HeaterOnReactorHot()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 651;
            wg.HeaterOn            = true;
            wg.SeperatorOn         = true;
            wg.SeperatorMotorSpeed = 2000;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Trouble, wg.Status);
        }
Пример #13
0
        public void TestTurnOff()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 475;
            wg.SeperatorOn         = true;
            wg.SeperatorMotorSpeed = 2000;
            wg.H2StoreLevel        = 2;
            wg.ProcessData();
            Assert.False(wg.PumpOn);
        }
Пример #14
0
        public void TestProcessingCo2Empty()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 475;
            wg.SeperatorOn         = true;
            wg.SeperatorMotorSpeed = 2000;
            wg.Co2StoreLevel       = 4;
            wg.ProcessData();
            Assert.Equal(0, wg.Co2StoreLevel);
        }
Пример #15
0
        public void TestProcessingTrouble_MethaneFull()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 475;
            wg.SeperatorOn         = true;
            wg.SeperatorMotorSpeed = 2000;
            wg.MethaneStoreLevel   = 100;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Trouble, wg.Status);
        }
Пример #16
0
        public void TestH2Empty_ChangeToStandby()
        {
            WaterGeneratorData wg = new WaterGeneratorData();

            wg.SeedData();
            wg.Status              = SystemStatus.Processing;
            wg.PumpOn              = true;
            wg.ReactorTemp         = 475;
            wg.SeperatorOn         = true;
            wg.SeperatorMotorSpeed = 2000;
            wg.H2StoreLevel        = 2;
            wg.ProcessData();
            Assert.Equal(SystemStatus.Standby, wg.Status);
        }
Пример #17
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);
        }