def get_samples(self):
        yield sample.Sample(
            self.timestamp,
            sample.SensorPath(
                sample.Part.BME280,
                self.instance,
                sample.BME280Subpart.TEMPERATURE,
            ),
            self.temperature,
        )

        yield sample.Sample(
            self.timestamp,
            sample.SensorPath(
                sample.Part.BME280,
                self.instance,
                sample.BME280Subpart.PRESSURE,
            ),
            self.pressure,
        )

        yield sample.Sample(
            self.timestamp,
            sample.SensorPath(
                sample.Part.BME280,
                self.instance,
                sample.BME280Subpart.HUMIDITY,
            ),
            self.humidity,
        )
 def get_samples(self):
     for id_, value in self.samples:
         yield sample.Sample(
             self.timestamp,
             sample.SensorPath(
                 sample.Part.DS18B20,
                 binascii.b2a_hex(id_).decode(),
             ),
             value,
         )
 def get_samples(self):
     for ts, channels in self.samples:
         for ch_i, ch_subpart in enumerate(self._ch_parts):
             yield sample.Sample(
                 ts,
                 sample.SensorPath(
                     sample.Part.TCS3200,
                     0,
                     ch_subpart,
                 ),
                 channels[ch_i]
             )
 def path(self):
     return sample.SensorPath(
         sample.Part.LSM303D,
         0,
         self._partmap[self.type_]
     )
class NoiseMessage:
    samples = None

    _header = struct.Struct(
        "<"
        "B"
    )

    _sample = struct.Struct(
        "<"
        "HLhh"
    )

    _sensor_path = sample.SensorPath(
        sample.Part.CUSTOM_NOISE,
        0,
    )

    def __init__(self, samples, type_=MsgType.SENSOR_NOISE):
        super().__init__()
        self.type_ = type_
        self.samples = list(samples)

    @classmethod
    def from_buf(cls, type_, buf):
        buf, (factor,) = unpack_and_splice(buf, cls._header)
        return cls(
            [
                (ts, sqavg / (2**24-1) / factor, min_, max_)
                for ts, sqavg, min_, max_
                in unpack_all(buf, cls._sample)
            ],
            type_=type_
        )

    def __repr__(self):
        return "<{}.{} samples={} at 0x{:x}>".format(
            __name__,
            type(self).__qualname__,
            self.samples,
            id(self),
        )

    def get_samples(self):
        for ts, sqavg, min_, max_ in self.samples:
            rms = math.sqrt(sqavg)
            yield sample.Sample(
                ts,
                self._sensor_path.replace(
                    subpart=sample.CustomNoiseSubpart.RMS
                ),
                rms,
            )
            yield sample.Sample(
                ts,
                self._sensor_path.replace(
                    subpart=sample.CustomNoiseSubpart.MIN
                ),
                min_ / (2**15-1)
            )
            yield sample.Sample(
                ts,
                self._sensor_path.replace(
                    subpart=sample.CustomNoiseSubpart.MAX
                ),
                max_ / (2**15-1)
            )