Beispiel #1
0
    def process_diagnostic_data(self):
        """
        Handles the processing of diagnostic data particles and handles error processing if events
        which should have occurred prior to receiving a diagnostic record did not happen.
        """
        # As diagnostics records have the same format as velocity records
        # you can use the same routine used to break down the velocity data

        timestamp = VelptAbDataParticle.get_timestamp(self._current_record)
        date_time_group = VelptAbDataParticle.get_date_time_string(
            self._current_record)

        self._diagnostics_data_dict = VelptAbDataParticle.generate_data_dict(
            self._current_record)

        # Check to see if the instrument metadata particle has been produced yet
        # If not, produce it now as this is the first diagnostics record. This assumes
        # that diagnostics data records will occur BEFORE velocity data records.
        if not self._config_metadata_built:
            self.build_instrument_metadata_particle(timestamp)

        # Upon encountering the first diagnostics record, grab its timestamp
        # for use in the diagnostics metadata particle. Produce that metadata
        # particle now.
        if self._first_diagnostics_record:
            self._first_diagnostics_record = False

            diagnostics_header_dict = VelptAbDataParticle.generate_diagnostics_header_dict(
                date_time_group, self._diagnostics_header_record)
            self._total_diagnostic_records = VelptAbDataParticle.\
                get_diagnostics_count(self._diagnostics_header_record)
            particle = self._extract_sample(self._metadata_class,
                                            None,
                                            diagnostics_header_dict,
                                            internal_timestamp=timestamp)
            self._diagnostic_header_published = True

            self._record_buffer.append(particle)

        # Cover the case where unexpected diagnostics records are encountered
        elif ((not self._diagnostic_header_published) | (not self._sending_diagnostics))\
            & (not self._bad_diagnostic_header):
            self._total_diagnostic_records = self.DEFAULT_DIAGNOSTICS_COUNT
            self._diagnostic_header_published = True
            log.warning('Unexpected diagnostic data record encountered')
            self._exception_callback(
                RecoverableSampleException(
                    'Unexpected diagnostic data record encountered, not preceded by header'
                ))

        particle = self._extract_sample(self._diagnostics_class,
                                        None,
                                        self._diagnostics_data_dict,
                                        internal_timestamp=timestamp)

        self._record_buffer.append(particle)

        self._diagnostics_count += 1
Beispiel #2
0
    def build_instrument_metadata_particle(self, timestamp):
        """
        The instrument metadata particle is built from three separate records:
        the hardware configuration record, the head configuration record and the
        user configuration record. These should all be concentrated at the very
        beginning of the recovered data file. This assumption is made because the
        instrument is configured before being deployed so the records holding
        this data would be stored first. The data files seen as of the date this
        code was written all start with the three config records, then a quantity
        of velocity data records, then a group of diagnostics (header plus data
        records) followed by more velocity data records. This sequence can be
        repeated a number of times in one file, though the config data will only
        occur once. It is remotely possible that a group of diagnostics could
        occur before any velocity data records are encountered. Publishing of
        the instrument metadata particle is triggered by encountering either the
        first velocity data record or the first diagnostics data record.
        Counting to see if all three configuration records were encountered and
        then producing the instrument metadata particle was rejected as it is
        remotely possible that one of the configuration records could be missing.
        """
        self._config_metadata_built = True

        date_time_group = VelptAbDataParticle.get_date_time_string(self._current_record)

        instrument_metadata_dict = VelptAbDataParticle.generate_instrument_metadata_dict\
            (date_time_group, self._hardware_config_dict, self._head_config_dict,
             self._user_config_dict)

        particle = self._extract_sample(self._instrument_metadata_class,
                                        None,
                                        instrument_metadata_dict,
                                        internal_timestamp=timestamp)

        self._record_buffer.append(particle)

        # Check to see if all the configuration records were found
        if not self._hardware_config_dict_generated:
            # Log a warning for the missing hardware config record
            log.warning(
                'Hardware configuration record invalid or not present in recovered data')
            self._exception_callback(RecoverableSampleException(
                'Hardware configuration record invalid or not present in recovered data'))

        if not self._head_config_dict_generated:
            # Log a warning for the missing head config record
            log.warning('Head configuration record invalid or not present in recovered data')
            self._exception_callback(RecoverableSampleException(
                'Head configuration record invalid or not present in recovered data'))

        if not self._user_config_dict_generated:
            # Log a warning for the missing user config record
            log.warning('User configuration record invalid or not present in recovered data')
            self._exception_callback(RecoverableSampleException(
                'User configuration record invalid or not present in recovered data'))
Beispiel #3
0
    def process_diagnostic_data(self):
        """
        Handles the processing of diagnostic data particles and handles error processing if events
        which should have occurred prior to receiving a diagnostic record did not happen.
        """
        # As diagnostics records have the same format as velocity records
        # you can use the same routine used to break down the velocity data

        timestamp = VelptAbDataParticle.get_timestamp(self._current_record)
        date_time_group = VelptAbDataParticle.get_date_time_string(self._current_record)

        self._diagnostics_data_dict = VelptAbDataParticle.generate_data_dict(self._current_record)

        # Check to see if the instrument metadata particle has been produced yet
        # If not, produce it now as this is the first diagnostics record. This assumes
        # that diagnostics data records will occur BEFORE velocity data records.
        if not self._config_metadata_built:
            self.build_instrument_metadata_particle(timestamp)

        # Upon encountering the first diagnostics record, grab its timestamp
        # for use in the diagnostics metadata particle. Produce that metadata
        # particle now.
        if self._first_diagnostics_record:
            self._first_diagnostics_record = False

            diagnostics_header_dict = VelptAbDataParticle.generate_diagnostics_header_dict(
                date_time_group, self._diagnostics_header_record)
            self._total_diagnostic_records = VelptAbDataParticle.\
                get_diagnostics_count(self._diagnostics_header_record)
            particle = self._extract_sample(self._metadata_class,
                                            None,
                                            diagnostics_header_dict,
                                            internal_timestamp=timestamp)
            self._diagnostic_header_published = True

            self._record_buffer.append(particle)

        # Cover the case where unexpected diagnostics records are encountered
        elif ((not self._diagnostic_header_published) | (not self._sending_diagnostics))\
            & (not self._bad_diagnostic_header):
            self._total_diagnostic_records = self.DEFAULT_DIAGNOSTICS_COUNT
            self._diagnostic_header_published = True
            log.warning('Unexpected diagnostic data record encountered')
            self._exception_callback(
                RecoverableSampleException('Unexpected diagnostic data record encountered, not preceded by header'))

        particle = self._extract_sample(self._diagnostics_class,
                                        None,
                                        self._diagnostics_data_dict,
                                        internal_timestamp=timestamp)

        self._record_buffer.append(particle)

        self._diagnostics_count += 1
Beispiel #4
0
    def build_instrument_metadata_particle(self, timestamp):
        """
        The instrument metadata particle is built from three separate records:
        the hardware configuration record, the head configuration record and the
        user configuration record. These should all be concentrated at the very
        beginning of the recovered data file. This assumption is made because the
        instrument is configured before being deployed so the records holding
        this data would be stored first. The data files seen as of the date this
        code was written all start with the three config records, then a quantity
        of velocity data records, then a group of diagnostics (header plus data
        records) followed by more velocity data records. This sequence can be
        repeated a number of times in one file, though the config data will only
        occur once. It is remotely possible that a group of diagnostics could
        occur before any velocity data records are encountered. Publishing of
        the instrument metadata particle is triggered by encountering either the
        first velocity data record or the first diagnostics data record.
        Counting to see if all three configuration records were encountered and
        then producing the instrument metadata particle was rejected as it is
        remotely possible that one of the configuration records could be missing.
        """
        self._config_metadata_built = True

        date_time_group = VelptAbDataParticle.get_date_time_string(self._current_record)

        instrument_metadata_dict = VelptAbDataParticle.generate_instrument_metadata_dict\
            (date_time_group, self._hardware_config_dict, self._head_config_dict,
             self._user_config_dict)

        particle = self._extract_sample(self._instrument_metadata_class,
                                        None,
                                        instrument_metadata_dict,
                                        timestamp)

        self._record_buffer.append(particle)

        # Check to see if all the configuration records were found
        if not self._hardware_config_dict_generated:
            # Log a warning for the missing hardware config record
            log.warning(
                'Hardware configuration record invalid or not present in recovered data')
            self._exception_callback(RecoverableSampleException(
                'Hardware configuration record invalid or not present in recovered data'))

        if not self._head_config_dict_generated:
            # Log a warning for the missing head config record
            log.warning('Head configuration record invalid or not present in recovered data')
            self._exception_callback(RecoverableSampleException(
                'Head configuration record invalid or not present in recovered data'))

        if not self._user_config_dict_generated:
            # Log a warning for the missing user config record
            log.warning('User configuration record invalid or not present in recovered data')
            self._exception_callback(RecoverableSampleException(
                'User configuration record invalid or not present in recovered data'))