Beispiel #1
0
class Command(object):
    """Performs hardware operations."""
    def __init__(self, mpf_path, machine_path, args):
        """Parse args."""
        self.mpf_path = mpf_path
        self.machine_path = machine_path
        self.args = args
        self.mpf = MachineController(
            self.mpf_path, self.machine_path, {
                "bcp": False,
                "no_load_cache": False,
                "mpfconfigfile": os.path.join(mpf_path, "mpfconfig.yaml"),
                "configfile": ["config"],
                "create_config_cache": False,
                "force_platform": False,
                "text_ui": False
            })
        self.mpf.initialise_mpf()

    def scan(self):
        """Scan hardware."""
        for name, platform in self.mpf.hardware_platforms.items():
            print("{}:".format(name))
            print(platform.get_info_string())
            print("---------")
Beispiel #2
0
class Command:

    """Runs the mpf game."""

    # pylint: disable-msg=too-many-locals,too-many-statements
    def __init__(self, mpf_path, machine_path, args):
        """Generate wiring for game from MPL file."""
        del mpf_path
        self.machine = None
        self._sigint_count = 0

        parser = argparse.ArgumentParser(description='Generates wiring .yaml file')

        parser.add_argument("-c",
                            action="store", dest="configfile",
                            default="config.yaml", metavar='config_file',
                            help="The name of a config file to load. Default "
                                 "is "
                                 "config.yaml. Multiple files can be used "
                                 "via a comma-"
                                 "separated list (no spaces between)")

        self.args = parser.parse_args(args)
        self.args.configfile = Util.string_to_event_list(self.args.configfile)

        # To initialize and check machine, load it onto the virtual platform - we have to use the virtual platform
        # because it would be helpful to be able to calculate wiring before setting up physical hardware.
        self.args.__dict__["production"] = False
        self.args.__dict__["force_platform"] = "smart_virtual"
        self.args.__dict__["text_ui"] = False
        self.args.__dict__["bcp"] = False

        config_loader = YamlMultifileConfigLoader(machine_path, self.args.configfile,
                                                  False, False)

        config = config_loader.load_mpf_config()

        # print(config.get_machine_config())

        self.machine = MachineController(vars(self.args), config)
        self.machine.initialise_mpf()

        result = wire(self.machine)

        yaml = YAML()
        yaml.default_flow_style = False
        f = open("wiring.yaml", "w", encoding="utf-8")
        yaml.dump(result, f)
        f.close()