Skip to content

Commit

Permalink
Finish script to generate sensor files
Browse files Browse the repository at this point in the history
  • Loading branch information
SuppenGeist committed Sep 9, 2016
1 parent f655555 commit 3416743
Show file tree
Hide file tree
Showing 2 changed files with 1,019 additions and 9 deletions.
24 changes: 15 additions & 9 deletions examples/sensor_files/generate_sensor_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@

import sys
import random
from datetime import datetime
import datetime

numberOfEntries = 0
numberOfEntries = 30
logDate = 0

if len(sys.argv) == 2:
numberOfEntries = sys.argv[1]
if len(sys.argv) >= 2:
numberOfEntries = int(sys.argv[1])

if len(sys.argv) == 3:
logDate = datetime.strptime(sys.argv[2], "%H:%M:%S")
if len(sys.argv) >= 3:
logDate = datetime.datetime.strptime(sys.argv[2], "%H:%M:%S")
else:
logDate = datetime.strptime(str(random.randint(0,24))+":"+str(random.randint(0,59))+":"+str(random.randint(0,59)),"%H:%M:%S")
logDate = datetime.datetime.strptime(str(random.randint(0,23))+":"+str(random.randint(0,59))+":"+str(random.randint(0,59)),"%H:%M:%S")

print numberOfEntries
print logDate
print "AK-Logger v1.0"
print "Datum: "+str(logDate.year)+"-"+str(logDate.month)+"-"+str(logDate.day)
print ""
print "Timestamp;Temperature;Humidity;"

for i in range(0,numberOfEntries):
print str(logDate.hour)+":"+str(logDate.minute)+":"+str(logDate.second)+";"+"{0:.2f}".format(random.uniform(15.0,30.0))+";"+"{0:.2f}".format(random.uniform(30.0,80.0))+";"
logDate += datetime.timedelta(seconds=1)

Loading

0 comments on commit 3416743

Please sign in to comment.