Skip to content

Commit

Permalink
Add input protection scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanielloNTIA committed Oct 17, 2023
1 parent efca003 commit d321ddf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/_input_protection_disable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json
from its_preselector.controlbyweb_web_relay import ControlByWebWebRelay
from its_preselector.web_relay_preselector import WebRelayPreselector

sensor_definition_file = "/opt/scos-sensor/configs/sensor_definition.json"
preselector_json_file = "/opt/scos-sensor/configs/preselector_config.json"
spu_relay_json_file = "/opt/scos-sensor/configs/switches/x410_config.json"

# Load Preselector
with open(sensor_definition_file, "r") as f:
sensor_definition_json = json.load(f)
with open(preselector_json_file, "r") as f:
preselector_json = json.load(f)
preselector = WebRelayPreselector(sensor_definition_json, preselector_json)

# Load SPU Relay
with open(spu_relay_json_file, "r") as f:
spu_json = json.load(f)
spu_relay = ControlByWebWebRelay(spu_json)

# Enable Preselector Power
spu_relay.set_state("power_on_preselector")

# Set Preselector to Antenna State
preselector.set_state("antenna")
25 changes: 25 additions & 0 deletions scripts/_input_protection_enable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json
from its_preselector.controlbyweb_web_relay import ControlByWebWebRelay
from its_preselector.web_relay_preselector import WebRelayPreselector

sensor_definition_file = "/opt/scos-sensor/configs/sensor_definition.json"
preselector_json_file = "/opt/scos-sensor/configs/preselector_config.json"
spu_relay_json_file = "/opt/scos-sensor/configs/switches/x410_config.json"

# Load Preselector
with open(sensor_definition_file, "r") as f:
sensor_definition_json = json.load(f)
with open(preselector_json_file, "r") as f:
preselector_json = json.load(f)
preselector = WebRelayPreselector(sensor_definition_json, preselector_json)

# Load SPU Relay
with open(spu_relay_json_file, "r") as f:
spu_json = json.load(f)
spu_relay = ControlByWebWebRelay(spu_json)

# Set Preselector to Noise Diode Off State
preselector.set_state("noise_diode_off")

# Disable Preselector Power
spu_relay.set_state("power_off_preselector")
29 changes: 29 additions & 0 deletions scripts/input_protection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Usage:
# - Activate a Python environment with the its_preselector
# package installed
# - Run this script with start and stop times for input
# protection specified as command line arguments.

# Example: Enable input protection from 10:00 to 12:00
# > sudo bash
# > cd /opt/scos-sensor
# > venv/bin/activate
# > pip install git+https://github.com/NTIA/Preselector
# > bash scripts/input_protection.sh 10:00 12:00

# This script sets the preselector state to "noise_diode_off"
# then powers off the preselector, at START_TIME
# Then, at STOP_TIME, the preselector is powered on and set to
# the "antenna" state.


START_TIME=$1
STOP_TIME=$2

SCRIPT_DIR=$(dirname "$0")

echo "python3 $SCRIPT_DIR/_input_protection_enable.py" | at $START_TIME

echo "python3 $SCRIPT_DIR/_input_protection_disable.py" | at $STOP_TIME

0 comments on commit d321ddf

Please sign in to comment.