Skip to content

Commit

Permalink
Merge pull request #58 from NTIA/RemoveRayInitialization
Browse files Browse the repository at this point in the history
Move power cycling to scos-sensor
  • Loading branch information
dboulware committed Mar 13, 2024
2 parents 36200ee + 369f14d commit 0d146b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
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/scos-actions@8.0.0",
"scos_actions @ git+https://github.com/NTIA/scos-actions@8.0.1",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/scos_tekrsa/__init__.py
@@ -1 +1 @@
__version__ = "5.0.1"
__version__ = "5.0.2"
39 changes: 22 additions & 17 deletions src/scos_tekrsa/hardware/tekrsa_sigan.py
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

0 comments on commit 0d146b4

Please sign in to comment.