Skip to main content

plc_interface

module core.interfaces.plc_interface


class PLCInterface

Uses the snap7 library to connect to the Siemens PLC operating the enclosure hardware.

Manual: https://buildmedia.readthedocs.org/media/pdf/python-snap7/latest/python-snap7.pdf

method __init__

__init__(plc_version: Literal[1, 2], plc_ip: StrictIPAdress)None

method connect

connect()None

Connects to the PLC Snap7. Times out after 30 seconds.


method cover_is_closed

cover_is_closed()bool

Reads the single value "state.cover_closed"


method disconnect

disconnect()None

Disconnects from the PLC Snap7


method get_cover_angle

get_cover_angle()int

Reads the single value "actors.current_angle"


method is_responsive

is_responsive()bool

Pings the PLC


method rain_is_detected

rain_is_detected()bool

Reads the single value "state.rain"


method read

read() → PLCState

Read the whole state of the PLC


method reset

reset()None

Does not check, whether the value has been changed


method reset_is_needed

reset_is_needed()bool

Reads the single value "state.reset_needed"


method set_auto_temperature

set_auto_temperature(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_cover_angle

set_cover_angle(value: int)None

Does not check, whether the value has been changed


method set_manual_control

set_manual_control(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_manual_temperature

set_manual_temperature(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_power_camera

set_power_camera(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_power_computer

set_power_computer(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_power_heater

set_power_heater(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_power_router

set_power_router(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_power_spectrometer

set_power_spectrometer(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method set_sync_to_tracker

set_sync_to_tracker(new_state: bool)None

Raises PLCInterface.PLCError, if value hasn't been changed


method update_config

update_config(new_plc_version: Literal[1, 2], new_plc_ip: StrictIPAdress)None

Update the internally used config (executed at the) beginning of enclosure-control's run-function.

Reconnecting to PLC, when IP has changed.