コード例 #1
0
ファイル: auto_run_backup.py プロジェクト: tj621/py_back
def thermal_screen_control(Outdoor, Parameter):
    global auto_thermal_screen
    if bad_weather == "true":
        if auto_thermal_screen == "on":
            tri_state_relay_output("thermal_screen", "off")
            wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
        auto_thermal_screen = "off"
    #         control.set_thermal_screen("off")
    elif auto_fogging == "on":
        if auto_thermal_screen == "on":
            tri_state_relay_output("thermal_screen", "off")
            wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
        auto_thermal_screen = "off"
    #         control.set_thermal_screen("off")
    else:
        current_hour = get_current_hour()
        current_month = get_current_month()
        if current_month > Parameter.get_month_to_open_thermal_screen() and current_month < Parameter.get_month_to_close_thermal_screen():
            if current_hour > Parameter.get_time_to_open_thermal_screen() and current_hour < Parameter.get_time_to_close_thermal_screen():
                if auto_thermal_screen == "off":
                    tri_state_relay_output("thermal_screen", "on")
                    wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
                auto_thermal_screen = "on"
            #                 control.set_thermal_screen("off")    #open
        else:
            if auto_thermal_screen == "on":
                tri_state_relay_output("thermal_screen", "off")
                wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
            auto_thermal_screen = "off"
コード例 #2
0
def thermal_screen_control(Outdoor,Parameter):
    global auto_thermal_screen
    if bad_weather=="true":
        if auto_thermal_screen=="on":
            tri_state_relay_output("thermal_screen", "off")
            wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
        auto_thermal_screen="off"
#         control.set_thermal_screen("off")
    elif auto_fogging=="on":
        if auto_thermal_screen=="on":
            tri_state_relay_output("thermal_screen", "off")
            wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
        auto_thermal_screen="off"
#         control.set_thermal_screen("off")
    else:
        current_hour=get_current_hour()
        current_month=get_current_month()
        if current_month>Parameter.get_month_to_open_thermal_screen() and current_month<Parameter.get_month_to_close_thermal_screen():
            if current_hour>Parameter.get_time_to_open_thermal_screen() and current_hour<Parameter.get_time_to_close_thermal_screen():
                if auto_thermal_screen=="off":
                    tri_state_relay_output("thermal_screen", "on")
                    wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
                auto_thermal_screen="on"
#                 control.set_thermal_screen("off")    #open
        else:
            if auto_thermal_screen=="on":
                tri_state_relay_output("thermal_screen", "off")
                wait_and_stop("side_vent", Parameter.get_thermal_screen_open_time(), "all")
            auto_thermal_screen="off"
コード例 #3
0
def lighting_control(Outdoor, Parameter):
    global t1, t2, t3, t4, t5, lighting_stop_time, lighting_stop_time2, lighting_stop_time3, lighting_open_time, lighting_open_time2
    global auto_lighting_1, auto_lighting_2
    month = int(get_current_month())
    hour = int(get_current_hour())

    if auto_lighting_1 == "off" and auto_lighting_2 == "off":
        if month > Parameter.get_month_to_open_lighting() and month < Parameter.get_month_to_close_lighting():
            if hour > Parameter.get_period_1_start_lighting() and hour < Parameter.get_period_1_stop_lighting():
                if Outdoor.get_radiation() < Parameter.get_radiation_1_to_open_lighting():
                    bi_state_relay_output("lighting_1", "on")
                    auto_lighting_1 = "on"
                    lighting_open_time = get_time()
            elif hour > Parameter.get_period_2_start_lighting() and hour < Parameter.get_period_2_stop_lighting():
                if Outdoor.get_radiation() < Parameter.get_radiation_2_to_open_lighting():
                    bi_state_relay_output("lighting_2", "on")
                    auto_lighting_2 = "on"
                    lighting_open_time2 = get_time()

    elif auto_lighting_1 == "on" and auto_lighting_2 == "off":
        t1 = float(get_time() - lighting_open_time)
        t2 = float(get_time() - lighting_open_time2)
        if t1 > 30 and t1 < 60:
            bi_state_relay_output("lighting_2", "on")
            auto_lighting_2 = "on"
        if t2 > 30 and t2 < 60:
            bi_state_relay_output("lighting_2", "on")
            auto_lighting_2 = "on"
    elif auto_lighting_1 == "on" and auto_lighting_2 == "on":
        if hour > Parameter.get_period_1_start_lighting() and hour < Parameter.get_period_1_stop_lighting():
            if Outdoor.get_radiation() > Parameter.get_radiation_1_to_open_lighting():
                bi_state_relay_output("lighting_1", "off")
                auto_lighting_1 = "off"
                lighting_stop_time = get_time()
        elif hour > Parameter.get_period_2_start_lighting() and hour < Parameter.get_period_2_stop_lighting():
            if Outdoor.get_radiation() > Parameter.get_radiation_2_to_open_lighting():
                bi_state_relay_output("lighting_1", "off")
                auto_lighting_1 = "off"
                lighting_stop_time2 = get_time()
        else:
            bi_state_relay_output("lighting_1", "off")
            auto_lighting_1 = "off"
            lighting_stop_time3 = get_time()

    elif auto_lighting_1 == "off" and auto_lighting_2 == "on":
        t3 = get_time() - lighting_stop_time3
        t4 = get_time() - lighting_stop_time2
        t5 = get_time() - lighting_stop_time
        if t3 > 30 and t3 < 60:
            bi_state_relay_output("lighting_2", "off")
            auto_lighting_2 = "off"
        if t4 > 30 and t4 < 60:
            bi_state_relay_output("lighting_2", "off")
            auto_lighting_2 = "off"
        if t5 > 30 and t5 < 60:
            bi_state_relay_output("lighting_2", "off")
            auto_lighting_2 = "off"
コード例 #4
0
def thermal_screen_control(Outdoor, Parameter):
    global auto_thermal_screen, thermal_screen_state
    if bad_weather == "true":
        if auto_thermal_screen == "on":
            thermal_screen_state = "open to close"
        auto_thermal_screen = "off"
    elif auto_fogging == "on":
        if auto_thermal_screen == "on":
            thermal_screen_state = "open to close"
        auto_thermal_screen = "off"
    else:
        current_hour = get_current_hour()
        current_month = get_current_month()
        if current_month > Parameter.get_month_to_open_thermal_screen() and current_month < Parameter.get_month_to_close_thermal_screen():
            if current_hour > Parameter.get_time_to_open_thermal_screen() and current_hour < Parameter.get_time_to_close_thermal_screen():
                if auto_thermal_screen == "off":
                    thermal_screen_state = "close to open"
                auto_thermal_screen = "on"
            if auto_thermal_screen == "on":
                thermal_screen_state = "open to close"
        auto_thermal_screen = "off"
    return thermal_screen_state
コード例 #5
0
def roof_vent_control(Outdoor, Parameter, Indoor):
    global temperature_set_temp0, temperature_set_temp1, temperature_set_temp2, angle, auto_roof_vent_north, auto_roof_vent_south, roof_start_time, roof_state
    current_hour = get_current_hour()
    roof_start_time = get_time()
    if bad_weather == "true":
        if auto_roof_vent_north == "on" and auto_roof_vent_south == "on":
            roof_state = "open all to close"
            if angle == "half":
                roof_state = "open half to close"
            elif angle == "small":
                roof_state = "open small to close"
        auto_roof_vent_north = "off"
        auto_roof_vent_south = "off"
        angle = "zero"
    else:
        if current_hour >= Parameter.get_time_1(
        ) and current_hour < Parameter.get_time_2():
            temperature_set_temp0 = float(Parameter.get_temperature_1())
        elif current_hour >= Parameter.get_time_2(
        ) and current_hour < Parameter.get_time_3():
            temperature_set_temp0 = float(Parameter.get_temperature_2())
        elif current_hour >= Parameter.get_time_3(
        ) and current_hour < Parameter.get_time_4():
            temperature_set_temp0 = float(Parameter.get_temperature_3())
        else:
            temperature_set_temp0 = float(Parameter.get_temperature_4())

            # humidity influence on temperature
        if float(Parameter.get_humidity_influence_range_of_air_temperature()
                 ) == 0:
            print "humidity_influence_range_of_air_temperature can not be 0"
        elif float(Parameter.get_expect_humidity()) == 95:
            print "expect_humidity can not be 95%"
        else:
            if float(Outdoor.get_humidity()) <= (
                    float(Parameter.get_expect_humidity()) - 5 -
                    float(Parameter.
                          get_humidity_influence_range_of_air_temperature())):
                temperature_set_temp1 = temperature_set_temp0 + float(
                    Parameter.get_low_humidity_influence_on_air_temperature())
            elif float(Outdoor.get_humidity()) <= (
                    float(Parameter.get_expect_humidity()) - 5):
                tmpt = (float(Parameter.get_expect_humidity(
                )) - 5 - float(Outdoor.get_humidity())) * float(
                    Parameter.get_low_humidity_influence_on_air_temperature()
                ) / float(Parameter.
                          get_humidity_influence_range_of_air_temperature())
                temperature_set_temp1 = temperature_set_temp0 + tmpt
            elif float(Outdoor.get_humidity()) >= (
                    float(Parameter.get_expect_humidity()) + 5):
                tmpt = (float(Outdoor.get_humidity()) - float(
                    Parameter.get_expect_humidity()) - 5) * float(
                        Parameter.
                        get_high_humidity_influence_on_air_temperature()) / (
                            100 - 5 - float(Parameter.get_expect_humidity()))
                temperature_set_temp1 = temperature_set_temp0 + tmpt
            else:
                temperature_set_temp1 = temperature_set_temp0

        # light influence on temperature
        if Outdoor.get_radiation() < Parameter.get_expect_light():
            temperature_set_temp2 = temperature_set_temp1
        else:
            temperature_set_temp2 = temperature_set_temp1 - float(
                Parameter.get_light_influence_on_air_temperature_slope()) * (
                    float(Outdoor.get_radiation()) -
                    float(Parameter.get_expect_light()))
        if temperature_set_temp2 > (temperature_set_temp1 + float(
                Parameter.get_low_light_influence_on_temperature())):
            temperature_set_temp2 = temperature_set_temp1 + float(
                Parameter.get_low_light_influence_on_temperature())
        elif temperature_set_temp2 < (temperature_set_temp1 - float(
                Parameter.get_high_light_influence_on_temperature())):
            temperature_set_temp2 = temperature_set_temp1 - float(
                Parameter.get_high_light_influence_on_temperature())
        else:
            if temperature_set_temp2 == 0:
                temperature_set_temp2 = 0

        if Outdoor.get_temperature() <= Parameter.get_frost_temperature():
            if auto_roof_vent_north == "on" and auto_roof_vent_south == "on":
                roof_state = "open all to close"
                if angle == "half":
                    roof_state = "open half to close"
                else:
                    roof_state = "open small to close"
            auto_roof_vent_north = "off"
            auto_roof_vent_south = "off"
            angle = "zero"
        elif Outdoor.get_temperature(
        ) <= Parameter.get_indoor_temperature_lower_limit():
            # small angle
            if auto_roof_vent_north == "off" and auto_roof_vent_south == "off":
                roof_state = "close to open small"
                if angle == "all":
                    roof_state = "open all to open small"
                elif angle == "half":
                    roof_state = "open half to open small"
            auto_roof_vent_north = "on"
            auto_roof_vent_south = "on"
            angle = "small"
        elif Outdoor.get_temperature() <= temperature_set_temp2:
            # open half
            if auto_roof_vent_north == "off" and auto_roof_vent_south == "off":
                roof_state = "close to open half"
                if angle == "small":
                    roof_state = "open small to half"
                elif angle == "all":
                    roof_state = "open all to open half"
            roof_start_time = get_time()
            auto_roof_vent_north = "on"
            auto_roof_vent_south = "on"
            angle = "half"
        else:
            #
            if auto_roof_vent_north == "off" and auto_roof_vent_south == "off":
                roof_state = "close to open all"
                if angle == "small":
                    roof_state = "open half to all"
                elif angle == "half":
                    roof_state = "open half to open all"
            auto_roof_vent_north = "on"
            auto_roof_vent_south = "on"
            angle = "all"
    return roof_state
コード例 #6
0
ファイル: autorun.py プロジェクト: tj621/py_back
def roof_vent_control(Outdoor, Parameter, Indoor):
    global temperature_set_temp0, temperature_set_temp1, temperature_set_temp2, angle, auto_roof_vent_north, auto_roof_vent_south, roof_start_time, roof_state
    current_hour = get_current_hour()
    roof_start_time = get_time()
    if bad_weather == "true":
        if auto_roof_vent_north == "on" and auto_roof_vent_south == "on":
            roof_state = "open all to close"
            if angle == "half":
                roof_state = "open half to close"
            elif angle == "small":
                roof_state = "open small to close"
        auto_roof_vent_north = "off"
        auto_roof_vent_south = "off"
        angle = "zero"
    else:
        if current_hour >= Parameter.get_time_1() and current_hour < Parameter.get_time_2():
            temperature_set_temp0 = float(Parameter.get_temperature_1())
        elif current_hour >= Parameter.get_time_2() and current_hour < Parameter.get_time_3():
            temperature_set_temp0 = float(Parameter.get_temperature_2())
        elif current_hour >= Parameter.get_time_3() and current_hour < Parameter.get_time_4():
            temperature_set_temp0 = float(Parameter.get_temperature_3())
        else:
            temperature_set_temp0 = float(Parameter.get_temperature_4())

            # humidity influence on temperature
        if float(Parameter.get_humidity_influence_range_of_air_temperature()) == 0:
            print "humidity_influence_range_of_air_temperature can not be 0"
        elif float(Parameter.get_expect_humidity()) == 95:
            print "expect_humidity can not be 95%"
        else:
            if float(Outdoor.get_humidity()) <= (float(Parameter.get_expect_humidity()) - 5 - float(
                    Parameter.get_humidity_influence_range_of_air_temperature())):
                temperature_set_temp1 = temperature_set_temp0 + float(
                    Parameter.get_low_humidity_influence_on_air_temperature())
            elif float(Outdoor.get_humidity()) <= (float(Parameter.get_expect_humidity()) - 5):
                tmpt = (float(Parameter.get_expect_humidity()) - 5 - float(Outdoor.get_humidity())) * float(
                    Parameter.get_low_humidity_influence_on_air_temperature()) / float(
                    Parameter.get_humidity_influence_range_of_air_temperature())
                temperature_set_temp1 = temperature_set_temp0 + tmpt
            elif float(Outdoor.get_humidity()) >= (float(Parameter.get_expect_humidity()) + 5):
                tmpt = (float(Outdoor.get_humidity()) - float(Parameter.get_expect_humidity()) - 5) * float(
                    Parameter.get_high_humidity_influence_on_air_temperature()) / (
                           100 - 5 - float(Parameter.get_expect_humidity()))
                temperature_set_temp1 = temperature_set_temp0 + tmpt
            else:
                temperature_set_temp1 = temperature_set_temp0

        # light influence on temperature
        if Outdoor.get_radiation() < Parameter.get_expect_light():
            temperature_set_temp2 = temperature_set_temp1
        else:
            temperature_set_temp2 = temperature_set_temp1 - float(
                Parameter.get_light_influence_on_air_temperature_slope()) * (float(Outdoor.get_radiation()) - float(
                Parameter.get_expect_light()))
        if temperature_set_temp2 > (temperature_set_temp1 + float(Parameter.get_low_light_influence_on_temperature())):
            temperature_set_temp2 = temperature_set_temp1 + float(Parameter.get_low_light_influence_on_temperature())
        elif temperature_set_temp2 < (
                    temperature_set_temp1 - float(Parameter.get_high_light_influence_on_temperature())):
            temperature_set_temp2 = temperature_set_temp1 - float(Parameter.get_high_light_influence_on_temperature())
        else:
            if temperature_set_temp2 == 0:
                temperature_set_temp2 = 0

        if Outdoor.get_temperature() <= Parameter.get_frost_temperature():
            if auto_roof_vent_north == "on" and auto_roof_vent_south == "on":
                roof_state = "open all to close"
                if angle == "half":
                    roof_state = "open half to close"
                else:
                    roof_state = "open small to close"
            auto_roof_vent_north = "off"
            auto_roof_vent_south = "off"
            angle = "zero"
        elif Outdoor.get_temperature() <= Parameter.get_indoor_temperature_lower_limit():
            # small angle
            if auto_roof_vent_north == "off" and auto_roof_vent_south == "off":
                roof_state = "close to open small"
                if angle == "all":
                    roof_state = "open all to open small"
                elif angle == "half":
                    roof_state = "open half to open small"
            auto_roof_vent_north = "on"
            auto_roof_vent_south = "on"
            angle = "small"
        elif Outdoor.get_temperature() <= temperature_set_temp2:
            # open half
            if auto_roof_vent_north == "off" and auto_roof_vent_south == "off":
                roof_state = "close to open half"
                if angle == "small":
                    roof_state = "open small to half"
                elif angle == "all":
                    roof_state = "open all to open half"
            roof_start_time = get_time()
            auto_roof_vent_north = "on"
            auto_roof_vent_south = "on"
            angle = "half"
        else:
            #
            if auto_roof_vent_north == "off" and auto_roof_vent_south == "off":
                roof_state = "close to open all"
                if angle == "small":
                    roof_state = "open half to all"
                elif angle == "half":
                    roof_state = "open half to open all"
            auto_roof_vent_north = "on"
            auto_roof_vent_south = "on"
            angle = "all"
    return roof_state