Esempio n. 1
0
        private void DatabaseGetExtendedParameters(bool useXmlReader)
        {
            List <Parameter> expectedList = new List <Parameter>();

            expectedList.Add(new SsmParameter(
                                 null,
                                 "E1",
                                 "IAM*",
                                 0x20124, //0x20118,
                                 4,
                                 new Conversion[] {
                Conversion.GetInstance("raw ecu value", "x", "0"),
                Conversion.GetInstance("multiplier", "x/16", "0.0000")
            }));

            expectedList.Add(new SsmParameter(
                                 null,
                                 "E2",
                                 "Engine Load*",
                                 0x2009A, //0x21847,
                                 4,
                                 new Conversion[] {
                Conversion.GetInstance("g/rev", "x*.00006103515625", "0.00"),
            }));

            SsmParameterSource database = new SsmParameterSource(EcuIdentifier, CompatibilityMap);

            using (Stream inputStream = File.OpenRead("logger.xml"))
            {
                if (useXmlReader)
                {
                    XmlReader reader = XmlReader.Create(inputStream);
                    database.LoadExtendedParameters(reader);
                }
                else
                {
                    XPathDocument document = SsmParameterSource.CreateDocument(inputStream);
                    database.LoadExtendedParameters(document);
                }
            }

            Assert.AreEqual(34, database.Parameters.Count, "Parameters.Count");
            Console.WriteLine("Count: " + database.Parameters.Count);

            foreach (SsmParameter parameter in database.Parameters)
            {
                Console.WriteLine(
                    string.Format(
                        "Parameter: {0,50} ID {1,5} Address {2,10}",
                        parameter.Name,
                        parameter.Id,
                        parameter.Address));
            }

            SsmParameterSourceTest.CompareLists(expectedList, database.Parameters);
        }
Esempio n. 2
0
        private static void CompareLists(IList <Parameter> expectedList, IList <Parameter> actualList)
        {
            foreach (SsmParameter expected in expectedList)
            {
                SsmParameter actual = null;
                if (!SsmParameterSourceTest.TryGetParameter(actualList, expected.Id, out actual))
                {
                    throw new Exception("Actual list does not contain " + expected.Name + " (" + expected.Id + ")");
                }

                Assert.AreEqual(expected.Conversions.Count, actual.Conversions.Count, "Conversions.Count");
                for (int i = 0; i < actual.Conversions.Count; i++)
                {
                    Assert.AreEqual(
                        expected.Conversions[i].Units,
                        actual.Conversions[i].Units,
                        "Conversions[i].Units");

                    Assert.AreEqual(
                        expected.Conversions[i].Expression,
                        actual.Conversions[i].Expression,
                        "Conversions[i].Expression");

                    Assert.AreEqual(
                        expected.Conversions[i].Format,
                        actual.Conversions[i].Format,
                        "Conversions[i].Format");
                }

                Assert.AreEqual(expected.Id, actual.Id, actual.Name + " Id");

                if (expected.IsCalculated)
                {
                    Assert.IsTrue(actual.IsCalculated, "IsCalculated");
                    Assert.IsTrue(actual.Dependencies != null, "Dependencies != null");
                    Assert.IsTrue(actual.Dependencies.Count > 0, "Dependencies.Count > 0");
                }
                else
                {
                    Assert.AreEqual(expected.Address, actual.Address, actual.Name + " Address");
                    Assert.IsTrue(actual.Dependencies == null, "Dependencies == null");
                }

                Assert.AreEqual(expected.EcuCapabilityByteIndex, actual.EcuCapabilityByteIndex, actual.Name + " EcuCapabilityByteIndex");
                Assert.AreEqual(expected.EcuCapabilityBitIndex, actual.EcuCapabilityBitIndex, actual.Name + " EcuCapabilityBitIndex");
            }

            // TODO: ensure no extra parameters
        }
Esempio n. 3
0
        private void DatabaseGetSwitches(bool useXmlReader)
        {
            List <Parameter> expectedList = new List <Parameter>();

            expectedList.Add(new SsmParameter(null, "S20", "Defogger Switch", 0x64, 1, new Conversion[] { Conversion.GetInstance(Conversion.Boolean, "x&(2^5)", "") }));
            expectedList.Add(new SsmParameter(null, "S65", "Set/Coast Switch", 0x121, 1, new Conversion[] { Conversion.GetInstance(Conversion.Boolean, "x&(2^5)", "") }));
            expectedList.Add(new SsmParameter(null, "S66", "Resume/Accelerate Switch", 0x121, 1, new Conversion[] { Conversion.GetInstance(Conversion.Boolean, "x&(2^4)", "") }));
            SsmParameterSource database = new SsmParameterSource(EcuIdentifier, CompatibilityMap);

            using (Stream inputStream = File.OpenRead("logger.xml"))
            {
                if (useXmlReader)
                {
                    XmlReader reader = XmlReader.Create(inputStream);
                    database.LoadSwitches(reader);
                }
                else
                {
                    XPathDocument document = SsmParameterSource.CreateDocument(inputStream);
                    database.LoadSwitches(document);
                }
            }

            Assert.AreEqual(68, database.Parameters.Count, "Switches.Count");
            Console.WriteLine("Count: " + database.Parameters.Count);

            foreach (SsmParameter parameter in database.Parameters)
            {
                Console.WriteLine(
                    string.Format(
                        "Parameter: {0,50} ID {1,5} Address {2,10} Conversion {3,10}",
                        parameter.Name,
                        parameter.Id,
                        parameter.Address,
                        parameter.Conversions[0]));
            }

            SsmParameterSourceTest.CompareLists(expectedList, database.Parameters);
        }
Esempio n. 4
0
        private void DatabaseGetStandardParameters(bool useXmlReader)
        {
            ReadOnlyCollection <Parameter> noDependencies = null;
            List <Parameter> expectedList = new List <Parameter>();

            expectedList.Add(new SsmParameter(
                                 null,
                                 "P9",
                                 "Vehicle Speed",
                                 0x000010,
                                 1,
                                 new Conversion[] {
                Conversion.GetInstance("mph", "x*0.621371192", "0"),
                Conversion.GetInstance("kph", "x", "0")
            },
                                 9,
                                 7,
                                 noDependencies));
            expectedList.Add(new SsmParameter(
                                 null,
                                 "P2",
                                 "Coolant Temperature",
                                 0x000008,
                                 1,
                                 new Conversion[] {
                Conversion.GetInstance("F", "32+9*(x-40)/5", "0"),
                Conversion.GetInstance("C", "x-40", "0")
            },
                                 8,
                                 6,
                                 noDependencies));
            expectedList.Add(new SsmParameter(
                                 null,
                                 "P8",
                                 "Engine Speed",
                                 0x00000E,
                                 2,
                                 new Conversion[] { Conversion.GetInstance("rpm", "x/4", "0") },
                                 8,
                                 0,
                                 noDependencies));

            SsmParameterSource database = new SsmParameterSource(EcuIdentifier, CompatibilityMap);

            using (Stream inputStream = File.OpenRead("logger.xml"))
            {
                if (useXmlReader)
                {
                    XmlReader reader = XmlReader.Create(inputStream);
                    database.LoadStandardParameters(reader);
                }
                else
                {
                    XPathDocument document = SsmParameterSource.CreateDocument(inputStream);
                    database.LoadStandardParameters(document);
                }
            }

            int expectedCount = 53; // was 92 prior to compatibility filtering

            Assert.AreEqual(expectedCount, database.Parameters.Count, "Parameters.Count");
            SsmParameterSourceTest.CompareLists(expectedList, database.Parameters);
        }