def test_light_factory(self): config = { 'odd_rgb': dict(r=4, g=4, b=4), 'even_rgb': dict(r=4, g=4, b=4) } for clazz in LightingEffect.inheritors(): if clazz.model is None: continue config['model'] = clazz.model effect = LightingEffect.factory(config) self.assertIsInstance(effect, LightingEffect)
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 set_lighting_controller(self, *args): if len(args) > 0: if args[0] in ('static', 'alternating', 'rgb_spectrum', 'spinning_rgb_spectrum', 'temperature'): fc = LightingEffect.factory(*args) self.daemon.lighting_manager.set_model(fc) return "success" return "argument 0 must be in [static|alternating|rgb_spectrum]"
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
from linux_thermaltake_rgb.controllers import ThermaltakeController from linux_thermaltake_rgb.fan_manager import FanModel from linux_thermaltake_rgb.daemon.config import Config from linux_thermaltake_rgb.lighting_manager import LightingEffect from linux_thermaltake_rgb import devices, LOGGER from linux_thermaltake_rgb.fan_manager import FanManager from linux_thermaltake_rgb.devices import ThermaltakeDevice from linux_thermaltake_rgb.globals import RGB import time logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format='%(message)s') self_config = Config() self_lighting_manager = LightingEffect.factory(self_config.lighting_manager) self_fan_manager = None self_attached_devices = {} self_controllers = {} self_attached_devices = {} 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(): dev = ThermaltakeDevice.factory(model, self_controllers[controller['unit']], id) self_controllers[controller['unit']].attach_device(id, dev)