def set_sources(self, dbusmonitor, settings, dbusservice): SystemCalcDelegate.set_sources(self, dbusmonitor, settings, dbusservice) self._buzzer_on = False self._timer = None # Find GPIO buzzer gpio_paths = sc_utils.gpio_paths(BuzzerControl.GPIO_BUZZER_PATH) self._gpio_path = None if len(gpio_paths) > 0: self._gpio_path = os.path.join(gpio_paths[0], 'value') logging.info('GPIO buzzer found: {}'.format(self._gpio_path)) # Find PWM buzzer self._pwm_frequency = None try: pwm_frequency = sc_utils.gpio_paths(BuzzerControl.PWM_BUZZER_PATH) if len(pwm_frequency) > 0: self._pwm_frequency = int(pwm_frequency[0]) logging.info('PWM buzzer found @ frequency: {}'.format(self._pwm_frequency)) except ValueError: logging.error('Parsing of PWM buzzer settings at %s failed', BuzzerControl.PWM_BUZZER_PATH) if self._gpio_path == None and self._pwm_frequency == None: logging.info('No buzzer found') return self._dbusservice.add_path('/Buzzer/State', value=0, writeable=True, onchangecallback=lambda p,v: exit_on_error(self._on_buzzer_state_changed, v)) # Reset the buzzer so the buzzer state equals the D-Bus value. It will also silence the buzzer after # a restart of the service/system. self._set_buzzer(False)
def set_sources(self, dbusmonitor, settings, dbusservice): SystemCalcDelegate.set_sources(self, dbusmonitor, settings, dbusservice) if os.path.exists('/dev/gpio'): relays = sorted(glob('/dev/gpio/relay_*')) else: # FIXME When the CCGX grows /dev/gpio, we can kill this. relays = gpio_paths(RelayState.RELAY_PATH) if len(relays) == 0: logging.info('No relays found') return i = 0 for r in relays: path = os.path.join(r, 'value') dbus_path = '/Relay/{}/State'.format(i) self._relays[dbus_path] = path self._dbusservice.add_path( dbus_path, value=None, writeable=True, onchangecallback=self._on_relay_state_changed) i += 1 logging.info('Relays found: {}'.format(', '.join( self._relays.values()))) gobject.idle_add(exit_on_error, lambda: not self._update_relay_state()) gobject.timeout_add(5000, exit_on_error, self._update_relay_state)
def set_sources(self, dbusmonitor, settings, dbusservice): SystemCalcDelegate.set_sources(self, dbusmonitor, settings, dbusservice) # Find GPIO buzzer gpio_paths = sc_utils.gpio_paths(BuzzerControl.GPIO_BUZZER_PATH) if len(gpio_paths) > 0: self._gpio_path = os.path.join(gpio_paths[0], 'value') logging.info('GPIO buzzer found: {}'.format(self._gpio_path)) # Find PWM buzzer self._pwm_frequency = None try: pwm_frequency = sc_utils.gpio_paths(BuzzerControl.PWM_BUZZER_PATH) if len(pwm_frequency) > 0: self._pwm_frequency = int(pwm_frequency[0]) logging.info('PWM buzzer found @ frequency: {}'.format(self._pwm_frequency)) except ValueError: logging.error('Parsing of PWM buzzer settings at %s failed', BuzzerControl.PWM_BUZZER_PATH) if self._gpio_path is None and self._pwm_frequency is None: logging.info('No buzzer found') return self._dbusservice.add_path('/Buzzer/State', value=0, writeable=True, onchangecallback=lambda p, v: exit_on_error(self._on_buzzer_state_changed, v)) # Reset the buzzer so the buzzer state equals the D-Bus value. It will also silence the buzzer after # a restart of the service/system. self._set_buzzer(False)
def set_sources(self, dbusmonitor, settings, dbusservice): SystemCalcDelegate.set_sources(self, dbusmonitor, settings, dbusservice) relays = sc_utils.gpio_paths('/etc/venus/relays') if len(relays) == 0: logging.info('No relays found') return self._relays = {} i = 0 for r in relays: path = os.path.join(r, 'value') dbus_path = '/Relay/{}/State'.format(i) self._relays[dbus_path] = path self._dbusservice.add_path(dbus_path, value=None, writeable=True, onchangecallback=self._on_relay_state_changed) i += 1 logging.info('Relays found: {}'.format(', '.join(self._relays.values()))) gobject.idle_add(exit_on_error, lambda: not self._update_relay_state()) gobject.timeout_add(5000, exit_on_error, self._update_relay_state)
def set_sources(self, dbusmonitor, settings, dbusservice): SystemCalcDelegate.set_sources(self, dbusmonitor, settings, dbusservice) if os.path.exists('/dev/gpio'): relays = sorted(glob('/dev/gpio/relay_*')) else: # FIXME When the CCGX grows /dev/gpio, we can kill this. relays = gpio_paths(RelayState.RELAY_PATH) if len(relays) == 0: logging.info('No relays found') return i = 0 for r in relays: path = os.path.join(r, 'value') dbus_path = '/Relay/{}/State'.format(i) self._relays[dbus_path] = path self._dbusservice.add_path(dbus_path, value=None, writeable=True, onchangecallback=self._on_relay_state_changed) i += 1 logging.info('Relays found: {}'.format(', '.join(self._relays.values()))) gobject.idle_add(exit_on_error, lambda: not self._update_relay_state()) gobject.timeout_add(5000, exit_on_error, self._update_relay_state)