Startup
This commit is contained in:
@@ -86,6 +86,8 @@ try:
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
else:
|
||||
sensors = get_camtool_stats(number_images, good_region=use_good_region)
|
||||
|
||||
|
||||
if plot_image:
|
||||
sensors.append(camtool.getDataMatrix())
|
||||
r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = before_sample, after_read = after_sample)
|
||||
|
||||
@@ -230,17 +230,58 @@ class CamtoolImage(ReadableMatrix):
|
||||
def wait_camtool_message(number_messages = 1, timeout = 10000):
|
||||
for i in range (number_messages):
|
||||
if not camtool.stream.waitCacheChange(timeout): raise Exception("Timeout receiving from Camtool")
|
||||
|
||||
|
||||
#Temporary wokarounbd
|
||||
|
||||
class CamtoolComX(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
v = camtool.getValue("x_profile")
|
||||
x = camtool.getValue("x_axis")
|
||||
s = 0
|
||||
p = 0
|
||||
for i in range(len(v)):
|
||||
s += x[i]*v[i]
|
||||
p += v[i]
|
||||
return s / p
|
||||
|
||||
class CamtoolComY(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
v = camtool.getValue("y_profile")
|
||||
x = camtool.getValue("y_axis")
|
||||
s = 0
|
||||
p = 0
|
||||
for i in range(len(v)):
|
||||
s += x[i]*v[i]
|
||||
p += v[i]
|
||||
return s / p
|
||||
|
||||
class CamtoolComErrorX(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
return 0.0
|
||||
|
||||
class CamtoolComErrorY(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
return 0.0
|
||||
|
||||
|
||||
def get_camtool_stats(number_images=1, async = True, interval=-1, good_region = False):
|
||||
#return [CamtoolValue("gr_x_fit_mean"), CamtoolValue("gr_y_fit_mean"), CamtoolValue("gr_x_fit_standard_deviation"), CamtoolValue("gr_y_fit_standard_deviation")]
|
||||
ret = []
|
||||
wait_camtool_message()
|
||||
prefix = "gr_" if good_region else ""
|
||||
"""
|
||||
for ident in [prefix+"x_fit_mean", prefix+"y_fit_mean", prefix+"x_fit_standard_deviation", prefix+"y_fit_standard_deviation"]:
|
||||
child = camtool.stream.getChild(ident)
|
||||
av = create_averager(child, number_images, interval)
|
||||
av.monitored = async
|
||||
ret.append(av)
|
||||
"""
|
||||
for dev in [CamtoolComX(), CamtoolComY(), CamtoolComErrorX(), CamtoolComErrorY()]:
|
||||
dev.initialize()
|
||||
av = create_averager (dev, number_images, 1/2.5)#(dev, number_images, interval)
|
||||
#av.monitored = async
|
||||
ret.append(av)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user