Severson-Group / AMDC-Firmware

Embedded system code (C and Verilog) which runs the AMDC Hardware
http://docs.amdc.dev/firmware
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

Add auto find log variables by regex #219

Closed npetersen2 closed 2 years ago

npetersen2 commented 2 years ago

Closes #233

This PR adds the ability to easily find (i.e. register) many log variables using Regular Expressions (regex).

Example Usage:

Consider a system with 6 current signals to log, current_1..6.

Instead of writing:

vars_to_log = 'current_1 current_2 current_3 current_4 current_5 current_6'
logger.register(vars_to_log)

you can explore all your source code and automatically find all log variables that match a given regex:

vars_to_log = logger.auto_find_vars(root, regex='current_*')[0]
logger.register(vars_to_log)

This can be very helpful as the number of log variables grows with complex control algorithms.

npetersen2 commented 2 years ago

@elsevers this PR is ready for review. The capability will be added in v1.0.2 release.

npetersen2 commented 2 years ago

This needs to be tested