diff --git a/kabuki/sources/camera.py b/kabuki/sources/camera.py index efaab25..33700df 100644 --- a/kabuki/sources/camera.py +++ b/kabuki/sources/camera.py @@ -1,8 +1,9 @@ from functools import wraps +from .cachedsource import CachedSource from .pvcollection import PVCollection -class Camera(PVCollection): +class Camera(CachedSource, PVCollection): """ Expects: pvname = "NAME:FPICTURE" Also creates NAME:WIDTH and NAME:HEIGHT @@ -13,12 +14,14 @@ class Camera(PVCollection): def __init__(self, pvname): assert pvname.endswith(":FPICTURE") base = pvname.rsplit(":", 1)[0] - super().__init__( + PVCollection.__init__( + self, base, image = pvname, width = base + ":WIDTH", height = base + ":HEIGHT" ) + CachedSource.__init__(self, size=1) self.pvs.image.auto_monitor = True def get(self): @@ -41,6 +44,9 @@ class Camera(PVCollection): return callback(*args, value=value, **kwargs) return self.pvs.image.add_callback(callback=wrapper, with_ctrlvars=False, **kwargs) + def remove_callback(self, *args, **kwargs): + return self.pvs.image.remove_callback(*args, **kwargs) + def clear_callbacks(self): self.pvs.image.clear_callbacks() diff --git a/kabuki/sources/source.py b/kabuki/sources/source.py index 344c7bc..a1ddb73 100644 --- a/kabuki/sources/source.py +++ b/kabuki/sources/source.py @@ -1,14 +1,16 @@ from epics import PV +from .cachedsource import CachedSource -class Source(PV): +class Source(CachedSource, PV): """ PV, but waits for connection on creation """ def __init__(self, pvname, *args, **kwargs): self.name = pvname - super().__init__(pvname, *args, **kwargs) + PV.__init__(self, pvname, *args, **kwargs) + CachedSource.__init__(self, size=100) self.is_connected = self.wait_for_connection()