Beispiel #1
0
    def __init__(self, database: SqliteDatabase, view: MainView,
                 presenter: MainPresenter, builder: MainBuilder,
                 udev_interactor: UdevInteractor, *args: Any,
                 **kwargs: Any) -> None:
        _LOG.debug("init Application")
        GLib.set_application_name(_(APP_NAME))
        super().__init__(*args,
                         application_id=APP_ID,
                         flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
                         **kwargs)

        database.connect()
        database.create_tables(
            [SpeedProfile, SpeedStep, CurrentSpeedProfile, Setting])

        if SpeedProfile.select().count() == 0:
            load_db_default_data()

        self.add_main_option_entries(self._get_main_option_entries())
        self._view = view
        self._presenter = presenter
        self._presenter.application_quit = self.quit
        self._window: Optional[Gtk.ApplicationWindow] = None
        self._builder: Gtk.Builder = builder
        self._udev_interactor = udev_interactor
        self._start_hidden: bool = False
Beispiel #2
0
 def _select_speed_profile(self, profile_id: int,
                           channel: ChannelType) -> None:
     if profile_id == _ADD_NEW_PROFILE_INDEX:
         self.main_view.set_apply_button_enabled(channel, False)
         self.main_view.set_edit_button_enabled(channel, False)
         self.main_view.show_add_speed_profile_dialog(channel)
         self.main_view.refresh_chart(channel_to_reset=channel.value)
         self._edit_speed_profile_presenter.show_add(channel)
     else:
         profile: SpeedProfile = SpeedProfile.get(id=profile_id)
         self._profile_selected[profile.channel] = profile
         if profile.read_only:
             self.main_view.set_edit_button_enabled(channel, False)
         else:
             self.main_view.set_edit_button_enabled(channel, True)
         self.main_view.set_apply_button_enabled(channel, True)
         self.main_view.refresh_chart(profile)
Beispiel #3
0
def load_db_default_data() -> None:
    fan_silent = SpeedProfile.create(name="Silent",
                                     channel=ChannelType.FAN.value, read_only=True)
    fan_perf = SpeedProfile.create(name="Performance", channel=ChannelType.FAN.value, read_only=True)
    fan_fixed = SpeedProfile.create(name="Fixed", channel=ChannelType.FAN.value, single_step=True)
    pump_silent = SpeedProfile.create(name="Silent", channel=ChannelType.PUMP.value, read_only=True)
    pump_perf = SpeedProfile.create(name="Performance", channel=ChannelType.PUMP.value, read_only=True)
    pump_fixed = SpeedProfile.create(name="Fixed", channel=ChannelType.PUMP.value, single_step=True)

    # Fan Silent
    SpeedStep.create(profile=fan_silent.id, temperature=20, duty=25)
    SpeedStep.create(profile=fan_silent.id, temperature=35, duty=25)
    SpeedStep.create(profile=fan_silent.id, temperature=50, duty=55)
    SpeedStep.create(profile=fan_silent.id, temperature=60, duty=100)

    # Fan Performance
    SpeedStep.create(profile=fan_perf.id, temperature=20, duty=50)
    SpeedStep.create(profile=fan_perf.id, temperature=35, duty=50)
    SpeedStep.create(profile=fan_perf.id, temperature=60, duty=100)

    # Fan Fixed
    SpeedStep.create(profile=fan_fixed.id, temperature=20, duty=FAN_MIN_DUTY)

    # Pump Silent
    SpeedStep.create(profile=pump_silent.id, temperature=20, duty=60)
    SpeedStep.create(profile=pump_silent.id, temperature=35, duty=60)
    SpeedStep.create(profile=pump_silent.id, temperature=55, duty=100)
    SpeedStep.create(profile=pump_silent.id, temperature=60, duty=100)

    # Pump Performance
    SpeedStep.create(profile=pump_perf.id, temperature=20, duty=70)
    SpeedStep.create(profile=pump_perf.id, temperature=35, duty=70)
    SpeedStep.create(profile=pump_perf.id, temperature=40, duty=80)
    SpeedStep.create(profile=pump_perf.id, temperature=60, duty=100)

    # Pump Fixed
    SpeedStep.create(profile=pump_fixed.id, temperature=20, duty=PUMP_MIN_DUTY)
Beispiel #4
0
 def _get_profile_list(channel: ChannelType) -> List[Tuple[int, str]]:
     return [(p.id, p.name) for p in SpeedProfile.select().where(
         SpeedProfile.channel == channel.value)]
Beispiel #5
0
 def _get_profile_list(channel: ChannelType) -> List[Tuple[int, str]]:
     # pylint: disable=not-an-iterable
     return [(p.id, p.name) for p in SpeedProfile.select().where(
         SpeedProfile.channel == channel.value)]