added PV for the PV type; convert type name to field type; added workaround for enum PV not working

This commit is contained in:
2024-11-14 17:35:49 +01:00
parent 42e042811f
commit 9c087476f0

View File

@ -5,11 +5,21 @@ from log import log
from utils import toggle
DTYPES = {
"float": "ai",
"int": "longin",
"bool": "bi",
"str": "stringin"
}
FN_ENTRIES = "/ioc/data/SATES20-CPCL-DYNA/entries"
FN_DB_TMPL = "/ioc/data/SATES20-CPCL-DYNA/dynamic.template"
pv_name = PV("SATES20-DYNA:NAME")
pv_dtyp = PV("SATES20-DYNA:TYPE")
pv_dtyp.get_ctrlvars() # without this, the enum returns only str(number)
@toggle
@ -18,7 +28,9 @@ def cb_add(value=None, **kwargs):
if not name:
log.info(f"add: ignoring name={repr(name)}")
return
log.info(f"add: name={repr(name)} {kwargs}")
dtyp = pv_dtyp.get(as_string=True)
dtyp = DTYPES[dtyp]
log.info(f"add: name={repr(name)} type={repr(dtyp)} {kwargs}")
data = load_data(FN_ENTRIES)
data.add(name)
save_data(data, FN_ENTRIES)