Example #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)

        # Upon encountering the first diagnostics record, use its timestamp
        # for 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,
                                            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,
                                        timestamp)

        self._record_buffer.append(particle)

        self._diagnostics_count += 1
Example #2
0
    def process_velocity_data(self):
        """
        Handles the processing of velocity data particles and handles error processing if events
        which should have occurred prior to receiving a velocity record did not happen.
        """
        # Get the timestamp of the velocity record in case we need it for the metadata particle.
        timestamp = VelptAbDataParticle.get_timestamp(self._current_record)

        # If this flag is still indicating TRUE, it means we found NO diagnostic records.
        # That's an error!
        if self._first_diagnostics_record:
            self._first_diagnostics_record = False
            log.warning('No diagnostic records present, just a header.'
                        'No particles generated')
            self._exception_callback(
                RecoverableSampleException('No diagnostic records present, just a header.'
                                           'No particles generated'))

        # This flag indicates that diagnostics were being produced and now that
        # the first velocity record has been encountered, it's time to match the
        # number of diagnostics particles produced against the number of diagnostic
        # records expected from the diagnostics header.
        if self._sending_diagnostics:
            self._sending_diagnostics = False
            if self._total_diagnostic_records != self._diagnostics_count:
                if self._diagnostics_count < self._total_diagnostic_records:
                    log.warning('Not enough diagnostics records, got %s, expected %s',
                                self._diagnostics_count, self._total_diagnostic_records)
                    self._exception_callback(
                        RecoverableSampleException('Not enough diagnostics records'))

                elif self._diagnostics_count > self._total_diagnostic_records:
                    log.warning('Too many diagnostics records, got %s, expected %s',
                                self._diagnostics_count, self._total_diagnostic_records)
                    self._exception_callback(
                        RecoverableSampleException('Too many diagnostics records'))
                    self._diagnostics_count = 0
                    self._total_diagnostic_records = 0

        velocity_data_dict = VelptAbDataParticle.generate_data_dict(self._current_record)

        particle = self._extract_sample(self._velocity_data_class,
                                        None,
                                        velocity_data_dict,
                                        timestamp)

        self._record_buffer.append(particle)
Example #3
0
    def process_velocity_data(self):
        """
        Handles the processing of velocity data particles and handles error processing if events
        which should have occurred prior to receiving a velocity record did not happen.
        """
        # Get the timestamp of the velocity record in case we need it for the metadata particle.
        timestamp = VelptAbDataParticle.get_timestamp(self._current_record)

        # If this flag is still indicating TRUE, it means we found NO diagnostic records.
        # That's an error!
        if self._first_diagnostics_record:
            self._first_diagnostics_record = False
            log.warning("No diagnostic records present, just a header." "No particles generated")
            self._exception_callback(
                RecoverableSampleException("No diagnostic records present, just a header." "No particles generated")
            )

        # This flag indicates that diagnostics were being produced and now that
        # the first velocity record has been encountered, it's time to match the
        # number of diagnostics particles produced against the number of diagnostic
        # records expected from the diagnostics header.
        if self._sending_diagnostics:
            self._sending_diagnostics = False
            if self._total_diagnostic_records != self._diagnostics_count:
                if self._diagnostics_count < self._total_diagnostic_records:
                    log.warning(
                        "Not enough diagnostics records, got %s, expected %s",
                        self._diagnostics_count,
                        self._total_diagnostic_records,
                    )
                    self._exception_callback(RecoverableSampleException("Not enough diagnostics records"))

                elif self._diagnostics_count > self._total_diagnostic_records:
                    log.warning(
                        "Too many diagnostics records, got %s, expected %s",
                        self._diagnostics_count,
                        self._total_diagnostic_records,
                    )
                    self._exception_callback(RecoverableSampleException("Too many diagnostics records"))
                    self._diagnostics_count = 0
                    self._total_diagnostic_records = 0

        velocity_data_dict = VelptAbDataParticle.generate_data_dict(self._current_record)

        particle = self._extract_sample(self._velocity_data_class, None, velocity_data_dict, timestamp)

        self._record_buffer.append(particle)
Example #4
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)

        # Upon encountering the first diagnostics record, use its timestamp
        # for 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, 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, timestamp)

        self._record_buffer.append(particle)

        self._diagnostics_count += 1