dbi = DBInsert(db_name = db_name, db_host = db_host, db_port = db_port, db_user = db_user, user_password = user_password) valve_open = 1.0 valve_closed = 0.0 try: while True: time_measurement = time.time() rtm1_0 = s.get_temperature_northeast() wt_3 = s.get_temperature_northwest() wt_2 = s.get_temperature_west() rtm1_1 = s.get_temperature_southwest() wt_0 = s.get_temperature_southeast() wt_1 = s.get_temperature_east() ex9024_level = a.get_valve_position() flowrate = s.get_flowrate() temperature_inlet = s.get_radiator_temperature_inlet() temperature_outlet = s.getradiator_temperature_outlet() temperatures = [rtm1_0, rtm1_1, wt_0, wt_1, wt_2, wt_3] weightings = [1, 1, 1, 1, 1, 1] temperatures_weighted = 0 for j, temperature in enumerate(temperatures): temperatures_weighted += weightings[j] * temperature temperature_room = temperatures_weighted / sum(weightings) if (temperature_room < 21.0) and (abs(ex9024_level-valve_open) > 0.05): print "too cold" a.set_valve_position(opening_level = valve_open)
from sensors_actuators_k004b.actuators import Actuators import os client_address_sensors = os.environ["EX9132_ADDRESS"] client_port_sensors = os.environ["EX9132_PORT_2"] a = Actuators(client_address_sensors, client_port_sensors) k = 0 print a.get_valve_position() print a.set_valve_position(opening_level=1.0) while k < 5: print a.get_valve_position() k += 1 del a
log.setLevel(logging.DEBUG) s = Sensors(client_address = sensor_client_address, \ client_port = sensor_client_port, \ server_address = server_address, \ server_port = server_port, \ serial_port = serial_port_sensors, \ baudrate = baudrate_sensors, \ parity = parity_sensors, \ stopbits = stopbits_sensors, \ bytesize = bytesize_sensors, \ timeout = timeout_sensors) a = Actuators(client_address = actuator_client_address, \ client_port = actuator_client_port) s.get_temperature_northwest() s.get_temperature_northeast() s.get_temperature_east() s.get_temperature_west() s.get_temperature_southwest() s.get_temperature_southeast() s.get_flowrate_radiator() s.get_temperature_radiator_inlet() s.get_temperature_radiator_outlet() s.get_radiation_total() s.get_radiation_diffuse() s.get_sunshine_presence() a.set_valve_position(opening_level=0.0) a.get_valve_position()