Skip to content

Commit

Permalink
Fix names, separate client and server side
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed May 21, 2024
1 parent 80c4741 commit 946c5c2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/python_testing/spec_parsing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ class XmlCluster:
pics: str


class ClusterSide(Enum):
SERVER = auto()
CLIENT = auto()


@dataclass
class XmlDeviceTypeClusterRequirements:
name: str
side: ClusterSide
conformance: Callable[[uint, list[uint], list[uint]], ConformanceDecision]
# TODO: add element requirements

Expand Down Expand Up @@ -159,6 +165,9 @@ class CommandType(Enum):
0x0072: 'ACFREMON',
0x0405: 'RH'}

CLUSTER_NAME_FIXES = {0x0036: 'WiFi Network Diagnostics', 0x042a: 'PM25 Concentration Measurement', 0x0006: 'On/Off'}
DEVICE_TYPE_NAME_FIXES = {0x010b: 'Dimmable Plug-In Unit', 0x010a: 'On/Off Plug-in Unit'}


def get_conformance(element: ElementTree.Element, cluster_id: int) -> ElementTree.Element:
for sub in element:
Expand Down Expand Up @@ -669,6 +678,9 @@ def parse_single_device_type(root: ElementTree.Element) -> tuple[list[ProblemNot
problems.append(ProblemNotice("Parse Device Type XML", location=location,
severity=ProblemSeverity.WARNING,
problem=f"Device type {name} does not a valid ID or revision. ID: {str_id} revision: {d.get('revision', 'UNKNOWN')}"))
break
if id in DEVICE_TYPE_NAME_FIXES:
name = DEVICE_TYPE_NAME_FIXES[id]
try:
classification = next(d.iter('classification'))
scope = classification.attrib['scope']
Expand All @@ -687,8 +699,16 @@ def parse_single_device_type(root: ElementTree.Element) -> tuple[list[ProblemNot
tmp_problems, conformance_xml = get_conformance(c, cid)
problems += tmp_problems
conformance = parse_device_type_callable_from_xml(conformance_xml)
side_dict = {'server': ClusterSide.SERVER, 'client': ClusterSide.CLIENT}
side = side_dict[c.attrib['side']]
if side == ClusterSide.CLIENT:
# For now, let's just look at server clusters, we can do client separately after
continue
name = c.attrib['name']
if cid in CLUSTER_NAME_FIXES:
name = CLUSTER_NAME_FIXES[cid]
device_types[id].clusters[cid] = XmlDeviceTypeClusterRequirements(
name=c.attrib['name'], conformance=conformance)
name=name, side=side, conformance=conformance)
except ConformanceException:
location = DeviceTypePathLocation(device_type_id=id, cluster_id=cid)
problems.append(ProblemNotice("Parse Device Type XML", location=location,
Expand Down

0 comments on commit 946c5c2

Please sign in to comment.