diff --git a/src/scos_tekrsa/hardware/tekrsa_sigan.py b/src/scos_tekrsa/hardware/tekrsa_sigan.py index e45374d..c2a8fb1 100644 --- a/src/scos_tekrsa/hardware/tekrsa_sigan.py +++ b/src/scos_tekrsa/hardware/tekrsa_sigan.py @@ -92,18 +92,16 @@ def connect(self): self.rsa.DEVICE_SearchAndConnect() except Exception as e: self._is_available = False - self.device_name = "NONE: Failed to connect to TekRSA" + self._model = "NONE: Failed to connect to TekRSA" logger.exception("Unable to connect to TEKRSA") raise e # Finish setup with either real or Mock RSA device - self.device_name = self.rsa.DEVICE_GetNomenclature() + self._model = self.rsa.DEVICE_GetNomenclature() self._firmware_version = self.rsa.DEVICE_GetFWVersion() self._api_version = self.rsa.DEVICE_GetAPIVersion() self.get_constraints() logger.debug("Using the following Tektronix RSA device:") - logger.debug( - f"{self.device_name} ({self.min_frequency}-{self.max_frequency} Hz)" - ) + logger.debug(f"{self._model} ({self.min_frequency}-{self.max_frequency} Hz)") # Populate instance variables for parameters on connect self._preamp_enable = self.preamp_enable self._attenuation = self.attenuation @@ -215,7 +213,7 @@ def reference_level(self, reference_level): @property def attenuation(self): - if self.device_name not in ["RSA306B", "RSA306"]: + if self._model not in ["RSA306B", "RSA306"]: # API returns attenuation as negative value. Convert to positive. self._attenuation = abs(self.rsa.CONFIG_GetRFAttenuator()) else: @@ -226,7 +224,7 @@ def attenuation(self): @attenuation.setter def attenuation(self, attenuation): """Set device attenuation, in dB, for RSA 500/600 series devices""" - if self.device_name not in ["RSA306B", "RSA306"]: + if self._model not in ["RSA306B", "RSA306"]: if self.min_attenuation <= abs(attenuation) <= self.max_attenuation: self.rsa.CONFIG_SetAutoAttenuationEnable(False) # API requires attenuation set as a negative number. Convert to negative. @@ -245,7 +243,7 @@ def attenuation(self, attenuation): @property def preamp_enable(self): - if self.device_name not in ["RSA306B", "RSA306"]: + if self._model not in ["RSA306B", "RSA306"]: self._preamp_enable = self.rsa.CONFIG_GetRFPreampEnable() else: logger.debug("Tektronix RSA 300 series device has no built-in preamp.") @@ -254,7 +252,7 @@ def preamp_enable(self): @preamp_enable.setter def preamp_enable(self, preamp_enable): - if self.device_name not in ["RSA306B", "RSA306"]: + if self._model not in ["RSA306B", "RSA306"]: if self.preamp_enable != preamp_enable: logger.debug("Switching preamp to " + str(preamp_enable)) self.rsa.CONFIG_SetRFPreampEnable(preamp_enable) @@ -386,7 +384,7 @@ def acquire_time_domain_samples( "sample_rate": self.rsa.IQSTREAM_GetAcqParameters()[1], "capture_time": self._capture_time, } - if self.device_name not in ["RSA306B", "RSA306"]: + if self._model not in ["RSA306B", "RSA306"]: measurement_result["attenuation"] = self.attenuation measurement_result["preamp_enable"] = self.preamp_enable return measurement_result diff --git a/tests/test_tekrsa_sigan.py b/tests/test_tekrsa_sigan.py index e80cc92..c464f89 100644 --- a/tests/test_tekrsa_sigan.py +++ b/tests/test_tekrsa_sigan.py @@ -133,12 +133,12 @@ def test_attenuation(self): setattr(self.rx, "attenuation", self.rx.max_attenuation + 1) # Test handling for RSA without manual attenuator - old_dev_name = self.rx.device_name - setattr(self.rx, "device_name", "RSA306B") + old_dev_name = self.rx.model + setattr(self.rx, "model", "RSA306B") assert self.rx.attenuation is None setattr(self.rx, "attenuation", 50) assert self.rx.attenuation is None - setattr(self.rx, "device_name", old_dev_name) + setattr(self.rx, "model", old_dev_name) def test_preamp_enable(self): assert isinstance(self.rx.preamp_enable, bool) @@ -149,12 +149,12 @@ def test_preamp_enable(self): assert self.rx.preamp_enable == True # Test handling for RSA without preamp - old_dev_name = self.rx.device_name - setattr(self.rx, "device_name", "RSA306B") + old_dev_name = self.rx.model + setattr(self.rx, "model", "RSA306B") assert self.rx.preamp_enable is None setattr(self.rx, "preamp_enable", False) assert self.rx.preamp_enable is None - setattr(self.rx, "device_name", old_dev_name) + setattr(self.rx, "model", old_dev_name) def test_acquire_samples_retry(self): # Not enough retries = acquisition should fail @@ -193,8 +193,8 @@ def test_acquire_samples(self): assert isinstance(r["capture_time"], str) # Can't predict this value # Attenuation/preamp keys should not exist for RSA30X - old_dev_name = self.rx.device_name - setattr(self.rx, "device_name", "RSA306B") + old_dev_name = self.rx.model + setattr(self.rx, "model", "RSA306B") r = self.rx.acquire_time_domain_samples( int(self.rx.iq_bandwidth * 0.001), cal_adjust=False ) @@ -202,7 +202,7 @@ def test_acquire_samples(self): _ = r["attenuation"] with pytest.raises(KeyError): _ = r["preamp_enable"] - setattr(self.rx, "device_name", old_dev_name) + setattr(self.rx, "model", old_dev_name) # Acquire n_samps resulting in integer number of milliseconds for duration_ms in [1, 2, 3, 7, 10]: