예제 #1
0
        public void FieldStaticAbsoluteConversion()
        {
            InitTest();

            // test data for Lister Storm EOAA GT:
            var FieldIndex = new MemoryField <int>("Index", MemoryAddress.StaticAbsolute, 0x7154c8, 0, 4); // +0x8 = driver index
            var FieldFuel  = new MemoryField <float>("FuelCapacity", MemoryAddress.StaticAbsolute, 0x718620, 0, 4, (x) => x * 2.0f);

            drvPool.Add(FieldIndex);
            drvPool.Add(FieldFuel);

            memory.Refresh();

            Assert.True(FieldIndex.HasChanged());
            Assert.True(FieldFuel.HasChanged());

            // only 1 read from pool:
            Assert.AreEqual(3, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154c8, actionLogbook[1].Address);
            Assert.AreEqual(0x4, actionLogbook[1].Size);
            Assert.AreEqual(0x718620, actionLogbook[2].Address);
            Assert.AreEqual(0x4, actionLogbook[2].Size);

            // And read some values in different types:
            Assert.AreEqual(0, drvPool.ReadAs <int>("Index"));
            Assert.AreEqual(0, drvPool.ReadAs <uint>("Index"));
            Assert.AreEqual(0.0f, drvPool.ReadAs <float>("Index"));

            Assert.AreEqual(2.0f * 100.0f, drvPool.ReadAs <float>("FuelCapacity"));
            Assert.AreEqual(2 * 100, drvPool.ReadAs <int>("FuelCapacity"));
            Assert.AreEqual(2 * 100.0, drvPool.ReadAs <double>("FuelCapacity"));

            memory.Refresh();

            Assert.False(FieldIndex.HasChanged());
            Assert.False(FieldFuel.HasChanged());

            Assert.AreEqual(6, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154c8, actionLogbook[1].Address);
            Assert.AreEqual(0x4, actionLogbook[1].Size);
            Assert.AreEqual(0x718620, actionLogbook[2].Address);
            Assert.AreEqual(0x4, actionLogbook[2].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[3].Address);
            Assert.AreEqual(0x6000, actionLogbook[3].Size);
            Assert.AreEqual(0x7154c8, actionLogbook[4].Address);
            Assert.AreEqual(0x4, actionLogbook[4].Size);
            Assert.AreEqual(0x718620, actionLogbook[5].Address);
            Assert.AreEqual(0x4, actionLogbook[5].Size);
        }
예제 #2
0
        public void FieldDynamicConversion()
        {
            InitTest();

            var FieldFuel  = new MemoryField <float>("FuelCapacity", MemoryAddress.Dynamic, 0, 0x3160, 4, (x) => x * 2.0f);
            var FieldIndex = new MemoryField <int>("Index", MemoryAddress.Dynamic, 0, 0x8, 4); // +0x8 = driver index

            drvPool.Add(FieldIndex);
            drvPool.Add(FieldFuel);

            memory.Refresh();

            Assert.True(FieldIndex.HasChanged());
            Assert.True(FieldFuel.HasChanged());

            // only 1 read from pool:
            Assert.AreEqual(1, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);

            // And read some values in different types:
            Assert.AreEqual(0, drvPool.ReadAs <int>("Index"));
            Assert.AreEqual(0, drvPool.ReadAs <uint>("Index"));
            Assert.AreEqual(0.0f, drvPool.ReadAs <float>("Index"));

            Assert.AreEqual(2.0f * 100.0f, drvPool.ReadAs <float>("FuelCapacity"));
            Assert.AreEqual(2 * 100, drvPool.ReadAs <int>("FuelCapacity"));
            Assert.AreEqual(2 * 100.0, drvPool.ReadAs <double>("FuelCapacity"));

            memory.Refresh();

            Assert.False(FieldIndex.HasChanged());
            Assert.False(FieldFuel.HasChanged());

            Assert.AreEqual(2, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[1].Address);
            Assert.AreEqual(0x6000, actionLogbook[1].Size);
        }
예제 #3
0
        public void FieldDynamicConversion()
        {
            InitTest();

            var FieldFuel = new MemoryField<float>("FuelCapacity", MemoryAddress.Dynamic, 0, 0x3160, 4, (x) => x * 2.0f);
            var FieldIndex = new MemoryField<int>("Index", MemoryAddress.Dynamic, 0, 0x8, 4); // +0x8 = driver index
            drvPool.Add(FieldIndex);
            drvPool.Add(FieldFuel);

            memory.Refresh();

            Assert.True(FieldIndex.HasChanged());
            Assert.True(FieldFuel.HasChanged());

            // only 1 read from pool:
            Assert.AreEqual(1, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);

            // And read some values in different types:
            Assert.AreEqual(0, drvPool.ReadAs<int>("Index"));
            Assert.AreEqual(0, drvPool.ReadAs<uint>("Index"));
            Assert.AreEqual(0.0f, drvPool.ReadAs<float>("Index"));

            Assert.AreEqual(2.0f * 100.0f, drvPool.ReadAs<float>("FuelCapacity"));
            Assert.AreEqual(2 * 100, drvPool.ReadAs<int>("FuelCapacity"));
            Assert.AreEqual(2 * 100.0, drvPool.ReadAs<double>("FuelCapacity"));

            memory.Refresh();

            Assert.False(FieldIndex.HasChanged());
            Assert.False(FieldFuel.HasChanged());

            Assert.AreEqual(2, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[1].Address);
            Assert.AreEqual(0x6000, actionLogbook[1].Size);
        }
예제 #4
0
        public void FieldStaticConversion()
        {
            InitTest();

            // test data for Lister Storm EOAA GT:
            var FieldIndex = new MemoryField<int>("Index", MemoryAddress.Static, 0x3154c8, 0, 4); // +0x8 = driver index
            var FieldFuel = new MemoryField<float>("FuelCapacity", MemoryAddress.Static, 0x318620, 0, 4, (x) => x * 2.0f);
            drvPool.Add(FieldIndex);
            drvPool.Add(FieldFuel);

            memory.Refresh();

            Assert.True(FieldIndex.HasChanged());
            Assert.True(FieldFuel.HasChanged());

            // only 1 read from pool:
            Assert.AreEqual(3, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154c8, actionLogbook[1].Address);
            Assert.AreEqual(0x4, actionLogbook[1].Size);
            Assert.AreEqual(0x718620, actionLogbook[2].Address);
            Assert.AreEqual(0x4, actionLogbook[2].Size);

            // And read some values in different types:
            Assert.AreEqual(0, drvPool.ReadAs<int>("Index"));
            Assert.AreEqual(0, drvPool.ReadAs<uint>("Index"));
            Assert.AreEqual(0.0f, drvPool.ReadAs<float>("Index"));

            Assert.AreEqual(2.0f * 100.0f, drvPool.ReadAs<float>("FuelCapacity"));
            Assert.AreEqual(2 * 100, drvPool.ReadAs<int>("FuelCapacity"));
            Assert.AreEqual(2 * 100.0, drvPool.ReadAs<double>("FuelCapacity"));

            memory.Refresh();

            Assert.False(FieldIndex.HasChanged());
            Assert.False(FieldFuel.HasChanged());

            Assert.AreEqual(6, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154c8, actionLogbook[1].Address);
            Assert.AreEqual(0x4, actionLogbook[1].Size);
            Assert.AreEqual(0x718620, actionLogbook[2].Address);
            Assert.AreEqual(0x4, actionLogbook[2].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[3].Address);
            Assert.AreEqual(0x6000, actionLogbook[3].Size);
            Assert.AreEqual(0x7154c8, actionLogbook[4].Address);
            Assert.AreEqual(0x4, actionLogbook[4].Size);
            Assert.AreEqual(0x718620, actionLogbook[5].Address);
            Assert.AreEqual(0x4, actionLogbook[5].Size);
        }