Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally ignore wiring information in HousekeepingConsumer #156

Merged
merged 5 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions dfmux/python/Housekeeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ class HousekeepingConsumer(object):

Also emits a Wiring frame from the housekeeping data. This requires a
recent (as of November 2018) version of pydfmux in order to read mapped
channel names from each board.
channel names from each board. If ignore_wiring=False, assumes that
the wiring map is handled by a separate process.

If collecting real-time data, you may want to set subprocess=True when
adding this module.
'''
def __init__(self):
def __init__(self, ignore_wiring=False):
self.tuber = {}
self.board_map = {}
self.board_serials = []
self.buffer = []
self.hwmf = None
self.ignore_wiring = ignore_wiring

def map_boards(self):
'''
Expand Down Expand Up @@ -77,9 +79,9 @@ def map_boards(self):

def __call__(self, frame):

# If a wiring frame has been emitted once already, then process every frame
# If boards have been mapped already, then process every frame
# as received.
if self.hwmf is not None:
if len(self.board_map):
return self.ProcessBuffered(frame)

# Otherwise, process at least one Timepoint frame first to gather
Expand Down Expand Up @@ -107,12 +109,22 @@ def ProcessBuffered(self, frame):
return [frame]

if frame.type == core.G3FrameType.Wiring:
core.log_fatal("Received spurious wiring frame. Do not use "
"PyDfMuxHardwareMapInjector with the HousekeepingConsumer. "
"You may update pydfmux to a newer version of pydfmux "
"that stores mapped channel names on the boards, and "
"rearrange your data acquisition script.",
unit='HousekeepingConsumer')
if self.ignore_wiring:
core.log_warn(
"Received a wiring frame, which may be inconsistent with "
"board housekeeping data. Store mapped channel names on the "
"board using updated pydfmux/hidfmux software.",
unit="HousekeepingConsumer",
)
else:
core.log_fatal(
"Received spurious wiring frame. Do not use "
"PyDfMuxHardwareMapInjector with the HousekeepingConsumer. "
"You may update pydfmux/hidfmux to a newer version that "
"stores mapped channel names on the boards, and rearrange "
"your data acquisition script.",
unit="HousekeepingConsumer",
)

if frame.type == core.G3FrameType.Housekeeping:
self.map_boards()
Expand All @@ -135,13 +147,16 @@ def ProcessBuffered(self, frame):
ismkid = ismkid or "mkid" in boardhk.firmware_name.lower()
hkdata[int(boardhk.serial)] = boardhk

if self.ignore_wiring:
continue

ip, crate, slot = self.board_map[board]
boardw = self.WiringFromJSON(dat, ip, crate, slot)
for key in boardw.keys():
hwm[key] = boardw[key]
found = True

if not found:
if not found and not self.ignore_wiring:
core.log_fatal("No mapped channels found on any IceBoards. "
"You may need to update pydfmux to a newer version of pydfmux "
"that stores mapped channel names on the boards, and reload "
Expand All @@ -150,6 +165,9 @@ def ProcessBuffered(self, frame):

frame['DfMuxHousekeeping'] = hkdata

if self.ignore_wiring:
return [frame]

hwmf = core.G3Frame(core.G3FrameType.Wiring)
hwmf['WiringMap'] = hwm
hwmf['ReadoutSystem'] = 'RF-ICE' if ismkid else 'ICE'
Expand Down
Loading