Skip to main content

enclosure_control

module core.modules.enclosure_control


class EnclosureControl

EnclosureControl allows to interact with TUM made weather protected enclosures that allow a 24/7 deployment of the FTIR spectrometer EM27/Sun in the field. The class takes the latest decision from measurement_conditions.py (StateInterface: measurements_should_be_running) and communicates with the enclosure's built in Siemens S7 PLC to read and write parameters to its database (PLCInterface). Additionally, it powers down the spectrometer during dusk to extend the overall spectrometer lifetime. During dawn, it powers up the spectrometer to prepare and warm it up for the next measurement day. At initialization, the PLC is set to control the ambient enclosure temperature in automatic mode. During flank changes of measurements_should_be_running it either tells the enclosure to open up the cover to allow direct sunlight to hit the CamTracker mirrors or close the cover to protect the instrument. Instrument protection from bad weather conditions is always prioritised over a slight maximization of measurement uptime.

method __init__

__init__(initial_config: Config)

method auto_set_power_spectrometer

auto_set_power_spectrometer()None

Shuts down spectrometer if the sun angle is too low. Starts up the spectrometer in the morning when minimum angle is satisfied.


method force_cover_close

force_cover_close()None

Emergency option to call to ensure that the cover is closed immediately. Accounts for possible blocking conditions caused by the PLC internals: 1. Reset needed 2. Sync to tracker still active 3. Manual control not active


method move_cover

move_cover(value: int)None

Moves the cover attached on top of the enclosure. The cover is moved by a electrical motor controlled by the PLC. The cover functions as weather protection for the measurement instrument. In case of bad weather the PLC takes over control and closes the cover itself. A movement of the cover during bad weather conditions shall not be allowed as instrument saefty is priotized higher than maximization of overall measurement uptime.


method perform_camera_power_cycle

perform_camera_power_cycle()None

Performs a power cycle of the camera every day at midnight: Turn off the camera power at midnight system time. Turn on the camera power two minutes later.

Exact logic: Whenever the time is between 00:00 and 00:15, and the last power down was on a different day or never logged (core has been stopped since last power cycle), power down the camera. Two minutes later, power up the camera. This works because this function should be run at least every 10 minutes (config.general.seconds_per_core_interval is <= 600).

It leads to multiple power cycles if the core is restarted between 00:00 and 00:15, but this doesn't break any hardware. The only way to circumvent this is adding it to the persistent state which is not worth it right now.


method run

run(new_config: Config)None

Called in every cycle of the main loop. Updates enclosure state based on the current automation status.


method sync_cover_to_measurement_status

sync_cover_to_measurement_status()None

Checks for flank changes in parameter measurement_should_be_running. Positive flank: Set sync_cover flag in PLC to start matching the Camtracker mirror position. Negative flank: Remove sync_cover flag in PLC and move cover to position 0.


method verify_cover_position

verify_cover_position()None

Verifies that the cover is closed when measurements are currently not set to be running. Closed the cover in case of a mismatch.

This functions allows to detect desync caused by previous user controlled decisions. It also functions as a failsafe to ensure weather protection of the instrument.


method verify_cover_sync

verify_cover_sync()None

Syncs the current cover_sync flag in the PLC with the present measurement status.

This functions allows to detect desync caused by previous user controlled decisions.


method wait_for_cover_closing

wait_for_cover_closing(throw_error: bool = True)None

Validates the progress of a cover closing call. Continues when cover is closed. Validation is done every 5s with a maximum waiting time of 60s.

Raises the custom error CoverError if clover doesn't close in time.