Update() public method

public Update ( int time ) : void
time int
return void
Ejemplo n.º 1
0
        public void QualifyTest()
        {
            var dummyDataSource = new MockDataSource();

            var archive = new TelemetryArchive();
            var loggerFromZero = new TelemetryLogger("test", new TelemetryLoggerConfiguration(true, true, true, true));
            loggerFromZero.SetDatasource(dummyDataSource);
            GlobalEvents.Fire(new SessionStarted(), true);

            Assert.False(archive.QualifiesForStorage(loggerFromZero));

            loggerFromZero.Update(0);

            Assert.False(archive.QualifiesForStorage(loggerFromZero));

            loggerFromZero.Update(1000);

            Assert.False(archive.QualifiesForStorage(loggerFromZero));

            loggerFromZero.Update(5000);

            Assert.False(archive.QualifiesForStorage(loggerFromZero));

            loggerFromZero.Update(10000);

            Assert.True(archive.QualifiesForStorage(loggerFromZero));

            loggerFromZero.Close();

            var loggerFromElse = new TelemetryLogger("test", new TelemetryLoggerConfiguration(true, true, true, true));
            loggerFromElse.SetDatasource(dummyDataSource);
            GlobalEvents.Fire(new SessionStarted(), true);

            Assert.False(archive.QualifiesForStorage(loggerFromElse));

            loggerFromElse.Update(10000);

            Assert.False(archive.QualifiesForStorage(loggerFromElse));

            loggerFromElse.Update(13000);

            Assert.False(archive.QualifiesForStorage(loggerFromElse));

            loggerFromElse.Update(0);

            Assert.False(archive.QualifiesForStorage(loggerFromElse));

            loggerFromElse.Update(20000);

            Assert.True(archive.QualifiesForStorage(loggerFromElse));

            loggerFromElse.Update(24*3600*1000);

            Assert.True(archive.QualifiesForStorage(loggerFromElse));
        }
Ejemplo n.º 2
0
        public void RecordTestData()
        {
            float[] rpmWave;
            float[] speedWave;
            GetWaves(out rpmWave, out speedWave);
            int index = 0;

            var provider = new MemoryProvider(null);
            var fakePool = new MemoryPool("Driver", MemoryAddress.StaticAbsolute, 0, 0);
            fakePool.Add(new MemoryFieldFunc<float>("Speed", (pool) => speedWave[index], true));
            fakePool.Add(new MemoryFieldFunc<float>("RPM", (pool) => rpmWave[index++], true));
            fakePool.Add(new MemoryFieldConstant<bool>("IsAI", false));
            fakePool.Add(new MemoryFieldConstant<bool>("IsPlayer", true));
            provider.Add(fakePool);

            var fakeDriver = new TelemetryDriver(fakePool);
            var fakeDrivers = new List<TelemetryDriver>(new[] {fakeDriver});

            TelemetryLogger logger = new TelemetryLogger("testSim", new TelemetryLoggerConfiguration(true, true, true, true));
            logger.SetDatasource(provider);
            logger.SetAnnotater( new TelemetryArchive());
            GlobalEvents.Fire(new SessionStarted(), true);
            GlobalEvents.Fire(new DriversAdded(null, fakeDrivers), true);

            for(int i = 0 ; i  <1024;i++)
                logger.Update(i*25);

            GlobalEvents.Fire(new SessionStopped(), true);
            Thread.Sleep(500);

            ZipStorer checkFile = ZipStorer.Open("tmp.zip", FileAccess.Read);

            var files = checkFile.ReadCentralDir();
            Assert.AreEqual(3, files.Count);
            Assert.AreEqual(1024 * 2 * 12 + 2 * 8, files.Where(x => x.FilenameInZip.Contains("Data.bin")).FirstOrDefault().FileSize);
            Assert.AreEqual(1024*8, files.Where(x => x.FilenameInZip.Contains("Time.bin")).FirstOrDefault().FileSize);
        }
Ejemplo n.º 3
0
        public void StoreLogFile()
        {
            var dummyDataSource = new MockDataSource();

            var archive =  new TelemetryArchive();
            var loggerFromZero = new TelemetryLogger("test", new TelemetryLoggerConfiguration(true, true, true, true));
            loggerFromZero.SetDatasource(dummyDataSource);
            loggerFromZero.SetAnnotater(archive);
            var logWriter = new LogFileWriter("test.zip","TelemetryArchiveTestsStoreLogFile");

            GlobalEvents.Fire(new SessionStarted(), true);

            loggerFromZero.Update(0);
            loggerFromZero.Update(10000);
            loggerFromZero.Update(20000);

            GlobalEvents.Fire(new SessionStopped(), true);

            Thread.Sleep(5000);
        }
Ejemplo n.º 4
0
        public void LapTests()
        {
            var lapsRecorded = new List<Lap>();

            GlobalEvents.Hook<TelemetryLapComplete>(lap => lapsRecorded.Add(lap.Lap),true);

            float[] rpmWave;
            float[] speedWave;
            GetWaves(out rpmWave, out speedWave);
            int index = 0;

            var provider = new MemoryProvider(null);
            var fakePool = new MemoryPool("Driver", MemoryAddress.StaticAbsolute, 0, 0);
            fakePool.Add(new MemoryFieldFunc<float>("Speed", (pool) => speedWave[index], true));
            fakePool.Add(new MemoryFieldFunc<float>("RPM", (pool) => rpmWave[index++], true));
            fakePool.Add(new MemoryFieldFunc<float>("Laps", (pool) =>
                                                                {
                                                                    if(index <= 100)
                                                                        return 0;
                                                                    if (index > 100 && index <= 225)
                                                                        return 1;
                                                                    if (index > 225 && index <= 325)
                                                                        return 2;
                                                                    if (index > 325 && index <= 500)
                                                                        return 3;
                                                                    if (index > 500 && index <= 575)
                                                                        return 4;
                                                                    if (index > 575 && index <= 1024)
                                                                        return 5;

                                                                        return -1;
                                                                }, true));
            fakePool.Add(new MemoryFieldConstant<bool>("IsAI", false));
            fakePool.Add(new MemoryFieldConstant<bool>("IsPlayer", true));
            provider.Add(fakePool);

            var fakeDriver = new TelemetryDriver(fakePool);
            var fakeDrivers = new List<TelemetryDriver>(new[] { fakeDriver });

            var logger = new TelemetryLogger("testSim", new TelemetryLoggerConfiguration(true, true, true, true));
            logger.SetDatasource(provider);
            //logger.SetAnnotater(new TelemetryArchive());
            GlobalEvents.Fire(new SessionStarted(), true);
            GlobalEvents.Fire(new DriversAdded(null, fakeDrivers), true);

            for (int i = 0; i < 1024; i++)
                logger.Update(i * 25);

            GlobalEvents.Fire(new SessionStopped(), true);
            Thread.Sleep(500);

            Assert.AreEqual(6, lapsRecorded.Count);
            Assert.AreEqual(0, lapsRecorded[0].LapNumber);
            Assert.AreEqual(1, lapsRecorded[1].LapNumber);
            Assert.AreEqual(2, lapsRecorded[2].LapNumber);
            Assert.AreEqual(3, lapsRecorded[3].LapNumber);
            Assert.AreEqual(4, lapsRecorded[4].LapNumber);
            Assert.AreEqual(5, lapsRecorded[5].LapNumber);

            Assert.AreEqual(100, lapsRecorded[0].Total);
            Assert.AreEqual(125, lapsRecorded[1].Total);
            Assert.AreEqual(100, lapsRecorded[2].Total);
            Assert.AreEqual(175, lapsRecorded[3].Total);
            Assert.AreEqual(75, lapsRecorded[4].Total);
            Assert.AreEqual(-1, lapsRecorded[5].Total);
        }