def lights_any( arguments ): global __arduino if __arduino: ArdnLib.clear_register() else: print 'lights_any (', arguments, ')'
def lights_all( arguments ): global __arduino if __arduino: ArdnLib.set_register() else: print 'lights_all (', arguments, ')'
def lights_off( arguments ): global __arduino zone = arguments[ 'zone' ].lower() if __arduino: ArdnLib.set_color( zone, 'off' ) else: print 'lights_off (', arguments, ')'
def signal_handler( signal, frame ): '''This method is in charge to capture SIGUSR signals and to close the server in the correct way. ''' global __server if not __server is None: __server.stop() ArdnLib.disconnect() sys.exit( 0 )
def lights_all( arguments ): global __arduino for i in range( 0, len( CmdManager.firestones ) ): CmdManager.firestones[ i ] = False if __arduino: ArdnLib.set_register() else: print 'lights_all (', arguments, ')' print CmdManager.firestones
def signal_handler( signal, frame ): '''This method is in charge to capture SIGUSR signals and to close the server in the correct way. ''' global __server print '\n> Closing firebrain...' if not __server is None: __server.stop() ArdnLib.disconnect() print '> Firebrain closed' sys.exit( 0 )
def main(): ardno = True if len( sys.argv ) == 2 and sys.argv[ 1 ] in [ '-n', '--no-arduino' ]: ardno = False arduino( ardno ) try: if ardno: ArdnLib.connect() except Exception, e: print print '[firebrain] Get sure arduino is connected, we haven\' found it.' print e print
def main(): # First we check if we want to used the phisical arduino or not ardno = True if len( sys.argv ) == 2 and sys.argv[ 1 ] in [ '-n', '--no-arduino' ]: ardno = False CommLib.Functions.arduino( ardno ) try: # If we want a connection with the arduino we try to get it if ardno: ArdnLib.connect() except Exception, e: # If we cant connect to the arduino and we ArdnçLiv hasn't find it # we infor the user and print the catched exception. print print '[firebrain] Get sure arduino is connected, we haven\' found it.' print e print
def lights_connection( arguments ): global __arduino zone = arguments[ 'zone' ] off = CmdManager.firestones_zones[ 'connections' ][ zone ] for zn in off: pos = CmdManager.firestones_zones[ 'groups' ][ zn ] CmdManager.firestones[ pos - 1 ] = False pos = CmdManager.firestones_zones[ 'groups' ][ zone ] CmdManager.firestones[ pos - 1 ] = True if __arduino: ArdnLib.send_line( CmdManager.firestones ) else: print 'lights_connection (', arguments, ')' print CmdManager.firestones
def lights_off( arguments ): global __arduino zone, zones = arguments[ 'zone' ], [ ] for zn in CmdManager.firestones_zones[ 'groups' ]: if zn == zone: zones.append( zn ) elif len( zn ) > 1 and zn[ 0 ] == zone: zones.append( zn ) for zn in zones: pos = CmdManager.firestones_zones[ 'groups' ][ zn ] CmdManager.firestones[ pos - 1 ] = False if __arduino: ArdnLib.send_line( CmdManager.firestones ) else: print 'lights_off (', arguments, ')' print CmdManager.firestones