From 8ae81ce8d2d2b12fc45a427926106a68c03288aa Mon Sep 17 00:00:00 2001 From: sfop Date: Mon, 29 Aug 2016 11:32:14 +0200 Subject: [PATCH] Script execution --- script/BpmStats.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/script/BpmStats.py b/script/BpmStats.py index 106f999..d4b5e2c 100644 --- a/script/BpmStats.py +++ b/script/BpmStats.py @@ -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)