Young32400WeatherStationDataClient

class lsst.ts.ess.csc.Young32400WeatherStationDataClient(config: types.SimpleNamespace, topics: salobj.Controller | types.SimpleNamespace, log: logging.Logger, simulation_mode: int = 0)

Bases: BaseReadLoopDataClient

Get environmental data from Young 32400 weather station serial interface.

The interface is assumed to be connected to a serial-to-ethernet adapter.

Parameters:
configtypes.SimpleNamespace

The configuration, after validation by the schema returned by get_config_schema and conversion to a types.SimpleNamespace.

topicssalobj.Controller or types.SimpleNamespace

The telemetry topics this data client can write, as a struct with attributes such as tel_temperature.

loglogging.Logger

Logger.

simulation_modeint, optional

Simulation mode; 0 for normal operation.

Notes

This code assumes the 32400 is configured to provide ASCII or PRECIPITATION formatted output, depending if there is a rain gauge.

Sensors must be connected as follows (this is the standard order for NMEA output, plus the standard input for a rain gauge):

  • VIN1: temperature

  • VIN2: relative humidity

  • VIN3: barometric pressure

  • VIN4: tipping bucket rain gauge

Attributes Summary

connected

Methods Summary

connect()

Connect to the data server.

descr()

Return a brief description, without the class name.

disconnect()

Disconnect from the data server.

get_config_schema()

Get the config schema as jsonschema dict.

handle_data(wind_speed, wind_direction, ...)

Process data.

rain_stopped_timer()

Wait for the configured time, then report that rain has stopped.

read_data()

Read raw data from the weather station.

read_data_once()

read_loop()

Call the read_data method in a loop.

restart_rain_stopped_timer()

Start or restart the "rain stopped" timer.

run()

Read data from the server and publish it as ESS telemetry.

setup_reading()

Perform any tasks before starting the read loop.

start()

Override start method to handle auto reconnecting if necessary.

start_tasks()

Call disconnect, connect, and start the run task.

stop()

Delegate handling of stop tasks to the stop_tasks method.

stop_tasks()

Stop reading and publishing data.

Attributes Documentation

connected

Methods Documentation

async connect() None

Connect to the data server.

This will not be called if already connected. See the Raises section for exceptions subclasses should raise.

Raises:
ConnectionError

If the data server rejects the connection. This may happen if the data server is down or the configuration specified an invalid address.

asyncio.TimeoutError

If a connection cannot be made in reasonable time.

Exception

(or any subclass) if any other serious problem occurs.

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 data server.

This must always be safe to call, whether connected or not.

classmethod get_config_schema() dict[str, Any]

Get the config schema as jsonschema dict.

async handle_data(wind_speed: int, wind_direction: int, humidity: int, temperature: int, pressure: int, rain_tip_count: int) None

Process data.

Parameters:
wind_directionint

Wind direction (raw units)

wind_speedint

Wind speed (raw units)

humidityint

Relative humidity (raw units)

temperatureint

Air temperature (raw units)

pressureint

Air pressure (raw units)

rain_tip_countint

Rain tip count (raw units)

async rain_stopped_timer() None

Wait for the configured time, then report that rain has stopped.

Intended to be run by restart_rain_stopped_timer.

async read_data() None

Read raw data from the weather station.

The format is as described by DATA_REGEX.

async read_data_once() None
async read_loop() None

Call the read_data method in a loop.

Allow for max_timeouts timeouts before raising a TimeoutError.

restart_rain_stopped_timer() None

Start or restart the “rain stopped” timer.

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 setup_reading() None

Perform any tasks before starting the read loop.

async start() None

Override start method to handle auto reconnecting if necessary.

async start_tasks() None

Call disconnect, connect, and start the run task.

Raises the same exceptions as connect. If disconnect raises, this logs the exception and continues.

async stop() None

Delegate handling of stop tasks to the stop_tasks method.

This allows implementing classes to customize stop behavior.

async stop_tasks() 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.