Ejemplo n.º 1
0
    def lighting(self, Outdorr, Parameter,
                 Control):  # 补光策略,在currenttime 加了一个get_time()函数

        while True:
            if Control.get_lighting_1() == "off" and Control.get_lighting_2(
            ) == "off":
                if get_current_month(
                ) > Parameter.month_to_open_lighting and get_current_month(
                ) < Parameter.month_to_close_lighting:
                    if get_current_time(
                    ) > Parameter.period1_start_lighting and get_current_time(
                    ) < Parameter.period1_stop_lighting:
                        if Outdoor.radiation < Parameter.radiation1_to_open_lighting:
                            Control.set_lighting_1("on")
                            open_time = get_time()
                    elif get_current_time(
                    ) > Parameter.period2_start_lighting and get_current_time(
                    ) < Parameter.period2_stop_lighting:
                        if Outdoor.radiation < Parameter.radiation2_to_open_lighting:
                            Control.set_lighting_1("on")
                            open_time2 = get_time()

            elif Control.get_lighting_1() == "on" and Control.get_lighting_2(
            ) == "off":
                t1 = int(get_time() - open_time)
                t2 = int(get_time() - open_time2)
                if t1 > 1750 and t1 < 1850:
                    Control.set_lighting_2("on")
                if t2 > 1750 and t2 < 1850:
                    Control.set_lighting_2("on")

            elif Control.get_lighting_1() == "on" and Control.get_lighting_2(
            ) == "on":
                if get_current_time(
                ) > Parameter.period1_start_lighting and get_current_time(
                ) < Parameter.period1_stop_lighting:
                    if Outdoor.radiation > Parameter.radiation1_to_open_lighting:
                        Control.set_lighting_1("off")
                        stop_time = get_time()
                elif get_current_time(
                ) > Parameter.period2_start_lighting and get_current_time(
                ) < Parameter.period2_stop_lighting:
                    if Outdoor.radiation > Parameter.radiation2_to_open_lighting:
                        Control.set_lighting_1("off")
                        stop_time2 = get_time()
                else:
                    Control.set_lighting_1("off")
                    stop_time3 = get_time()

            elif Control.get_lighting_1() == "off" and Control.get_lighting_2(
            ) == "on":
                t3 = get_time() - stop_time3
                t4 = get_time() - stop_time2
                t5 = get_time() - stop_time
                if t3 > 1750 and t3 < 1850:
                    Control.set_lighting_2("off")
                if t4 > 1750 and t4 < 1850:
                    Control.set_lighting_2("off")
                if t5 > 1750 and t5 < 1850:
                    Control.set_lighting_2("off")
Ejemplo n.º 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"
Ejemplo n.º 3
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"
Ejemplo n.º 4
0
    def lighting(self,Outdorr,Parameter,Control):#补光策略,在currenttime 加了一个get_time()函数

        while True:
            if Control.get_lighting_1()=="off" and Control.get_lighting_2()=="off":
                if get_current_month()>Parameter.month_to_open_lighting and get_current_month()<Parameter.month_to_close_lighting:
                    if get_current_time()>Parameter.period1_start_lighting and get_current_time()<Parameter.period1_stop_lighting:
                        if Outdoor.radiation<Parameter.radiation1_to_open_lighting:

                            Control.set_lighting_1("on")
                            open_time=get_time()
                    elif get_current_time()>Parameter.period2_start_lighting and get_current_time()<Parameter.period2_stop_lighting:
                        if Outdoor.radiation<Parameter.radiation2_to_open_lighting:
                            Control.set_lighting_1("on")
                            open_time2=get_time()

            elif Control.get_lighting_1()=="on" and Control.get_lighting_2()=="off":
                t1=int(get_time()-open_time)
                t2=int(get_time()-open_time2)
                if t1>1750 and t1<1850:
                    Control.set_lighting_2("on")
                if t2>1750 and t2<1850:
                    Control.set_lighting_2("on")

            elif Control.get_lighting_1()=="on" and Control.get_lighting_2()=="on":
                if get_current_time()>Parameter.period1_start_lighting and get_current_time()<Parameter.period1_stop_lighting:
                    if Outdoor.radiation>Parameter.radiation1_to_open_lighting:
                        Control.set_lighting_1("off")
                        stop_time=get_time()
                elif get_current_time()>Parameter.period2_start_lighting and get_current_time()<Parameter.period2_stop_lighting:
                    if Outdoor.radiation>Parameter.radiation2_to_open_lighting:
                        Control.set_lighting_1("off")
                        stop_time2=get_time()
                else:
                    Control.set_lighting_1("off")
                    stop_time3=get_time()

            elif Control.get_lighting_1()=="off" and Control.get_lighting_2()=="on":
                t3=get_time()-stop_time3
                t4=get_time()-stop_time2
                t5=get_time()-stop_time
                if t3>1750 and t3<1850:
                    Control.set_lighting_2("off")
                if t4>1750 and t4<1850:
                    Control.set_lighting_2("off")
                if t5>1750 and t5<1850:
                    Control.set_lighting_2("off")
Ejemplo n.º 5
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"
Ejemplo n.º 6
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
Ejemplo n.º 7
0
def lighting_control(Control, Outdoor, Parameter):
    global lighting_stop_time, lighting_stop_time2, lighting_stop_time3
    auto_lighting_1 = Control.get_lighting_1()
    auto_lighting_2 = Control.get_lighting_2()
    if auto_lighting_1 == "off" and auto_lighting_2 == "off":
        if get_current_month() > Parameter.get_month_to_open_lighting() and get_current_month() < Parameter.get_month_to_close_lighting():
            if get_current_time() > Parameter.get_period_1_start_lighting() and get_current_time() < Parameter.get_period_1_stop_lighting():
                if Outdoor.get_radiation() < Parameter.get_radiation_1_to_open_lighting():
                    #                         Control.set_lighting_1("on")
                    bi_state_relay_output("lighting_1", "on")
                    auto_lighting_1 = "on"
                    lighting_open_time = get_time()
            elif get_current_time() > Parameter.get_period_2_start_lighting() and get_current_time() < Parameter.get_period_2_stop_lighting():
                if Outdoor.get_radiation() < Parameter.get_radiation_2_to_open_lighting():
                    #                         Control.set_lighting_1("on")
                    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 = int(get_time() - lighting_open_time)
        t2 = int(get_time() - lighting_open_time2)
        if t1 > 1750 and t1 < 1850:
            bi_state_relay_output("ligting_2", "on")
            auto_lighting_2 = "on"
        #                 Control.set_lighting_2("on")
        if t2 > 1750 and t2 < 1850:
            #                 Control.set_lighting_2("on")
            bi_state_relay_output("ligting_2", "on")
            auto_lighting_2 = "on"
    elif auto_lighting_1 == "on" and auto_lighting_2 == "on":
        if get_current_time() > Parameter.get_period_1_start_lighting() and get_current_time() < Parameter.get_period_1_stop_lighting():
            if Outdoor.get_radiation() > Parameter.get_radiation_1_to_open_lighting():
                #                     Control.set_lighting_1("off")
                bi_state_relay_output("ligting_1", "off")
                auto_lighting_1 = "off"
                lighting_stop_time = get_time()
        elif get_current_time() > Parameter.get_period_2_start_lighting() and get_current_time() < Parameter.get_period_2_stop_lighting():
            if Outdoor.get_radiation() > Parameter.get_radiation_2_to_open_lighting():
                #                     Control.set_lighting_1("off")
                bi_state_relay_output("ligting_1", "off")
                auto_lighting_1 = "off"
                lighting_stop_time2 = get_time()
        else:
            #                 Control.set_lighting_1("off")
            bi_state_relay_output("ligting_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 > 1750 and t3 < 1850:
            bi_state_relay_output("ligting_2", "off")
        #                 Control.set_lighting_2("off")
        if t4 > 1750 and t4 < 1850:
            bi_state_relay_output("ligting_2", "off")
        #                 Control.set_lighting_2("off")
        if t5 > 1750 and t5 < 1850:
            bi_state_relay_output("ligting_2", "off")
        #                 Control.set_lighting_2("off")
    else:
        bi_state_relay_output("ligting_2", "off")
        bi_state_relay_output("ligting_1", "off")
Ejemplo n.º 8
0
def lighting_control(Control, Outdoor, Parameter):
    global lighting_stop_time, lighting_stop_time2, lighting_stop_time3
    auto_lighting_1 = Control.get_lighting_1()
    auto_lighting_2 = Control.get_lighting_2()
    if auto_lighting_1 == "off" and auto_lighting_2 == "off":
        if get_current_month() > Parameter.get_month_to_open_lighting(
        ) and get_current_month() < Parameter.get_month_to_close_lighting():
            if get_current_time() > Parameter.get_period_1_start_lighting(
            ) and get_current_time() < Parameter.get_period_1_stop_lighting():
                if Outdoor.get_radiation(
                ) < Parameter.get_radiation_1_to_open_lighting():
                    #                         Control.set_lighting_1("on")
                    bi_state_relay_output("lighting_1", "on")
                    auto_lighting_1 = "on"
                    lighting_open_time = get_time()
            elif get_current_time() > Parameter.get_period_2_start_lighting(
            ) and get_current_time() < Parameter.get_period_2_stop_lighting():
                if Outdoor.get_radiation(
                ) < Parameter.get_radiation_2_to_open_lighting():
                    #                         Control.set_lighting_1("on")
                    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 = int(get_time() - lighting_open_time)
        t2 = int(get_time() - lighting_open_time2)
        if t1 > 1750 and t1 < 1850:
            bi_state_relay_output("ligting_2", "on")
            auto_lighting_2 = "on"
        #                 Control.set_lighting_2("on")
        if t2 > 1750 and t2 < 1850:
            #                 Control.set_lighting_2("on")
            bi_state_relay_output("ligting_2", "on")
            auto_lighting_2 = "on"
    elif auto_lighting_1 == "on" and auto_lighting_2 == "on":
        if get_current_time() > Parameter.get_period_1_start_lighting(
        ) and get_current_time() < Parameter.get_period_1_stop_lighting():
            if Outdoor.get_radiation(
            ) > Parameter.get_radiation_1_to_open_lighting():
                #                     Control.set_lighting_1("off")
                bi_state_relay_output("ligting_1", "off")
                auto_lighting_1 = "off"
                lighting_stop_time = get_time()
        elif get_current_time() > Parameter.get_period_2_start_lighting(
        ) and get_current_time() < Parameter.get_period_2_stop_lighting():
            if Outdoor.get_radiation(
            ) > Parameter.get_radiation_2_to_open_lighting():
                #                     Control.set_lighting_1("off")
                bi_state_relay_output("ligting_1", "off")
                auto_lighting_1 = "off"
                lighting_stop_time2 = get_time()
        else:
            #                 Control.set_lighting_1("off")
            bi_state_relay_output("ligting_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 > 1750 and t3 < 1850:
            bi_state_relay_output("ligting_2", "off")
        #                 Control.set_lighting_2("off")
        if t4 > 1750 and t4 < 1850:
            bi_state_relay_output("ligting_2", "off")
        #                 Control.set_lighting_2("off")
        if t5 > 1750 and t5 < 1850:
            bi_state_relay_output("ligting_2", "off")
        #                 Control.set_lighting_2("off")
    else:
        bi_state_relay_output("ligting_2", "off")
        bi_state_relay_output("ligting_1", "off")