LightningDataClient¶
- class lsst.ts.ess.csc.LightningDataClient(config: SimpleNamespace, topics: lsst.ts.salobj.controller.Controller | types.SimpleNamespace, log: Logger, simulation_mode: int = 0)¶
Bases:
ControllerDataClient
Get lightning and electrical field strength data from a Raspberry Pi.
- Parameters:
- config
types.SimpleNamespace
The configuration, after validation by the schema returned by
get_config_schema()
and conversion to a types.SimpleNamespace.- topics
salobj.Controller
ortypes.SimpleNamespace
The telemetry topics this data client can write, as a struct with attributes such as
tel_temperature
.- log
logging.Logger
Logger.
- simulation_mode
int
, optional Simulation mode; 0 for normal operation.
- config
Attributes Summary
Methods Summary
Store device configurations.
connect
()Connect to the RPi and configure it.
descr
()Return a brief description, without the class name.
Disconnect from the RPi.
Get the config schema as jsonschema dict.
Perform any tasks before starting the read loop.
process_efm100c_telemetry
(sensor_name, ...)Process EFM-100C electric field strength detector telemetry.
process_ld250_noise_or_status
(sensor_name, ...)process_ld250_strike
(sensor_name, timestamp, ...)process_ld250_telemetry
(sensor_name, ...)Process LD-250 lightning detector telemetry.
process_telemetry
(sensor_name, timestamp, ...)Process the sensor telemetry.
read
()Read and unmarshal a json-encoded dict.
Read and process data from the RPi.
Call the read_data function in a loop and allow for max_timeouts timeouts before raising a TimeoutError.
run
()Read data from the server and publish it as ESS telemetry.
run_command
(command, **parameters)Write a command.
sleep_timer
(sleep_time)Simple timer that sleeps for the given amount of time.
start
()Call disconnect, connect, and start the run task.
stop
()Stop reading and publishing data.
Attributes Documentation
- connected¶
Methods Documentation
- configure() None ¶
Store device configurations.
This provides easy access when processing telemetry.
- async connect() None ¶
Connect to the RPi and configure it.
- Raises:
- RuntimeError
If already connected.
- descr() str ¶
Return a brief description, without the class name.
This should be just enough information to distinguish one instance of this client from another. For example RPiDataClient should return something like:
f"host={self.config.host}, port={self.config.port}"
- async disconnect() None ¶
Disconnect from the RPi.
Always safe to call, though it may raise asyncio.CancelledError if the writer is currently being closed.
- async process_efm100c_telemetry(sensor_name: str, timestamp: float, response_code: int, sensor_data: Sequence[float | str | int]) None ¶
Process EFM-100C electric field strength detector telemetry.
- async process_ld250_noise_or_status(sensor_name: str, timestamp: float, response_code: int, sensor_data: Sequence[float | str | int]) None ¶
- async process_ld250_strike(sensor_name: str, timestamp: float, response_code: int, sensor_data: Sequence[float | str | int]) None ¶
- async process_ld250_telemetry(sensor_name: str, timestamp: float, response_code: int, sensor_data: Sequence[float | str | int]) None ¶
Process LD-250 lightning detector telemetry.
- async process_telemetry(sensor_name: str, timestamp: float, response_code: int, sensor_data: Sequence[float | int | str]) None ¶
Process the sensor telemetry.
- async read() dict ¶
Read and unmarshal a json-encoded dict.
This may be a command acknowedgement or telemetry data.
Time out if reading takes longer than COMMUNICATE_TIMEOUT seconds.
- Returns:
- data
dict
The read data, after json-decoding it.
- data
- Raises:
- RuntimeError
In case of not being connected. In case parsing gthe JSON data fails.
- async read_loop() None ¶
Call the read_data function in a loop and allow for max_timeouts timeouts before raising a TimeoutError.
- async run() None ¶
Read data from the server and publish it as ESS telemetry.
This is called once after
connect
and it should keep running until cancelled. See the Raises section for exceptions subclasses should raise.- Raises:
- ConnectionError
If the connection to the data server is lost.
- asyncio.TimeoutError
If data is not received in reasonable time.
- Exception
(or any subclass) if any other serious problem occurs.
- async run_command(command: str, **parameters: Any) None ¶
Write a command. Time out if it takes too long.
- Parameters:
- Raises:
- ConnectionError
If not connected.
- asyncio.TimeoutError
If it takes more than COMMUNICATE_TIMEOUT seconds to acquire the lock or write the data.
- async sleep_timer(sleep_time: float) None ¶
Simple timer that sleeps for the given amount of time.
- Parameters:
- sleep_time
float
The amount of time to sleep [s].
- sleep_time
- async start() None ¶
Call disconnect, connect, and start the run task.
Raises the same exceptions as
connect
. Ifdisconnect
raises, this logs the exception and continues.
- async stop() None ¶
Stop reading and publishing data.
This is alway safe to call, whether connected or not. This should raise no exceptions except asyncio.CancelledError. If
disconnect
raises, this logs the exception and continues.