Compare commits
2 commits
4ea79271e7
...
1f24d7486b
Author | SHA1 | Date | |
---|---|---|---|
1f24d7486b | |||
ce1b61b952 |
6 changed files with 31 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.1.4
|
current_version = 0.1.5
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ with open('README.rst') as f:
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='TSGRain Controller',
|
name='TSGRain Controller',
|
||||||
version='0.1.4',
|
version='0.1.5',
|
||||||
author='ThetaDev',
|
author='ThetaDev',
|
||||||
description='TSGRain irrigation controller',
|
description='TSGRain irrigation controller',
|
||||||
long_description=README,
|
long_description=README,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.4'
|
__version__ = '0.1.5'
|
||||||
|
|
|
@ -176,6 +176,7 @@ class Application(models.AppInterface):
|
||||||
systimecfg.set_system_timezone(tz, self.cfg.cmd_set_timezone)
|
systimecfg.set_system_timezone(tz, self.cfg.cmd_set_timezone)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
"""Starte die Anwendung"""
|
||||||
logging.info('Starting application')
|
logging.info('Starting application')
|
||||||
self._running = True
|
self._running = True
|
||||||
self.io.start()
|
self.io.start()
|
||||||
|
@ -185,6 +186,7 @@ class Application(models.AppInterface):
|
||||||
self.grpc_server.start()
|
self.grpc_server.start()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
"""Stoppe die Anwendung"""
|
||||||
logging.info('Stopping application')
|
logging.info('Stopping application')
|
||||||
self._running = False
|
self._running = False
|
||||||
self.grpc_server.stop(None)
|
self.grpc_server.stop(None)
|
||||||
|
|
|
@ -51,10 +51,10 @@ class Job:
|
||||||
and date_now.minute == self.date.minute
|
and date_now.minute == self.date.minute
|
||||||
|
|
||||||
return date_now.year == self.date.year \
|
return date_now.year == self.date.year \
|
||||||
and date_now.month == self.date.month \
|
and date_now.month == self.date.month \
|
||||||
and date_now.day == self.date.day \
|
and date_now.day == self.date.day \
|
||||||
and date_now.hour == self.date.hour \
|
and date_now.hour == self.date.hour \
|
||||||
and date_now.minute == self.date.minute
|
and date_now.minute == self.date.minute
|
||||||
|
|
||||||
def serialize(self) -> Dict[str, Any]:
|
def serialize(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
|
@ -96,6 +96,10 @@ class Job:
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate(self, app: 'AppInterface'):
|
def validate(self, app: 'AppInterface'):
|
||||||
|
"""
|
||||||
|
Prüfe, ob der Task gültige Daten enthält
|
||||||
|
(Zonen existieren, Bewässerungszeit > 0)
|
||||||
|
"""
|
||||||
if not self.zones:
|
if not self.zones:
|
||||||
raise util.InvalidInputException('No zones set')
|
raise util.InvalidInputException('No zones set')
|
||||||
if self.duration < 1:
|
if self.duration < 1:
|
||||||
|
@ -309,7 +313,7 @@ class AppInterface:
|
||||||
|
|
||||||
:param request: Objekt, dass die Parameter der neuen Aufgabe enthält.
|
:param request: Objekt, dass die Parameter der neuen Aufgabe enthält.
|
||||||
:return: Statusobjekt (Information, ob eine Aufgabe gestartet oder gestoppt
|
:return: Statusobjekt (Information, ob eine Aufgabe gestartet oder gestoppt
|
||||||
wurde).
|
wurde).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def start_task(self, source: Source, zone_id: int, duration: int,
|
def start_task(self, source: Source, zone_id: int, duration: int,
|
||||||
|
@ -321,7 +325,7 @@ class AppInterface:
|
||||||
:param zone_id: ID der Bewässerungszone
|
:param zone_id: ID der Bewässerungszone
|
||||||
:param duration: Bewässerungsdauer in Sekunden (0 für Standarddauer)
|
:param duration: Bewässerungsdauer in Sekunden (0 für Standarddauer)
|
||||||
:param queuing: Neue Aufgabe in die Warteschlange einreihen, wenn momentan
|
:param queuing: Neue Aufgabe in die Warteschlange einreihen, wenn momentan
|
||||||
eine andere Zone bewässert wird.
|
eine andere Zone bewässert wird.
|
||||||
:return: True wenn die Aufgabe erfolgreich gestartet wurde
|
:return: True wenn die Aufgabe erfolgreich gestartet wurde
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,20 @@ class StoppableThread(threading.Thread):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run_cycle(self):
|
def run_cycle(self):
|
||||||
pass
|
"""
|
||||||
|
Führe einen Durchlauf des Threads aus.
|
||||||
|
|
||||||
|
Diese Funktion darf nicht blockieren, sonst kann der
|
||||||
|
Thread nicht gestoppt werden.
|
||||||
|
"""
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
"""
|
||||||
|
Führe die ``run_cycle()``-Funktion in
|
||||||
|
Endlosschleife aus, mit einer durch das
|
||||||
|
``interval``-Attribut bestimmten Verzögerung zwischen
|
||||||
|
den Durchläufen.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
|
@ -146,6 +157,10 @@ class StoppableThread(threading.Thread):
|
||||||
sys.excepthook(*sys.exc_info())
|
sys.excepthook(*sys.exc_info())
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
"""
|
||||||
|
Stoppe den Thread und warte bis er beendet. Dies dauert
|
||||||
|
maximal ``interval`` + Durchlaufzeit von ``run_cycle()``.
|
||||||
|
"""
|
||||||
self._stop_signal.set()
|
self._stop_signal.set()
|
||||||
try:
|
try:
|
||||||
self.join()
|
self.join()
|
||||||
|
|
Loading…
Reference in a new issue