Esempio n. 1
1
def set_color(color, state="on"):
    if not color in functions_optcode.keys():
        raise UnknownColor(color)
    if color in colors_connection.keys():
        for connection in colors_connection[color]:
            Core.send_byte(functions_optcode[connection]["off" if state == "on" else "on"])
    Core.send_byte(functions_optcode[color][state])
Esempio n. 2
1
def set_register():
    Core.send_byte(functions_optcode["set"])
Esempio n. 3
1
def clear_register():
    Core.send_byte(functions_optcode["clear"])
Esempio n. 4
0
def set_register():
    '''Function to switch on all the
    lamps in the installation.
    '''
    for color in functions_optcode.keys():
        if color in [ 'set', 'clear' ]:
            continue
        if not color in connections_relations.keys():
            Core.send_byte( functions_optcode[ color ][ 'on' ] )
        else:
            Core.send_byte( functions_optcode[ color ][ 'off' ] )
Esempio n. 5
0
def set_color( color, state = 'on' ):
    '''Function to swicth on or switch off a 
    specific colored region lamps in the
    installation.
    
     :param color: Identifier of the colored region
     :param state: On or Off (string)
    '''
    if not color in colors_names.keys():
        raise Exceptions.UnknownColor( 'color opcode ( %s )' % color )

    color = colors_names[ color ]
    if not color in functions_optcode.keys():
        raise Exceptions.UnknownColor( color )
    
    if color in connections_relations.keys():
        for primary in connections_relations[ color ]:
                Core.send_byte( functions_optcode[ primary ][ 'off' ] )        
    
    Core.send_byte( functions_optcode[ color ][ state ] )

    if color in [ 'red', 'green', 'blue' ] and state == 'off':
        lights_off()
Esempio n. 6
0
def clear_register():
    '''Function to switch off all the
    lamps in the installation.
    '''
    Core.send_byte( functions_optcode[ 'clear' ] )
Esempio n. 7
0
def lights_off():
    for color in connections_relations.keys():
        Core.send_byte( functions_optcode[ color ][ 'off' ] )