def _state_changed(self, state, changed): """ Emit signal and handle special cases where extra work is needed in response to a state change. """ # make sure resolution of center are the same as the device's tunning resolution center = float( np.round( state.center, -1 * int(np.log10(self._dut.properties.TUNING_RESOLUTION)))) state = SpecAState(state, center=center) if not state.sweeping(): # force span to correct value for the mode given if state.decimation > 1: span = (float(self._dut.properties.FULL_BW[state.rfe_mode()]) / state.decimation * self._dut.properties.DECIMATED_USABLE) else: span = self._dut.properties.USABLE_BW[state.rfe_mode()] state = SpecAState(state, span=span) changed = [x for x in changed if x != 'span'] if not self._state or span != self._state.span: changed.append('span') elif 'mode' in changed and 'span' not in changed: span = self._dut.properties.DEFAULT_SPECA_SPAN state = SpecAState(state, span=span) changed.append('span') self._state = state # start capture loop again when user switches output path # back to the internal digitizer XXX: very WSA5000-specific if 'device_settings.iq_output_path' in changed: if state.device_settings.get('iq_output_path') == 'DIGITIZER': self.start_capture() elif state.device_settings.get('iq_output_path') == 'CONNECTOR': if state.sweeping(): state.mode = self._dut.properties.RFE_MODES[0] if self._recording_file: self._dut.inject_recording_state(state.to_json_object()) self.state_change.emit(state, changed)
def apply_settings(self, **kwargs): """ Apply state settings and trigger a state change event. :param kwargs: keyword arguments of SpecAState attributes """ if self._state is None: logger.warn('apply_settings with _state == None: %r' % kwargs) return state = SpecAState(self._state, **kwargs) self._state_changed(state, kwargs.keys())
def apply_device_settings(self, **kwargs): """ Apply device-specific settings and trigger a state change event. :param kwargs: keyword arguments of SpecAState.device_settings """ device_settings = dict(self._state.device_settings, **kwargs) state = SpecAState(self._state, device_settings=device_settings) if device_settings.get( 'iq_output_path') == 'CONNECTOR' or 'trigger' in kwargs: self._capture_device.configure_device(device_settings) changed = ['device_settings.%s' % s for s in kwargs] self._state_changed(state, changed)