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

REL: merge development into main, change CI #17

Merged
merged 44 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e32c2c2
TST: Cleaner interpretation test
cbespin Dec 16, 2024
055e746
TST: Use absolute file locations
cbespin Dec 16, 2024
bcabff4
Merge branch 'tests' of https://github.com/SiLab-Bonn/aidatlu into tests
cbespin Dec 18, 2024
b655f6e
Add mock for I2C core to test without connected hardware
cbespin Dec 18, 2024
c86a6f6
ENH: started on test_configuration + hardware write read tests
rpartzsch Dec 20, 2024
47f71fd
ENH: test configuration
rpartzsch Dec 23, 2024
e71fa61
ENH: added tlu test run
rpartzsch Dec 23, 2024
c4e45e3
ENH: added verbosity trigger edge + switch mock in test config
rpartzsch Jan 3, 2025
3ed5a2b
ENH: pytest in workflow with coverage report
rpartzsch Jan 3, 2025
83a12b8
GIT: debugging pytest in github actions
rpartzsch Jan 3, 2025
0739258
ENH: tests with hardware + pytest in documentation
rpartzsch Jan 6, 2025
321c48d
TST: read register tests after configuration steps
rpartzsch Jan 6, 2025
cee55d1
MAINT: improved mock read write + removed IOcontroller in config pars…
rpartzsch Jan 7, 2025
9f976b6
TST: set mock or hardware tests with environment variable
rpartzsch Jan 8, 2025
a8a2c33
TST: improved environment variable handling
rpartzsch Jan 8, 2025
33c31ce
MAINT: removed legacy debugging functions
rpartzsch Jan 8, 2025
1389b7b
Merge pull request #12 from SiLab-Bonn/tests
rpartzsch Jan 13, 2025
e75ab99
Move test data to fixture folder
cbespin Jan 13, 2025
2de338c
Add fixtures
cbespin Jan 13, 2025
19b5051
Add version attribute to module
cbespin Jan 13, 2025
2d1050c
Use pyproject.toml for installation
cbespin Jan 13, 2025
36dca37
Remove uhal from pyproject.toml
cbespin Jan 13, 2025
4e71f8a
Use test requirements in CI
cbespin Jan 13, 2025
c7a7189
Dynamic distribution version in docs
cbespin Jan 13, 2025
ce3425e
Remove obsolete version and setup.py file
cbespin Jan 13, 2025
14b0a91
Reflect deletion of DataParser
cbespin Jan 13, 2025
17a83c8
Import uhal only when using as a script
cbespin Jan 13, 2025
115af9b
Import uhal only when using as a script
cbespin Jan 13, 2025
436cfd3
Fix getting version from package
cbespin Jan 13, 2025
56022e0
Codestyle
cbespin Jan 13, 2025
0b65cab
Move test confguration to fixtures
cbespin Jan 15, 2025
2966873
Add optional dependency to build docs
cbespin Jan 15, 2025
960a401
Merge pull request #13 from SiLab-Bonn/packaging
rpartzsch Jan 15, 2025
ba5a712
DBG: correct FIFO full warning + small dbg log improvments
rpartzsch Jan 16, 2025
b78b669
MAINT: removed first_event flag
rpartzsch Jan 16, 2025
0090b10
DOC: added FIFO function descriptions
rpartzsch Jan 16, 2025
5ef6e05
Merge pull request #14 from SiLab-Bonn/fifo_full_warning
rpartzsch Jan 16, 2025
91965f0
GIT: added badges for documentation, tests and pre-commit
rpartzsch Jan 29, 2025
0ed401a
MAINT: refactoring of run loop
rpartzsch Jan 29, 2025
8f39a1f
Merge pull request #15 from SiLab-Bonn/git_badges
rpartzsch Feb 3, 2025
e2cb6a0
MAINT: stop comdition comparison, adapted blank fifo pull after run
rpartzsch Feb 3, 2025
8b5ef5b
Merge pull request #16 from SiLab-Bonn/refactoring_run_loop
rpartzsch Feb 10, 2025
8517507
REL: update to version 1.2.0
rpartzsch Feb 10, 2025
6a851e1
REL: Set version to 1.0.0 for first release
rpartzsch Feb 12, 2025
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
8 changes: 3 additions & 5 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ jobs:
- uses: actions/setup-python@v5
- name: Install dependencies
run: |
pip install -e .
pip install pydata-sphinx-theme
pip install sphinx sphinx_rtd_theme myst_parser sphinx_mdinclude
pip install -e .[doc]
- name: Sphinx build
run: |
sphinx-build docs/source _build
sphinx-build docs/source build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
publish_dir: build/
force_orphan: true
14 changes: 14 additions & 0 deletions .github/workflows/pre_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: [main, development]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
18 changes: 8 additions & 10 deletions .github/workflows/workflows.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
name: standard tests
name: tests

on:
pull_request:
push:
branches: [main, development]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1

installation:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install dependencies
run: |
pip install -e .
pip install -e .[test]
pip install pytest

- name: Test with pytest
run: |
pytest -sv
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#debugging and data files
test.ipynb
*.h5
!/aidatlu/test/interpreted_data.h5
!/aidatlu/test/raw_data_test.h5
!aidatlu/test/fixtures/*
.vscode

# Byte-compiled / optimized / DLL files
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# AIDA-TLU
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![tests](https://github.com/SiLab-Bonn/aidatlu/actions/workflows/tests.yml/badge.svg)](https://github.com/SiLab-Bonn/aidatlu/actions/workflows/tests.yml)
[![pre-commit](https://github.com/SiLab-Bonn/aidatlu/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/SiLab-Bonn/aidatlu/actions/workflows/pre-commit.yml)
[![documentation](https://github.com/SiLab-Bonn/aidatlu/actions/workflows/documentation.yml/badge.svg)](https://github.com/SiLab-Bonn/aidatlu/actions/workflows/documentation.yml)

Repository for controlling the AIDA-2020 Trigger Logic Unit (TLU) with Python using uHAL bindings from [IPbus](https://ipbus.web.cern.ch/).
The Python control software is based on [EUDAQ2](https://github.com/eudaq/eudaq/tree/master/user/tlu).
The software is a lightweight version written in Python with a focus on readability and user-friendliness.
Most user cases can be set with a .yaml configuration file and started by executing a single Python script.
For a more in-depth look at the hardware components please take a look at the official [AIDA-2020 TLU project](https://ohwr.org/project/fmc-mtlu).
Additionally, take a look at the [documentation](https://silab-bonn.github.io/aidatlu/) for this software.
# Installation
## IPbus
You need to install [IPbus](https://ipbus.web.cern.ch/doc/user/html/software/install/compile.html) and its Python bindings to the desired interpreter.
Expand Down Expand Up @@ -77,5 +80,23 @@ For more commands take a look at the python script aidatlu.py.

All configurations are done by the use of a yaml file (tlu_configuration.yaml).

# Tests
With pytest (https://docs.pytest.org/en/7.4.x/) the AIDA TLU control program can be tested.
There is also an implemented AIDA-TLU mock, to allow tests and software development without hardware,
which also allows software development and testing without a working IPbus installation.
The mock is used as a default.

Additionally, take a look at the [documentation](https://silab-bonn.github.io/aidatlu/).
```bash
pytest -sv
```
To test with connected hardware set an environment variable ```HW=True````:

```bash
HW=True pytest -sv
```

You can also set the variable ```HW=False```` to test the mock TLU:

```bash
HW=False pytest -sv
```
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

3 changes: 2 additions & 1 deletion aidatlu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ These operators are used in conjunction with the input channels CH1-CH6 and inte
For example "(CH1 & ~CH2) & (CH3 | CH4 | CH5 | CH6)" produces a valid trigger, when CH1 and not CH2 triggers and when one of CH3, CH4, CH5 or CH6 triggers.
An input channel that is not explicitly set to 'veto' or 'enabled' is automatically set to 'do not care'.

Trigger polarity controls if the TLU should trigger on a rising (0) or falling (1) edge of an incoming trigger signal.
TLU can trigger on a rising or falling edge. Trigger polarity is set using a string or boolean,
'rising' corresponds to false (0) and 'falling' to true (1)

Each trigger input signal can be delayed and stretched by a given number of clock cycles.
This is set with a list containing the number of clock cycles for every different trigger input.
Expand Down
1 change: 1 addition & 0 deletions aidatlu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
40 changes: 0 additions & 40 deletions aidatlu/hardware/ioexpander_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,46 +58,6 @@ def init_output_expander(self) -> None:

### LED Control ###

def test_leds(self, single=True) -> None:
"""Test the 11 LEDs

Args:
single (bool, optional): Test all possible RGB combinations for all LEDs. Defaults to True.
"""
self.log.info("Testing LEDs colors")
if single:
for color in [
[0, 1, 1],
[1, 0, 1],
[1, 1, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 0],
]:
for i in range(11):
if i + 1 == 5:
pass
else:
self._set_led(i + 1, color)
time.sleep(0.1)
self.all_off()
time.sleep(0.05)
for color in [[0, 0, 1], [0, 1, 1], [1, 0, 1]]:
self._set_led(5, color)
time.sleep(0.15)
self.all_off()
time.sleep(0.1)

else:
for color in ["w", "r", "g", "b"]:
self.log.info("Testing LEDs color: %s" % color)

self.all_on(color)
time.sleep(1)
self.all_off()
time.sleep(1)

def all_on(self, color: str = "w") -> None:
"""Set all LEDs to same color

Expand Down
52 changes: 34 additions & 18 deletions aidatlu/main/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@


class TLUConfigure:
def __init__(self, TLU, io_control, config_path) -> None:
def __init__(self, TLU, config_path) -> None:
self.log = logger.setup_main_logger(__class__.__name__)

self.tlu = TLU
self.io_control = io_control

with open(config_path, "r") as file:
self.conf = yaml.full_load(file)
Expand All @@ -18,15 +17,7 @@ def configure(self) -> None:
self.conf_dut()
self.conf_trigger_inputs()
self.conf_trigger_logic()
self.tlu.io_controller.clock_lemo_output(
self.conf["clock_lemo"]["enable_clock_lemo_output"]
)
[
self.tlu.dac_controller.set_voltage(
i + 1, self.conf["pmt_control"]["pmt_%s" % (i + 1)]
)
for i in range(len(self.conf["pmt_control"]))
]
self.conf_auxillary()
self.tlu.set_enable_record_data(1)
self.log.success("TLU configured")

Expand Down Expand Up @@ -95,7 +86,7 @@ def get_data_handling(self) -> tuple:
tuple: two bools, save and interpret data.
"""

return self.conf["save_data"], self.conf["save_data"]
return self.conf["save_data"]

def get_stop_condition(self) -> tuple:
"""Information about tlu stop condition.
Expand Down Expand Up @@ -131,6 +122,18 @@ def get_zmq_connection(self) -> str:
"""
return self.conf["zmq_connection"]

def conf_auxillary(self):
"""Configures PMT power outputs and clock LEMO I/O"""
self.tlu.io_controller.clock_lemo_output(
self.conf["clock_lemo"]["enable_clock_lemo_output"]
)
[
self.tlu.dac_controller.set_voltage(
i + 1, self.conf["pmt_control"]["pmt_%s" % (i + 1)]
)
for i in range(len(self.conf["pmt_control"]))
]

def conf_dut(self) -> None:
"""Parse the configuration for the DUT interface to the AIDATLU."""
dut = [0, 0, 0, 0]
Expand Down Expand Up @@ -181,7 +184,11 @@ def conf_dut(self) -> None:
self.tlu.dut_logic.set_dut_mask_mode(
dut_mode[0] | dut_mode[1] | dut_mode[2] | dut_mode[3]
)

self.log.debug("Set DUT mask: %s" % (dut[0] | dut[1] | dut[2] | dut[3]))
self.log.debug(
"Set DUT mask mode: %s"
% (dut_mode[0] | dut_mode[1] | dut_mode[2] | dut_mode[3])
)
# Special configs
self.tlu.dut_logic.set_dut_mask_mode_modifier(0)
self.tlu.dut_logic.set_dut_ignore_busy(0)
Expand All @@ -190,9 +197,18 @@ def conf_dut(self) -> None:
def conf_trigger_logic(self) -> None:
"""Configures the trigger logic. So the trigger polarity and the trigger pulse length and stretch."""

self.tlu.trigger_logic.set_trigger_polarity(
self.conf["trigger_inputs"]["trigger_polarity"]["polarity"]
)
if self.conf["trigger_inputs"]["trigger_polarity"]["polarity"] in [
0,
"0",
"rising",
]:
self.tlu.trigger_logic.set_trigger_polarity(0)
elif self.conf["trigger_inputs"]["trigger_polarity"]["polarity"] in [
1,
"1",
"falling",
]:
self.tlu.trigger_logic.set_trigger_polarity(1)

self.tlu.trigger_logic.set_pulse_stretch_pack(
self.conf["trigger_inputs"]["trigger_signal_shape"]["stretch"]
Expand Down Expand Up @@ -234,9 +250,9 @@ def conf_trigger_inputs(self) -> None:
if trigger_configuration is not None:
for trigger_led in range(6):
if "~CH%i" % (trigger_led + 1) in trigger_configuration:
self.io_control.switch_led(trigger_led + 6, "r")
self.tlu.io_controller.switch_led(trigger_led + 6, "r")
elif "CH%i" % (trigger_led + 1) in trigger_configuration:
self.io_control.switch_led(trigger_led + 6, "g")
self.tlu.io_controller.switch_led(trigger_led + 6, "g")

long_word = 0x0
# Goes through all possible trigger combinations and checks if the combination is valid with the trigger logic.
Expand Down
Loading
Loading