From e82563e7f50b0e684fa510bd93a32436918a9443 Mon Sep 17 00:00:00 2001
From: Alessio Igor Bogani <alessio.bogani@elettra.eu>
Date: Tue, 11 Jan 2022 22:43:17 +0100
Subject: [PATCH] Avoid to change device's mode during init()

---
 src/Agilent4uhv.cpp | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/Agilent4uhv.cpp b/src/Agilent4uhv.cpp
index 7f39cb1..f7a76ad 100644
--- a/src/Agilent4uhv.cpp
+++ b/src/Agilent4uhv.cpp
@@ -249,6 +249,15 @@ void Agilent4uhv::init_device()
 		attr_Model_read[0] = new char[MAX_DEVSTRING_LENGTH];
 		attr_SerialNumber_read[0] = new char[MAX_DEVSTRING_LENGTH];
 
+		/* Che if the mBar is pressure unit used */
+		int pressure_unit;
+		read_window(600, pressure_unit);
+		if (pressure_unit != 1) {
+			Tango::Except::throw_exception( "",
+					"mBar is not the pressure unit used",
+					"Agilent4uhv::init_device()");
+		}
+
 		/* Identify model:
 		* 9299200/1 con 2 canali x 80W  --> attivi canali 1 e 2
 		* 9299020   con 2 canali x 200W --> attivi canali 1 e 3
@@ -279,16 +288,8 @@ void Agilent4uhv::init_device()
 		read_window(323, serial);
 		strncpy(attr_SerialNumber_read[0], serial.c_str(), MAX_DEVSTRING_LENGTH);
 
-		// Set the mode
-//		int mode = 0; /* Serial */
-//		write_window(8, mode);
-
-		/* Setup mBar as pressure unit used */
-		int pressure_unit = 1 /* mBar */;
-		write_window(600, pressure_unit);
-
 		/* Read all the device data */
-		static const int nw[] = { 8, /*, 108, 320, 323, 503, 504, 600 */
+		static const int nw[] = { 8, /*, 108, 205, 320, 319, 323, 503, 504, 600 */
 			601, 602, 603, 800, 801, 802, 803, 804, 808, 809, 810, 811};
 		vector<int> normal_windows(nw, nw + sizeof(nw) / sizeof(nw[0]));
 		for (size_t i=0; i<channels.size(); ++i) {
-- 
GitLab