Skip to content

Commit

Permalink
TC-IDM-10.1: Consolidate scripts, add new checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Sep 29, 2023
1 parent 4a9dab1 commit f6cccad
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 59 deletions.
27 changes: 23 additions & 4 deletions src/controller/python/chip/clusters/ClusterObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,31 @@ def FromTLV(cls, data: bytes):
def descriptor(cls):
raise NotImplementedError()

# The below dictionaries will be filled dynamically
# and are used for quick lookup/mapping from cluster/attribute id to the correct class
ALL_CLUSTERS = {}
ALL_ATTRIBUTES = {}
# These need to be separate because there can be overlap in command ids for commands and responses.
ALL_ACCEPTED_COMMANDS = {}
ALL_GENERATED_COMMANDS = {}

class ClusterCommand(ClusterObject):
def __init_subclass__(cls, *args, **kwargs) -> None:
"""Register a subclass."""
super().__init_subclass__(*args, **kwargs)
try:
if cls.is_client:
if cls.cluster_id not in ALL_ACCEPTED_COMMANDS:
ALL_ACCEPTED_COMMANDS[cls.cluster_id] = {}
ALL_ACCEPTED_COMMANDS[cls.cluster_id][cls.command_id] = cls
else:
if cls.cluster_id not in ALL_GENERATED_COMMANDS:
ALL_GENERATED_COMMANDS[cls.cluster_id] = {}
ALL_GENERATED_COMMANDS[cls.cluster_id][cls.command_id] = cls
except NotImplementedError:
# handle case where the ClusterAttribute class is not (fully) subclassed
# and accessing the id property throws a NotImplementedError.
pass
@ChipUtility.classproperty
def cluster_id(self) -> int:
raise NotImplementedError()
Expand All @@ -221,10 +244,6 @@ def must_use_timed_invoke(cls) -> bool:
return False


# The below dictionaries will be filled dynamically
# and are used for quick lookup/mapping from cluster/attribute id to the correct class
ALL_CLUSTERS = {}
ALL_ATTRIBUTES = {}


class Cluster(ClusterObject):
Expand Down
Loading

0 comments on commit f6cccad

Please sign in to comment.