fix: align mechanical dynamic port validation
This commit is contained in:
1 parent
6a064892e2
commit
4e0b9fd8cc
7 files changed
+105
-7
No files matched your search
+27
-1
@@ -538,6 +538,21 @@ def _registered_port(
|
||||
return None
|
||||
return next((port for port in spec.ports if port.name == port_name), None)
|
||||
|
||||
def _active_registered_ports(
|
||||
component: SystemXmlComponent,
|
||||
) -> tuple[PortDefinition, ...]:
|
||||
spec = COMPONENT_MODEL_REGISTRY.get(component.model_type)
|
||||
if spec is None:
|
||||
return ()
|
||||
values = {
|
||||
parameter.name: parameter.value
|
||||
for parameter in component.parameters
|
||||
}
|
||||
try:
|
||||
return spec.active_ports(values)
|
||||
except (KeyError, ValueError):
|
||||
return ()
|
||||
|
||||
|
||||
def _validate_connections(
|
||||
document: SystemXmlDocument,
|
||||
@@ -615,6 +630,17 @@ def _validate_connections(
|
||||
)
|
||||
)
|
||||
continue
|
||||
if port not in _active_registered_ports(component):
|
||||
issues.append(
|
||||
_semantic_issue(
|
||||
"ENDPOINT_PORT_INACTIVE",
|
||||
f"Connection {connection.id} references inactive port "
|
||||
f"{endpoint.component}.{endpoint.port} for its parameters.",
|
||||
endpoint_path,
|
||||
endpoint.line,
|
||||
)
|
||||
)
|
||||
continue
|
||||
resolved_endpoints.append((endpoint, port))
|
||||
referenced_ports.add(endpoint.key)
|
||||
if port.kind == "physical":
|
||||
@@ -696,7 +722,7 @@ def _validate_connections(
|
||||
spec = COMPONENT_MODEL_REGISTRY.get(component.model_type)
|
||||
if spec is None:
|
||||
continue
|
||||
for port in spec.ports:
|
||||
for port in _active_registered_ports(component):
|
||||
if (component.id, port.name) not in referenced_ports:
|
||||
issues.append(
|
||||
_semantic_issue(
|
||||
|
||||
Reference in new issue
Block a user