refactored decide functions
This commit is contained in:
@ -10,41 +10,41 @@ def get_src(pvname, cls):
|
|||||||
src = src_cache[pvname]
|
src = src_cache[pvname]
|
||||||
assert isinstance(src, cls)
|
assert isinstance(src, cls)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
src = cls(pvname)
|
src = src_cache[pvname] = cls(pvname)
|
||||||
src_cache[pvname] = src
|
|
||||||
return src
|
return src
|
||||||
|
|
||||||
|
|
||||||
def decide_src_plt(pvname):
|
def decide_src_plt(pvname):
|
||||||
pvname = pvname.upper()
|
Src = decide_src_type(pvname)
|
||||||
|
src = get_src(pvname, Src)
|
||||||
|
if not src.is_connected:
|
||||||
|
raise RuntimeError(f"{pvname} is not connected")
|
||||||
|
|
||||||
if pvname.endswith(":FPICTURE"):
|
Plt = decide_plt_type(src)
|
||||||
print("Camera", pvname)
|
plt = Plt(name=pvname)
|
||||||
src = get_src(pvname, Camera)
|
|
||||||
plt = Plot2D
|
|
||||||
if not src.is_connected:
|
|
||||||
raise RuntimeError(f"{pvname} is not connected")
|
|
||||||
|
|
||||||
else:
|
|
||||||
print("Source", pvname)
|
|
||||||
src = get_src(pvname, Source)
|
|
||||||
if not src.is_connected:
|
|
||||||
raise RuntimeError(f"{pvname} is not connected")
|
|
||||||
print(src.nelm)
|
|
||||||
if src.nelm == 0:
|
|
||||||
raise RuntimeError(f"{src}: {src.value}")
|
|
||||||
|
|
||||||
if src.nelm == 1:
|
|
||||||
print("Scalar")
|
|
||||||
plt = Plot0D
|
|
||||||
else:
|
|
||||||
print("Curve")
|
|
||||||
plt = Plot1D
|
|
||||||
|
|
||||||
plt = plt(name=pvname)
|
|
||||||
return src, plt
|
return src, plt
|
||||||
|
|
||||||
|
|
||||||
|
def decide_src_type(pvname):
|
||||||
|
if pvname.endswith(":FPICTURE"):
|
||||||
|
return Camera
|
||||||
|
return Source
|
||||||
|
|
||||||
|
|
||||||
|
def decide_plt_type(src):
|
||||||
|
if isinstance(src, Camera):
|
||||||
|
return Plot2D
|
||||||
|
|
||||||
|
nelm = src.nelm
|
||||||
|
if nelm == 1:
|
||||||
|
return Plot0D
|
||||||
|
elif nelm > 1:
|
||||||
|
return Plot1D
|
||||||
|
|
||||||
|
raise RuntimeError(f"Cannot decide plot type for {src}: {src.value}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Actor:
|
class Actor:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user