/// <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);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the structure. Used when instantiating a data stream structure to store the simulated fault log.
        /// </summary>
        /// <param name="logType">The type of log.</param>
        /// <param name="durationMs">The duration of the log, in ms.</param>
        /// <param name="durationPostTripMs">The duration of the log, in ms, following the trip.</param>
        /// <param name="frameIntervalMs">The interval, in ms, between successive data frames.</param>
        public DataStream_t(LogType logType, double durationMs, double durationPostTripMs, short frameIntervalMs)
        {
            DataStreamTypeParameters = new DataStreamTypeParameters_t();
            StreamNumber = CommonConstants.NotDefined;
            LogType = LogType.SimulatedDataStream;
            EventDescription = string.Empty;
            FrameIntervalMs = frameIntervalMs;

            DurationMs = (int)durationMs;
            SampleCount = (short)(DurationMs / frameIntervalMs);
            DurationPostTripMs = (int)durationPostTripMs;
            DurationPreTripMs = (int)(durationMs - durationPostTripMs);

            DataStreamTypeParameters.TripIndex = (short)(((durationMs - durationPostTripMs) / durationMs) * SampleCount);

            Workset = new Workset_t();
            WatchFrameList = new List<WatchFrame_t>(SampleCount);
            AutoScaleWatchValues = new AutoScale_t[Parameter.WatchSize];
            TimeOrigin = CommonConstants.NotDefined;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the structure. Used when initializing a data stream to store recorded watch values.
        /// </summary>
        /// <param name="frameIntervalMs">The interval, in ms, between successive data frames.</param>
        public DataStream_t(short frameIntervalMs)
        {
            DataStreamTypeParameters = new DataStreamTypeParameters_t();
            DataStreamTypeParameters.SetToDefaulDataStreamType();

            StreamNumber = CommonConstants.NotDefined;
            LogType = LogType.Watch;
            EventDescription = string.Empty;
            FrameIntervalMs = frameIntervalMs;

            DurationMs = CommonConstants.NotDefined;
            SampleCount = CommonConstants.NotDefined;
            DurationPostTripMs = CommonConstants.NotDefined;
            DurationPreTripMs = CommonConstants.NotDefined;
            
            Workset = new Workset_t();
            WatchFrameList = new List<WatchFrame_t>();
            AutoScaleWatchValues = new AutoScale_t[Parameter.WatchSize];
            TimeOrigin = CommonConstants.NotDefined;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the structure. Used when initializing a datastream to store fault log data retrieved from the VCU. 
        /// </summary>
        /// <param name="eventRecord">The event record associated with the data stream.</param>
        /// <param name="watchCount">The number of watch variables contained within the data stream.</param>
        /// <param name="sampleCount">The number of data samples associated with the data stream.</param>
        /// <param name="sampleMultiple">The multiple of the base sample interval at which the data is recorded.</param>
        /// <param name="workset">The workset associated with the data stream.</param>
        public DataStream_t(EventRecord eventRecord, short watchCount, short sampleCount, short sampleMultiple, Workset_t workset)
        {
            // Get the log information associated with the event record.
            Log log = Lookup.LogTable.Items[eventRecord.LogIdentifier];

            DataStreamTypeParameters = log.DataStreamTypeParameters;
            StreamNumber = eventRecord.StreamNumber;
            LogType = LogType.DataStream;
            EventDescription = eventRecord.Description;
            FrameIntervalMs = (short)(sampleMultiple * log.SampleIntervalMs);

            SampleCount = sampleCount;
            DurationMs = (SampleCount - 1) * FrameIntervalMs;

            DurationPreTripMs = DataStreamTypeParameters.TripIndex * FrameIntervalMs;
            DurationPostTripMs = DurationMs - DurationPreTripMs;

            Workset = new Workset_t();
            Workset = workset;

            WatchFrameList = new List<WatchFrame_t>(SampleCount);
            AutoScaleWatchValues = new AutoScale_t[workset.Count];
            TimeOrigin = CommonConstants.NotDefined;
        }