Bewaesserungsanlage/main.py

24 lines
901 B
Python

import threading
import time
from Webserver import Webserver
from ZoneManager import ZoneManager
from SystemSettings import SystemSettings
from FileIO import FileIO
systemSettings = SystemSettings(cronJobFrequency=0.5, dataDir="/Data", multiZoneIrrigation=False, defaultAutoIrrigationDuration=10, defaultManualIrrigationDuration=10, defaultManualOffDuration=10, webDurationOptions=[1, 5, 10, 15, 20, 25, 30, 45, 60])
fileIO = FileIO(systemSettings)
zoneManager = ZoneManager(systemSettings=systemSettings, fileIO=fileIO)
webserver = Webserver(zoneManager=zoneManager, port=80)
def cronJobs():
while True:
zoneManager.cronJobs()
print("Cronjobs done\nactual Time: " + str(time.time()))
time.sleep(systemSettings.cronJobFrequency)
if __name__ == "__main__":
cronjob_Thread = threading.Thread(target=cronJobs)
cronjob_Thread.start()
webserver.startWebserver()