示例#1
0
        public static string GetValueAsString(KWP2000ScalingTableRecord scalingRecord, byte[] valueData)
        {
            string result = null;

            if (scalingRecord != null)
            {
                List <string> valueStrings;
                scalingRecord.GetStringsFromData(valueData, out valueStrings);

                if (valueStrings != null)
                {
                    foreach (var valueString in valueStrings)
                    {
                        if (result == null)
                        {
                            result = "";
                        }
                        else
                        {
                            result += ", ";
                        }

                        result += valueString;
                    }
                }
            }

            return(result);
        }
示例#2
0
        private static void GenerateTableRecords(byte[] tableData, out List <KWP2000ScalingTableRecord> records)
        {
            records = new List <KWP2000ScalingTableRecord>();

            if (tableData != null)
            {
                int indexOfOffset = 0;

                while (indexOfOffset < tableData.Length)
                {
                    byte sizeOfRecord = tableData[indexOfOffset];

                    //check for end of table offset, and for running off the end of the array
                    if ((sizeOfRecord != 0xFF) && (indexOfOffset + sizeOfRecord <= tableData.Length))
                    {
                        //is the record large enough to include the identification option and offset?
                        if (sizeOfRecord >= 2)
                        {
                            var recordData = new byte[sizeOfRecord];
                            Buffer.BlockCopy(tableData, indexOfOffset, recordData, 0, sizeOfRecord);

                            var record = new KWP2000ScalingTableRecord(recordData);
                            records.Add(record);
                        }

                        indexOfOffset += sizeOfRecord;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
示例#3
0
        public bool GetScalingRecordForIdentificationOption(byte identificationOption, out KWP2000ScalingTableRecord record)
        {
            bool found = false;

            record = null;

            if (TableRecords != null)
            {
                if (identificationOption == (byte)KWP2000IdentificationOption.ECUIdentificationDataTable)
                {
                    found = true;

                    var recordData = new byte[ScalingTableData.Length];
                    Buffer.BlockCopy(ScalingTableData, 0, recordData, 0, ScalingTableData.Length);

                    record = new KWP2000ScalingTableRecord(recordData);
                }
                else
                {
                    foreach (var curRecord in TableRecords)
                    {
                        if (curRecord.IdentOption == identificationOption)
                        {
                            found  = true;
                            record = curRecord;
                            break;
                        }
                    }
                }
            }

            return(found);
        }
示例#4
0
        public static string GetValueAsString(byte[] scalingData, byte[] valueData)
        {
            var scalingRecord = new KWP2000ScalingTableRecord(scalingData);

            return(GetValueAsString(scalingRecord, valueData));
        }