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

Initialization and users app #267

Merged
merged 221 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 217 commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
f26bfba
Enable mock sensor. Set BASE_IMAGE to USRP. Update requirements for U…
dboulware Dec 5, 2023
32d0d79
debug scos_actions.
dboulware Dec 6, 2023
56d7434
debugging.
dboulware Dec 7, 2023
478ff00
scos-actions 7.0.1
dboulware Dec 7, 2023
dc85300
empty_calibration_params
dboulware Dec 7, 2023
27f1bab
don't use mock_sigan
dboulware Dec 7, 2023
b30e694
Update readme and add default sensor_calibration.json file.
dboulware Dec 11, 2023
22f5734
Update BASE_IMAGE and add link to readme.
dboulware Dec 11, 2023
5139b27
Rename default calibration file. Set DEFAULT_CALIBRATION_FILE variabl…
dboulware Jan 3, 2024
834e9dd
default cal file and update readme.
dboulware Jan 8, 2024
7c63bf2
sigan monitor
dboulware Jan 8, 2024
de81df7
move signal_analyzer_monitor to scos_actions.status
dboulware Jan 8, 2024
95b9743
typo fix.
dboulware Jan 8, 2024
598c098
print actions dir.
dboulware Jan 8, 2024
8a9a479
Set ACTIONS_DIR in all settings.
dboulware Jan 8, 2024
114ea89
Register actions in configs/actions.
dboulware Jan 8, 2024
9dd9201
Switch actions and tekrsa branches.
dboulware Jan 9, 2024
51e8986
scos_actions.core refactor.
dboulware Jan 9, 2024
3d59c77
discover action types, gps and sigan and ensure one sigan and actions…
dboulware Jan 11, 2024
3b2d892
delete faulty import.
dboulware Jan 11, 2024
d2c55b6
remove erroneous import.
dboulware Jan 11, 2024
403899b
sigan->signal_analyzer.
dboulware Jan 11, 2024
194a0a1
typo
dboulware Jan 12, 2024
5d88874
fix sigan detection.
dboulware Jan 12, 2024
ae5a1ee
fix setting sigan in actions.
dboulware Jan 12, 2024
629b199
remove scheduler signal_analyzer.
dboulware Jan 12, 2024
f74dc64
debugging
dboulware Jan 12, 2024
fcc8910
fix log message.
dboulware Jan 12, 2024
315b46d
Add SIGAN_MODULE and SIGAN_CLASS settings.
dboulware Jan 12, 2024
c62c282
Instantiate specified sigan and pass to scheduler.
dboulware Jan 12, 2024
4ba3080
remove action_registrar.
dboulware Jan 12, 2024
c9495ae
remove register_action
dboulware Jan 12, 2024
b1cd580
remove checking for sigan and gps from actions/__init__.py
dboulware Jan 12, 2024
f9cf7c2
import from actions in schedule.
dboulware Jan 12, 2024
45911e9
import environs in config.py
dboulware Jan 12, 2024
ec84466
fix logging error.
dboulware Jan 12, 2024
1592ea5
register sigan as status provider. Correct default sigan module.
dboulware Jan 12, 2024
549dd16
typo fix.
dboulware Jan 12, 2024
b57e87d
fix setting scheduler sigan.
dboulware Jan 12, 2024
d71762f
add initializatino package and create Sensor in gunicorn/config.py
dboulware Jan 13, 2024
50d61ad
add logging to settings. Fix actions_loader import.
dboulware Jan 13, 2024
cb61023
move action loading functions into settings.
dboulware Jan 13, 2024
2ea680b
uppercase settings ACTIONS.
dboulware Jan 13, 2024
5bdc21d
move initialization utilities.
dboulware Jan 13, 2024
fb1efc9
remove actions app from settings and don't import django setting in i…
dboulware Jan 13, 2024
fe0c73a
sync settings files.
dboulware Jan 13, 2024
65b5744
move capabilities into settings.
dboulware Jan 13, 2024
4d5d3cc
add missing capabilities in settings files.
dboulware Jan 13, 2024
87bf2e9
remove refs to scos_actions.capabilities
dboulware Jan 13, 2024
25185fd
syntax.
dboulware Jan 13, 2024
d0a5a23
import django settings in gunicorn/config.py
dboulware Jan 13, 2024
3fb91ff
remove migration and runtime settings. Make switch_configs_dir a Path.
dboulware Jan 13, 2024
7ec6df3
Initialize calibrations and pass to signal analyzer.
dboulware Jan 13, 2024
2c643dd
mark Calibrations as default or not.
dboulware Jan 13, 2024
af3f5dd
add status and signal analyzer registration handlers. Don't import ca…
dboulware Jan 13, 2024
6ff7994
register sigan.
dboulware Jan 13, 2024
3956cef
import logging.
dboulware Jan 13, 2024
3c1d1a4
import load_from_json
dboulware Jan 13, 2024
6e22f7a
pass if is_default into loading calibration from json.
dboulware Jan 14, 2024
d629cd5
fix register_sigan handler
dboulware Jan 14, 2024
3973c12
fix mistaken deletion
dboulware Jan 14, 2024
d1e5beb
fix loop to register switches.
dboulware Jan 14, 2024
15c4f77
send signal in config.
dboulware Jan 14, 2024
356e1f0
typo fix.
dboulware Jan 14, 2024
e8b6ecc
debugging.
dboulware Jan 14, 2024
11b5fe7
load preselector config from json.
dboulware Jan 14, 2024
b9a9d44
send signal in config. add type hints.
dboulware Jan 14, 2024
29bcd32
Replace scheduler signal_analyzer with sensor.
dboulware Jan 14, 2024
7a4d16c
correct ref to signal_analyzer in status.
dboulware Jan 14, 2024
17d27af
move status registration into initializatino methods.
dboulware Jan 14, 2024
16e571e
Add register sensor handler. Update registered sensors location when …
dboulware Jan 14, 2024
a1838e6
Fix sensor import in location handler.
dboulware Jan 14, 2024
ce50dc4
send register sensor signal.
dboulware Jan 14, 2024
1a8abb2
add sender to register sensor signal send.
dboulware Jan 14, 2024
1b46c91
If there is an active location in the database, use it over the senso…
dboulware Jan 14, 2024
bac837f
initialize location to None.
dboulware Jan 14, 2024
377a94c
Set description when saving location from sensor definition file.
dboulware Jan 14, 2024
603fc53
cleanup
dboulware Jan 14, 2024
ad179fc
log location handler. Correct comment.
dboulware Jan 14, 2024
fc3e6db
Remove actions app.
dboulware Jan 14, 2024
1b0258e
use description from sensor def file if saving loc to db.
dboulware Jan 15, 2024
19caf84
Move scos_actions imports so django is configured.
dboulware Jan 15, 2024
861c5d7
Place all initialization methods in intialization/__init__.py. Defer …
dboulware Jan 15, 2024
36ab6ce
don't set SENSOR_DEFINITION_HASH in settings.
dboulware Jan 15, 2024
db17975
missing import.
dboulware Jan 15, 2024
d04a825
Initialize actions, and capabilities in settings so they are there du…
dboulware Jan 15, 2024
9b5a8f3
remove invalid imports.
dboulware Jan 15, 2024
d6926fc
set sigan and sensor calibration file environment variables.
dboulware Jan 15, 2024
5f2275d
Set DEFAULT_CALIBRATION_FILE environment variable.
dboulware Jan 15, 2024
64df810
Fix env error
dboulware Jan 15, 2024
d28091a
set env vars as strings.
dboulware Jan 15, 2024
6be34cb
Fix handler tests. Sync sensor/wsgi with gunicorn/config.py
dboulware Jan 16, 2024
cba6b7b
use action_classes in plugins instead of action_types.
dboulware Jan 16, 2024
78ab76f
fix logger init.
dboulware Jan 16, 2024
51eb890
move action loading to actions app.
dboulware Jan 16, 2024
65ec944
load actions in actions app. load capabilities in capabilities. Impor…
dboulware Jan 16, 2024
0fb769d
don't use signals in action loading.
dboulware Jan 16, 2024
0bb485d
DRIVERS_DIR typo
dboulware Jan 16, 2024
d164b83
actions_dir typo
dboulware Jan 16, 2024
6e98d02
add missing actions/apps.py
dboulware Jan 16, 2024
78f1813
import sensor_capabilities from capabilities.
dboulware Jan 16, 2024
12b9c59
try ActionLoader singleton.
dboulware Jan 16, 2024
13d1cdd
typo
dboulware Jan 16, 2024
5e796f0
fix scos_actions imports.
dboulware Jan 16, 2024
9a1190d
typo fix.
dboulware Jan 16, 2024
d99a347
debugging.
dboulware Jan 16, 2024
72d5a6b
add missing import.
dboulware Jan 16, 2024
7c89d38
debugging
dboulware Jan 16, 2024
cfa4b49
Initialize actions as empty dictionary and set _instance actions.
dboulware Jan 16, 2024
40bf0f2
remove setter for ActionLoader.
dboulware Jan 16, 2024
67b098c
set cls._instance.actions.
dboulware Jan 16, 2024
a0c47b6
add init to ActionLoader.
dboulware Jan 16, 2024
2c7db90
move ActionLoader actions initialization into __init__
dboulware Jan 16, 2024
cda5e6b
import init.
dboulware Jan 16, 2024
89e482a
check if actions have been loaded.
dboulware Jan 16, 2024
037922a
check if ActionLoader has attribute.
dboulware Jan 16, 2024
566eb08
use ActionLoader in schedule/serializers.py
dboulware Jan 16, 2024
936589b
Make initiliazation an app and make it the first to load. Move Action…
dboulware Jan 17, 2024
e9bcbfd
make initialization app load first.
dboulware Jan 17, 2024
7c8d14c
pass SENSOR_DEFINITION_FILE setting to load_capabilities
dboulware Jan 17, 2024
df83fc3
Move sensor instantiation into scheduler.
dboulware Jan 17, 2024
63e8f43
Fix tests.
dboulware Jan 17, 2024
78df6a4
Consolidate initialization into initialization app.
dboulware Jan 17, 2024
5375e0f
Fix gunicorn/config.py post_worker_init
dboulware Jan 17, 2024
bc1a14e
add register_component_with_status signal. Remove register_sensor sig…
dboulware Jan 17, 2024
9f5bb32
Remove sensors refs from test_handlers.py
dboulware Jan 17, 2024
80ecacf
remove register_sensor from test_handlers.py
dboulware Jan 17, 2024
284c001
correct checking for sensor and capabilities attributes.
dboulware Jan 17, 2024
6d2382f
Update sensor location with database location on startup.
dboulware Jan 18, 2024
8284faf
Make sure sensor is not None when updating location.
dboulware Jan 18, 2024
9dc682f
Move location updating in status to app ready.
dboulware Jan 18, 2024
2f8e431
import Location within ready.
dboulware Jan 18, 2024
5638fbf
catch any exception in status ready.
dboulware Jan 18, 2024
50dad78
pass switches to sigan.
dboulware Jan 18, 2024
578de5b
add named argument for switches.
dboulware Jan 18, 2024
30b40e2
catch exceptions creating signal analyzer.
dboulware Jan 18, 2024
80a002c
make SWITCH_CONFIGS_DIR a Path.
dboulware Jan 18, 2024
65e577b
Use environment variable to flag when running migrations to avoid con…
dboulware Jan 18, 2024
5b60820
default running migrations to false to ensure sensor is created.
dboulware Jan 18, 2024
8b3aa0c
defer instantiation of signal_analyzer to sigan repo.
dboulware Jan 18, 2024
0b3c7d6
add signal_analyzer to sensor loader.
dboulware Jan 18, 2024
812f11d
Add signal_analyzer to SensorLoader new.
dboulware Jan 18, 2024
666ab22
Only add last_calibration_datetime if it exists.
dboulware Jan 18, 2024
7819d20
log signal analyzer found.
dboulware Jan 18, 2024
272f8ca
debugging.
dboulware Jan 18, 2024
dc37ebb
debugging
dboulware Jan 18, 2024
610778e
debugging
dboulware Jan 18, 2024
2b235fe
load switches in sigan.
dboulware Jan 18, 2024
fd46c57
Return to loading sigan in sensor loader for testing.
dboulware Jan 19, 2024
08a9421
remove sigan arg.
dboulware Jan 19, 2024
58ca738
remove action_loader.signal_analyzer.
dboulware Jan 19, 2024
aa31c9c
remove sigan arg from load_sensor.
dboulware Jan 19, 2024
92b7dfc
use dynamically loaded sigan.
dboulware Jan 19, 2024
8993bdd
handle SIGABRT.
dboulware Jan 19, 2024
d77688c
use importlib to load sigan.
dboulware Jan 19, 2024
0cbd37d
fix sigan_loader
dboulware Jan 19, 2024
3f38efa
send signal.
dboulware Jan 19, 2024
6dbf45e
correct component in signal.
dboulware Jan 19, 2024
28fdddd
remove preselector loaders from sigan_loader.
dboulware Jan 19, 2024
3477638
move sigan_loader into initialization.
dboulware Jan 19, 2024
306d055
import initialization.sigan_loader.
dboulware Jan 19, 2024
e0363a9
Set logging to debug in sigan_loader.
dboulware Jan 19, 2024
b2aed98
Don't check if running migrations in sigan_loader.
dboulware Jan 19, 2024
ae7a369
cast to string before setting env var.
dboulware Jan 19, 2024
4ce7ce6
try sigan_initializer
dboulware Jan 19, 2024
b8a542a
fix import
dboulware Jan 19, 2024
211154f
Remove sigan_loader and sigan_initializer and create sigan directly i…
dboulware Jan 20, 2024
2ed9a1f
remove registration for abort signal.
dboulware Jan 20, 2024
0c0510d
test triggering container restart.
dboulware Jan 22, 2024
aec3311
Configure logging for initialization app.
dboulware Jan 22, 2024
734c96d
Remove actions logging config.
dboulware Jan 22, 2024
ddbe4d0
Set start_time in status when sigan is not initialized.
dboulware Jan 22, 2024
657fdae
correct sigan -> signal_analyzer.
dboulware Jan 22, 2024
3cf5632
correct sensor_loader.sensor.signal_analyzer
dboulware Jan 22, 2024
28ec3fd
Add USB_PATH setting and don't set RUNNING_MIGRATIONS to false until …
dboulware Jan 22, 2024
3a623fa
Merge branch 'master' of https://github.com/NTIA/scos-sensor into Act…
dboulware Jan 22, 2024
defdc78
Use an app for user initialization instead of script to avoid setting…
dboulware Jan 22, 2024
fb9a84a
don't copy super user script.
dboulware Jan 22, 2024
1311ca6
convert usb_path to Path.
dboulware Jan 22, 2024
d67bfeb
move adding of users into ready method.
dboulware Jan 22, 2024
9a90ff7
remove dead code.
dboulware Jan 22, 2024
d743c18
use logging in users app.
dboulware Jan 22, 2024
117d978
Only continue initialization if usb is found when required.
dboulware Jan 22, 2024
cb42268
initialize objects to allow system to continue to start when not heal…
dboulware Jan 22, 2024
d94502b
try making /dev/bus/usb a volume.
dboulware Jan 22, 2024
552aece
use lsusb to check for required usb device.
dboulware Jan 22, 2024
a9d0a2e
add USB_DEVICE to settings.
dboulware Jan 22, 2024
2a1d1d8
decode lsusb output. Add usbutils to docker container.
dboulware Jan 22, 2024
5b60c10
add USB_DEVICE to env.template and reset container if sigan is not he…
dboulware Jan 22, 2024
8ee8c64
cleanup
dboulware Jan 22, 2024
6b6882a
correct Action import.
dboulware Jan 22, 2024
738693f
Remove /dev/bus/usb volume. It makes no difference.
dboulware Jan 22, 2024
562f461
use sensor_loader sensor in test_db_location_deleted_handler.
dboulware Jan 22, 2024
6e3927e
Fix tests. remove dead code.
dboulware Jan 23, 2024
095c3c9
Remove an evil comma converting the string last_calibration_datetime …
dboulware Jan 23, 2024
7b29867
move capabilities in sensor constructor.
dboulware Jan 26, 2024
a2e4c34
Fix location handler logging.
dboulware Jan 26, 2024
159cb90
scos-actions 8.0.0
dboulware Jan 27, 2024
ef43af2
remove unused and duplicate imports
aromanielloNTIA Jan 29, 2024
5eab69a
scos-tekrsa 5.0.0
aromanielloNTIA Jan 29, 2024
cd920ac
Update readme, env.template, and optimize imports. Update requirement…
dboulware Jan 29, 2024
95ffe14
Merge branch 'ActionRefactorActionsApp' of https://github.com/NTIA/sc…
dboulware Jan 29, 2024
e8ed7ba
update readme.
dboulware Jan 29, 2024
338eb0a
readme
dboulware Jan 29, 2024
183e82c
Update readme to describe changing sigan.
dboulware Jan 30, 2024
c7f040e
Add note to update USB_DEVICE when switching signal analyzers.
dboulware Jan 30, 2024
db2e525
Remove unused imports and logger.
dboulware Jan 30, 2024
274ceff
Add create_superuser.py back to allow manual creation of additional u…
dboulware Jan 30, 2024
f0e922d
fix typo, reduce size of calibration example
aromanielloNTIA Jan 30, 2024
9d42b8d
remove unused code
aromanielloNTIA Jan 30, 2024
b0922e4
remove placeholder debug message
aromanielloNTIA Jan 30, 2024
b615e6c
avoid using function name as variable name
aromanielloNTIA Jan 30, 2024
ac15395
consistent use of logger.exception
aromanielloNTIA Jan 30, 2024
e9bb866
load test actions from any SCOS plugin, or local
aromanielloNTIA Jan 30, 2024
5a7d369
debug when registered component has no get_status
aromanielloNTIA Jan 30, 2024
9965e1a
Revert "load test actions from any SCOS plugin, or local"
aromanielloNTIA Jan 30, 2024
530b16f
import settings from django.conf
aromanielloNTIA Jan 30, 2024
b25601a
Merge branch 'master' into ActionRefactorActionsApp
aromanielloNTIA Jan 31, 2024
4dcfd4f
Don't set default values for SIGAN_MODULE, SIGAN_CLASS, or DEVICE_MOD…
dboulware Jan 31, 2024
c3b95bd
Add actions folder with readme.
dboulware Jan 31, 2024
7de7c4e
typo fix.
dboulware Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 179 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,24 @@ settings in the environment file:

- ADDITIONAL_USER_NAMES: Comma separated list of additional admin usernames.
- ADDITIONAL_USER_PASSWORD: Password for additional admin users.
- ADMIN_NAME: Username for the admin user.
- ADMIN_EMAIL: Email used to generate admin user. Change in production.
- ADMIN_NAME: Username for the admin user.
- ADMIN_PASSWORD: Password used to generate admin user. Change in production.
- AUTHENTICATION: Authentication method used for scos-sensor. Supports `TOKEN` or
`CERT`.
- BASE_IMAGE: Base docker image used to build the API container.
- BASE_IMAGE: Base docker image used to build the API container. These docker
images, combined with any drivers found in the signal analyzer repos, are
responsible for providing the operating system suitable for the chosen signal
analyzer. Note, this should be updated when switching signal analyzers.
By default, this is configured to
use a version of `ghcr.io/ntia/scos-tekrsa/tekrsa_usb` to use a Tektronix
signal analyzer.
- CALLBACK_AUTHENTICATION: Sets how to authenticate to the callback URL. Supports
`TOKEN` or `CERT`.
- CALLBACK_SSL_VERIFICATION: Set to “true” in production environment. If false, the SSL
certificate validation will be ignored when posting results to the callback URL.
- CALLBACK_TIMEOUT: The timeout for the requests sent to the callback URL.
- CALLBACK_TIMEOUT: The timeout for the posts sent to the callback URL when a scheduled
action is completed.
- DEBUG: Django debug mode. Set to False in production.
- DOCKER_TAG: Always set to “latest” to install newest version of docker containers.
- DOMAINS: A space separated list of domain names. Used to generate [ALLOWED_HOSTS](
Expand All @@ -344,17 +351,36 @@ settings in the environment file:
- POSTGRES_PASSWORD: Sets password for the Postgres database for the “postgres” user.
Change in production. The env.template file sets to a randomly generated value.
- REPO_ROOT: Root folder of the repository. Should be correctly set by default.
- SCOS_SENSOR_GIT_TAG: The scos-sensor branch name.
- SCOS_SENSOR_GIT_TAG: The scos-sensor branch name. This value may be used in action
metadata to capture the version of the software that produced the sigmf archive.
- SECRET_KEY: Used by Django to provide cryptographic signing. Change to a unique,
unpredictable value. See
<https://docs.djangoproject.com/en/3.0/ref/settings/#secret-key>. The env.template
file sets to a randomly generated value.
- SIGAN_CLASS: The name of the signal analyzer class to use. By default, this is
set to `TekRSASigan` to use a Tektronix signal analyzer. This must be changed
to switch to a different signal analyzer.
- SIGAN_MODULE: The name of the python module that provides the signal analyzer
implementation. This defaults to `scos_tekrsa.hardware.tekrsa_sigan` for the
Tektronix signal analyzers. This must be changed to switch to a different
signal analyzer.
- SIGAN_POWER_CYCLE_STATES: Optional setting to provide the name of the control_state
in the SIGAN_POWER_SWITCH that will power cycle the signal analyzer.
- SIGAN_POWER_SWITCH: Optional setting used to indicate the name of a
[WebRelay](https://github.com/NTIA/Preselector) that may be used to power cycle
the signal analyzer if necessary. Note: specifics of power cycling behavior
are implemented within the signal analyzer implementations or actions.
- SSL_CA_PATH: Path to a CA certificate used to verify scos-sensor client
certificate(s) when authentication is set to CERT.
- SSL_CERT_PATH: Path to server SSL certificate. Replace the certificate in the
scos-sensor repository with a valid certificate in production.
- SSL_KEY_PATH: Path to server SSL private key. Use the private key for your valid
certificate in production.
- SSL_CA_PATH: Path to a CA certificate used to verify scos-sensor client
certificate(s) when authentication is set to CERT.
- USB_DEVICE: Optional string used to search for available USB devices. By default,
this is set to Tektronix to see if the Tektronix signal analyzer is available. If
the specified value is not found in the output of lsusb, scos-sensor will attempt
to restart the api container. If switching to a different signal analyzer, this
setting should be updated or removed.

### Sensor Definition File

Expand Down Expand Up @@ -391,6 +417,106 @@ specific to the sensor you are using.
}
```

### Sensor Calibration File

By default, scos-sensor will use `configs/default_calibration.json` as the sensor
calibration file. However, if`configs/sensor_calibration.json` or
`configs/sigan_calibration.json` exist they will be used instead of the default
calibration file. Sensor calibration files allow scos-sensor to apply a gain based
on a laboratory calibration of the sensor and may also contain other useful
metadata that characterizes the sensor performance. For additional
information on the calibration data, see the
[NTIA-Sensor SigMF Calibration Object](https://github.com/NTIA/sigmf-ns-ntia/blob/master/ntia-sensor.sigmf-ext.md#08-the-calibration-object).
The default calibration file is shown below:

```json
{
"calibration_data":{
"datetime": "1970-01-01T00:00:00.000000Z",
"gain": 0,
"noise_figure": null,
"1db_compression_point": null,
"enbw": null,
"temperature": 26.85
},
"last_calibration_datetime": "1970-01-01T00:00:00.000000Z",
"calibration_parameters": [],
"clock_rate_lookup_by_sample_rate": [
],
"sensor_uid": "DEFAULT CALIBRATION",
"calibration_reference": "noise source output"
}
```

The `calibration_parameters` key lists the parameters that will be used to obtain
the calibration data. In the case of the default calibration, there are no
`calibration_parameters` so the calibration data is found directly within the
`calibration_data` element and by default scos-sensor will not apply any additional
gain. Typically, a sensor would be calibrated at particular
sensing parameters. The calibration data for specific parameters should be listed
within the calibration_data object and accessed by the values of the settings
listed in the calibration_parameters element. For example, the calibration below
provides an example of a sensor calibrated at a sample rate of 14000000.0 samples
per second at several frequencies with a signal analyzer reference level setting of -25.

```json
{
"last_calibration_datetime": "2023-10-23T14:39:13.682Z",
"calibration_parameters": [
"sample_rate",
"frequency",
"reference_level",
"preamp_enable",
"attenuation"
],
"clock_rate_lookup_by_sample_rate": [],
"calibration_data": {
"14000000.0": {
"3545000000.0": {
"-25": {
"true": {
"0": {
"datetime": "2023-10-23T14:38:02.882Z",
"gain": 30.09194805857024,
"noise_figure": 4.741521295220736,
"temperature": 15.6
}
}
}
},
"3555000000.0": {
"-25": {
"true": {
"0": {
"datetime": "2023-10-23T14:38:08.022Z",
"gain": 30.401008416406599,
"noise_figure": 4.394893979804061,
"temperature": 15.6
}
}
}
},
"3565000000.0": {
"-25": {
"true": {
"0": {
"datetime": "2023-10-23T14:38:11.922Z",
"gain": 30.848049817892105,
"noise_figure": 4.0751785215495819,
"temperature": 15.6
}
}
}
}
}
}
}
```

When an action is run with the above calibration, SCOS will expect the action to have
a sample_rate, frequency, and reference_level specified in the action config. The values
specified for these parameters will then be used to retrieve the calibration data.

## Security

This section covers authentication, permissions, and certificates used to access the
Expand Down Expand Up @@ -661,25 +787,60 @@ repository. The scos-actions repository is intended to be a dependency for every
as it contains the actions base class and signals needed to interface with scos-sensor.
These actions use a common but flexible signal analyzer interface that can be
implemented for new types of hardware. This allows for action re-use by passing the
signal analyzer interface implementation and the required hardware and measurement
parameters to the constructor of these actions. Alternatively, custom actions that
support unique hardware functionality can be added to the plugin.
measurement parameters to the constructor of these actions and supplying the
Sensor instance (including the signal analyzer) to the `__call__` method.
Alternatively, custom actions that support unique hardware functionality can be
added to the plugin.

The scos-actions repository can also be installed as a plugin which uses a mock signal
analyzer.

scos-sensor uses the following convention to discover actions offered by plugins: if
Scos-sensor uses the following convention to discover actions offered by plugins: if
any Python package begins with "scos_", and contains a dictionary of actions at the
Python path `package_name.discover.actions`, these actions will automatically be
available for scheduling.

The scos-usrp plugin adds support for the Ettus B2xx line of signal analyzers.
It can also be used as an example of a plugin which adds new hardware support and
re-uses the common actions in scos-actions.
available for scheduling. Similarly, plugins may offer new action types by including
a dictionary of action classes at the Python path `package_name.discover.action_classes`.
Scos-sensor will load all plugin actions and action classes prior to creating actions
defined in yaml files in `configs/actions` directory. In this manner, a plugin may add new
action types to scos-sensor and those new types may be instantiated/parameterized with yaml
config files.

The [scos-usrp](https://github.com/ntia/scos-usrp) plugin adds support for the Ettus B2xx
line of signal analyzers and [scos-tekrsa](https://github.com/ntia/scos-tekrsa) adss
support for Tektronix RSA306, RSA306B, RSA503A,
RSA507A, RSA513A, RSA518A, RSA603A, and RSA607A real-time spectrum analyzers.
These repositories may also be used as examples of plugins which provide new hardware
support and re-use the common actions in scos-actions.

For more information on adding actions and hardware support, see [scos-actions](
<https://github.com/ntia/scos-actions#development>).

### Switching Signal Analyzers

Scos-sensor currently supports Ettus B2xx signal analyzers through
the [scos-usrp](https://github.com/ntia/scos-usrp) plugin and
Tektronix RSA306, RSA306B, RSA503A, RSA507A, RSA513A,
RSA518A, RSA603A, and RSA607A real-time spectrum analyzers through
the [scos-tekrsa](https://github.com/ntia/scos-tekrsa) plugin. To
configure scos-sensor for the desired signal analyzer review the
instructions in the plugin repository. Generally,
switching signal analyzers involves updating the `BASE_IMAGE`
setting, updating the requirements, and updating the `SIGAN_MODULE`,
`SIGAN_CLASS`, and `USB_DEVICE` settings. To identify the
`BASE_IMAGE`, go to the preferred plugin repository and find
the latest docker image. For example, see
[scos-tekrsa base images](https://github.com/NTIA/scos-tekrsa/pkgs/container/scos-tekrsa%2Ftekrsa_usb)
or
[scos-usrp base images](https://github.com/NTIA/scos-usrp/pkgs/container/scos-usrp%2Fscos_usrp_uhd).
Update the `BASE_IMAGE` setting in env file to the desired base image.
Then update the `SIGAN_MODULE` and `SIGAN_CLASS` settings with
the appropriate Python module and class that provide
an implementation of the `SignalAnalyzerInterface`
(you will have to look in the plugin repo to identify the correct module and class). Finally,
update the requirements with the selected plugin repo.
See [Requirements and Configuration](https://github.com/NTIA/scos-sensor?tab=readme-ov-file#requirements-and-configuration)
and [Using pip-tools](https://github.com/NTIA/scos-sensor?tab=readme-ov-file#using-pip-tools)
for additional information. Be sure to re-source the environment file, update the
requirements files, and prune any existing containers
before rebuilding scos-sensor.

## Preselector Support

Scos-sensor can be configured to support
Expand Down
16 changes: 16 additions & 0 deletions configs/default_calibration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"calibration_data":{
"datetime": "1970-01-01T00:00:00.000000Z",
"gain": 0,
"noise_figure": 0.0,
"1db_compression_point": null,
"enbw": null,
"temperature": 26.85
},
"last_calibration_datetime": "1970-01-01T00:00:00.000000Z",
"calibration_parameters": [],
"clock_rate_lookup_by_sample_rate": [
],
"sensor_uid": "DEFAULT CALIBRATION",
"calibration_reference": "noise source output"
}
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ services:
- POSTGRES_PASSWORD
- SCOS_SENSOR_GIT_TAG
- SECRET_KEY
- SIGAN_MODULE
- SIGAN_CLASS
- SIGAN_POWER_SWITCH
- SIGAN_POWER_CYCLE_STATES
- RUNNING_MIGRATIONS
- USB_DEVICE
expose:
- '8000'
volumes:
Expand Down
5 changes: 1 addition & 4 deletions docker/Dockerfile-api
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apt-get update -q && \
apt-get install -qy --no-install-recommends \
libusb-1.0-0 libpython3.8 \
git smartmontools \
python3-pip python3.8 python3.8-dev && \
python3-pip python3.8 python3.8-dev usbutils && \
apt-get clean && rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED 1
Expand All @@ -27,9 +27,6 @@ COPY ./gunicorn /gunicorn
RUN mkdir -p /entrypoints
COPY ./entrypoints/api_entrypoint.sh /entrypoints

RUN mkdir -p /scripts
COPY ./scripts/create_superuser.py /scripts

RUN chmod +x /entrypoints/api_entrypoint.sh

COPY ./configs /configs
Expand Down
12 changes: 3 additions & 9 deletions entrypoints/api_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ function cleanup_demodb {

trap cleanup_demodb SIGTERM
trap cleanup_demodb SIGINT
# This is done to avoid loading actions and connecting to the sigan when migrations are applied and when
# the super user is created.
cp sensor/migration_settings.py sensor/settings.py
RUNNING_MIGRATIONS="True"
export RUNNING_MIGRATIONS
echo "Starting Migrations"
python3.8 manage.py migrate


echo "Creating superuser (if managed)"
python3.8 /scripts/create_superuser.py
cp sensor/runtime_settings.py sensor/settings.py

RUNNING_MIGRATIONS="False"
echo "Starting Gunicorn"
exec gunicorn sensor.wsgi -c ../gunicorn/config.py &
wait
Loading
Loading