def control(self, output, temp): if temp > self.setpoint+self.neutralZone and output.state: output.disable() print(printCurrentTime()+"Raditoren slukkes ! - Fra Class \o/") if temp < self.setpoint-self.neutralZone and not(output.state): output.enable() print(printCurrentTime()+"Radiatoren tændes ! - Fra Class \o/")
def control(self, output, temp): if temp > self.setpoint + self.neutralZone and output.state: output.disable() print(printCurrentTime() + "Raditoren slukkes ! - Fra Class \o/") if temp < self.setpoint - self.neutralZone and not (output.state): output.enable() print(printCurrentTime() + "Radiatoren tændes ! - Fra Class \o/")
def controlLoop(): ct=Timer(15.0, controlLoop) #t.daemon = True ct.start() print(printCurrentTime()+"Regulering aktiv !") #print(time.clock()) controller.control(radiator, temp)
def logLoop(): lt=Timer(60.0, logLoop) #t.daemon = True lt.start() print(printCurrentTime()+"Starter logning...") try: myKeys = { 'Vrk_temp': round(rumsensor.read_temperature(),2), 'Vrk_hum': round(rumsensor.read_humidity(),2) } mySqlSenderAnalog(myKeys,1) print(printCurrentTime()+"Logning komplet !") except OSError as err: print(printCurrentTime()+"OS error: {0}".format(err))
# -*- coding: utf-8 -*- import time import random from Relay import Relay from Controls import BangBang from threading import Timer import threading import requests from HTU21D import HTU21D from mySqlTools import mySqlSenderAnalog from HeaterControlTools import printCurrentTime print(printCurrentTime()+"Imports complete") setpoint = 16 zone = 0.2 radiator = Relay(12) rumsensor = HTU21D() controller = BangBang(setpoint, zone) temp = round(rumsensor.read_temperature(),2) print(printCurrentTime()+"Setup complete") temp = 0 def controlLoop(): ct=Timer(15.0, controlLoop) #t.daemon = True ct.start() print(printCurrentTime()+"Regulering aktiv !") #print(time.clock()) controller.control(radiator, temp)