From 24cbccb6a6a341217fc7d08ecd3785557ed8ddfc Mon Sep 17 00:00:00 2001 From: reiche Date: Thu, 27 Jun 2024 14:49:05 +0200 Subject: [PATCH] Added routines to get only the PVs from snapshot file and to get the data by these PVS. This avoids crashed of too many files open when used often --- interface/__init__.py | 2 ++ interface/snap.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/interface/__init__.py b/interface/__init__.py index 397be37..4621928 100644 --- a/interface/__init__.py +++ b/interface/__init__.py @@ -1,4 +1,6 @@ from .snap import getSnap +from .snap import getSnapPV +from .snap import getSnapVal from .snap import saveSnap from .snap import loadSnap from .snap import parseSnapShotReqYAML diff --git a/interface/snap.py b/interface/snap.py index 5cc0063..5842b73 100644 --- a/interface/snap.py +++ b/interface/snap.py @@ -61,6 +61,24 @@ def getSnap(pvs=None): ret[pv]=float(val[i]) return ret +def getSnapPV(pvs=None): + if not isinstance(pvs,list): + pvs = parseSnapShotReqYAML(pvs) + if not pvs: + return + return [epics.PV(pvname,auto_monitor = False) for pvname in pvs] + + +def getSnapVal(pvs=None): + if not pvs: + return None + ret={} + val = [pv.value for pv in pvs] + for i,pv in enumerate(pvs): + if not val[i] is None: # filter out None values + ret[pv.pvname]=float(val[i]) + return ret + def saveSnap(pvs={},label="", comment = "generated by application",reqfile = "SF_settings.yaml"): filename = datetime.datetime.now().strftime('/sf/data/applications/snapshot/SF_settings_%Y%m%d_%H%M%S.snap') with open(filename,'w') as fid: