From 7975a23ab064b3948debe0aec0c67b34eb3620a8 Mon Sep 17 00:00:00 2001
From: Giulio Gaio <giulio.gaio@elettra.eu>
Date: Fri, 21 Jan 2022 16:07:35 +0100
Subject: [PATCH] Removed polling

---
 src/CalcStats.py | 178 +++--------------------------------------------
 1 file changed, 8 insertions(+), 170 deletions(-)

diff --git a/src/CalcStats.py b/src/CalcStats.py
index e0311b4..975968d 100755
--- a/src/CalcStats.py
+++ b/src/CalcStats.py
@@ -139,10 +139,16 @@ class DeviceObj:
 		self.enable_targets = 0xffffffff
 		self.enable_states = 0xffff
 		try:
+			if ERR_DBG == 1:
+				print('Connecting to ',self.device_name)
+			
 			self.device = DeviceProxy(self.device_name)
+			
+			if ERR_DBG == 1:
+				print('Connected to ',self.device_name)		
+		
 			self.device.set_timeout_millis(200)
-			self.util = tango.Util.instance()
-			print(util.get_host_name())
+
 		except DevFailed as df:
 			if ERR_DBG:
 				print('Error initializing ', self.device_name,'/',self.command) 
@@ -589,167 +595,6 @@ class DeviceObj:
 			if ERR_DBG:
 				print('Setting sequencer error ', self.device_name)
 
-	#
-	# DeviceObj::set_polling_attribute()
-	#
-	def set_polling_state(self):
-
-		if (self.index >= 0):
-			if self.polling_configured == False:
-				self.polling_configured = True
-				self.device.set_timeout_millis(10000)
-				if selfseq_dev.EnablePolling == True:
-					print("enable polling: ", self.device_name);
-						
-					#acquisition_period = int(selfseq_dev.AcquisitionPeriod * 1000 * 10)
-					acquisition_period = int(0)
-
-					# copy statistics to the sequencer
-					if (self.enable == True):
-						try:
-							attribute=self.prefix()+'{:03d}_AcqState'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:						
-							attribute=self.prefix()+'{:03d}_Mean'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_MinMax'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_Min'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_Max'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_Median'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_Std'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_Skew'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_Kurt'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-						try:
-							attribute=self.prefix()+'{:03d}_ValidSamples'.format(self.index+1);selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-						except:
-							print('Error configuring',attribute)
-					if self.tag == SENSOR_TAG:
-						for target in target_dev:
-							if (target.enable == True) and (self.enable == True):
-								if self.enable_targets & (1 << target.index):
-									attribute='s{:03d}_t{:03d}_Corr'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)											
-									attribute='s{:03d}_t{:03d}_CorrFiltAbs'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-									attribute='s{:03d}_t{:03d}_CorrHigh'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-									attribute='s{:03d}_t{:03d}_CorrLow'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-									attribute='s{:03d}_t{:03d}_Direction'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-
-					elif self.tag == TARGET_TAG:
-						for target in target_dev:
-							if (target.enable == True) and (self.enable == True):
-								if self.enable_targets & (1 << target.index):
-									attribute='t{:03d}_t{:03d}_Corr'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-									attribute='t{:03d}_t{:03d}_CorrFiltAbs'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)	
-									attribute='t{:03d}_t{:03d}_CorrHigh'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-									attribute='t{:03d}_t{:03d}_CorrLow'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-									attribute='t{:03d}_t{:03d}_Direction'.format(self.index+1,target.index+1)
-									try:
-										selfseq_dev.poll_attribute(attribute,acquisition_period);print('Enable poll',attribute,acquisition_period);
-									except:
-										print('Error configuring',attribute)
-				if selfseq_dev.DisablePolling == True:
-
-					# copy statistics to the sequencer
-					attribute=self.prefix()+'{:03d}_AcqState'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Mean'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_MinMax'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Min'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Max'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Median'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Std'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Skew'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_Kurt'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-					attribute=self.prefix()+'{:03d}_ValidSamples'.format(self.index+1);selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-
-					if self.tag == SENSOR_TAG:
-						for target in target_dev:
-							attribute='s{:03d}_t{:03d}_Corr'.format(self.index+1,target.index+1)
-							selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-							attribute='s{:03d}_t{:03d}_CorrFiltAbs'.format(self.index+1,target.index+1)
-							selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);	
-							attribute='s{:03d}_t{:03d}_CorrHigh'.format(self.index+1,target.index+1)
-							selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-							attribute='s{:03d}_t{:03d}_CorrLow'.format(self.index+1,target.index+1)
-							selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-							attribute='s{:03d}_t{:03d}_Direction'.format(self.index+1,target.index+1)
-							selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-
-					elif self.tag == TARGET_TAG:
-						for target in target_dev:
-							if (self.index+1) < (target.index+1):
-								attribute='t{:03d}_t{:03d}_Corr'.format(self.index+1,target.index+1)
-								selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-								attribute='t{:03d}_t{:03d}_CorrFiltAbs'.format(self.index+1,target.index+1)
-								selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-								attribute='t{:03d}_t{:03d}_CorrHigh'.format(self.index+1,target.index+1)
-								selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-								attribute='t{:03d}_t{:03d}_CorrLow'.format(self.index+1,target.index+1)
-								selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-								attribute='t{:03d}_t{:03d}_Direction'.format(self.index+1,target.index+1)
-								selfseq_dev.stop_poll_attribute(attribute);print('Disable poll',attribute);
-			
-
-
-
-		self.device.set_timeout_millis(1000)
 
 	#
 	# DeviceObj::filter_data()
@@ -1179,13 +1024,6 @@ while 1:
 		
 	for dev in target_dev:
 		dev.filter_data()
-
-
-#	for dev in sensor_dev:
-#		dev.set_polling_state()
-		
-#	for dev in target_dev:
-#		dev.set_polling_state()
 		
 	for dev in sensor_dev:
 		dev.process_stats()	
-- 
GitLab