Ejemplo n.º 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 = VelptAbDclDataParticle.get_timestamp(self._current_record)
        date_time_group = VelptAbDclDataParticle.get_date_time_string(
            self._current_record)

        self._diagnostics_data_dict = VelptAbDclDataParticle.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 = VelptAbDclDataParticle.generate_diagnostics_header_dict(
                date_time_group, self._diagnostics_header_record)
            self._total_diagnostic_records = VelptAbDclDataParticle.\
                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
Ejemplo n.º 2
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 = VelptAbDclDataParticle.get_timestamp(self._current_record)
        date_time_group = VelptAbDclDataParticle.get_date_time_string(self._current_record)

        self._diagnostics_data_dict = VelptAbDclDataParticle.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 = VelptAbDclDataParticle.generate_diagnostics_header_dict(
                date_time_group, self._diagnostics_header_record)
            self._total_diagnostic_records = VelptAbDclDataParticle.\
                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