Example #1
0
    def __init__(self, machine):
        """Make sure pinproc was loaded."""
        super().__init__(machine)

        if not pinproc_imported:
            raise AssertionError('Could not import "pinproc". Most likely you do not '
                                 'have libpinproc and/or pypinproc installed. You can '
                                 'run MPF in software-only "virtual" mode by using '
                                 'the -x command like option for now instead.') from import_error

        self.pdbconfig = None
        self.pinproc = pinproc
        self.log = None
        self.hw_switch_rules = {}
        self.version = None
        self.revision = None
        self.hardware_version = None
        self.dipswitches = None
        self.event_task = None
        self.proc_thread = None
        self.proc_process = None
        self.proc_process_instance = None
        self._commands_running = 0
        self.config = {}
        self.pdled_state = defaultdict(PdLedStatus)

        self.machine_type = pinproc.normalize_machine_type(
            self.machine.config['hardware']['driverboards'])
Example #2
0
 def __init__(self, machine_type):
     super(GameController, self).__init__()
     self.logger = logging.getLogger('game')
     self.machine_type = pinproc.normalize_machine_type(machine_type)
     self.proc = self.create_pinproc()
     self.proc.reset(1)
     self.modes = ModeQueue(self)
     self.t0 = time.time()
Example #3
0
	def __init__(self, machine_type):
		super(GameController, self).__init__()
		self.logger = logging.getLogger('game')
		self.machine_type = pinproc.normalize_machine_type(machine_type)
		self.proc = self.create_pinproc()
		self.proc.reset(1)
		self.modes = ModeQueue(self)
		self.t0 = time.time()
Example #4
0
def tool_run(options, args):
    if len(args) != 1:
        return False

    if options.machine_type:
        machine_type = pinproc.normalize_machine_type(options.machine_type)
    else:
        machine_type = pinproc.MachineTypeCustom

    game = PlayerGame(machine_type=machine_type)

    game.play(filename=args[0], repeat=options.repeat)

    game.run_loop()
    del game
    return True
Example #5
0
def tool_run(options, args):
    if len(args) != 1:
        return False

    if options.machine_type:
        machine_type = pinproc.normalize_machine_type(options.machine_type)
    else:
        machine_type = pinproc.MachineTypeCustom

    game = PlayerGame(machine_type=machine_type, width=options.size[0], height=options.size[1])

    game.play(filename=args[0], repeat=options.repeat, hold=options.hold, frametime=options.frametime)

    game.run_loop()
    del game
    return True
def tool_run(options, args):
	if len(args) != 1:
		return False
	
	if options.machine_type:
		machine_type = pinproc.normalize_machine_type(options.machine_type)
	else:
		machine_type = pinproc.MachineTypeCustom
	
	game = PlayerGame(machine_type=machine_type,width=options.size[0], height=options.size[1])

	game.play(filename=args[0], repeat=options.repeat, hold=options.hold, frametime = options.frametime)
	
	game.run_loop()
	del game
	return True
Example #7
0
def tool_run(options, args):
	if len(args) != 1:
		return False
	
	if options.machine_type:
		machine_type = pinproc.normalize_machine_type(options.machine_type)
	else:
		machine_type = pinproc.MachineTypeCustom
	
	game = PlayerGame(machine_type=machine_type)
	
	game.play(filename=args[0], repeat=options.repeat)
	
	game.run_loop()
	del game
	return True
Example #8
0
    def __init__(self, machine):
        """Make sure pinproc was loaded."""
        super().__init__(machine)

        if not pinproc_imported:
            raise AssertionError(
                'Could not import "pinproc". Most likely you do not '
                'have libpinproc and/or pypinproc installed. You can '
                'run MPF in software-only "virtual" mode by using '
                'the -x command like option for now instead.')

        self.pinproc = pinproc
        self.proc = None
        self.log = None
        self.hw_switch_rules = {}

        self.machine_type = pinproc.normalize_machine_type(
            self.machine.config['hardware']['driverboards'])
Example #9
0
    def __init__(self):
        """Initialize platform."""
        self.proc = pinproc.PinPROC(pinproc.normalize_machine_type('pdb'))
        self.proc.reset(1)

        # reset all drivers to off
        for i in range(0, 255):
            state = {'driverNum': i,
                     'outputDriveTime': 0,
                     'polarity': True,
                     'state': False,
                     'waitForFirstTimeSlot': False,
                     'timeslots': 0,
                     'patterOnTime': 0,
                     'patterOffTime': 0,
                     'patterEnable': False,
                     'futureEnable': False}

            self.proc.driver_update_state(state)

        # some magic stuff we don't understand but it has to be this way
        for group_ctr in range(0, 4):
            self.proc.driver_update_group_config(
                group_ctr,
                0,
                group_ctr,
                0,
                0,
                False,
                True,
                True,
                True)

        # enable banks for boards 0-7
        for bank_num in range(0, 16):
            self.proc.driver_update_group_config(
                bank_num + 4,
                0,
                bank_num,
                0,
                0,
                False,
                True,
                True,
                True)

        self.proc.driver_update_global_config(
                                           False,
                                           True,  # Polarity
                                           False,  # N/A
                                           False,  # N/A
                                           1,  # N/A
                                           0,
                                           0,
                                           False,  # Active low rows? No
                                           False,  # N/A
                                           False,  # Stern? No
                                           False,  # Reset watchdog trigger
                                           True,  # Enable watchdog
                                           1000)

        self.proc.driver_update_global_config(
                                           True,
                                           True,  # Polarity
                                           False,  # N/A
                                           False,  # N/A
                                           1,  # N/A
                                           0,
                                           0,
                                           False,  # Active low rows? No
                                           False,  # N/A
                                           False,  # Stern? No
                                           False,  # Reset watchdog trigger
                                           True,  # Enable watchdog
                                           1000)
        self.callbacks = {}     # type: Dict[str:callable]
Example #10
0
def machine_type_from_yaml(config_path):
    config = _yaml.load(open(config_path, "r"))
    machine_type = config["PRGame"]["machineType"]
    return _pinproc.normalize_machine_type(machine_type)
Example #11
0
def machine_type_from_yaml(config_path):
    config = _yaml.load(open(config_path, 'r'))
    machine_type = config['PRGame']['machineType']
    return _pinproc.normalize_machine_type(machine_type)
Example #12
0
import pinproc

proc = pinproc.PinPROC(pinproc.normalize_machine_type('pdb'))

for switch, state in enumerate(proc.switch_get_states()):

    if not switch % 16:
        print('')
        print('SW-16 Board Address {0}'.format(switch / 16))

    print('Switch {0} State {1}'.format(switch, state))
def machine_type_from_json(config_path):
	config = _json.load(open(config_path, 'r'))
	machine_type = config['PRGame']['machineType']
	return _pinproc.normalize_machine_type(machine_type)
Example #14
0
File: p3_roc.py Project: jherrm/mpf
    def __init__(self, machine):
        super(HardwarePlatform, self).__init__(machine)
        self.log = logging.getLogger("P3-ROC")
        self.log.debug("Configuring P3-ROC hardware.")

        if not pinproc_imported:
            self.log.error(
                'Could not import "pinproc". Most likely you do not '
                "have libpinproc and/or pypinproc installed. You can"
                ' run MPF in software-only "virtual" mode by using '
                "the -x command like option for now instead."
            )
            sys.exit()

        # ----------------------------------------------------------------------
        # Platform-specific hardware features. WARNING: Do not edit these. They
        # are based on what the P3-ROC hardware can and cannot do.
        self.features["max_pulse"] = 255
        self.features["hw_timer"] = False
        self.features["hw_rule_coil_delay"] = False
        self.features["variable_recycle_time"] = False
        self.features["variable_debounce_time"] = False
        self.features["hw_enable_auto_disable"] = False
        self.features["hw_led_fade"] = True
        # todo need to add differences between patter and pulsed_patter

        # Make the platform features available to everyone
        self.machine.config["platform"] = self.features
        # ----------------------------------------------------------------------

        self.machine_type = pinproc.normalize_machine_type(self.machine.config["hardware"]["driverboards"])

        # Connect to the P3-ROC. Keep trying if it doesn't work the first time.

        self.proc = None

        self.log.info("Connecting to P3-ROC")

        while not self.proc:
            try:
                self.proc = pinproc.PinPROC(self.machine_type)
                self.proc.reset(1)
            except IOError:
                print "Retrying..."

        self.log.info("Successfully connected to P3-ROC")

        """
        Since the P3-ROC has no Aux port, this code will break it.
        # Clear out the default program for the aux port since we might need it
        # for a 9th column. Details:
        # http://www.pinballcontrollers.com/forum/index.php?topic=1360
        commands = []
        commands += [pinproc.aux_command_disable()]

        for i in range(1, 255):
            commands += [pinproc.aux_command_jump(0)]

        self.proc.aux_send_commands(0, commands)
        # End of the clear out the default program for the aux port.
        """

        # Because PDBs can be configured in many different ways, we need to
        # traverse the YAML settings to see how many PDBs are being used.
        # Then we can configure the P3-ROC appropriately to use those PDBs.
        # Only then can we relate the YAML coil/light #'s to P3-ROC numbers for
        # the collections.

        self.log.debug("Configuring P3-ROC for PDBs (P-ROC driver boards).")
        self.pdbconfig = PDBConfig(self.proc, self.machine.config)

        self.polarity = (
            self.machine_type == pinproc.MachineTypeSternWhitestar
            or self.machine_type == pinproc.MachineTypeSternSAM
            or self.machine_type == pinproc.MachineTypePDB
        )