Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move power cycling to scos-sensor #58

Merged
merged 10 commits into from
Mar 13, 2024
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ classifiers = [
dependencies = [
"environs>=9.5.0",
"tekrsa-api-wrap>=1.3.2",
"scos_actions @ git+https://github.com/NTIA/[email protected].0",
"scos_actions @ git+https://github.com/NTIA/[email protected].1",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/scos_tekrsa/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.0.1"
__version__ = "5.0.2"
39 changes: 22 additions & 17 deletions src/scos_tekrsa/hardware/tekrsa_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
sigan_cal: Calibration = None,
switches: Optional[Dict[str, WebRelay]] = None,
):

try:
super().__init__(sensor_cal, sigan_cal, switches)
logger.debug("Initializing Tektronix RSA Signal Analyzer")
Expand Down Expand Up @@ -51,13 +52,23 @@ def __init__(
self.sensor_calibration_data = None
self.sigan_calibration_data = None
self._capture_time = None
self._reference_level = None
self._frequency = None
self._iq_bandwidth = None
self._sample_rate = None
self._attenuation = None
self._preamp_enable = None
self._api_version = None
self._firmware_version = None
self.max_iq_bandwidth = None
self.min_iq_bandwidth = None
self.overload = None
self.connect()

except Exception as error:
logger.error(
f"Unable to initialize sigan: {error}.\nAttempting to power cycle and reconnect..."
)
self.power_cycle_and_connect()
except BaseException as error:
logger.error(f"Unable to initialize sigan: {error}.")
self._is_available = False
self._model = "NONE: Failed to connect to TekRSA"

def get_constraints(self):
self.min_frequency = self.rsa.CONFIG_GetMinCenterFreq()
Expand All @@ -78,23 +89,17 @@ def connect(self):
self.rsa = MockRSA(randomize_values=random)
else:
try:
# Load API wrapper
logger.debug("Loading RSA API wrapper")
import rsa_api
except ImportError as import_error:
logger.exception("API Wrapper not loaded - disabling signal analyzer.")
self._is_available = False
raise import_error
try:
logger.debug("Initializing ")
self.rsa = rsa_api.RSA()
# Connect to device using API wrapper
self.rsa.DEVICE_SearchAndConnect()
except Exception as e:
self._is_available = False
self._model = "NONE: Failed to connect to TekRSA"
logger.exception("Unable to connect to TEKRSA")
raise e
raise import_error
logger.debug("Initializing ")
self.rsa = rsa_api.RSA()
# Connect to device using API wrapper
self.rsa.DEVICE_SearchAndConnect()

# Finish setup with either real or Mock RSA device
self._model = self.rsa.DEVICE_GetNomenclature()
self._firmware_version = self.rsa.DEVICE_GetFWVersion()
Expand Down
Loading