From 6f4364665b9c649bf2c2dcccc48bdd4cee88a96e Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 16 Apr 2017 21:44:12 +0000 Subject: [PATCH] Autopilotenklasse optimiert --- .gitignore | 1 + __pycache__/core.cpython-36.pyc | Bin 714 -> 845 bytes autopilot.py | 72 ++++++++++++++++---------------- core.py | 2 + manual_controll.py | 50 +++++++++++----------- vero.py | 32 +++++++++----- 6 files changed, 87 insertions(+), 70 deletions(-) diff --git a/.gitignore b/.gitignore index 4a295fd..9f73cfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/autopilot.cpython-36.pyc __pycache__/vero.cpython-36.pyc sensoren/__pycache__/ +__pycache__/core.cpython-36.pyc diff --git a/__pycache__/core.cpython-36.pyc b/__pycache__/core.cpython-36.pyc index 00692c8cfd7e7efcd95775079f66a704712f5d53..629881f868d6e3d9e5feaa0ef63d4a4d322e99fd 100644 GIT binary patch delta 153 zcmX@bdX|mTn3tE!{_f|9&l5RY8C53s%kreKwJ=1nrmzPyXmV`az{IFj!;r<$%)rQy z!T=Ov^wVU##b2CS5}cY>oL>}{m{XcsJozG{ghEk%X-Q^YDjx#_LopMOU|_7`an3JF w)q_e*p1~NwC@}dWqZA|CWF96hHeR5bBEHGyOp07=Kqdzx2MY(&>{0}".format(input)) doIt(input); -except MoveException: - print("Move Exception...") except KeyboardInterrupt: print("Verlasse Erinaco...") core.__del__(); diff --git a/vero.py b/vero.py index 87d0bab..94b3d10 100644 --- a/vero.py +++ b/vero.py @@ -5,6 +5,7 @@ """ from sensoren.boolsensor import Boolsensor as BOOLSENSOR from sensoren.ultraschall import Ultraschall as ULTRASCHALL +import time #from sensoren.dht11 import Dht11 as DHT11 class Vero(object): def __init__(self): @@ -18,18 +19,29 @@ class Vero(object): self.infarotRechts=BOOLSENSOR(21); self.infarotMitteLinks=BOOLSENSOR(16); self.infarotMitteRechts=BOOLSENSOR(20); - def printValues(self): + self.timestampValue=0; + def printValues(self): #self.dht.setValues(); - print("PIR: {0}".format(self.pir.getValue())); + print("PIR: {0}".format(self.pirValue)); #print("Temperatur: {0}".format(self.dht.getTemperatur())); #print("Luftfeuchtigkeit: {0}".format(self.dht.getLuftfeuchtigkeit())); - print("Ultraschall-Links: {0}cm".format(self.ultraschallLinks.getValue())); - print("Ultraschall-Mitte: {0}cm".format(self.ultraschallMitte.getValue())); - print("Ultraschall-Rechts: {0}cm".format(self.ultraschallRechts.getValue())); - print("Infarot Links: {0}".format(self.infarotLinks.getValue())); - print("Infarot Mitte-Links: {0}".format(self.infarotMitteLinks.getValue())); - print("Infarot Mitte-Rechts: {0}".format(self.infarotMitteRechts.getValue())); - print("Infarot Rechts: {0}".format(self.infarotRechts.getValue())); + print("Ultraschall-Links: {0}cm".format(self.ultraschallLinksValue)); + print("Ultraschall-Mitte: {0}cm".format(self.ultraschallMitteValue)); + print("Ultraschall-Rechts: {0}cm".format(self.ultraschallRechtsValue)); + print("Infarot Links: {0}".format(self.infarotLinksValue)); + print("Infarot Mitte-Links: {0}".format(self.infarotMitteLinksValue)); + print("Infarot Mitte-Rechts: {0}".format(self.infarotMitteRechtsValue)); + print("Infarot Rechts: {0}".format(self.infarotRechtsValue)); def saveToDB(self): #Speichert die Werte in der Datenbank pass - + def setSensorValues(self): + if(time.time() >= self.timestampValue+1): #Werte maximal jede Sekunde abspeichern + self.pirValue = self.pir.getValue(); + self.infarotMitteLinksValue = self.infarotMitteLinks.getValue(); + self.infarotMitteRechtsValue = self.infarotMitteRechts.getValue(); + self.infarotLinksValue = self.infarotLinks.getValue(); + self.infarotRechtsValue = self.infarotRechts.getValue(); + self.ultraschallLinksValue = self.ultraschallLinks.getValue(); + self.ultraschallMitteValue = self.ultraschallMitte.getValue(); + self.ultraschallRechtsValue = self.ultraschallRechts.getValue(); + self.timestampValue = time.time();