Wraps MAX IV's dsconfig JSON generator to let the user use Python to generate the config
Project description
dsconfig-wrapper
This is a small Python library to complement MAX IV's excellent dsconfig library, which can make the database for the Tango controls system declarative by updating it from a JSON file.
Usually, it looks like this:
flowchart TD
DatabaseDs[(Tango Database)]
DatabaseDs -->|dsconfig.dump| JsonFile[JSON file]
Human -->|vim/emacs| JsonFile
JsonFile -->|json2tango| DatabaseDs
With this tool, it looks like this:
flowchart TD
DatabaseDs[(Tango Database)]
Human -->|vim/emacs| PythonFile[Python file]
DsconfigWrapper[dsconfig-wrapper] -->|import| PythonFile
PythonFile -->|dsconfig-wrapper| JsonFile
JsonFile -->|json2tango| DatabaseDs
This way, we can have our configuration not in JSON, but in Python! And in Python, we can have, for instance, argparse
, to create a little program that can generate a configuration with parameters. You can also use Python DRY elements in your configuration (say, you have the same motor, but with various different properties set).
Usage
Just do
pip install dsconfig-wrapper
and then use it to create a config JSON. Example:
test_servers = [
Server(
instance_name="my_instance_name",
class_name="my_class_name",
devices=[
Device(
identifier=Identifier(
domain="my_domain",
family="my_family",
member="my_member",
host="my_host:10000",
),
properties={
"prop_str": "strvalue",
"prop_list_str": ["value1", "value2"],
"prop_list_int": [2000, 3000],
"prop_int": 2000,
},
polled_commands={"update": 1000},
attribute_properties={
"State": AttributeProperties(archive_period_ms=1001),
"velocity_mm_per_s": AttributeProperties(
archive_abs_change=(-0.5, 0.5),
archive_period_ms=5000,
rel_change=(-0.05, 0.05),
),
},
)
],
)
]
test_config = Config(servers=test_servers)
print(config_to_json(test_config))
Here, we create a config for a device server with class my_class_name
and one instance running at tango://myhost:10000/my_domain/my_family/my_member
. The update
command is polled every second, and we also set some properties and attribute properties.
We now run this program (say it's stored in main.py
) and pipe it into dsconfig:
python main.py | json2tango
Voila!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dsconfig_wrapper-1.1.0.tar.gz
.
File metadata
- Download URL: dsconfig_wrapper-1.1.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.0 CPython/3.10.12 Linux/6.1.47
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03c35c7a1896c6cdc35bb532b9c25a200acc0ad6b01cc8d628974d388c0609b2 |
|
MD5 | cbc2d9f9f4b0d50cebdd6e28e8bfab97 |
|
BLAKE2b-256 | 71169558ce281b566e0f1e1d75600f752994157e278cfaa6f682ed451eb5e505 |
File details
Details for the file dsconfig_wrapper-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: dsconfig_wrapper-1.1.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.0 CPython/3.10.12 Linux/6.1.47
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ba2cd8b8055007978570f631c07743bb70398afb10e5d820f77d855068fc87 |
|
MD5 | 4c755e2da81553fa8b709b25e1dca481 |
|
BLAKE2b-256 | 66fe174f693216ed47a5e53eab73d0a5e47a13b79fa5421f1a5e773debf295fe |