refactor: add script to export info on blocks from panda to yaml

This commit is contained in:
gac-x07da
2024-08-02 18:13:55 +02:00
parent fa32f78303
commit 62521228d2
4 changed files with 2532 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,32 @@
""" Field Types
-----------
Each field type determines the set of attributes available for the field. The
types and their attributes are documented below.
=================== ============================================================
Field type Description
=================== ============================================================
``param`` subtype Configurable parameter. The `subtype` determines the
precise behaviour and the available attributes.
``read`` subtype A read only hardware field, used for monitoring status.
Again, `subtype` determines available attributes.
``write`` subtype A write only field, `subtype` determines possible values
and attributes.
``time`` Configurable timer parameter.
``bit_out`` Bit output, can be configured as bit input for ``bit_mux``
fields.
``pos_out`` Position output, can be configured for data capture and as
position input for ``pos_mux`` fields.
``ext_out`` extra Extended output values, can be configured for data capture,
but not available on position bus.
``bit_mux`` Bit input with configurable delay.
``pos_mux`` Position input multiplexer selection.
``table`` Table data with special access methods.
=================== ============================================================
"""
from abc import ABC

View File

@ -137,7 +137,7 @@ class BitMuxField(FieldBase):
max_delay: Optional[int]
available_fields = {
PANDA_FIELDS = {
"uint": UIntField,
"int": IntField,
"scalar": ScalarField,

View File

@ -0,0 +1,33 @@
def main():
from ophyd_devices.devices.panda_box import PandaController
from ophyd_devices.devices.panda_blocks import PANDA_TYPES
from ophyd_devices.devices.panda_fields import PANDA_FIELDS
from pandablocks.commands import Raw
controller = PandaController(name="redpanda", socket_host="x02da-panda-2.psi.ch")
# Get info about fields for all blocks
block_info = {}
# loop over name of all blocks
for name in PANDA_TYPES:
block_info[name] = {}
field_info = controller.send_command(Raw(f"{name}.*?"))
for field in sorted(field_info):
if not field.strip("."):
continue
field_name = field.split(" ")[0].strip("!")
field_type = field.split(" ")[2:]
block_info[name][field_name] = {"type" : field_type}
print(block_info)
import yaml
import os
cur_dir = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(cur_dir, "block_info.yaml")
with open(output_file, "w") as file:
yaml.dump(block_info, file, default_flow_style=False)
if __name__ == "__main__":
main()