DAQ: cleaned up aeradetector script and stop acquisition before auto_exposure and initialising.
This commit is contained in:
@@ -62,72 +62,15 @@ class epicsAD(object):
|
||||
pass
|
||||
|
||||
def __init_auto_exp(self, settings: AutoExposureSettings = AutoExposureSettings()):
|
||||
self.acquire.put(0)
|
||||
self.aoi_start_x.put(settings.aoi_offset_x)
|
||||
self.aoi_start_y.put(settings.aoi_offset_y)
|
||||
self.aoi_size_x.put(settings.aoi_size_x)
|
||||
self.aoi_size_y.put(settings.aoi_size_y)
|
||||
self.gain_max.put(settings.gain_max)
|
||||
self.exp_max.put(settings.exp_max)
|
||||
self.set_auto_once()
|
||||
self.set_auto(AutoEnum.ONCE)
|
||||
self.auto_white_balance.put(1)
|
||||
|
||||
def monitorCB(self, epicsArgs, userArgs):
|
||||
self.img = epicsArgs["pv_value"]
|
||||
self.img.dtype = np.uint8
|
||||
self.img.shape = self.shape
|
||||
self.monitored = True
|
||||
|
||||
def setMonitor(self):
|
||||
ndim = self.ndim.get()
|
||||
dim0 = self.dim0.get()
|
||||
dim1 = self.dim1.get()
|
||||
dim2 = self.dim2.get()
|
||||
if ndim == 3:
|
||||
size = dim0 * dim1 * dim2
|
||||
self.shape = (dim2, dim1, dim0)
|
||||
else:
|
||||
size = dim0 * dim1
|
||||
self.shape = (dim1, dim0)
|
||||
self.data.add_masked_array_event(None, size, None, self.monitorCB)
|
||||
|
||||
def clearMonitor(self):
|
||||
self.data.clear_event()
|
||||
self.monitored = False
|
||||
|
||||
def getShape(self):
|
||||
ndim = self.ndim.get()
|
||||
dim0 = self.dim0.get()
|
||||
dim1 = self.dim1.get()
|
||||
dim2 = self.dim2.get()
|
||||
|
||||
if ndim == 3:
|
||||
shape = (dim2, dim1, dim0)
|
||||
else:
|
||||
shape = (dim1, dim0)
|
||||
return shape
|
||||
|
||||
def get_image_center(self):
|
||||
shape = self.getShape()
|
||||
return (shape[0] / 2, shape[1] / 2)
|
||||
|
||||
def get_single_image(self):
|
||||
self.image_mode.put(0)
|
||||
counter = self.counter.get()
|
||||
self.acquire.put(1)
|
||||
while self.counter.get() == counter:
|
||||
epics.poll(0.01)
|
||||
|
||||
def collect_one_image(self):
|
||||
self.acquire.put(0)
|
||||
self.image_mode.put(0, wait=True)
|
||||
|
||||
self.acquire.put(1, wait=True)
|
||||
while self.busy.value == 1:
|
||||
epics.poll(0.01)
|
||||
|
||||
def collect_auto(self):
|
||||
self.acquire.put(0)
|
||||
self.image_mode.put(2)
|
||||
self.acquire.put(1)
|
||||
|
||||
def get_image(self, gray=True) -> np.ndarray:
|
||||
@@ -169,26 +112,8 @@ class epicsAD(object):
|
||||
self.acquire.put(1)
|
||||
|
||||
def set_auto(self, state: AutoEnum):
|
||||
"""Uses AutoEnum 0 is Manual, 1 is Once, 2 is Auto"""
|
||||
self.acquire.put(0, wait=True)
|
||||
self.gain_mode.put(state.value) # automatic gain control
|
||||
self.expo_mode.put(state.value) # automatic exposure control
|
||||
self.acquire.put(1)
|
||||
|
||||
def set_auto_once(self):
|
||||
self.expo_mode.put(AutoEnum.ONCE.value)
|
||||
self.gain_mode.put(AutoEnum.ONCE.value)
|
||||
|
||||
def set_manual(self):
|
||||
self.acquire.put(0, wait=True)
|
||||
self.gain_mode.put(AutoEnum.MANUAL.value) # manual gain control
|
||||
self.expo_mode.put(AutoEnum.MANUAL.value) # manual exposure control
|
||||
self.acquire.put(1)
|
||||
|
||||
def restore(self, gain: float = 5, expo: float = 0.025):
|
||||
# Put this values, so the camera faster resores proper values in Auto mode
|
||||
self.acquire.put(0, wait=True)
|
||||
self.gain.put(gain)
|
||||
self.expo.put(expo)
|
||||
self.gain_mode.put(2) # automatic gain control
|
||||
self.expo_mode.put(2) # automatic exposure control
|
||||
self.acquire.put(1)
|
||||
self.acquire.put(1)
|
||||
Reference in New Issue
Block a user