Esempio n. 1
0
class ConnectionComponent(BaseComponent):
    counter = 0
    # Dictionary linking connection types with icons
    icons = {
        "plus": get_content_path() / "icons/plus_conn.png",
        "minus": get_content_path() / "icons/minus_conn.png",
        "regular": get_content_path() / "icons/regular_conn.png",
    }
    colors = {"plus": [1, 0, 0], "minus": [0, 0, 1], "regular": [0, 1, 0]}

    def __init__(self,
                 type=None,
                 left_connection=None,
                 right_connection=None,
                 *args,
                 **kwargs):
        super().__init__(*args, **kwargs)
        self.name = "Connection"
        self.icon_route = get_content_path() / "icons/resistor.png"
        self.id = ConnectionComponent.counter
        self.type = type
        self.left_connection = left_connection
        self.right_connection = right_connection
        self.led_color = "green"
        ConnectionComponent.counter += 1
 def __init__(self,
              value=None,
              drop_event=None,
              left_connection=None,
              right_connection=None,
              *args,
              **kwargs):
     self.board = None
     self.name = "default_name"
     self.drop_event = drop_event
     self.icon_route = get_content_path()
     self.value = value
     self.unit = "ohm"
     self.short_name = "R"
     self.id = BaseComponent.counter
     self.global_id = BaseComponent.counter
     self.element_length = 3
     self.left_connection_id = None
     self.right_connection_id = None
     if self.drop_event:
         BaseComponent.counter += 1
     Components.components[self.global_id] = self
     self.left_pin = [None, None]
     self.right_pin = [None, None]
     self.connection_loop = False
     self.type = None
     self.left_connection = left_connection
     self.right_connection = right_connection
     self.led_color = config.component_dict.resistor.led_color if config.component_dict.resistor.led_color else [
         1, 0, 0
     ]
 def __init__(self, value=config.component_dict.inductor.default_value, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.name = config.component_dict.inductor.default_name
     self.icon_route = get_content_path() / "icons/inductor.png"
     self.id = InductorComponent.counter
     self.value = value
     self.unit = config.component_dict.inductor.default_unit
     self.short_name = config.component_dict.inductor.default_shortname
     self.led_color = config.component_dict.inductor.led_color
     if self.drop_event:
         InductorComponent.counter += 1
Esempio n. 4
0
 def __init__(self,
              value=config.component_dict.battery.default_value,
              *args,
              **kwargs):
     super().__init__(*args, **kwargs)
     self.name = config.component_dict.battery.default_name
     self.icon_route = get_content_path() / "icons/battery.png"
     self.id = BatteryComponent.counter
     self.value = value
     self.unit = config.component_dict.battery.default_unit
     self.short_name = config.component_dict.battery.default_shortname
     if self.drop_event:
         BatteryComponent.counter += 1
Esempio n. 5
0
 def __init__(self,
              type=None,
              left_connection=None,
              right_connection=None,
              *args,
              **kwargs):
     super().__init__(*args, **kwargs)
     self.name = "Connection"
     self.icon_route = get_content_path() / "icons/resistor.png"
     self.id = ConnectionComponent.counter
     self.type = type
     self.left_connection = left_connection
     self.right_connection = right_connection
     self.led_color = "green"
     ConnectionComponent.counter += 1
Esempio n. 6
0
    def init_ui(self):
        # self.windowTitleChanged.connect(self.onWindowTitleChange)
        # self.windowTitleChanged.connect(lambda x: self.my_custom_fn(x, 25))
        content_pathlib = get_content_path()
        self.setWindowTitle("Entrenador electronico")
        self.content_widget = QtWidgets.QWidget()
        self.main_layout = QtWidgets.QHBoxLayout()
        self.resize(config.general.width, config.general.height)

        self.components_widget = ComponentsWidget()
        self.main_layout.addWidget(self.components_widget, 1)

        # for i in range(12):
        #     QtWidgets.QListWidgetItem(f'item {i}', self.components_widget)

        self.builder_widget = BuilderWidget()
        self.main_layout.addWidget(self.builder_widget, 3)

        # Sets-up the toolbar
        toolbar = QtWidgets.QToolBar("Start connection phase")
        self.addToolBar(toolbar)
        icon_path = content_pathlib / "icons/icon_connections.png"
        connection_phase_action = QtWidgets.QAction(
            QtGui.QIcon(os.path.relpath(icon_path)), "Connection phase", self)
        connection_phase_action.setStatusTip("Start connection phase")
        connection_phase_action.triggered.connect(self.connection_phase_window)
        toolbar.addAction(connection_phase_action)

        # Sets-up the statusbar
        self.setStatusBar(QtWidgets.QStatusBar(self))

        self.content_widget.setLayout(self.main_layout)
        self.setCentralWidget(self.content_widget)

        if config.general.led_system:
            self.led_mapper = LedMapper()
            self.led_mapper.lights_off()
        self.show()