def configure_led(self, config): if not self.rgb_connection: self.log.critical("A request was made to configure a FAST LED, " "but no connection to an LED processor is " "available") sys.exit() if not self.flag_led_tick_registered: self.machine.events.add_handler('timer_tick', self.update_leds) self.flag_led_tick_registered = True # if the LED number is in <channel> - <led> format, convert it to a # FAST hardware number if '-' in config['number_str']: num = config['number_str'].split('-') config['number'] = int((num[0] * 64) + num[1]) self.config['config_number_format'] = 'int' else: config['number'] = str(config['number']) if self.config['config_number_format'] == 'int': config['number'] = Config.int_to_hex_string(config['number']) else: config['number'] = Config.normalize_hex_string(config['number']) this_fast_led = FASTDirectLED(config['number']) self.fast_leds.add(this_fast_led) return this_fast_led
def configure_matrixlight(self, config): if not self.net_connection: self.log.critical("A request was made to configure a FAST matrix " "light, but no connection to a NET processor is " "available") sys.exit() if self.machine_type == 'wpc': # translate number to FAST light num config['number'] = self.wpc_light_map.get( config['number_str'].upper()) elif self.config['config_number_format'] == 'int': config['number'] = Config.int_to_hex_string(config['number']) else: config['number'] = Config.normalize_hex_string(config['number']) return (FASTMatrixLight(config['number'], self.net_connection.send), config['number'])
def configure_driver(self, config, device_type='coil'): if not self.net_connection: self.log.critical("A request was made to configure a FAST driver, " "but no connection to a NET processor is " "available") sys.exit() # If we have WPC driver boards, look up the driver number if self.machine_type == 'wpc': config['number'] = self.wpc_driver_map.get( config['number_str'].upper()) if ('connection' in config and config['connection'].lower() == 'network'): config['connection'] = 1 else: config['connection'] = 0 # local driver (default for WPC) # If we have fast driver boards, we need to make sure we have hex strs elif self.machine_type == 'fast': if self.config['config_number_format'] == 'int': config['number'] = Config.int_to_hex_string(config['number']) else: config['number'] = Config.normalize_hex_string(config['number']) # Now figure out the connection type if ('connection' in config and config['connection'].lower() == 'local'): config['connection'] = 0 else: config['connection'] = 1 # network driver (default for FAST) else: self.log.critical("Invalid machine type: {0{}}".format( self.machine_type)) sys.exit() return (FASTDriver(config, self.net_connection.send), (config['number'], config['connection']))
def configure_switch(self, config): """Configures the switch object for a FAST Pinball controller. FAST Controllers support two types of switches: `local` and `network`. Local switches are switches that are connected to the FAST controller board itself, and network switches are those connected to a FAST I/O board. MPF needs to know which type of switch is this is. You can specify the switch's connection type in the config file via the ``connection:`` setting (either ``local`` or ``network``). If a connection type is not specified, this method will use some intelligence to try to figure out which default should be used. If the DriverBoard type is ``fast``, then it assumes the default is ``network``. If it's anything else (``wpc``, ``system11``, ``bally``, etc.) then it assumes the connection type is ``local``. Connection types can be mixed and matched in the same machine. """ if not self.net_connection: self.log.critical("A request was made to configure a FAST switch, " "but no connection to a NET processor is " "available") sys.exit() if self.machine_type == 'wpc': # translate switch number to FAST switch config['number'] = self.wpc_switch_map.get( config['number_str'].upper()) if 'connection' not in config: config['connection'] = 0 # local switch (default for WPC) else: config['connection'] = 1 # network switch elif self.machine_type == 'fast': if 'connection' not in config: config['connection'] = 1 # network switch (default for FAST) else: config['connection'] = 0 # local switch if self.config['config_number_format'] == 'int': config['number'] = Config.int_to_hex_string(config['number']) else: config['number'] = Config.normalize_hex_string(config['number']) # convert the switch number into a tuple which is: # (switch number, connection) config['number'] = (config['number'], config['connection']) if 'debounce_open' not in config: config['debounce_open'] = self.config['default_debounce_open'] if 'debounce_close' not in config: config['debounce_close'] = self.config['default_debounce_close'] self.log.debug("FAST Switch hardware tuple: %s", config['number']) switch = FASTSwitch(number=config['number'], debounce_open=config['debounce_open'], debounce_close=config['debounce_close'], sender=self.net_connection.send) return switch, config['number']