Lightning Detector Agent
The lightning detector agent communicates with the Lightning Detector System at the site and parses the data to obtain approximate lightning strike distances and standardized alarm levels.
usage: agent.py [-h] [--mode {idle,init,acq}]
[--sample-interval SAMPLE_INTERVAL]
Agent Options
- --mode
Possible choices: idle, init, acq
Starting action for the agent.
- --sample-interval
Time between samples in seconds.
Default: 0.2
Configuration File Examples
Below are configuration examples for the ocs config file and for running the Agent in a docker container.
OCS Site Config
An example site-config-file block:
{'agent-class': 'LDMonitorAgent',
'instance-id': 'ld-monitor',
'arguments': ['--mode', 'acq']},
Docker Compose
An example docker-compose configuration:
ocs-ld-monitor:
image: simonsobs/socs:latest
hostname: ocs-docker
ports:
- "1110:1110/udp"
environment:
- INSTANCE_ID=ld-monitor
- SITE_HUB=ws://127.0.0.1:8001/ws
- SITE_HTTP=http://127.0.0.1:8001/call
- LOGLEVEL=info
volumes:
- ${OCS_CONFIG_DIR}:/config
Description
The Lightning Detector System is connnected through serial communication with a dedicated PC at the site, in which a propietary application calculates approximate lightning strike distances and adjusts alarm levels accordingly. Data is parsed and the most important parameters are updated. The dedicated PC is continously running a script that streams the data via UDP to the client.
Transmitted Data
The lightning detector transmits its data in “sentences”. There are 5 types of expected sentences:
electric field
lightning strike
high-field
status
alarm timers
Electric field sentences report the electric field value measured by the Electric Field Mill in kV/m. Strike sentences include lightning strike distance and units (meters or miles) and is only transmitted if a strike is detected. High field sentences report an alarm status with respect to set thresholds of electric field. Status sentences include data such as alarms (red, orange, yellow), remaining timers, all clear status, fault codes, among others. Alarm timers sentences are disregarded, as its information is redundant. Each of the sentences’ data are parsed and published to the feed.
Agent API
- class socs.agents.ld_monitor.agent.LDMonitorAgent(agent, sample_interval=15.0)[source]
Monitor the Lightning Detector data via UDP.
- Parameters:
agent (OCSAgent) – OCSAgent object which forms this Agent
sample_interval (float) – Time between samples in seconds.
- agent
OCSAgent object which forms this Agent
- Type:
OCSAgent
- take_data
Tracks whether or not the agent is actively issuing SNMP GET commands to the ibootbar. Setting to false stops sending commands.
- Type:
bool
- log
txaio logger object, created by the OCSAgent
- Type:
txaio.tx.Logger
- init_ld_monitor(auto_acquire=False)[source]
Task - Perform first time setup of the LD.
- Parameters:
auto_acquire (bool, optional) – Starts data acquisition after initialization if True. Defaults to False.
- acq()[source]
Process - Starts the data acquisition process
Notes
The most recent data collected is stored in session data in the structure:
>>> response.session['data'] {'fields':{ 'd_type': 3, 'field_value': 0.28, 'rot_fault': 0, 'time_last': -1.0, 'tsince_last': -1.0, 'dist': -1, 'unit_d': 0, 'high_field': -1, 'hifield_value': -1000.0, 'alarm_r': 0, 'alarm_o': 0, 'alarm_y': 0, 'delay_g': 1, 'clear': 1, 'r_timer': 0, 'o_timer': 0, 'y_timer': 0, 'g_timer': 0, 'allclear_timer': 0, 'faultcode': 0 }, ... 'connection': { 'conn_timestamp': 1711285858.1063662, 'connected': True}, 'data_timestamp': 1711285864.6254003 } }
Supporting APIs
- class socs.agents.ld_monitor.agent.LDMonitor(port=1110)[source]
Receives and decodes data of the lightning detector via UDP
- Parameters:
host (str) – Address of the computer reading the data.
port (int) – Port of host where data will be received, default 1110.
- port
Port number in the local host to be bound to receive the data
- Type:
int
- log
txaio logger object, created by the OCSAgent
- Type:
txaio.tx.Logger
- sockopen
Indicates when the socket is open
- Type:
bool
- inittime
Logs the time at which initialization was carried out
- Type:
float
- data_dict
Dictionary data stored from the lightning detector
- Type:
dictionary
- newdata_dict
Dictionary where new data is received
- Type:
dictionary