Skip to content

quantity ¤

Classes:

Name Description
Quantity

Quantity is used to describe the attributes of a driver

Functions:

Name Description
newcfg

generate a new config

Quantity(name: str, value=None, ch: int = 0, unit: str = '') ¤

Bases: object

Quantity is used to describe the attributes of a driver

Source code in quark/driver/common/quantity.py
30
31
32
33
34
def __init__(self, name: str, value=None, ch: int = 0, unit: str = ''):
    self.name: str = name
    self.default: dict = dict(value=value,
                              unit=unit,
                              ch='global' if not ch else ch)

newcfg(quantlist: list[Quantity] = [], CHs: list[int | str] = []) -> dict ¤

generate a new config

Source code in quark/driver/common/quantity.py
40
41
42
43
44
45
46
47
48
49
50
51
def newcfg(quantlist: list[Quantity] = [], CHs: list[int | str] = []) -> dict:
    '''generate a new config'''
    config = {}
    for q in deepcopy(quantlist):
        _cfg = {}
        _default = dict(value=q.default['value'], unit=q.default['unit'])
        for i in CHs:
            _cfg.update({i: deepcopy(_default)})
        if q.default['ch'] == 'global':
            _cfg.update({'global': deepcopy(_default)})
        config.update({q.name: _cfg})
    return config