def _start(): '''Start the module This uses the global variables from setup and adds a set of global variables ''' global parser, args, config, r, response, patch global monitor, debug, address, artnet, dmxdata, prevtime # this can be used to show parameters that have changed monitor = EEGsynth.monitor(name=name, debug=patch.getint('general','debug')) # get the options from the configuration file debug = patch.getint('general','debug') # prepare the data for a single universe address = [0, 0, patch.getint('artnet','universe')] artnet = ArtNet.ArtNet(ip=patch.getstring('artnet','broadcast'), port=patch.getint('artnet','port')) # blank out dmxdata = [0] * 512 artnet.broadcastDMX(dmxdata,address) # keep a timer to send a packet every now and then prevtime = time.time() # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
def _start(): '''Start the module This uses the global variables from setup and adds a set of global variables ''' global parser, args, config, r, response, patch, name global monitor, debug, address, artnet, dmxsize, dmxframe, prevtime # this can be used to show parameters that have changed monitor = EEGsynth.monitor(name=name, debug=patch.getint('general', 'debug')) # get the options from the configuration file debug = patch.getint('general', 'debug') # prepare the data for a single universe address = [0, 0, patch.getint('artnet', 'universe')] artnet = ArtNet.ArtNet(ip=patch.getstring('artnet', 'broadcast'), port=patch.getint('artnet', 'port')) # determine the size of the universe dmxsize = 0 chanlist, chanvals = list(map(list, list(zip(*config.items('input'))))) for chanindx in range(0, 512): chanstr = "channel%03d" % (chanindx + 1) if chanstr in chanlist: # the last channel determines the size dmxsize = chanindx + 1 # FIXME the artnet code fails if the size is smaller than 512 dmxsize = 512 monitor.info("universe size = %d" % dmxsize) # make an empty frame dmxframe = [0] * dmxsize # blank out artnet.broadcastDMX(dmxframe, address) # keep a timer to send a packet every now and then prevtime = time.time() # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
db=0) response = r.client_list() except redis.ConnectionError: print("Error: cannot connect to redis server") exit() # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) del config # this determines how much debugging information gets printed debug = patch.getint('general', 'debug') # prepare the data for a single universe address = [0, 0, patch.getint('artnet', 'universe')] artnet = ArtNet.ArtNet(ip=patch.getstring('artnet', 'broadcast'), port=patch.getint('artnet', 'port')) # blank out dmxdata = [0] * 512 artnet.broadcastDMX(dmxdata, address) # keep a timer to send a packet every now and then prevtime = time.time() try: while True: time.sleep(patch.getfloat('general', 'delay')) # loop over the control values, these are 1-offset in the ini file for chanindx in range(1, 512): chanstr = "channel%03d" % chanindx
debug = config.getint('general', 'debug') try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0) response = r.client_list() if debug > 0: print "Connected to redis server" except redis.ConnectionError: print "Error: cannot connect to redis server" exit() # prepare the data for a single universe address = [0, 0, config.getint('artnet', 'universe')] artnet = ArtNet.ArtNet(ip=config.get('artnet', 'broadcast'), port=config.getint('artnet', 'port')) # blank out dmxdata = [0] * 512 artnet.broadcastDMX(dmxdata, address) # keep a timer to send a packet every now and then prevtime = time.time() try: while True: time.sleep(config.getfloat('general', 'delay')) for chanindx in range(1, 256): chanstr = "channel%03d" % chanindx
print("Timeout") continue """Identify the sACN packets""" sACN_packet_type = sACN.identify_sacn_packet(sacn_input_packet) if sACN_packet_type == "sACN_DATA_PACKET": sACN_start_code = sACN.identify_sacn_startcode(sacn_input_packet) if debug_level >= 4: print(f"{sACN_packet_type} with start code {sACN_start_code}") # If it is a DATA_PACKET check the start code. sACN.sacn_data_check_validity( sacn_input_packet) # Check if the data packet is valid if sACN_start_code == "DMX": sACN_data = sACN.sacn_dmx_input(sacn_input_packet) sACN_data["dmx_data"] = sACN.merge_sacn_inputs(sACN_data) ArtNet.artdmx_output(sACN_data) # If the START_CODE is 0x00, send DMX elif sACN_start_code == "PER_CHANNEL_PRIORITY": sACN_data = sACN.sacn_per_channel_input(sacn_input_packet) sACN.add_sacn_priority(sACN_data) # If the START_CODE is 0xDD, update the Priority for the universe elif sACN_start_code == "RDM": pass # ToDo for when E1.33 is published elif sACN_start_code == "ALTERNATE": ArtNet.artnzs_output(sACN_data) # If the START_CODE is alternating, send a Non-Zero-Start-Code packet. elif sACN_packet_type == "sACN_EXTENDED_SYNCHRONIZATION": if debug_level >= 4: print(f"{sACN_packet_type}") # ToDo elif sACN_packet_type == "sACN_EXTENDED_DISCOVERY":