Skip to content

Commit 732f5fd

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 658cea6 commit 732f5fd

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
@@ -1303,35 +1303,44 @@ def _configure_trigger_input(self, node_map, cfg, *, strict: bool = False) -> No
13031303
self._set_enum_node(node_map, "TriggerMode", "Off", strict=False)
13041304

13051305
selector_ok = self._set_enum_node(node_map, "TriggerSelector", selector, strict=strict)
1306-
activation_ok = self._set_enum_node(node_map, "TriggerActivation", activation, strict=strict)
1306+
1307+
resolved_source, source_supported = self._resolve_trigger_source(
1308+
node_map,
1309+
source,
1310+
strict=strict,
1311+
)
13071312

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

1331-
if not selector_ok:
1322+
activation_ok = self._set_enum_node(
1323+
node_map,
1324+
"TriggerActivation",
1325+
activation,
1326+
strict=False,
1327+
)
1328+
1329+
# TriggerSelector and TriggerSource are required routing nodes.
1330+
# If either failed in non-strict mode, do not arm TriggerMode=On.
1331+
# Otherwise the camera may wait on a previous/default input line.
1332+
if not (selector_ok and source_ok):
13321333
LOG.warning(
1333-
"Could not apply GenTL TriggerSelector=%s; disabling trigger.",
1334+
"Could not apply GenTL trigger input routing "
1335+
"(selector_ok=%s, source_ok=%s); disabling trigger. "
1336+
"requested role=%s selector=%s source=%s resolved_source=%s activation=%s",
1337+
selector_ok,
1338+
source_ok,
1339+
role,
13341340
selector,
1341+
source,
1342+
resolved_source,
1343+
activation,
13351344
)
13361345
self._configure_trigger_off(node_map, strict=False)
13371346
self._trigger = CameraTriggerSettings()
@@ -1352,15 +1361,16 @@ def _configure_trigger_input(self, node_map, cfg, *, strict: bool = False) -> No
13521361
return
13531362

13541363
LOG.info(
1355-
"GenTL trigger input configured: role=%s selector=%s activation=%s "
1356-
"selector_ok=%s activation_ok=%s source_requested=%s source_ok=%s",
1364+
"GenTL trigger input configured: role=%s selector=%s source_requested=%s "
1365+
"source=%s activation=%s selector_ok=%s source_ok=%s activation_ok=%s",
13571366
role,
13581367
selector,
1368+
source,
1369+
resolved_source,
13591370
activation,
13601371
selector_ok,
1361-
activation_ok,
1362-
source,
13631372
source_ok,
1373+
activation_ok,
13641374
)
13651375

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

0 commit comments

Comments
 (0)