From a6b8269234399e9904a1622cc769994869609503 Mon Sep 17 00:00:00 2001
From: Giulio Gaio <giulio.gaio@elettra.eu>
Date: Mon, 29 May 2023 11:51:53 +0200
Subject: [PATCH] Supporting mode 0 in Get...

---
 src/DataVampire.cpp | 19 +++++++------------
 src/acqthread.cpp   |  2 +-
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/DataVampire.cpp b/src/DataVampire.cpp
index efad341..b33ef97 100644
--- a/src/DataVampire.cpp
+++ b/src/DataVampire.cpp
@@ -1384,9 +1384,8 @@ Tango::DevVarDoubleArray *DataVampire::get_sum(const Tango::DevVarLongArray *arg
 	
 		// check and extract input parameters
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);	
-	
 		// if data not preset get data and store it into circular buffers
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		// get start idx of the circular buffer
 		int32_t start_idx = get_start_index(mode, num_samples, bn_start, bn_end);	
@@ -1444,7 +1443,7 @@ Tango::DevVarDoubleArray *DataVampire::get_mean(const Tango::DevVarLongArray *ar
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);
 		
 		// if data not preset get data and store it into circular buffers	
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		
 		// get start idx of the circular buffer
@@ -1504,7 +1503,7 @@ Tango::DevVarDoubleArray *DataVampire::get_hor_pos(const Tango::DevVarLongArray
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);
 		
 		// if data not preset get data and store it into circular buffers	
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		
 		// get start idx of the circular buffer
@@ -1564,7 +1563,7 @@ Tango::DevVarDoubleArray *DataVampire::get_ver_pos(const Tango::DevVarLongArray
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);
 		
 		// if data not preset get data and store it into circular buffers	
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		
 		// get start idx of the circular buffer
@@ -1624,7 +1623,7 @@ Tango::DevVarDoubleArray *DataVampire::get_hor_pos_std(const Tango::DevVarLongAr
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);
 		
 		// if data not preset get data and store it into circular buffers	
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		
 		// get start idx of the circular buffer
@@ -1684,7 +1683,7 @@ Tango::DevVarDoubleArray *DataVampire::get_ver_pos_std(const Tango::DevVarLongAr
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);
 		
 		// if data not preset get data and store it into circular buffers	
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		
 		// get start idx of the circular buffer
@@ -1744,7 +1743,7 @@ Tango::DevVarDoubleArray *DataVampire::get_valid_values(const Tango::DevVarLongA
 		get_param_in(argin, &mode, &num_samples, &bn_start, &bn_end);
 		
 		// if data not preset get data and store it into circular buffers	
-		if (bn_end > last_bn)
+		if ((bn_end > last_bn) || (mode == 0))
 			store_circ_data(mode, num_samples, last_bn+1, bn_end);	
 		
 		// get start idx of the circular buffer
@@ -2818,10 +2817,6 @@ void DataVampire::store_circ_data(int32_t mode, int32_t num_samples, int32_t bn_
 		}	
 	}	
 
-	/*for (int i = 0; i < cmd_input_value.size(); i++) {
-		printf("in %d %f\n",i, cmd_input_value[i]);
-	}*/
-
 	try {
 		// prepare input
 		Tango::DeviceData Din = cmd_insert_values(cmd_in_type, cmd_input_value, cmd_input_value_str);
diff --git a/src/acqthread.cpp b/src/acqthread.cpp
index dd2618d..98e7637 100644
--- a/src/acqthread.cpp
+++ b/src/acqthread.cpp
@@ -13,7 +13,7 @@
  */		
 void *acqthread::run_undetached(void *) 
 {
-	int margin = 2;
+	int margin = 3;
 	double frequency = 50;
 	int32_t old_bn = 0;
 	Tango::DevLong bunch_number;
-- 
GitLab