Пример #1
0
def bi_state_relay_output(key, value):
    relay = control_relay.get("bi_state")
    str1 = relay.get(key)
    if value == "on":
        out_str = str1[1]
    else:
        out_str = str1[0]
    send_command(out_str)
    print '%s relay off ' % key
Пример #2
0
def bi_state_relay_output(key, value):
    """ 两态继电器输出
    根据 key 获取对应指令元组
    根据 value 获取开关指令
    """
    relay = control_relay.get("bi_state")
    str1 = relay.get(key)

    if value == "on":
        out_str = str1[1]
    else:
        out_str = str1[0]
    send_command(out_str)
    print '%s relay off ' % key
Пример #3
0
def tri_state_relay_output(key, value):
    relay = control_relay.get("tri_state")
    str1 = relay.get(key)
    if value == "on":
        out_str = str1.get("on")[1]
        send_command(out_str)
        print '%s relay01 on ' % key
        out_str = str1.get("off")[0]
        send_command(out_str)
        print '%s relay02 off ' % key
    elif value == "off":
        out_str = str1.get("on")[0]
        send_command(out_str)
        print '%s relay01 off ' % key
        out_str = str1.get("off")[1]
        send_command(out_str)
        print '%s relay02 on ' % key
    else:
        out_str = str1.get("off")[0]
        send_command(out_str)
        print '%s relay01 off ' % key
        out_str = str1.get("on")[0]
        send_command(out_str)
        print '%s relay02 off ' % key
    print key + ': ' + value
Пример #4
0
def tri_state_relay_output(key, value):
    relay = control_relay.get("tri_state")
    str1 = relay.get(key)
    if value == "on":
        out_str = str1.get("on")[1]
        send_command(out_str)
        print '\n%s relay01 on ' % key
        out_str = str1.get("off")[0]
        send_command(out_str)
        print '%s relay02 off ' % key
    elif value == "off":
        out_str = str1.get("on")[0]
        send_command(out_str)
        print '\n%s relay01 off ' % key
        out_str = str1.get("off")[1]
        send_command(out_str)
        print '%s relay02 on ' % key
    else:
        out_str = str1.get("off")[0]
        send_command(out_str)
        print '\n%s relay01 off ' % key
        out_str = str1.get("on")[0]
        send_command(out_str)
        print '%s relay02 off ' % key
    print key + ': ' + value


# test
# str="lighting_2"
# print control_relay.get("bi_state").get(str)
# print "%s relay01 off" %str
# test_first=[first_1st_on,first_1st_off,first_2nd_on,first_2nd_off,first_3rd_on,first_3rd_off,first_4th_on,first_4th_off,first_5th_on,first_5th_off,first_6th_on,first_6th_off
#     ,first_7th_on,first_7th_off,first_8th_on,first_8th_off,first_open_all,first_close_all]
# for test in test_first:
#     send_command(test)
#
# test_third=[third_1st_on,third_1st_off,third_2nd_on,third_2nd_off,third_3rd_on,third_3rd_off,third_4th_on,third_4th_off,third_5th_on,third_5th_off,third_6th_on,third_6th_off
#     ,third_7th_on,third_7th_off,third_8th_on,third_8th_off,third_open_all,third_close_all]
# for test in test_third:
#     send_command(test)