Ejemplo n.º 1
0
    def __init__(self):
        LOGGER.info('initializing thermaltake rgb daemon')

        LOGGER.debug('loading config')
        self.config = Config()

        LOGGER.debug('creating fan manager')
        fan_model = FanModel.factory(self.config.fan_manager)
        self.fan_manager = FanManager(fan_model)

        LOGGER.debug('creating lighting manager')
        self.lighting_manager = LightingEffect.factory(
            self.config.lighting_manager)

        self.attached_devices = {}
        self.controllers = {}

        LOGGER.debug('configuring controllers')
        for controller in self.config.controllers:
            self.controllers[
                controller['unit']] = ThermaltakeController.factory(
                    controller['type'], controller.get('unit'))
            for id, model in controller['devices'].items():
                LOGGER.debug(' configuring devices for controller %s: %s',
                             controller['type'], controller.get('unit'))
                dev = ThermaltakeDevice.factory(
                    model, self.controllers[controller['unit']], id)
                self.controllers[controller['unit']].attach_device(id, dev)
                self.register_attached_device(controller['unit'], id, dev)

        self._continue = False
Ejemplo n.º 2
0
    def __init__(self):
        self.config = Config()

        fan_model = FanModel.factory(self.config.fan_manager)
        self.fan_manager = FanManager(fan_model)

        self.lighting_manager = LightingEffect.factory(self.config.lighting_manager)

        self.dbus_service = ThermaltakeDbusService(self)

        self.attached_devices = {}
        self.controllers = {}

        for controller in self.config.controllers:
            self.controllers[controller['unit']] = controller_factory(controller['type'], controller['unit'])
            for id, model in controller['devices'].items():
                dev = ThermaltakeDevice.factory(model, self.controllers[controller['unit']], id)
                self.controllers[controller['unit']].attach_device(id, dev)
                self.register_attached_device(controller['unit'], id, dev)

        self._thread = Thread(target=self._main_loop)

        self._continue = False
Ejemplo n.º 3
0
class ThermaltakeDaemon:
    def __init__(self):
        self.config = Config()

        fan_model = FanModel.factory(self.config.fan_manager)
        self.fan_manager = FanManager(fan_model)

        self.lighting_manager = LightingEffect.factory(self.config.lighting_manager)

        self.dbus_service = ThermaltakeDbusService(self)

        self.attached_devices = {}
        self.controllers = {}

        for controller in self.config.controllers:
            self.controllers[controller['unit']] = controller_factory(controller['type'], controller['unit'])
            for id, model in controller['devices'].items():
                dev = ThermaltakeDevice.factory(model, self.controllers[controller['unit']], id)
                self.controllers[controller['unit']].attach_device(id, dev)
                self.register_attached_device(controller['unit'], id, dev)

        self._thread = Thread(target=self._main_loop)

        self._continue = False

    def register_attached_device(self, unit, port, dev=None):
        if isinstance(dev, devices.ThermaltakeFanDevice):
            self.fan_manager.attach_device(dev)
        if isinstance(dev, devices.ThermaltakeRGBDevice):
            self.lighting_manager.attach_device(dev)

        self.attached_devices[f'{unit}:{port}'] = dev

    def run(self):
        self._continue = True
        self._thread.start()
        self.lighting_manager.start()
        self.fan_manager.start()
        self.dbus_service.start()

    def stop(self):
        self._continue = False
        self.lighting_manager.stop()
        self.fan_manager.stop()
        self._thread.join()
        self.dbus_service.stop()
        for controller in self.controllers.values():
            controller.save_profile()

    def _main_loop(self):
        while self._continue:
            time.sleep(1)
Ejemplo n.º 4
0
class ThermaltakeDaemon:
    def __init__(self):
        LOGGER.info('initializing thermaltake rgb daemon')

        LOGGER.debug('loading config')
        self.config = Config()

        LOGGER.debug('creating fan manager')
        fan_model = FanModel.factory(self.config.fan_manager)
        self.fan_manager = FanManager(fan_model)

        LOGGER.debug('creating lighting manager')
        self.lighting_manager = LightingEffect.factory(
            self.config.lighting_manager)

        self.attached_devices = {}
        self.controllers = {}

        LOGGER.debug('configuring controllers')
        for controller in self.config.controllers:
            self.controllers[
                controller['unit']] = ThermaltakeController.factory(
                    controller['type'], controller.get('unit'))
            for id, model in controller['devices'].items():
                LOGGER.debug(' configuring devices for controller %s: %s',
                             controller['type'], controller.get('unit'))
                dev = ThermaltakeDevice.factory(
                    model, self.controllers[controller['unit']], id)
                self.controllers[controller['unit']].attach_device(id, dev)
                self.register_attached_device(controller['unit'], id, dev)

        self._continue = False

    def register_attached_device(self, unit, port, dev=None):
        if isinstance(dev, devices.ThermaltakeFanDevice):
            LOGGER.debug('  registering %s with fan manager', dev.model)
            self.fan_manager.attach_device(dev)
        if isinstance(dev, devices.ThermaltakeRGBDevice):
            LOGGER.debug('  registering %s with lighting manager', dev.model)
            self.lighting_manager.attach_device(dev)

        self.attached_devices[f'{unit}:{port}'] = dev

    def run(self):
        self._continue = True
        LOGGER.debug('starting lighting manager')
        self.lighting_manager.start()
        LOGGER.debug('starting fan manager')
        self.fan_manager.start()

    def stop(self):
        LOGGER.debug('recieved exit command')
        self._continue = False
        LOGGER.debug('stopping lighting manager')
        self.lighting_manager.stop()
        LOGGER.debug('stopping fan manager')
        self.fan_manager.stop()
        LOGGER.debug('saving controller profiles')
        for controller in self.controllers.values():
            controller.save_profile()

    def _main_loop(self):
        while self._continue:
            time.sleep(1)