Skip to content

Commit b1337ba

Browse files
committed
Refactor GenTL trigger source handling and logging
Replace manual TriggerSource symbol checks with _resolve_trigger_source and only set TriggerSource when supported. Delay setting TriggerActivation until after source resolution and use non-strict writes for activation. Add safety check: do not arm TriggerMode=On unless both TriggerSelector and TriggerSource succeeded (avoids waiting on a previous/default input). Improve log messages to include selector_ok, source_ok, requested/ resolved source and activation for clearer diagnostics.
1 parent 91bd8c7 commit b1337ba

1 file changed

Lines changed: 38 additions & 28 deletions

File tree

dlclivegui/cameras/backends/gentl_backend.py

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,35 +1300,44 @@ def _configure_trigger_input(self, node_map, cfg, *, strict: bool = False) -> No
13001300
self._set_enum_node(node_map, "TriggerMode", "Off", strict=False)
13011301

13021302
selector_ok = self._set_enum_node(node_map, "TriggerSelector", selector, strict=strict)
1303-
activation_ok = self._set_enum_node(node_map, "TriggerActivation", activation, strict=strict)
1303+
1304+
resolved_source, source_supported = self._resolve_trigger_source(
1305+
node_map,
1306+
source,
1307+
strict=strict,
1308+
)
13041309

13051310
source_ok = False
1306-
if source and source.lower() not in {"", "auto", "none"}:
1307-
source_node = self._node(node_map, "TriggerSource")
1308-
source_symbolics = self._node_symbolics(source_node)
1309-
1310-
if source_node is not None:
1311-
if source in source_symbolics:
1312-
source_ok = self._set_enum_node(node_map, "TriggerSource", source, strict=False)
1313-
if not source_ok:
1314-
LOG.warning(
1315-
"GenTL TriggerSource=%s is supported but not writable; "
1316-
"continuing without changing TriggerSource. Available: %s",
1317-
source,
1318-
source_symbolics,
1319-
)
1320-
else:
1321-
LOG.warning(
1322-
"Requested GenTL TriggerSource=%s not in available sources %s; "
1323-
"continuing without changing TriggerSource.",
1324-
source,
1325-
source_symbolics,
1326-
)
1311+
if source_supported:
1312+
source_ok = self._set_enum_node(
1313+
node_map,
1314+
"TriggerSource",
1315+
resolved_source,
1316+
strict=strict,
1317+
)
13271318

1328-
if not selector_ok:
1319+
activation_ok = self._set_enum_node(
1320+
node_map,
1321+
"TriggerActivation",
1322+
activation,
1323+
strict=False,
1324+
)
1325+
1326+
# TriggerSelector and TriggerSource are required routing nodes.
1327+
# If either failed in non-strict mode, do not arm TriggerMode=On.
1328+
# Otherwise the camera may wait on a previous/default input line.
1329+
if not (selector_ok and source_ok):
13291330
LOG.warning(
1330-
"Could not apply GenTL TriggerSelector=%s; disabling trigger.",
1331+
"Could not apply GenTL trigger input routing "
1332+
"(selector_ok=%s, source_ok=%s); disabling trigger. "
1333+
"requested role=%s selector=%s source=%s resolved_source=%s activation=%s",
1334+
selector_ok,
1335+
source_ok,
1336+
role,
13311337
selector,
1338+
source,
1339+
resolved_source,
1340+
activation,
13321341
)
13331342
self._configure_trigger_off(node_map, strict=False)
13341343
self._trigger = CameraTriggerSettings()
@@ -1349,15 +1358,16 @@ def _configure_trigger_input(self, node_map, cfg, *, strict: bool = False) -> No
13491358
return
13501359

13511360
LOG.info(
1352-
"GenTL trigger input configured: role=%s selector=%s activation=%s "
1353-
"selector_ok=%s activation_ok=%s source_requested=%s source_ok=%s",
1361+
"GenTL trigger input configured: role=%s selector=%s source_requested=%s "
1362+
"source=%s activation=%s selector_ok=%s source_ok=%s activation_ok=%s",
13541363
role,
13551364
selector,
1365+
source,
1366+
resolved_source,
13561367
activation,
13571368
selector_ok,
1358-
activation_ok,
1359-
source,
13601369
source_ok,
1370+
activation_ok,
13611371
)
13621372

13631373
def _configure_trigger_master(self, node_map, cfg, *, strict: bool = False) -> None:

0 commit comments

Comments
 (0)