Skip to content

Commit

Permalink
Merge pull request #16 from cuplsensor/dev
Browse files Browse the repository at this point in the history
Merging 1.0.1
  • Loading branch information
malcolmmackay committed Jun 29, 2020
2 parents 0fb9dcb + 7829ee6 commit 314e415
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="cuplcodec",
version="1",
version="1.0.1",
author="Malcolm Mackay",
author_email="malcolm@plotsensor.com",
description="Package for creating and decoding URLs that contain temperature and humidity samples.",
Expand Down
12 changes: 7 additions & 5 deletions wscodec/decoder/hdc2021.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class TempSample(Sample):
def __init__(self, rawtemp: int, timestamp: datetime = None):
def __init__(self, rawtemp: int, timestamp: datetime):
"""
:param rawtemp:
Expand All @@ -23,7 +23,7 @@ def reading_to_temp(reading: int) -> float:


class TempRHSample(TempSample):
def __init__(self, rawtemp: int, rawrh: int, timestamp: datetime = None):
def __init__(self, rawtemp: int, rawrh: int, timestamp: datetime):
super().__init__(rawtemp, timestamp)
self.rawrh = rawrh
self.rh = self.reading_to_rh(rawrh)
Expand All @@ -45,12 +45,13 @@ def __init__(self, *args, **kwargs):
temperature (degrees C) and relative humidity (%) readings.
"""
super().__init__(*args, **kwargs)
timestamp_gen = self.generate_timestamp()

for pair in self.pairs:
temp = pair.rd0
rh = pair.rd1

sample = TempRHSample(temp, rh, timestamp=self.generate_timestamp())
sample = TempRHSample(temp, rh, timestamp=next(timestamp_gen))
self.samples.append(sample)


Expand All @@ -62,11 +63,12 @@ def __init__(self, *args, **kwargs):
temperature reading in degrees C.
"""
super().__init__(*args, **kwargs)
timestamp_gen = self.generate_timestamp()

for pair in self.pairs:
if pair.rd1 != 4095:
sample = TempSample(pair.rd1)
sample = TempSample(pair.rd1, timestamp=next(timestamp_gen))
self.samples.append(sample)

sample = TempSample(pair.rd0, timestamp=self.generate_timestamp())
sample = TempSample(pair.rd0, timestamp=next(timestamp_gen))
self.samples.append(sample)
2 changes: 1 addition & 1 deletion wscodec/decoder/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ def generate_timestamp(self):
"""
sampleindex = 0
while sampleindex < len(self.samples):
while 1:
yield self.newest_timestamp - sampleindex * self.timeinterval
sampleindex = sampleindex + 1

0 comments on commit 314e415

Please sign in to comment.