Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions luxtronik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(
This ensures that the created data vectors only contain valid fields.
If None is passed, all available fields will be added.
"""
self._lock = get_host_lock(host)
self.__lock = get_host_lock(host)

self._host = host
LuxtronikSocketInterface.__init__(self, host, port_config)
Expand All @@ -162,7 +162,7 @@ def __init__(

@property
def lock(self):
return self._lock
return self.__lock

def create_all_data(self, safe=True):
"""
Expand All @@ -175,7 +175,7 @@ def create_all_data(self, safe=True):
Returns:
LuxtronikAllData: The created data-collection.
"""
return LuxtronikAllData(None, None, None, None, None, self._version, safe)
return LuxtronikAllData(None, None, None, None, None, self.version, safe)

def read_all(self, data=None):
"""
Expand Down
221 changes: 169 additions & 52 deletions luxtronik/cfi/interface.py

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions luxtronik/interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from abc import ABC, abstractmethod


class LuxtronikBaseInterface(ABC):
"""
Base class for each Luxtronik interface class.
Defines common methods that must be implemented in the derived classes.
"""

@property
@abstractmethod
def lock(self):
"""
Get the unique lock object associated with a given host.
The same thread can acquire a RLock as often as desired.

Returns:
RLock: The lock object of the interface.
"""
pass

@property
@abstractmethod
def version(self):
"""
Get the specified or detected version.

Returns:
tuple[int]: The used version of the interface.
"""
pass

@abstractmethod
def read_version(self):
"""
Read the controller version via the first valid version field.

Returns:
tuple[int]: The read controller version.
"""

@abstractmethod
def create_data(self, safe=True):
"""
Create a data vector collection only with fields that match the stored version.

Args:
safe (bool): If true, prevent write-able fields marked as
not secure from being written to.

Returns:
type of the data collection: The created data-collection.
"""
pass

@abstractmethod
def read(self, data=None):
"""
Read the data of all fields within the data vector collection
that are supported by the controller.

Args:
data (type of the data collection | None): Optional existing data vector collection.
If None is provided, a new instance is created.

Returns:
type of the data collection: The passed / created data vector collection.
"""
pass

@abstractmethod
def write(self, data):
"""
Write the data of all fields within the data vector (collection)
that are supported by the controller.

Args:
data (type of the data collection or data vector): The data vector (collection) containing field data.
If None is provided, the write is aborted.

Returns:
bool: True if no errors occurred, otherwise False.
"""
pass

@abstractmethod
def write_and_read(self, write_data, read_data=None):
"""
Write and then read the data of all fields within the data vector (collection)
that are supported by the controller.

Args:
write_data (type of the data collection or data vector):
The data vector (collection) containing field data.
If None is provided, the write is aborted.
read_data (type of the data collection | None): Optional existing data vector collection
for the read data. If None is provided, a new instance is created.

Returns:
type of the data collection: The passed / created data vector collection for the read data.
"""
pass
2 changes: 1 addition & 1 deletion luxtronik/scripts/watch_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def dump_all(screen, client, changes, prev_data, this_data):
update_changes(changes, prev_data.visibilities, this_data.visibilities)

# Print changes
print_watch_header(screen, f"Watch CFI of {client._host}:{client._port}")
print_watch_header(screen, f"Watch CFI of {client._LuxtronikSocketInterface__host}:{client._LuxtronikSocketInterface__port}")
sorted_changes = OrderedDict(sorted(changes.items()))
for key, values in sorted_changes.items():
screen.write(values)
Expand Down
2 changes: 1 addition & 1 deletion luxtronik/scripts/watch_shi.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def dump_all(screen, client, changes, prev_data, this_data):
update_changes(changes, prev_data.holdings, this_data.holdings)

# Print changes
print_watch_header(screen, f"Watch SHI of {client._interface._client._host}:{client._interface._client._port}")
print_watch_header(screen, f"Watch SHI of {client._LuxtronikSmartHomeInterface_interface._client._host}:{client._LuxtronikSmartHomeInterface_interface._client._port}")
sorted_changes = OrderedDict(sorted(changes.items()))
for key, values in sorted_changes.items():
screen.write(values)
Expand Down
Loading
Loading