Skip to content

Commit 82ab3f6

Browse files
Merge pull request #48 from Waltham-Data-Science/claude/fix-epoch-duplicates-fmU4s
Filter epoch entries by matching DAQ system device name
2 parents 4d8ebf1 + f4a97db commit 82ab3f6

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/ndi/probe/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,26 @@ def buildepochtable(self) -> list[dict[str, Any]]:
108108
for daqsys in daqsystems:
109109
# Get device epoch table
110110
device_et = daqsys.epochtable()
111+
daqsys_name = getattr(daqsys, "name", getattr(daqsys, "_name", ""))
111112

112113
for device_entry in device_et:
113114
# Check if any epochprobemap matches this probe
114115
epochprobemaps = device_entry.get("epochprobemap", [])
115116
matching_epm = self._find_matching_epochprobemap(epochprobemaps)
116117

117118
if matching_epm is not None:
119+
# Only include if the matching epochprobemap's device
120+
# belongs to this DAQ system
121+
epm_devicename = ""
122+
if hasattr(matching_epm, "devicename"):
123+
epm_devicename = matching_epm.devicename
124+
elif hasattr(matching_epm, "devicestring"):
125+
parts = matching_epm.devicestring.split(":")
126+
epm_devicename = parts[0] if parts else ""
127+
128+
if epm_devicename.lower() != daqsys_name.lower():
129+
continue
130+
118131
epoch_number += 1
119132

120133
# Get clock and timing info from device entry
@@ -381,12 +394,25 @@ def buildmultipleepochtables(
381394
for _daqsys_id, device_info in device_tables.items():
382395
daqsys = device_info["system"]
383396
device_et = device_info["epochtable"]
397+
daqsys_name = getattr(daqsys, "name", getattr(daqsys, "_name", ""))
384398

385399
for device_entry in device_et:
386400
epochprobemaps = device_entry.get("epochprobemap", [])
387401
matching_epm = probe._find_matching_epochprobemap(epochprobemaps)
388402

389403
if matching_epm is not None:
404+
# Only include if the matching epochprobemap's device
405+
# belongs to this DAQ system
406+
epm_devicename = ""
407+
if hasattr(matching_epm, "devicename"):
408+
epm_devicename = matching_epm.devicename
409+
elif hasattr(matching_epm, "devicestring"):
410+
parts = matching_epm.devicestring.split(":")
411+
epm_devicename = parts[0] if parts else ""
412+
413+
if epm_devicename.lower() != daqsys_name.lower():
414+
continue
415+
390416
epoch_number += 1
391417
et.append(
392418
{

tests/test_element.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ def test_buildepochtable_with_matching_epoch(self):
559559
mock_session = MagicMock()
560560

561561
mock_daqsys = MagicMock()
562+
mock_daqsys.name = "dev1"
563+
mock_daqsys._name = "dev1"
562564
mock_daqsys.epochtable.return_value = [
563565
{
564566
"epoch_number": 1,

0 commit comments

Comments
 (0)