Skip to content

Commit

Permalink
Merge pull request #34 from H3c702/VarTypes
Browse files Browse the repository at this point in the history
Test varTypes
  • Loading branch information
DevTown authored Oct 6, 2021
2 parents bf92923 + 516c9e2 commit c11e485
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Hector9000/HectorServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import paho.mqtt.client as mqtt
from Hector9000.conf import HectorConfig as HC

from Hector9000.HectorHardware import HectorHardware as Hector
# from Hector9000.HectorSimulator import HectorSimulator as Hector
# from Hector9000.HectorHardware import HectorHardware as Hector
from Hector9000.HectorSimulator import HectorSimulator as Hector


# global vars
Expand Down
12 changes: 6 additions & 6 deletions Hector9000/conf/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,30 +146,30 @@ def _import_settings(self):
"""INSERT INTO "Settings" ("setting", "value") VALUES ('cupsize', '400');""")
self.con.commit()

def _check_Table_is_Filled(self, table):
def _check_Table_is_Filled(self, table: str):
self.cur.execute("SELECT * FROM " + table)
items = self.cur.fetchall()
return len(items) > 0

def get_Setting(self, setting):
def get_Setting(self, setting: str):
self.cur.execute(
"SELECT value from Settings where setting = ? ;", (setting,))
items = self.cur.fetchone()
return items[0]

def set_Setting(self, setting, value):
def set_Setting(self, setting: str, value: str):
self.cur.execute(
"UPDATE Settings set value = ? where setting = ? ;", (value, setting))
self.con.commit()
return self.get_Setting(setting)

def get_Servo(self, servo):
def get_Servo(self, servo: int):
self.cur.execute(
"SELECT Code FROM Servos WHERE ServoNr = ? ;", (servo,))
items = self.cur.fetchone()
return items[0]

def set_Servo(self, servo, code):
def set_Servo(self, servo: int, code: str):
self.cur.execute(
"UPDATE Servos set Code = ? where ServoNr = ? ;", (code, servo))
self.con.commit()
Expand Down Expand Up @@ -222,7 +222,7 @@ def get_AllIngredients_asJson(self):

return json.dumps({"Ingredients": datalist})

def countUpDrink(self, drink):
def countUpDrink(self, drink: str):
self.cur.execute(
"INSERT INTO DrinksLog (drink, date) VALUES (?, ?)",
(drink,
Expand Down
9 changes: 9 additions & 0 deletions Hector9000/tools/SetValveIng.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ def get_Valves():
if 0 < valve <= 12:
print(ing[1] + " goes into " + str(valve))
db.set_Servo(valve, ing[0])
if valve == 13:
print("------------------")
print(db.get_AllIngredients_asJson())
print("------------------")
if valve == 14:
print("------------------")
print(db.get_Servos_asJson())
print("------------------")

except ValueError:
print("Oops! That was no valid number. Try again...")

Expand Down
20 changes: 10 additions & 10 deletions Hector9000/utils/HectorAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def light_off(self):
pass

@abc.abstractmethod
def arm_out(self, cback=debugOut):
def arm_out(self, cback = debugOut):
pass

@abc.abstractmethod
def arm_in(self, cback=debugOut):
def arm_in(self, cback = debugOut):
pass

@abc.abstractmethod
Expand All @@ -55,32 +55,32 @@ def pump_stop(self):
pass

@abc.abstractmethod
def valve_open(self, index, open=1):
def valve_open(self, index: int, open: int = 1):
pass

@abc.abstractmethod
def valve_close(self, index):
def valve_close(self, index: int):
pass

@abc.abstractmethod
def valve_dose(
self,
index,
index: int,
amount,
timeout=30,
cback=debugOut,
timeout: int = 30,
cback = debugOut,
progress=(
0,
100),
topic=""):
topic: str = ""):
return 0

@abc.abstractmethod
def finger(self, pos=0):
def finger(self, pos: int = 0):
pass

@abc.abstractmethod
def ping(self, num, retract=True, cback=None):
def ping(self, num: int, retract: bool = True, cback = None):
pass

@abc.abstractmethod
Expand Down
10 changes: 5 additions & 5 deletions Hector9000/utils/LEDStripAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import abc


def debugOut(name, value):
def debugOut(name: str, value: str):
print("=> %s: %d" % (name, value))


Expand All @@ -18,17 +18,17 @@ def __init__(self):
pass

@abc.abstractmethod
def standart(self, color=(80, 80, 30), type=0):
def standart(self, color=(80, 80, 30), type = 0):
pass

@abc.abstractmethod
def dosedrink(self, color=(20, 20, 255), type=0):
def dosedrink(self, color=(20, 20, 255), type = 0):
pass

@abc.abstractmethod
def drinkfinish(self, color=(80, 80, 30), type=0):
def drinkfinish(self, color=(80, 80, 30), type = 0):
pass

@abc.abstractmethod
def standby(self, color=(80, 80, 30), type=0):
def standby(self, color=(80, 80, 30), type = 0):
pass
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ venv:
ln -snf ~/.venv/python_project/ venv
venv/bin/pip install -e ."[dev]"

# activate - Activate venv
## activate - Activate venv
activate:
source venv/bin/activate

Expand Down

0 comments on commit c11e485

Please sign in to comment.