-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from UMONS-GFA/develop
Develop
- Loading branch information
Showing
11 changed files
with
434 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.idea | ||
ardas/*.ssr | ||
ardas/settings.py | ||
ardas/data/* | ||
ardas/logs/* | ||
cronlog.log | ||
ardas/__pycache__/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
[[source]] | ||
|
||
url = "https://pypi.python.org/simple" | ||
name = "pypi" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.5" | ||
|
||
[packages] | ||
|
||
pyserial = "*" | ||
pandas = "*" | ||
influxdb = "*" | ||
"w1thermsensor" = "*" | ||
ntplib = "*" | ||
influxdb = "*" | ||
numpy = "*" | ||
|
||
|
||
[dev-packages] | ||
sphinx = "*" | ||
"sphinx-rtd-theme" = "*" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import random | ||
import time | ||
import datetime | ||
from calendar import timegm | ||
|
||
|
||
class Fake1WireSensor: | ||
"""Generic fake 1-Wire sensor""" | ||
def __init__(self, seller_id='00-00000'): | ||
"""Generate a unique id with hexadecimal timestamp""" | ||
self.id = seller_id + hex(timegm(datetime.datetime.now().utctimetuple()))[3:] | ||
|
||
|
||
class FakeTempSensor(Fake1WireSensor): | ||
"""Fake 1-Wire temperature sensor default is DS18B20""" | ||
def __init__(self): | ||
Fake1WireSensor.__init__(self, seller_id='28-00000') | ||
self.name = 't' | ||
self.temperature = 0 | ||
|
||
def set_name(self, new_name): | ||
self.name = new_name | ||
|
||
def get_temperature(self): | ||
self.temperature = random.uniform(20, 28) | ||
return self.temperature | ||
|
||
|
||
def generate_temp_sensor(nb_sensor=2): | ||
sensors = [] | ||
for i in range(nb_sensor): | ||
s = FakeTempSensor() | ||
s.set_name('T' + str(i)) | ||
sensors.append(s) | ||
time.sleep(1) # mandatory otherwise each sensor will have the same name | ||
return sensors | ||
|
||
|
||
def main(): | ||
sensors = generate_temp_sensor() | ||
for s in sensors: | ||
print("Temperature of {:s} is {:.3f}".format(s.id, s.get_temperature())) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.