Script execution

This commit is contained in:
sfop
2016-08-29 11:32:14 +02:00
parent dbc517271f
commit 8ae81ce8d2
+11 -12
View File
@@ -8,12 +8,12 @@ import random
class BpmStats(DeviceBase):
def __init__(self, name, prefix ):
DeviceBase.__init__(self, name, read_interval = 0.1)
self.prefix = prefix
def __init__(self, name, prefix, read_interval = 0.1):
DeviceBase.__init__(self, name)
self.read_interval = read_interval
self.bpm_x = Channel(prefix + ":X1", type = 'd', name + " x")
self.bpm_y = Channel(prefix + ":Y1", type = 'd', name + " y")
self.prefix = prefix
self.bpm_x = Channel(prefix + ":X1", type = 'd', alias = name + " x")
self.bpm_y = Channel(prefix + ":Y1", type = 'd', alias = name + " y")
self.com_x_samples, self.com_y_samples = [], []
class ComX(Readable):
def read(self):
@@ -50,9 +50,8 @@ class BpmStats(DeviceBase):
cx = self.bpm_x.read()
cy = self.bpm_y.read()
print "centroid ",[cx,cy]
if centroid is not None:
self.com_x_samples.append(cx)
self.com_y_samples.append(cy)
self.com_x_samples.append(cx)
self.com_y_samples.append(cy)
def setNumberOfImages(self, value):
self.num_images = value
@@ -75,10 +74,10 @@ class BpmStats(DeviceBase):
if __name__ == "__builtin__":
add_device(BpmStats("bpm com", "SINEG01-DBPM340"))
bpm_stats.setNumberOfImages(5)
add_device(BpmStats("bpm_com", "SINEG01-DBPM340"))
bpm_com.setNumberOfImages(5)
for i in range (10):
bpm_stats.update()
print bpm_stats.take(), bpm_stats.com_x_mean.read(), bpm_stats.com_y_mean.read()
bpm_com.update()
print bpm_com.take(), bpm_com.com_x_mean.read(), bpm_com.com_y_mean.read()
time.sleep(1)