示例#1
0
    def _parse_chunk(self):
        records = []

        sample = self.chunk["content"][4:].strip()
        parts = sample.split("\t")
        record = {
            # TODO: Set correct params
            #'model': parts[0],
            #'serial': parts[1],
            'C': float(parts[2]),
            'D': float(parts[3]),
            'E': float(parts[4]),
            'F': float(parts[5]),
            'G': float(parts[6]),
            'H': float(parts[7]),
            'I': float(parts[8]),
            'J': float(parts[9]),
            'K': float(parts[10]),
            'L': float(parts[11]),
        }
        ntp_timestamp = ntplib.system_to_ntp_time(self.chunk["timestamp"])
        particle = FlexDataParticle(driver_timestamp=ntp_timestamp, stream_name=STREAM_NAME)
        particle.set_data_values(record)
        records.append(particle)

        return records
示例#2
0
    def _parse_chunk(self):
        records = []

        sample = self.chunk["content"][4:].strip()
        parts = sample.split("\t")
        record = {
            # TODO: Set correct params
            #'model': parts[0],
            #'serial': parts[1],
            'C': float(parts[2]),
            'D': float(parts[3]),
            'E': float(parts[4]),
            'F': float(parts[5]),
            'G': float(parts[6]),
            'H': float(parts[7]),
            'I': float(parts[8]),
            'J': float(parts[9]),
            'K': float(parts[10]),
            'L': float(parts[11]),
        }
        ntp_timestamp = ntplib.system_to_ntp_time(self.chunk["timestamp"])
        particle = FlexDataParticle(driver_timestamp=ntp_timestamp,
                                    stream_name=STREAM_NAME)
        particle.set_data_values(record)
        records.append(particle)

        return records
示例#3
0
    def _parse_chunk(self):
        data = self.chunk["content"]

        record = {
            # TODO: Set correct params
            'raw': data,
        }
        ntp_timestamp = ntplib.system_to_ntp_time(self.chunk["timestamp"])
        particle = FlexDataParticle(driver_timestamp=ntp_timestamp, stream_name=STREAM_NAME)
        particle.set_data_values(record)
        records = []
        records.append(particle)

        return records
示例#4
0
    def get_records(self, max_count=MAX_RECORDS_PER_GRANULE):
        """
        return a list of dicts, each dict describes one record in the current profile
        or None if the last profile has been read completely
        """
        if self._profile_index >= len(self._profiles):
            return None
        particle_list = []

        profile = self._profiles[self._profile_index]
        start = profile['start']
        end = profile['end']
        records = profile['records']

        last_index = min(max_count + self._record_index, len(records))
        while self._record_index < last_index:
            data = records[self._record_index]
            time = self._interpolate_time(self._record_index, start, end,
                                          len(records))
            ntp_timestamp = ntplib.system_to_ntp_time(time)
            if time > self._parse_after:
                record = {
                    'upload_time': self._upload_time,
                    'conductivity': self._get_conductivity(data),
                    'temp': self._get_temperature(data),
                    'pressure': self._get_pressure(data),
                    'oxygen': self._get_oxygen(data)
                }
                particle = FlexDataParticle(driver_timestamp=ntp_timestamp)
                particle.set_data_values(record)
                particle_list.append(particle.generate(encode=False))
            self._record_index += 1

        if self._record_index == len(records):
            self._record_index = 0
            self._profile_index += 1

        log.debug("get_records(max_count=%s) returns %s particles", max_count,
                  len(particle_list))

        return particle_list
示例#5
0
    def get_records(self, max_count=MAX_RECORDS_PER_GRANULE):
        """
        return a list of dicts, each dict describes one record in the current profile
        or None if the last profile has been read completely
        """
        if self._profile_index >= len(self._profiles):
            return None
        particle_list = []

        profile = self._profiles[self._profile_index]
        start = profile['start']
        end = profile['end']
        records = profile['records']

        last_index = min(max_count + self._record_index, len(records))
        while self._record_index < last_index:
            data = records[self._record_index]
            time = self._interpolate_time(self._record_index, start, end, len(records))
            ntp_timestamp = ntplib.system_to_ntp_time(time)
            if time > self._parse_after:
                record = {
                    'upload_time': self._upload_time,
                    'conductivity': self._get_conductivity(data),
                    'temp': self._get_temperature(data),
                    'pressure': self._get_pressure(data),
                    'oxygen': self._get_oxygen(data)
                }
                particle = FlexDataParticle(driver_timestamp=ntp_timestamp)
                particle.set_data_values(record)
                particle_list.append(particle.generate(encode=False))
            self._record_index += 1

        if self._record_index == len(records):
            self._record_index = 0
            self._profile_index += 1

        log.debug("get_records(max_count=%s) returns %s particles", max_count, len(particle_list))

        return particle_list