Пример #1
0
def switch_dev(id, state):
    global step_id

    try:
        control = mp709.relaysControl()
        control.setId(id)
        control.setState(state)
        control.main()

        if get_controls_state(id) != state:
            step_id = step_id - 1
    except:
        pass
Пример #2
0
def controls_info():
    global gui

    try:
        state = ("off", "on")
        control = mp709.relaysControl()
        rels = control.enumerateRelays()
        inf_str = ""
        for r in rels:
            inf = r.getInfo()
            inf_str = inf_str + " " + str(inf['id']) + ":" + str(state[int(r.getPort())]) + "  "

            print inf['id'], ":", state[int(r.getPort())]

        gui.update_top_center(inf_str)
    except:
        pass
Пример #3
0
def get_controls_state(control_id):
    global gui
    ret_state = "none"
    state = ("off", "on")

    try:

        control = mp709.relaysControl()
        rels = control.enumerateRelays()

        for r in rels:
            inf = r.getInfo()

            if inf['id'] == control_id:
                ret_state = str(state[int(r.getPort())])

        print get_current_time(), "get_controls_state control_id:", control_id, "state:", ret_state
        return ret_state


    except:
        pass
        print get_current_time(), "get_controls_state control_id:", control_id, "state:", ret_state
        return ret_state