Repository to try to merge different ideas for the python accelerator middle layer together.
Clone the repository and cd into its root folder. Then install with pip install .
There are two example files available in examples for how to generate a simple configuration for MLS and the MAX IV 1.5 GeV ring.
It is in no way complete but just an illustration showing the idea for those who are interested in being able to generate the config by creating pydantic objects directly.
Keywords and structure are just an example which can be changed.
There is not yet any example of parsers but the idea is sufficiently modular to also create a config object by parsing it in externally.
From the configuration an object of the type Accelerator can be created. This class is inspired by the philosophy behind the MML AcceleratorObject (AO).
The functionality of it is as an registry to store the configuration data but also be able to view and browse it.
Potentially it should also be possible to change specific fields without reloading the config as can be done in MML.
For details about the MML functionality that this idea is aiming to replace see Appendix III in MML manual.
The idea is that device objects with business logic are not created at initalization but only at the point when the user needs them. Then the Accelerator object is used to extract the required configuration to be able to create the device for the mode the user wants. There is no example of that yet. This just focuses on the configuration layer.
Assuming that you have run the example for creating the MLS config.
# Get the facility name
>>> mls.facility
'MLS'
# Get the machine name
>>> mls.machine
'storage_ring'
# Get the different control modes
>>> mls.controls
{'live': EPICSConfig(access_type=<EPICSType.CA: 'CA'>, pv_prefix=''),
'twin': EPICSConfig(access_type=<EPICSType.CA: 'CA'>, pv_prefix='twin')}
# Get the different simulator modes
>>> mls.simulators
{'design': SimulatorConfig(type=<SimulationEngine.PYAT: 'pyat'>, model='design_lattice.json'),
'error': SimulatorConfig(type=<SimulationEngine.PYAT: 'pyat'>, model='error_lattice.json'),
'measured': SimulatorConfig(type=<SimulationEngine.PYAT: 'pyat'>, model='measured_lattice.json')}
# Get the devices
>>> mls.devices
{'Q1M1K1RP': MagnetConfig(name='Q1M1K1RP', magnet_type='quadrupole', power_supply='Q1P1K1RP'), 'Q1M1L2RP': MagnetConfig(name='Q1M1L2RP', magnet_type='quadrupole', power_supply='Q1P1L2RP'), 'Q1M1K3RP': MagnetConfig(name='Q1M1K3RP', magnet_type='quadrupole', power_supply='Q1P1K3RP'), 'Q1M1L4RP': MagnetConfig(name='Q1M1L4RP', magnet_type='quadrupole', power_supply='Q1P1L4RP'), 'Q1M2K1RP': MagnetConfig(name='Q1M2K1RP', magnet_type='quadrupole', power_supply='Q1P2K1RP'), 'Q1M2L2RP': MagnetConfig(name='Q1M2L2RP', magnet_type='quadrupole', power_supply='Q1P2L2RP'), 'Q1M2K3RP': MagnetConfig(name='Q1M2K3RP', magnet_type='quadrupole', power_supply='Q1P2K3RP'), 'Q1M2L4RP': MagnetConfig(name='Q1M2L4RP', magnet_type='quadrupole', power_supply='Q1P2L4RP'), 'Q2M1K1RP': MagnetConfig(name='Q2M1K1RP', magnet_type='quadrupole', power_supply='Q2P1K1RP'), 'Q2M1L2RP': MagnetConfig(name='Q2M1L2RP', magnet_type='quadrupole', power_supply='Q2P1L2RP'), 'Q2M1K3RP': MagnetConfig(name='Q2M1K3RP', magnet_type='quadrupole', power_supply='Q2P1K3RP'), 'Q2M1L4RP': MagnetConfig(name='Q2M1L4RP', magnet_type='quadrupole', power_supply='Q2P1L4RP'), 'Q2M2K1RP': MagnetConfig(name='Q2M2K1RP', magnet_type='quadrupole', power_supply='Q2P2K1RP'), 'Q2M2L2RP': MagnetConfig(name='Q2M2L2RP', magnet_type='quadrupole', power_supply='Q2P2L2RP'), 'Q2M2K3RP': MagnetConfig(name='Q2M2K3RP', magnet_type='quadrupole', power_supply='Q2P2K3RP'), 'Q2M2L4RP': MagnetConfig(name='Q2M2L4RP', magnet_type='quadrupole', power_supply='Q2P2L4RP'), 'Q3M1K1RP': MagnetConfig(name='Q3M1K1RP', magnet_type='quadrupole', power_supply='Q3P1K1RP'), 'Q3M1L2RP': MagnetConfig(name='Q3M1L2RP', magnet_type='quadrupole', power_supply='Q3P1L2RP'), 'Q3M1K3RP': MagnetConfig(name='Q3M1K3RP', magnet_type='quadrupole', power_supply='Q3P1K3RP'), 'Q3M1L4RP': MagnetConfig(name='Q3M1L4RP', magnet_type='quadrupole', power_supply='Q3P1L4RP'), 'Q3M2K1RP': MagnetConfig(name='Q3M2K1RP', magnet_type='quadrupole', power_supply='Q3P2K1RP'), 'Q3M2L2RP': MagnetConfig(name='Q3M2L2RP', magnet_type='quadrupole', power_supply='Q3P2L2RP'), 'Q3M2K3RP': MagnetConfig(name='Q3M2K3RP', magnet_type='quadrupole', power_supply='Q3P2K3RP'), 'Q3M2L4RP': MagnetConfig(name='Q3M2L4RP', magnet_type='quadrupole', power_supply='Q3P2L4RP')}
# Get the families
>>> mls.families
{'Q1': ['Q1M1K1RP',
'Q1M1L2RP',
'Q1M1K3RP',
'Q1M1L4RP',
'Q1M2K1RP',
'Q1M2L2RP',
'Q1M2K3RP',
'Q1M2L4RP'],
'Q2': ['Q2M1K1RP',
'Q2M1L2RP',
'Q2M1K3RP',
'Q2M1L4RP',
'Q2M2K1RP',
'Q2M2L2RP',
'Q2M2K3RP',
'Q2M2L4RP'],
'Q3': ['Q3M1K1RP',
'Q3M1L2RP',
'Q3M1K3RP',
'Q3M1L4RP',
'Q3M2K1RP',
'Q3M2L2RP',
'Q3M2K3RP',
'Q3M2L4RP'],
'TuneCorrectors': ['Q1M1K1RP',
'Q1M1L2RP',
'Q1M1K3RP',
'Q1M1L4RP',
'Q1M2K1RP',
'Q1M2L2RP',
'Q1M2K3RP',
'Q1M2L4RP',
'Q3M1K1RP',
'Q3M1L2RP',
'Q3M1K3RP',
'Q3M1L4RP',
'Q3M2K1RP',
'Q3M2L2RP',
'Q3M2K3RP',
'Q3M2L4RP']}