コード例 #1
0
ファイル: EventTable.cs プロジェクト: SiGenixDave/PtuPc
        /// <summary>
        /// Build an array of lists of <c>Struct_t</c> records associated with each unique <c>STRUCTID</c> value defined in the <c>STRUCT</c> table of
        /// the data dictionary. The array element is mapped to the <c>STRUCTID</c> field of the table.
        /// </summary>
        /// <param name="structDataTable">Reference to the <c>STRUCT</c> table of the data dictionary.</param>
        /// <returns>An array of lists of <c>Struct_t</c> records associated with each unique <c>STRUCTID</c> value in the <c>STRUCT</c> table of the
        /// data dictionary, if the parameters are valid; otherwise, null.</returns>
        private List <Struct_t>[] BuildStructLists(DataDictionary.STRUCTDataTable structDataTable)
        {
            // Local copy of the data table.
            List <Struct_t>[] records;

            if (structDataTable == 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 < structDataTable.Count; recordIndex++)
                {
                    iDCurrent = structDataTable[recordIndex].STRUCTID;
                    if (iDCurrent > iDMax)
                    {
                        iDMax = iDCurrent;
                    }
                }

                // Instantiate the lookup array.
                records = new List <Struct_t> [iDMax + 1];

                // Instantiate a generic list for each
                for (int recordIndex = 0; recordIndex < iDMax + 1; recordIndex++)
                {
                    records[recordIndex] = new List <Struct_t>();
                }

                // Populate the lookup table;
                int identifier;
                DataDictionary.STRUCTRow row;
                for (int recordIndex = 0; recordIndex < structDataTable.Count; recordIndex++)
                {
                    row        = structDataTable[recordIndex];
                    identifier = row.STRUCTID;

                    // Instantiate a new structure to contain the data and copy the data across.
                    Struct_t record = new Struct_t();
                    record.StructureIdentifier     = row.STRUCTID;
                    record.EventVariableIdentifier = row.EVENTVARID;

                    // Add the record to the correct element of the array.
                    records[identifier].Add(record);
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(records);
        }
コード例 #2
0
ファイル: EventTable.cs プロジェクト: SiGenixDave/PtuPc
        /// <summary>
        /// Initialize a new instance of the class.
        /// </summary>
        /// <param name="dataTable">Reference to the <c>EVENTS</c> table of the data dictionary. This table contains the VCU system event definitions.</param>
        /// <param name="structDataTable">Reference to the <c>STRUCT</c> table of the data dictionary. This table defines which event variables are associated
        /// with each VCU system event.</param>
        public EventTable(DataDictionary.EVENTSDataTable dataTable, DataDictionary.STRUCTDataTable structDataTable)
            : base(dataTable)
        {
            if (structDataTable == null)
            {
                return;
            }

            m_EventsDataTable = dataTable;

            m_StructLists = BuildStructLists(structDataTable);

            AddEventVariableLists();

            m_CommonEventVariableCount = m_StructLists[0].Count - HeaderEventVariableCount;
        }