Skip to content

Commit

Permalink
feat: add example config for DAQJobCAENToolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Dec 25, 2024
1 parent 0b9bcec commit ff6d3a2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
14 changes: 14 additions & 0 deletions configs/examples/toolbox.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
daq_job_type = "DAQJobCAENToolbox"

# Digitizer type from caen-toolbox cli
digitizer_type = "dig1"
# Through optical link, with link number 0. See CAEN docs for more info
connection_string = "-c OPTICAL_LINK -l 0"

[[register_labels]]
register = "0x11a8"
label = "ADC_ch_1_Temperature"

[store_config.csv]
file_path = "digitizer_registers.csv"
add_date = true
12 changes: 10 additions & 2 deletions src/enrgdaq/daq/jobs/caen/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from datetime import datetime
from shutil import which

from msgspec import Struct

from enrgdaq.daq.base import DAQJob
from enrgdaq.daq.store.models import (
DAQJobMessageStoreTabular,
Expand All @@ -14,6 +16,11 @@
DAQ_JOB_CAEN_TOOLBOX_SLEEP_INTERVAL = 1


class RegisterLabel(Struct):
register: str
label: str


class DAQJobCAENToolboxConfig(StorableDAQJobConfig):
"""
Configuration for the DAQ job that dumps register data of a CAEN digitizer using the caen-toolbox cli.
Expand All @@ -25,7 +32,7 @@ class DAQJobCAENToolboxConfig(StorableDAQJobConfig):

digitizer_type: str
connection_string: str
register_labels: dict[str, str]
register_labels: list[RegisterLabel]


class DAQJobCAENToolbox(DAQJob):
Expand Down Expand Up @@ -70,7 +77,8 @@ def _dump_digitizer(self) -> dict[str, int]:
parts = line.split(",")
raw_registers[parts[0]] = int(parts[1], 16)
registers = {}
for key, label in self.config.register_labels.items():
for reg_label in self.config.register_labels:
key, label = reg_label.register, reg_label.label
registers[label] = raw_registers[key]
return registers

Expand Down
11 changes: 9 additions & 2 deletions src/tests/test_toolbox.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
from unittest.mock import MagicMock, mock_open, patch

from enrgdaq.daq.jobs.caen.toolbox import DAQJobCAENToolbox, DAQJobCAENToolboxConfig
from enrgdaq.daq.jobs.caen.toolbox import (
DAQJobCAENToolbox,
DAQJobCAENToolboxConfig,
RegisterLabel,
)


class TestDAQJobCAENToolbox(unittest.TestCase):
Expand All @@ -12,7 +16,10 @@ def setUp(self, mock_which):
digitizer_type="dig1",
connection_string="-c OPTICAL_LINK -l 0",
store_config=MagicMock(),
register_labels={"reg1": "caen_reg1", "reg2": "caen_reg2"},
register_labels=[
RegisterLabel(register="reg1", label="caen_reg1"),
RegisterLabel(register="reg2", label="caen_reg2"),
],
)
self.daq_job = DAQJobCAENToolbox(self.config)

Expand Down

0 comments on commit ff6d3a2

Please sign in to comment.