Esempio n. 1
0
        /// <summary>
        /// Initialize a new instance of the class.
        /// </summary>
        /// <param name="dataTable">Reference to the <c>LOGS</c> table of the data dictionary.</param>
        /// <param name="dataStreamTypesDataTable">Reference to the <c>DataStreamTypes</c> table of the data dictionary i.e. the data stream parameters associated with each log.</param>
        public LogTable(DataDictionary.LOGSDataTable dataTable, DataDictionary.DataStreamTypesDataTable dataStreamTypesDataTable)
            : base(dataTable)
        {
            if (dataStreamTypesDataTable == null)
            {
                return;
            }

            m_LogsDataTable = dataTable;

            m_DataStreamTypes = BuildDataStreamTypeParametersTable(dataStreamTypesDataTable);

            // Update each log with the data stream type parameters associated with the DataStreamTypeIdentifier property/member variable.
            for (int recordIndex = 0; recordIndex < Items.Length; recordIndex++)
            {
                if (Items[recordIndex] != null)
                {
                    try
                    {
                        Items[recordIndex].DataStreamTypeParameters = m_DataStreamTypes[Items[recordIndex].DataStreamTypeIdentifier];
                    }
                    catch (Exception)
                    {
                        Items[recordIndex].DataStreamTypeParameters.SetToDefaulDataStreamType();
                    }
                }
            }

            // Convert the variable array to a generic list for convenience and manipulation.
            m_RecordList = new List <Log>();
            m_RecordList.AddRange(Items);
        }
Esempio n. 2
0
        /// <summary>
        /// Build an array of the records contained within the <c>DataStreamTypes</c> table of the data dictionary. This is used to access the data stream parameters
        /// associated with a particular log. The array element is mapped to the data stream type identifier field of the table.
        /// </summary>
        /// <param name="dataStreamTypesDataTable">Reference to the <c>DataStreamTypes</c> table of the data dictionary.</param>
        /// <returns>An array of the records contained within the <c>DataStreamTypes</c> table of the data dictionary, if the parameters are valid; otherwise, null.</returns>
        private DataStreamTypeParameters_t[] BuildDataStreamTypeParametersTable(DataDictionary.DataStreamTypesDataTable dataStreamTypesDataTable)
        {
            // Local copy of the data table.
            DataStreamTypeParameters_t[] dataStreamTypes;

            if (dataStreamTypesDataTable == null)
            {
                return(null);
            }

            try
            {
                // Determine the maximum value of the identifier field in the data table, it cannot be assumed that the table is sorted by identifier.
                int iDMax     = 0;
                int iDCurrent = 0;
                for (int recordIndex = 0; recordIndex < dataStreamTypesDataTable.Count; recordIndex++)
                {
                    iDCurrent = dataStreamTypesDataTable[recordIndex].DataStreamTypeIdentifier;
                    if (iDCurrent > iDMax)
                    {
                        iDMax = iDCurrent;
                    }
                }

                // Instantiate the lookup array.
                dataStreamTypes = new DataStreamTypeParameters_t[iDMax + 1];

                // Initialize all elements of the array to the default data stream type.
                for (int dataStreamTypeIndex = 0; dataStreamTypeIndex < dataStreamTypes.Length; dataStreamTypeIndex++)
                {
                    dataStreamTypes[dataStreamTypeIndex].SetToDefaulDataStreamType();
                }

                // Overlay any data stream type definitions that have been defined in the data dictionary.
                short identifier;
                DataDictionary.DataStreamTypesRow row;
                for (int recordIndex = 0; recordIndex < dataStreamTypesDataTable.Count; recordIndex++)
                {
                    try
                    {
                        row        = dataStreamTypesDataTable[recordIndex];
                        identifier = row.DataStreamTypeIdentifier;
                        dataStreamTypes[identifier] = new DataStreamTypeParameters_t();

                        // Copy the data from the record in the data dictionary.
                        dataStreamTypes[identifier].Identifier        = identifier;
                        dataStreamTypes[identifier].TripIndex         = row.TripIndex;
                        dataStreamTypes[identifier].WatchVariablesMax = row.WatchVariablesMax;
                        dataStreamTypes[identifier].Name = row.DataStreamTypeName;
                    }
                    catch (StrongTypingException)
                    {
                        dataStreamTypes[recordIndex].SetToDefaulDataStreamType();
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(dataStreamTypes);
        }