def netlist_from_config(cls, config): for compname, compconfig in config.items(): modname = "components." + compname classname = "".join(word[0].upper() + word[1:] for word in compname.split("_")) #output heading for each part type in blue ct.print_heading("Initializing component: {} (import {} from {})".format(compname, classname, modname)) if compconfig is None: ct.print_warning("Component list for {} is empty".format(compname)) continue try: imported = __import__("components." + compname, globals(), locals(), [classname]) except Exception as e: ct.format_exception(e, "Import failed") continue try: cls = getattr(imported, classname) except Exception as e: ct.format_exception(e, "getattr failed:") continue try: cls.boot(compconfig) ct.print_info("booted {}".format(cls.__name__)) except Exception as e: ct.format_exception(e, "Class boot failed:") raise e continue cls.first_eval_all()
def __init__(self, board, network, scheduler): self.board = board self.scheduler = scheduler self.parts_initialized = False self.mac = network.mac self.data = {} self.mine = None self.version = "0.8.0" self.listeners = [] self.read_cache() # if (type(self.mine) is dict and "parts" in self.mine): # ct.print_heading("initializing from cache") # Part.init_parts(board, scheduler, self.mine["parts"]) Component.setup_services(board, scheduler) if (type(self.mine) is dict and "components" in self.mine): ct.print_heading("initializing from cache") Component.netlist_from_config(self.mine["components"]) Component.print_netlist() MQTT.subscribe(config_topic_base + self.mac + "/config", self.on_mqtt)
def print_signals(cls): for sig in Signal.by_name.values(): ct.print_heading(str(sig)) for fanout in sig.fanouts: ct.print_info(fanout.name)
def print_components(cls): for name, comp in Component.by_name.items(): ct.print_heading("component {} of type {}".format(name, type(comp))) ct.print_info(str(comp))