From cc50f4deec95081526c80ef45c7a1c003ceff922 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Fri, 23 Feb 2024 17:50:40 +0100
Subject: [PATCH 01/14] early skeleton

---
 .gitignore                      |   8 +
 Makefile                        |   3 +
 src/ClassFactory.cpp            |  53 +++
 src/E2Corrector.cpp             | 604 ++++++++++++++++++++++++
 src/E2Corrector.h               | 274 +++++++++++
 src/E2Corrector.xmi             | 122 +++++
 src/E2CorrectorClass.cpp        | 784 ++++++++++++++++++++++++++++++++
 src/E2CorrectorClass.h          | 241 ++++++++++
 src/E2CorrectorStateMachine.cpp | 204 +++++++++
 src/main.cpp                    |  89 ++++
 10 files changed, 2382 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Makefile
 create mode 100644 src/ClassFactory.cpp
 create mode 100644 src/E2Corrector.cpp
 create mode 100644 src/E2Corrector.h
 create mode 100644 src/E2Corrector.xmi
 create mode 100644 src/E2CorrectorClass.cpp
 create mode 100644 src/E2CorrectorClass.h
 create mode 100644 src/E2CorrectorStateMachine.cpp
 create mode 100644 src/main.cpp

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..563ccc8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+.nse_depinfo*
+bin
+obj
+
+# Eclipse
+.cproject
+.project
+.settings
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..edaad1d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+NAME_SRV = e2corrector-srv
+
+include ../makefiles/Make-9.3.6.in
diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp
new file mode 100644
index 0000000..c241d0b
--- /dev/null
+++ b/src/ClassFactory.cpp
@@ -0,0 +1,53 @@
+/*----- PROTECTED REGION ID(E2Corrector::ClassFactory.cpp) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        ClassFactory.cpp
+//
+// description : C++ source for the class_factory method of the DServer
+//               device class. This method is responsible for the creation of
+//               all class singleton for a device server. It is called
+//               at device server startup.
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+
+#include <tango/tango.h>
+#include "E2CorrectorClass.h"
+
+//	Add class header files if needed
+
+
+/**
+ *	Create E2Corrector Class singleton and store it in DServer object.
+ */
+
+void Tango::DServer::class_factory()
+{
+	//	Add method class init if needed
+	add_class(E2Corrector_ns::E2CorrectorClass::init("E2Corrector"));
+}
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::ClassFactory.cpp
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
new file mode 100644
index 0000000..0530359
--- /dev/null
+++ b/src/E2Corrector.cpp
@@ -0,0 +1,604 @@
+/*----- PROTECTED REGION ID(E2Corrector.cpp) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        E2Corrector.cpp
+//
+// description : C++ source for the E2Corrector class and its commands.
+//               The class is derived from Device. It represents the
+//               CORBA servant object which will be accessed from the
+//               network. All commands which can be executed on the
+//               E2Corrector are implemented in this file.
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+
+
+#include "E2Corrector.h"
+#include "E2CorrectorClass.h"
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector.cpp
+
+/**
+ *  E2Corrector class description:
+ *    Elettra 2.0 pure corrector magnet device
+ *    Use calibration table handle current/strgenght converstions.
+ *    The magnet device is connected to a power supply tango device , real or simulated.
+ *    
+ *    Based on ESRF EBSmagnet concepts and libraries.
+ */
+
+//================================================================
+//  The following table gives the correspondence
+//  between command and method names.
+//
+//  Command name            |  Method name
+//================================================================
+//  State                   |  Inherited (no method)
+//  Status                  |  Inherited (no method)
+//  Reset                   |  reset
+//  ResetResonanceStrength  |  reset_resonance_strength
+//================================================================
+
+//================================================================
+//  Attributes managed are:
+//================================================================
+//  Strength            |  Tango::DevDouble	Scalar
+//  CorrectionStrength  |  Tango::DevDouble	Scalar
+//  ResonanceStrength   |  Tango::DevDouble	Scalar
+//  Current             |  Tango::DevDouble	Scalar
+//  BeamEnergy          |  Tango::DevDouble	Scalar
+//================================================================
+
+namespace E2Corrector_ns
+{
+/*----- PROTECTED REGION ID(E2Corrector::namespace_starting) ENABLED START -----*/
+/* clang-format on */
+//	static initializations
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::namespace_starting
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::E2Corrector()
+ * Description:  Constructors for a Tango device
+ *                implementing the classE2Corrector
+ */
+//--------------------------------------------------------
+E2Corrector::E2Corrector(Tango::DeviceClass *cl, std::string &s)
+ : TANGO_BASE_CLASS(cl, s.c_str())
+{
+	/*----- PROTECTED REGION ID(E2Corrector::constructor_1) ENABLED START -----*/
+	/* clang-format on */
+	init_device();
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::constructor_1
+}
+//--------------------------------------------------------
+E2Corrector::E2Corrector(Tango::DeviceClass *cl, const char *s)
+ : TANGO_BASE_CLASS(cl, s)
+{
+	/*----- PROTECTED REGION ID(E2Corrector::constructor_2) ENABLED START -----*/
+	/* clang-format on */
+	init_device();
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::constructor_2
+}
+//--------------------------------------------------------
+E2Corrector::E2Corrector(Tango::DeviceClass *cl, const char *s, const char *d)
+ : TANGO_BASE_CLASS(cl, s, d)
+{
+	/*----- PROTECTED REGION ID(E2Corrector::constructor_3) ENABLED START -----*/
+	/* clang-format on */
+	init_device();
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::constructor_3
+}
+//--------------------------------------------------------
+E2Corrector::~E2Corrector()
+{
+	delete_device();
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::delete_device()
+ * Description:  will be called at device destruction or at init command
+ */
+//--------------------------------------------------------
+void E2Corrector::delete_device()
+{
+	DEBUG_STREAM << "E2Corrector::delete_device() " << device_name << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::delete_device) ENABLED START -----*/
+	/* clang-format on */
+	//	Delete device allocated objects
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::delete_device
+	delete[] attr_Strength_read;
+	delete[] attr_BeamEnergy_read;
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::init_device()
+ * Description:  will be called at device initialization.
+ */
+//--------------------------------------------------------
+void E2Corrector::init_device()
+{
+	DEBUG_STREAM << "E2Corrector::init_device() create device " << device_name << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::init_device_before) ENABLED START -----*/
+	/* clang-format on */
+	//	Initialization before get_device_property() call
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device_before
+
+
+	//	Get the device properties from database
+	get_device_property();
+
+	attr_Strength_read = new Tango::DevDouble[1];
+	attr_BeamEnergy_read = new Tango::DevDouble[1];
+	/*----- PROTECTED REGION ID(E2Corrector::init_device) ENABLED START -----*/
+	/* clang-format on */
+	//	Initialize device
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::get_device_property()
+ * Description:  Read database to initialize property data members.
+ */
+//--------------------------------------------------------
+void E2Corrector::get_device_property()
+{
+	/*----- PROTECTED REGION ID(E2Corrector::get_device_property_before) ENABLED START -----*/
+	/* clang-format on */
+	//	Initialize property data members
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::get_device_property_before
+
+
+	//	Read device properties from database.
+	Tango::DbData	dev_prop;
+	dev_prop.push_back(Tango::DbDatum("CurrentDevice"));
+	dev_prop.push_back(Tango::DbDatum("Model"));
+	dev_prop.push_back(Tango::DbDatum("SerialNumber"));
+	dev_prop.push_back(Tango::DbDatum("Type"));
+	dev_prop.push_back(Tango::DbDatum("MagnetName"));
+	dev_prop.push_back(Tango::DbDatum("CalibrationName"));
+
+	//	is there at least one property to be read ?
+	if (dev_prop.size()>0)
+	{
+		//	Call database and extract values
+		if (Tango::Util::instance()->_UseDb==true)
+			get_db_device()->get_property(dev_prop);
+
+		//	get instance on E2CorrectorClass to get class property
+		Tango::DbDatum	def_prop, cl_prop;
+		E2CorrectorClass	*ds_class =
+			(static_cast<E2CorrectorClass *>(get_device_class()));
+		int	i = -1;
+
+		//	Try to initialize CurrentDevice from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  currentDevice;
+		else {
+			//	Try to initialize CurrentDevice from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  currentDevice;
+		}
+		//	And try to extract CurrentDevice value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  currentDevice;
+
+		//	Try to initialize Model from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  model;
+		else {
+			//	Try to initialize Model from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  model;
+		}
+		//	And try to extract Model value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  model;
+
+		//	Try to initialize SerialNumber from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  serialNumber;
+		else {
+			//	Try to initialize SerialNumber from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  serialNumber;
+		}
+		//	And try to extract SerialNumber value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  serialNumber;
+
+		//	Try to initialize Type from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  type;
+		else {
+			//	Try to initialize Type from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  type;
+		}
+		//	And try to extract Type value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  type;
+
+		//	Try to initialize MagnetName from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  magnetName;
+		else {
+			//	Try to initialize MagnetName from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  magnetName;
+		}
+		//	And try to extract MagnetName value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  magnetName;
+
+		//	Try to initialize CalibrationName from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  calibrationName;
+		else {
+			//	Try to initialize CalibrationName from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  calibrationName;
+		}
+		//	And try to extract CalibrationName value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  calibrationName;
+
+	}
+
+	/*----- PROTECTED REGION ID(E2Corrector::get_device_property_after) ENABLED START -----*/
+	/* clang-format on */
+	//	Check device property data members init
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::get_device_property_after
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::always_executed_hook()
+ * Description:  method always executed before any command is executed
+ */
+//--------------------------------------------------------
+void E2Corrector::always_executed_hook()
+{
+	DEBUG_STREAM << "E2Corrector::always_executed_hook()  " << device_name << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::always_executed_hook) ENABLED START -----*/
+	/* clang-format on */
+	//	code always executed before all requests
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::always_executed_hook
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::read_attr_hardware()
+ * Description:  Hardware acquisition for attributes
+ */
+//--------------------------------------------------------
+void E2Corrector::read_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
+{
+	DEBUG_STREAM << "E2Corrector::read_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_attr_hardware) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_attr_hardware
+}
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::write_attr_hardware()
+ * Description:  Hardware writing for attributes
+ */
+//--------------------------------------------------------
+void E2Corrector::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
+{
+	DEBUG_STREAM << "E2Corrector::write_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::write_attr_hardware) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_attr_hardware
+}
+
+//--------------------------------------------------------
+/**
+ *	Read attribute Strength related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::read_Strength(Tango::Attribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::read_Strength(Tango::Attribute &attr) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_Strength) ENABLED START -----*/
+	/* clang-format on */
+	//	Set the attribute value
+	attr.set_value(attr_Strength_read);
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_Strength
+}
+//--------------------------------------------------------
+/**
+ *	Write attribute Strength related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::write_Strength(Tango::WAttribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::write_Strength(Tango::WAttribute &attr) entering... " << std::endl;
+	//	Retrieve write value
+	Tango::DevDouble	w_val;
+	attr.get_write_value(w_val);
+	/*----- PROTECTED REGION ID(E2Corrector::write_Strength) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Strength
+}
+//--------------------------------------------------------
+/**
+ *	Read attribute CorrectionStrength related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::read_CorrectionStrength(Tango::Attribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::read_CorrectionStrength(Tango::Attribute &attr) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_CorrectionStrength) ENABLED START -----*/
+	/* clang-format on */
+	//	Set the attribute value
+	attr.set_value(attr_CorrectionStrength_read);
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_CorrectionStrength
+}
+//--------------------------------------------------------
+/**
+ *	Write attribute CorrectionStrength related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::write_CorrectionStrength(Tango::WAttribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::write_CorrectionStrength(Tango::WAttribute &attr) entering... " << std::endl;
+	//	Retrieve write value
+	Tango::DevDouble	w_val;
+	attr.get_write_value(w_val);
+	/*----- PROTECTED REGION ID(E2Corrector::write_CorrectionStrength) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_CorrectionStrength
+}
+//--------------------------------------------------------
+/**
+ *	Read attribute ResonanceStrength related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::read_ResonanceStrength(Tango::Attribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::read_ResonanceStrength(Tango::Attribute &attr) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_ResonanceStrength) ENABLED START -----*/
+	/* clang-format on */
+	//	Set the attribute value
+	attr.set_value(attr_ResonanceStrength_read);
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_ResonanceStrength
+}
+//--------------------------------------------------------
+/**
+ *	Write attribute ResonanceStrength related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr) entering... " << std::endl;
+	//	Retrieve write value
+	Tango::DevDouble	w_val;
+	attr.get_write_value(w_val);
+	/*----- PROTECTED REGION ID(E2Corrector::write_ResonanceStrength) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_ResonanceStrength
+}
+//--------------------------------------------------------
+/**
+ *	Read attribute Current related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::read_Current(Tango::Attribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::read_Current(Tango::Attribute &attr) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_Current) ENABLED START -----*/
+	/* clang-format on */
+	//	Set the attribute value
+	attr.set_value(attr_Current_read);
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_Current
+}
+//--------------------------------------------------------
+/**
+ *	Write attribute Current related method
+ *
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::write_Current(Tango::WAttribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::write_Current(Tango::WAttribute &attr) entering... " << std::endl;
+	//	Retrieve write value
+	Tango::DevDouble	w_val;
+	attr.get_write_value(w_val);
+	/*----- PROTECTED REGION ID(E2Corrector::write_Current) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Current
+}
+//--------------------------------------------------------
+/**
+ *	Read attribute BeamEnergy related method
+ * Description:  Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::read_BeamEnergy(Tango::Attribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::read_BeamEnergy(Tango::Attribute &attr) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_BeamEnergy) ENABLED START -----*/
+	/* clang-format on */
+	//	Set the attribute value
+	attr.set_value(attr_BeamEnergy_read);
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_BeamEnergy
+}
+//--------------------------------------------------------
+/**
+ *	Write attribute BeamEnergy related method
+ * Description:  Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::write_BeamEnergy(Tango::WAttribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::write_BeamEnergy(Tango::WAttribute &attr) entering... " << std::endl;
+	//	Retrieve write value
+	Tango::DevDouble	w_val;
+	attr.get_write_value(w_val);
+	/*----- PROTECTED REGION ID(E2Corrector::write_BeamEnergy) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_BeamEnergy
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::add_dynamic_attributes()
+ * Description:  Create the dynamic attributes if any
+ *                for specified device.
+ */
+//--------------------------------------------------------
+void E2Corrector::add_dynamic_attributes()
+{
+	/*----- PROTECTED REGION ID(E2Corrector::add_dynamic_attributes) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code to create and add dynamic attributes if any
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::add_dynamic_attributes
+}
+
+//--------------------------------------------------------
+/**
+ *	Command Reset related method
+ * Description:  reset the corrector
+ *
+ */
+//--------------------------------------------------------
+void E2Corrector::reset()
+{
+	DEBUG_STREAM << "E2Corrector::Reset()  - " << device_name << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::reset) ENABLED START -----*/
+	/* clang-format on */
+
+	//	Add your own code
+
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::reset
+}
+//--------------------------------------------------------
+/**
+ *	Command ResetResonanceStrength related method
+ * Description:  Reset ResonanceStrength to 0
+ *
+ */
+//--------------------------------------------------------
+void E2Corrector::reset_resonance_strength()
+{
+	DEBUG_STREAM << "E2Corrector::ResetResonanceStrength()  - " << device_name << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::reset_resonance_strength) ENABLED START -----*/
+	/* clang-format on */
+
+	//	Add your own code
+
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::reset_resonance_strength
+}
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::add_dynamic_commands()
+ * Description:  Create the dynamic commands if any
+ *                for specified device.
+ */
+//--------------------------------------------------------
+void E2Corrector::add_dynamic_commands()
+{
+	/*----- PROTECTED REGION ID(E2Corrector::add_dynamic_commands) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code to create and add dynamic commands if any
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::add_dynamic_commands
+}
+
+/*----- PROTECTED REGION ID(E2Corrector::namespace_ending) ENABLED START -----*/
+/* clang-format on */
+//	Additional Methods
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::namespace_ending
+} //	namespace
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
new file mode 100644
index 0000000..df8ce45
--- /dev/null
+++ b/src/E2Corrector.h
@@ -0,0 +1,274 @@
+/*----- PROTECTED REGION ID(E2Corrector.h) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        E2Corrector.h
+//
+// description : Include file for the E2Corrector class
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+
+
+#ifndef E2Corrector_H
+#define E2Corrector_H
+
+#include <tango/tango.h>
+
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector.h
+
+#ifdef TANGO_LOG
+	// cppTango after c934adea (Merge branch 'remove-cout-definition' into 'main', 2022-05-23)
+	// nothing to do
+#else
+	// cppTango 9.3-backports and older
+	#define TANGO_LOG       cout
+	#define TANGO_LOG_INFO  cout2
+	#define TANGO_LOG_DEBUG cout3
+#endif // TANGO_LOG
+
+/**
+ *  E2Corrector class description:
+ *    Elettra 2.0 pure corrector magnet device
+ *    Use calibration table handle current/strgenght converstions.
+ *    The magnet device is connected to a power supply tango device , real or simulated.
+ *    
+ *    Based on ESRF EBSmagnet concepts and libraries.
+ */
+
+
+namespace E2Corrector_ns
+{
+/*----- PROTECTED REGION ID(E2Corrector::Additional Class Declarations) ENABLED START -----*/
+/* clang-format on */
+//	Additional Class Declarations
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Class Declarations
+
+class E2Corrector : public TANGO_BASE_CLASS
+{
+
+/*----- PROTECTED REGION ID(E2Corrector::Data Members) ENABLED START -----*/
+/* clang-format on */
+//	Add your own data members
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::Data Members
+
+//	Device property data members
+public:
+	//	CurrentDevice:	power supply device name
+	std::string	currentDevice;
+	//	Model:	corrector model
+	std::string	model;
+	//	SerialNumber:	
+	std::string	serialNumber;
+	//	Type:	corrector type (H or V)
+	std::string	type;
+	//	MagnetName:	Name of magnet
+	std::string	magnetName;
+	//	CalibrationName:	name of calibration table
+	std::string	calibrationName;
+
+//	Attribute data members
+public:
+	Tango::DevDouble	*attr_Strength_read;
+	Tango::DevDouble	*attr_CorrectionStrength_read;
+	Tango::DevDouble	*attr_ResonanceStrength_read;
+	Tango::DevDouble	*attr_Current_read;
+	Tango::DevDouble	*attr_BeamEnergy_read;
+
+//	Constructors and destructors
+public:
+	/**
+	 * Constructs a newly device object.
+	 *
+	 *	@param cl	Class.
+	 *	@param s 	Device Name
+	 */
+	E2Corrector(Tango::DeviceClass *cl,std::string &s);
+	/**
+	 * Constructs a newly device object.
+	 *
+	 *	@param cl	Class.
+	 *	@param s 	Device Name
+	 */
+	E2Corrector(Tango::DeviceClass *cl,const char *s);
+	/**
+	 * Constructs a newly device object.
+	 *
+	 *	@param cl	Class.
+	 *	@param s 	Device name
+	 *	@param d	Device description.
+	 */
+	E2Corrector(Tango::DeviceClass *cl,const char *s,const char *d);
+	/**
+	 * The device object destructor.
+	 */
+	~E2Corrector();
+
+
+//	Miscellaneous methods
+public:
+	/*
+	 *	will be called at device destruction or at init command.
+	 */
+	void delete_device();
+	/*
+	 *	Initialize the device
+	 */
+	virtual void init_device();
+	/*
+	 *	Read the device properties from database
+	 */
+	void get_device_property();
+	/*
+	 *	Always executed method before execution command method.
+	 */
+	virtual void always_executed_hook();
+
+
+//	Attribute methods
+public:
+	//--------------------------------------------------------
+	/*
+	 *	Method      : E2Corrector::read_attr_hardware()
+	 * Description:  Hardware acquisition for attributes.
+	 */
+	//--------------------------------------------------------
+	virtual void read_attr_hardware(std::vector<long> &attr_list);
+	//--------------------------------------------------------
+	/*
+	 *	Method      : E2Corrector::write_attr_hardware()
+	 * Description:  Hardware writing for attributes.
+	 */
+	//--------------------------------------------------------
+	virtual void write_attr_hardware(std::vector<long> &attr_list);
+
+/**
+ *	Attribute Strength related methods
+ *
+ *
+ *	Data type:  Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+	virtual void read_Strength(Tango::Attribute &attr);
+	virtual void write_Strength(Tango::WAttribute &attr);
+	virtual bool is_Strength_allowed(Tango::AttReqType type);
+/**
+ *	Attribute CorrectionStrength related methods
+ *
+ *
+ *	Data type:  Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+	virtual void read_CorrectionStrength(Tango::Attribute &attr);
+	virtual void write_CorrectionStrength(Tango::WAttribute &attr);
+	virtual bool is_CorrectionStrength_allowed(Tango::AttReqType type);
+/**
+ *	Attribute ResonanceStrength related methods
+ *
+ *
+ *	Data type:  Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+	virtual void read_ResonanceStrength(Tango::Attribute &attr);
+	virtual void write_ResonanceStrength(Tango::WAttribute &attr);
+	virtual bool is_ResonanceStrength_allowed(Tango::AttReqType type);
+/**
+ *	Attribute Current related methods
+ *
+ *
+ *	Data type:  Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+	virtual void read_Current(Tango::Attribute &attr);
+	virtual void write_Current(Tango::WAttribute &attr);
+	virtual bool is_Current_allowed(Tango::AttReqType type);
+/**
+ *	Attribute BeamEnergy related methods
+ * Description:  Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
+ *
+ *	Data type:  Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+	virtual void read_BeamEnergy(Tango::Attribute &attr);
+	virtual void write_BeamEnergy(Tango::WAttribute &attr);
+	virtual bool is_BeamEnergy_allowed(Tango::AttReqType type);
+
+
+	//--------------------------------------------------------
+	/**
+	 *	Method      : E2Corrector::add_dynamic_attributes()
+	 * Description:  Add dynamic attributes if any.
+	 */
+	//--------------------------------------------------------
+	void add_dynamic_attributes();
+
+
+
+
+//	Command related methods
+public:
+	/**
+	 *	Command Reset related method
+	 * Description:  reset the corrector
+	 *
+	 */
+	virtual void reset();
+	virtual bool is_Reset_allowed(const CORBA::Any &any);
+	/**
+	 *	Command ResetResonanceStrength related method
+	 * Description:  Reset ResonanceStrength to 0
+	 *
+	 */
+	virtual void reset_resonance_strength();
+	virtual bool is_ResetResonanceStrength_allowed(const CORBA::Any &any);
+
+
+	//--------------------------------------------------------
+	/**
+	 *	Method      : E2Corrector::add_dynamic_commands()
+	 * Description:  Add dynamic commands if any.
+	 */
+	//--------------------------------------------------------
+	void add_dynamic_commands();
+
+/*----- PROTECTED REGION ID(E2Corrector::Additional Method prototypes) ENABLED START -----*/
+/* clang-format on */
+//	Additional Method prototypes
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Method prototypes
+};
+
+/*----- PROTECTED REGION ID(E2Corrector::Additional Classes Definitions) ENABLED START -----*/
+/* clang-format on */
+//	Additional Classes Definitions
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Classes Definitions
+
+}	//	End of namespace
+
+#endif   //	E2Corrector_H
diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
new file mode 100644
index 0000000..0fb0f75
--- /dev/null
+++ b/src/E2Corrector.xmi
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
+  <classes name="E2Corrector" pogoRevision="9.8">
+    <description description="Elettra 2.0 pure corrector magnet device&#xA;Use calibration table handle current/strgenght converstions.&#xA;The magnet device is connected to a power supply tango device , real or simulated.&#xA;&#xA;Based on ESRF EBSmagnet concepts and libraries." title="Elettra 2.0 pure corrector magnet device" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/e2corrector/src" language="Cpp" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="Elettra - Sincrotrone Trieste S.c.p.A." hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
+      <inheritances classname="Device_Impl" sourcePath=""/>
+      <identification contact="at elettra.eu - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.eu" classFamily="MagneticDevices" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference="">
+        <keyWords>magnet</keyWords>
+        <keyWords>pure corrector</keyWords>
+        <keyWords>fast corrector</keyWords>
+        <keyWords>Elettra 2.0</keyWords>
+        <keyWords>calibartion</keyWords>
+      </identification>
+    </description>
+    <classProperties name="BeamEnergy" description="default electron beam energy, in GeV.&#xA;Use to initialize all magnet istances BeamEnergy attribute.">
+      <type xsi:type="pogoDsl:DoubleType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <DefaultPropValue>2.4</DefaultPropValue>
+    </classProperties>
+    <deviceProperties name="CurrentDevice" description="power supply device name">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="Model" description="corrector model">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="SerialNumber" description="">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="Type" description="corrector type (H or V)">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="MagnetName" description="Name of magnet">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="CalibrationName" description="name of calibration table">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <DefaultPropValue>name of cvs file containg calibration</DefaultPropValue>
+    </deviceProperties>
+    <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
+      <argin description="none">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argin>
+      <argout description="Device state">
+        <type xsi:type="pogoDsl:StateType"/>
+      </argout>
+      <status abstract="true" inherited="true" concrete="true"/>
+    </commands>
+    <commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
+      <argin description="none">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argin>
+      <argout description="Device status">
+        <type xsi:type="pogoDsl:ConstStringType"/>
+      </argout>
+      <status abstract="true" inherited="true" concrete="true"/>
+    </commands>
+    <commands name="Reset" description="reset the corrector" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
+      <argin description="">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argin>
+      <argout description="">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argout>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </commands>
+    <commands name="ResetResonanceStrength" description="Reset ResonanceStrength to 0" execMethod="reset_resonance_strength" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
+      <argin description="">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argin>
+      <argout description="">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argout>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </commands>
+    <attributes name="Strength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="" label="" unit="m-1" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <attributes name="CorrectionStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="" label="" unit="m-1" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <attributes name="ResonanceStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="" label="" unit="m-1" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <attributes name="Current" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <attributes name="BeamEnergy" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations." label="electron beam ebergy [eV]" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.3.6/share/pogo/preferences"/>
+  </classes>
+</pogoDsl:PogoSystem>
diff --git a/src/E2CorrectorClass.cpp b/src/E2CorrectorClass.cpp
new file mode 100644
index 0000000..d322445
--- /dev/null
+++ b/src/E2CorrectorClass.cpp
@@ -0,0 +1,784 @@
+/*----- PROTECTED REGION ID(E2CorrectorClass.cpp) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        E2CorrectorClass.cpp
+//
+// description : C++ source for the E2CorrectorClass.
+//               A singleton class derived from DeviceClass.
+//               It implements the command and attribute list
+//               and all properties and methods required
+//               by the E2Corrector once per process.
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+
+
+#include "E2CorrectorClass.h"
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass.cpp
+
+//-------------------------------------------------------------------
+/**
+ *	Create E2CorrectorClass singleton and
+ *	return it in a C function for Python usage
+ */
+//-------------------------------------------------------------------
+extern "C" {
+#ifdef _TG_WINDOWS_
+
+__declspec(dllexport)
+
+#endif
+
+	Tango::DeviceClass *_create_E2Corrector_class(const char *name) {
+		return E2Corrector_ns::E2CorrectorClass::init(name);
+	}
+}
+
+namespace E2Corrector_ns
+{
+//===================================================================
+//	Initialize pointer for singleton pattern
+//===================================================================
+E2CorrectorClass *E2CorrectorClass::_instance = NULL;
+
+//===================================================================
+//	Class constants
+//===================================================================
+//--------------------------------------------------------
+/**
+ * method : 		E2CorrectorClass::E2CorrectorClass(std::string &s)
+ * description : 	constructor for the E2CorrectorClass
+ *
+ * @param s	The class name
+ */
+//--------------------------------------------------------
+E2CorrectorClass::E2CorrectorClass(std::string &s):Tango::DeviceClass(s)
+{
+	TANGO_LOG_INFO << "Entering E2CorrectorClass constructor" << std::endl;
+	set_default_property();
+	get_class_property();
+	write_class_property();
+
+	/*----- PROTECTED REGION ID(E2CorrectorClass::constructor) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::constructor
+
+	TANGO_LOG_INFO << "Leaving E2CorrectorClass constructor" << std::endl;
+}
+
+//--------------------------------------------------------
+/**
+ * method : 		E2CorrectorClass::~E2CorrectorClass()
+ * description : 	destructor for the E2CorrectorClass
+ */
+//--------------------------------------------------------
+E2CorrectorClass::~E2CorrectorClass()
+{
+	/*----- PROTECTED REGION ID(E2CorrectorClass::destructor) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::destructor
+
+	_instance = NULL;
+}
+
+
+//--------------------------------------------------------
+/**
+ * method : 		E2CorrectorClass::init
+ * description : 	Create the object if not already done.
+ *                  Otherwise, just return a pointer to the object
+ *
+ * @param	name	The class name
+ */
+//--------------------------------------------------------
+E2CorrectorClass *E2CorrectorClass::init(const char *name)
+{
+	if (_instance == NULL)
+	{
+		try
+		{
+			std::string s(name);
+			_instance = new E2CorrectorClass(s);
+		}
+		catch (std::bad_alloc &)
+		{
+			throw;
+		}
+	}
+	return _instance;
+}
+
+//--------------------------------------------------------
+/**
+ * method : 		E2CorrectorClass::instance
+ * description : 	Check if object already created,
+ *                  and return a pointer to the object
+ */
+//--------------------------------------------------------
+E2CorrectorClass *E2CorrectorClass::instance()
+{
+	if (_instance == NULL)
+	{
+		std::cerr << "Class is not initialised !!" << std::endl;
+		exit(-1);
+	}
+	return _instance;
+}
+
+
+
+//===================================================================
+//	Command execution method calls
+//===================================================================
+//--------------------------------------------------------
+/**
+ * method : 		ResetClass::execute()
+ * description : 	method to trigger the execution of the command.
+ *
+ * @param	device	The device on which the command must be executed
+ * @param	in_any	The command input data
+ *
+ *	returns The command output data (packed in the Any object)
+ */
+//--------------------------------------------------------
+CORBA::Any *ResetClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
+{
+	TANGO_LOG_INFO << "ResetClass::execute(): arrived" << std::endl;
+	((static_cast<E2Corrector *>(device))->reset());
+	return new CORBA::Any();
+}
+
+//--------------------------------------------------------
+/**
+ * method : 		ResetResonanceStrengthClass::execute()
+ * description : 	method to trigger the execution of the command.
+ *
+ * @param	device	The device on which the command must be executed
+ * @param	in_any	The command input data
+ *
+ *	returns The command output data (packed in the Any object)
+ */
+//--------------------------------------------------------
+CORBA::Any *ResetResonanceStrengthClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
+{
+	TANGO_LOG_INFO << "ResetResonanceStrengthClass::execute(): arrived" << std::endl;
+	((static_cast<E2Corrector *>(device))->reset_resonance_strength());
+	return new CORBA::Any();
+}
+
+
+//===================================================================
+//	Properties management
+//===================================================================
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::get_class_property()
+ * Description:  Get the class property for specified name.
+ */
+//--------------------------------------------------------
+Tango::DbDatum E2CorrectorClass::get_class_property(std::string &prop_name)
+{
+	for (unsigned int i=0 ; i<cl_prop.size() ; i++)
+		if (cl_prop[i].name == prop_name)
+			return cl_prop[i];
+	//	if not found, returns  an empty DbDatum
+	return Tango::DbDatum(prop_name);
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::get_default_device_property()
+ * Description:  Return the default value for device property.
+ */
+//--------------------------------------------------------
+Tango::DbDatum E2CorrectorClass::get_default_device_property(std::string &prop_name)
+{
+	for (unsigned int i=0 ; i<dev_def_prop.size() ; i++)
+		if (dev_def_prop[i].name == prop_name)
+			return dev_def_prop[i];
+	//	if not found, return  an empty DbDatum
+	return Tango::DbDatum(prop_name);
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::get_default_class_property()
+ * Description:  Return the default value for class property.
+ */
+//--------------------------------------------------------
+Tango::DbDatum E2CorrectorClass::get_default_class_property(std::string &prop_name)
+{
+	for (unsigned int i=0 ; i<cl_def_prop.size() ; i++)
+		if (cl_def_prop[i].name == prop_name)
+			return cl_def_prop[i];
+	//	if not found, return  an empty DbDatum
+	return Tango::DbDatum(prop_name);
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::get_class_property()
+ * Description:  Read database to initialize class property data members.
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::get_class_property()
+{
+	/*----- PROTECTED REGION ID(E2CorrectorClass::get_class_property_before) ENABLED START -----*/
+	/* clang-format on */
+	//	Initialize class property data members
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::get_class_property_before
+	//	Read class properties from database.
+	cl_prop.push_back(Tango::DbDatum("BeamEnergy"));
+
+	//	Call database and extract values
+	if (Tango::Util::instance()->_UseDb==true)
+		get_db_class()->get_property(cl_prop);
+	Tango::DbDatum	def_prop;
+	int	i = -1;
+
+	//	Try to extract BeamEnergy value
+	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  beamEnergy;
+	else
+	{
+		//	Check default value for BeamEnergy
+		def_prop = get_default_class_property(cl_prop[i].name);
+		if (def_prop.is_empty()==false)
+		{
+			def_prop    >>  beamEnergy;
+			cl_prop[i]  <<  beamEnergy;
+		}
+	}
+	/*----- PROTECTED REGION ID(E2CorrectorClass::get_class_property_after) ENABLED START -----*/
+	/* clang-format on */
+	//	Check class property data members init
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::get_class_property_after
+
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::set_default_property()
+ * Description:  Set default property (class and device) for wizard.
+ *                For each property, add to wizard property name and description.
+ *                If default value has been set, add it to wizard property and
+ *                store it in a DbDatum.
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::set_default_property()
+{
+	std::string	prop_name;
+	std::string	prop_desc;
+	std::string	prop_def;
+	std::vector<std::string>	vect_data;
+
+	//	Set Default Class Properties
+	prop_name = "BeamEnergy";
+	prop_desc = "default electron beam energy, in GeV.\nUse to initialize all magnet istances BeamEnergy attribute.";
+	prop_def  = "2.4";
+	vect_data.clear();
+	vect_data.push_back("2.4");
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		cl_def_prop.push_back(data);
+		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_class_prop(prop_name, prop_desc);
+
+	//	Set Default device Properties
+	prop_name = "CurrentDevice";
+	prop_desc = "power supply device name";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "Model";
+	prop_desc = "corrector model";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "SerialNumber";
+	prop_desc = "";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "Type";
+	prop_desc = "corrector type (H or V)";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "MagnetName";
+	prop_desc = "Name of magnet";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "CalibrationName";
+	prop_desc = "name of calibration table";
+	prop_def  = "name of cvs file containg calibration";
+	vect_data.clear();
+	vect_data.push_back("name of cvs file containg calibration");
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::write_class_property()
+ * Description:  Set class description fields as property in database
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::write_class_property()
+{
+//	First time, check if database used
+if (Tango::Util::_UseDb == false)
+	return;
+
+Tango::DbData	data;
+std::string	classname = get_name();
+std::string	header;
+
+//	Put title
+Tango::DbDatum	title("ProjectTitle");
+std::string	str_title("Elettra 2.0 pure corrector magnet device");
+title << str_title;
+data.push_back(title);
+
+//	Put Description
+Tango::DbDatum	description("Description");
+std::vector<std::string>	str_desc;
+str_desc.push_back("Elettra 2.0 pure corrector magnet device");
+str_desc.push_back("Use calibration table handle current/strgenght converstions.");
+str_desc.push_back("The magnet device is connected to a power supply tango device , real or simulated.");
+str_desc.push_back("");
+str_desc.push_back("Based on ESRF EBSmagnet concepts and libraries.");
+description << str_desc;
+data.push_back(description);
+
+//  Put inheritance
+Tango::DbDatum	inher_datum("InheritedFrom");
+std::vector<std::string> inheritance;
+inheritance.push_back("TANGO_BASE_CLASS");
+inher_datum << inheritance;
+data.push_back(inher_datum);
+
+//	Call database and and values
+get_db_class()->put_property(data);
+}
+
+//===================================================================
+//	Factory methods
+//===================================================================
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::device_factory()
+ * Description:  Create the device object(s)
+ *                and store them in the device list
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)
+{
+/*----- PROTECTED REGION ID(E2CorrectorClass::device_factory_before) ENABLED START -----*/
+/* clang-format on */
+//	Add your own code
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::device_factory_before
+
+//	Create devices and add it into the device list
+for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
+{
+	TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << std::endl;
+	device_list.push_back(new E2Corrector(this, (*devlist_ptr)[i]));
+}
+
+//	Manage dynamic attributes if any
+erase_dynamic_attributes(devlist_ptr, get_class_attr()->get_attr_list());
+
+//	Export devices to the outside world
+for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
+{
+	//	Add dynamic attributes if any
+	E2Corrector *dev = static_cast<E2Corrector *>(device_list[device_list.size()-i]);
+	dev->add_dynamic_attributes();
+
+	//	Check before if database used.
+	if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
+		export_device(dev);
+	else
+		export_device(dev, dev->get_name().c_str());
+}
+
+/*----- PROTECTED REGION ID(E2CorrectorClass::device_factory_after) ENABLED START -----*/
+/* clang-format on */
+//	Add your own code
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::device_factory_after
+}
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::attribute_factory()
+ * Description:  Create the attribute object(s)
+ *                and store them in the attribute list
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
+{
+	/*----- PROTECTED REGION ID(E2CorrectorClass::attribute_factory_before) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::attribute_factory_before
+	//	Attribute : Strength
+	StrengthAttrib	*strength = new StrengthAttrib();
+	Tango::UserDefaultAttrProp	strength_prop;
+	//	description	not set for Strength
+	//	label	not set for Strength
+	strength_prop.set_unit("m-1");
+	//	standard_unit	not set for Strength
+	//	display_unit	not set for Strength
+	//	format	not set for Strength
+	//	max_value	not set for Strength
+	//	min_value	not set for Strength
+	//	max_alarm	not set for Strength
+	//	min_alarm	not set for Strength
+	//	max_warning	not set for Strength
+	//	min_warning	not set for Strength
+	//	delta_t	not set for Strength
+	//	delta_val	not set for Strength
+	strength->set_default_properties(strength_prop);
+	//	Not Polled
+	strength->set_disp_level(Tango::OPERATOR);
+	//	Not Memorized
+	att_list.push_back(strength);
+
+	//	Attribute : CorrectionStrength
+	CorrectionStrengthAttrib	*correctionstrength = new CorrectionStrengthAttrib();
+	Tango::UserDefaultAttrProp	correctionstrength_prop;
+	//	description	not set for CorrectionStrength
+	//	label	not set for CorrectionStrength
+	correctionstrength_prop.set_unit("m-1");
+	//	standard_unit	not set for CorrectionStrength
+	//	display_unit	not set for CorrectionStrength
+	//	format	not set for CorrectionStrength
+	//	max_value	not set for CorrectionStrength
+	//	min_value	not set for CorrectionStrength
+	//	max_alarm	not set for CorrectionStrength
+	//	min_alarm	not set for CorrectionStrength
+	//	max_warning	not set for CorrectionStrength
+	//	min_warning	not set for CorrectionStrength
+	//	delta_t	not set for CorrectionStrength
+	//	delta_val	not set for CorrectionStrength
+	correctionstrength->set_default_properties(correctionstrength_prop);
+	//	Not Polled
+	correctionstrength->set_disp_level(Tango::OPERATOR);
+	//	Not Memorized
+	att_list.push_back(correctionstrength);
+
+	//	Attribute : ResonanceStrength
+	ResonanceStrengthAttrib	*resonancestrength = new ResonanceStrengthAttrib();
+	Tango::UserDefaultAttrProp	resonancestrength_prop;
+	//	description	not set for ResonanceStrength
+	//	label	not set for ResonanceStrength
+	resonancestrength_prop.set_unit("m-1");
+	//	standard_unit	not set for ResonanceStrength
+	//	display_unit	not set for ResonanceStrength
+	//	format	not set for ResonanceStrength
+	//	max_value	not set for ResonanceStrength
+	//	min_value	not set for ResonanceStrength
+	//	max_alarm	not set for ResonanceStrength
+	//	min_alarm	not set for ResonanceStrength
+	//	max_warning	not set for ResonanceStrength
+	//	min_warning	not set for ResonanceStrength
+	//	delta_t	not set for ResonanceStrength
+	//	delta_val	not set for ResonanceStrength
+	resonancestrength->set_default_properties(resonancestrength_prop);
+	//	Not Polled
+	resonancestrength->set_disp_level(Tango::OPERATOR);
+	//	Not Memorized
+	att_list.push_back(resonancestrength);
+
+	//	Attribute : Current
+	CurrentAttrib	*current = new CurrentAttrib();
+	Tango::UserDefaultAttrProp	current_prop;
+	//	description	not set for Current
+	//	label	not set for Current
+	//	unit	not set for Current
+	//	standard_unit	not set for Current
+	//	display_unit	not set for Current
+	//	format	not set for Current
+	//	max_value	not set for Current
+	//	min_value	not set for Current
+	//	max_alarm	not set for Current
+	//	min_alarm	not set for Current
+	//	max_warning	not set for Current
+	//	min_warning	not set for Current
+	//	delta_t	not set for Current
+	//	delta_val	not set for Current
+	current->set_default_properties(current_prop);
+	//	Not Polled
+	current->set_disp_level(Tango::OPERATOR);
+	//	Not Memorized
+	att_list.push_back(current);
+
+	//	Attribute : BeamEnergy
+	BeamEnergyAttrib	*beamenergy = new BeamEnergyAttrib();
+	Tango::UserDefaultAttrProp	beamenergy_prop;
+	beamenergy_prop.set_description("Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.");
+	beamenergy_prop.set_label("electron beam ebergy [eV]");
+	//	unit	not set for BeamEnergy
+	//	standard_unit	not set for BeamEnergy
+	//	display_unit	not set for BeamEnergy
+	//	format	not set for BeamEnergy
+	//	max_value	not set for BeamEnergy
+	//	min_value	not set for BeamEnergy
+	//	max_alarm	not set for BeamEnergy
+	//	min_alarm	not set for BeamEnergy
+	//	max_warning	not set for BeamEnergy
+	//	min_warning	not set for BeamEnergy
+	//	delta_t	not set for BeamEnergy
+	//	delta_val	not set for BeamEnergy
+	beamenergy->set_default_properties(beamenergy_prop);
+	//	Not Polled
+	beamenergy->set_disp_level(Tango::EXPERT);
+	//	Not Memorized
+	att_list.push_back(beamenergy);
+
+
+	//	Create a list of static attributes
+	create_static_attribute_list(get_class_attr()->get_attr_list());
+	/*----- PROTECTED REGION ID(E2CorrectorClass::attribute_factory_after) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::attribute_factory_after
+}
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::pipe_factory()
+ * Description:  Create the pipe object(s)
+ *                and store them in the pipe list
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::pipe_factory()
+{
+	/*----- PROTECTED REGION ID(E2CorrectorClass::pipe_factory_before) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::pipe_factory_before
+	/*----- PROTECTED REGION ID(E2CorrectorClass::pipe_factory_after) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::pipe_factory_after
+}
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::command_factory()
+ * Description:  Create the command object(s)
+ *                and store them in the command list
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::command_factory()
+{
+	/*----- PROTECTED REGION ID(E2CorrectorClass::command_factory_before) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::command_factory_before
+
+
+	//	Command Reset
+	ResetClass	*pResetCmd =
+		new ResetClass("Reset",
+			Tango::DEV_VOID, Tango::DEV_VOID,
+			"",
+			"",
+			Tango::OPERATOR);
+	command_list.push_back(pResetCmd);
+
+	//	Command ResetResonanceStrength
+	ResetResonanceStrengthClass	*pResetResonanceStrengthCmd =
+		new ResetResonanceStrengthClass("ResetResonanceStrength",
+			Tango::DEV_VOID, Tango::DEV_VOID,
+			"",
+			"",
+			Tango::OPERATOR);
+	command_list.push_back(pResetResonanceStrengthCmd);
+
+	/*----- PROTECTED REGION ID(E2CorrectorClass::command_factory_after) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::command_factory_after
+}
+
+//===================================================================
+//	Dynamic attributes related methods
+//===================================================================
+
+//--------------------------------------------------------
+/**
+ * method : 		E2CorrectorClass::create_static_attribute_list
+ * description : 	Create the a list of static attributes
+ *
+ * @param	att_list	the created attribute list
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::create_static_attribute_list(std::vector<Tango::Attr *> &att_list)
+{
+	for (unsigned long i=0 ; i<att_list.size() ; i++)
+	{
+		std::string att_name(att_list[i]->get_name());
+		transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower);
+		defaultAttList.push_back(att_name);
+	}
+
+	TANGO_LOG_INFO << defaultAttList.size() << " attributes in default list" << std::endl;
+
+	/*----- PROTECTED REGION ID(E2CorrectorClass::create_static_att_list) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::create_static_att_list
+}
+
+
+//--------------------------------------------------------
+/**
+ * method : 		E2CorrectorClass::erase_dynamic_attributes
+ * description : 	delete the dynamic attributes if any.
+ *
+ * @param	devlist_ptr	the device list pointer
+ * @param	list of all attributes
+ */
+//--------------------------------------------------------
+void E2CorrectorClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, std::vector<Tango::Attr *> &att_list)
+{
+	Tango::Util *tg = Tango::Util::instance();
+
+	for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
+	{
+		Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((std::string)(*devlist_ptr)[i]).c_str());
+		E2Corrector *dev = static_cast<E2Corrector *> (dev_impl);
+
+		std::vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list();
+		std::vector<Tango::Attribute *>::iterator ite_att;
+		for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att)
+		{
+			std::string att_name((*ite_att)->get_name_lower());
+			if ((att_name == "state") || (att_name == "status"))
+				continue;
+			std::vector<std::string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name);
+			if (ite_str == defaultAttList.end())
+			{
+				TANGO_LOG_INFO << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << std::endl;
+				Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str());
+				dev->remove_attribute(att_list[att.get_attr_idx()], true, false);
+				--ite_att;
+			}
+		}
+	}
+	/*----- PROTECTED REGION ID(E2CorrectorClass::erase_dynamic_attributes) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::erase_dynamic_attributes
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2CorrectorClass::get_attr_object_by_name()
+ * Description:  returns Tango::Attr * object found by name
+ */
+//--------------------------------------------------------
+Tango::Attr *E2CorrectorClass::get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname)
+{
+	std::vector<Tango::Attr *>::iterator it;
+	for (it=att_list.begin() ; it<att_list.end() ; ++it)
+		if ((*it)->get_name()==attname)
+			return (*it);
+	//	Attr does not exist
+	return NULL;
+}
+
+
+/*----- PROTECTED REGION ID(E2CorrectorClass::Additional Methods) ENABLED START -----*/
+/* clang-format on */
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::Additional Methods
+} //	namespace
diff --git a/src/E2CorrectorClass.h b/src/E2CorrectorClass.h
new file mode 100644
index 0000000..7915dc2
--- /dev/null
+++ b/src/E2CorrectorClass.h
@@ -0,0 +1,241 @@
+/*----- PROTECTED REGION ID(E2CorrectorClass.h) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        E2CorrectorClass.h
+//
+// description : Include for the E2Corrector root class.
+//               This class is the singleton class for
+//                the E2Corrector device class.
+//               It contains all properties and methods which the
+//               E2Corrector requires only once e.g. the commands.
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+
+
+#ifndef E2CorrectorClass_H
+#define E2CorrectorClass_H
+
+#include <tango/tango.h>
+#include "E2Corrector.h"
+
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass.h
+
+
+namespace E2Corrector_ns
+{
+/*----- PROTECTED REGION ID(E2CorrectorClass::classes for dynamic creation) ENABLED START -----*/
+/* clang-format on */
+
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::classes for dynamic creation
+
+//=========================================
+//	Define classes for attributes
+//=========================================
+//	Attribute Strength class definition
+class StrengthAttrib: public Tango::Attr
+{
+public:
+	StrengthAttrib():Attr("Strength",
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
+	~StrengthAttrib() {};
+	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
+		{(static_cast<E2Corrector *>(dev))->read_Strength(att);}
+	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
+		{(static_cast<E2Corrector *>(dev))->write_Strength(att);}
+	virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
+		{return (static_cast<E2Corrector *>(dev))->is_Strength_allowed(ty);}
+};
+
+//	Attribute CorrectionStrength class definition
+class CorrectionStrengthAttrib: public Tango::Attr
+{
+public:
+	CorrectionStrengthAttrib():Attr("CorrectionStrength",
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
+	~CorrectionStrengthAttrib() {};
+	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
+		{(static_cast<E2Corrector *>(dev))->read_CorrectionStrength(att);}
+	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
+		{(static_cast<E2Corrector *>(dev))->write_CorrectionStrength(att);}
+	virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
+		{return (static_cast<E2Corrector *>(dev))->is_CorrectionStrength_allowed(ty);}
+};
+
+//	Attribute ResonanceStrength class definition
+class ResonanceStrengthAttrib: public Tango::Attr
+{
+public:
+	ResonanceStrengthAttrib():Attr("ResonanceStrength",
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
+	~ResonanceStrengthAttrib() {};
+	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
+		{(static_cast<E2Corrector *>(dev))->read_ResonanceStrength(att);}
+	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
+		{(static_cast<E2Corrector *>(dev))->write_ResonanceStrength(att);}
+	virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
+		{return (static_cast<E2Corrector *>(dev))->is_ResonanceStrength_allowed(ty);}
+};
+
+//	Attribute Current class definition
+class CurrentAttrib: public Tango::Attr
+{
+public:
+	CurrentAttrib():Attr("Current",
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
+	~CurrentAttrib() {};
+	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
+		{(static_cast<E2Corrector *>(dev))->read_Current(att);}
+	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
+		{(static_cast<E2Corrector *>(dev))->write_Current(att);}
+	virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
+		{return (static_cast<E2Corrector *>(dev))->is_Current_allowed(ty);}
+};
+
+//	Attribute BeamEnergy class definition
+class BeamEnergyAttrib: public Tango::Attr
+{
+public:
+	BeamEnergyAttrib():Attr("BeamEnergy",
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
+	~BeamEnergyAttrib() {};
+	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
+		{(static_cast<E2Corrector *>(dev))->read_BeamEnergy(att);}
+	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
+		{(static_cast<E2Corrector *>(dev))->write_BeamEnergy(att);}
+	virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
+		{return (static_cast<E2Corrector *>(dev))->is_BeamEnergy_allowed(ty);}
+};
+
+
+//=========================================
+//	Define classes for commands
+//=========================================
+//	Command Reset class definition
+class ResetClass : public Tango::Command
+{
+public:
+	ResetClass(const char   *cmd_name,
+	               Tango::CmdArgType in,
+				   Tango::CmdArgType out,
+				   const char        *in_desc,
+				   const char        *out_desc,
+				   Tango::DispLevel  level)
+	:Command(cmd_name,in,out,in_desc,out_desc, level)	{};
+
+	ResetClass(const char   *cmd_name,
+	               Tango::CmdArgType in,
+				   Tango::CmdArgType out)
+	:Command(cmd_name,in,out)	{};
+	~ResetClass() {};
+
+	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
+	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
+	{return (static_cast<E2Corrector *>(dev))->is_Reset_allowed(any);}
+};
+
+//	Command ResetResonanceStrength class definition
+class ResetResonanceStrengthClass : public Tango::Command
+{
+public:
+	ResetResonanceStrengthClass(const char   *cmd_name,
+	               Tango::CmdArgType in,
+				   Tango::CmdArgType out,
+				   const char        *in_desc,
+				   const char        *out_desc,
+				   Tango::DispLevel  level)
+	:Command(cmd_name,in,out,in_desc,out_desc, level)	{};
+
+	ResetResonanceStrengthClass(const char   *cmd_name,
+	               Tango::CmdArgType in,
+				   Tango::CmdArgType out)
+	:Command(cmd_name,in,out)	{};
+	~ResetResonanceStrengthClass() {};
+
+	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
+	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
+	{return (static_cast<E2Corrector *>(dev))->is_ResetResonanceStrength_allowed(any);}
+};
+
+
+/**
+ *	The E2CorrectorClass singleton definition
+ */
+
+#ifdef _TG_WINDOWS_
+class __declspec(dllexport)  E2CorrectorClass : public Tango::DeviceClass
+#else
+class E2CorrectorClass : public Tango::DeviceClass
+#endif
+{
+	/*----- PROTECTED REGION ID(E2CorrectorClass::Additional DServer data members) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::Additional DServer data members
+
+	public:
+		//	Class properties data members
+		//	BeamEnergy:	default electron beam energy, in GeV.
+		//  Use to initialize all magnet istances BeamEnergy attribute.
+		Tango::DevDouble	beamEnergy;
+		//	write class properties data members
+		Tango::DbData	cl_prop;
+		Tango::DbData	cl_def_prop;
+		Tango::DbData	dev_def_prop;
+		//	Method prototypes
+		static E2CorrectorClass *init(const char *);
+		static E2CorrectorClass *instance();
+		~E2CorrectorClass();
+		Tango::DbDatum	get_class_property(std::string &);
+		Tango::DbDatum	get_default_device_property(std::string &);
+		Tango::DbDatum	get_default_class_property(std::string &);
+
+	protected:
+		E2CorrectorClass(std::string &);
+		static E2CorrectorClass *_instance;
+		void command_factory();
+		void attribute_factory(std::vector<Tango::Attr *> &);
+		void pipe_factory();
+		void write_class_property();
+		void set_default_property();
+		void get_class_property();
+		std::string get_cvstag();
+		std::string get_cvsroot();
+
+	private:
+		void device_factory(TANGO_UNUSED(const Tango::DevVarStringArray *));
+		void create_static_attribute_list(std::vector<Tango::Attr *> &);
+		void erase_dynamic_attributes(const Tango::DevVarStringArray *,std::vector<Tango::Attr *> &);
+		std::vector<std::string>	defaultAttList;
+		Tango::Attr *get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname);
+};
+
+}	//	End of namespace
+
+#endif   //	E2Corrector_H
diff --git a/src/E2CorrectorStateMachine.cpp b/src/E2CorrectorStateMachine.cpp
new file mode 100644
index 0000000..a0ad2cf
--- /dev/null
+++ b/src/E2CorrectorStateMachine.cpp
@@ -0,0 +1,204 @@
+/*----- PROTECTED REGION ID(E2CorrectorStateMachine.cpp) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        E2CorrectorStateMachine.cpp
+//
+// description : State machine file for the E2Corrector class
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+
+#include "E2Corrector.h"
+
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::E2CorrectorStateMachine.cpp
+
+//================================================================
+//  States  |  Description
+//================================================================
+
+
+namespace E2Corrector_ns
+{
+//=================================================
+//		Attributes Allowed Methods
+//=================================================
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_Strength_allowed()
+ * Description:  Execution allowed for Strength attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_Strength_allowed(TANGO_UNUSED(Tango::AttReqType type))
+{
+	//	Not any excluded states for Strength attribute in Write access.
+	/*----- PROTECTED REGION ID(E2Corrector::StrengthStateAllowed_WRITE) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::StrengthStateAllowed_WRITE
+
+	//	Not any excluded states for Strength attribute in read access.
+	/*----- PROTECTED REGION ID(E2Corrector::StrengthStateAllowed_READ) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::StrengthStateAllowed_READ
+	return true;
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_CorrectionStrength_allowed()
+ * Description:  Execution allowed for CorrectionStrength attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_CorrectionStrength_allowed(TANGO_UNUSED(Tango::AttReqType type))
+{
+	//	Not any excluded states for CorrectionStrength attribute in Write access.
+	/*----- PROTECTED REGION ID(E2Corrector::CorrectionStrengthStateAllowed_WRITE) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::CorrectionStrengthStateAllowed_WRITE
+
+	//	Not any excluded states for CorrectionStrength attribute in read access.
+	/*----- PROTECTED REGION ID(E2Corrector::CorrectionStrengthStateAllowed_READ) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::CorrectionStrengthStateAllowed_READ
+	return true;
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_ResonanceStrength_allowed()
+ * Description:  Execution allowed for ResonanceStrength attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_ResonanceStrength_allowed(TANGO_UNUSED(Tango::AttReqType type))
+{
+	//	Not any excluded states for ResonanceStrength attribute in Write access.
+	/*----- PROTECTED REGION ID(E2Corrector::ResonanceStrengthStateAllowed_WRITE) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::ResonanceStrengthStateAllowed_WRITE
+
+	//	Not any excluded states for ResonanceStrength attribute in read access.
+	/*----- PROTECTED REGION ID(E2Corrector::ResonanceStrengthStateAllowed_READ) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::ResonanceStrengthStateAllowed_READ
+	return true;
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_Current_allowed()
+ * Description:  Execution allowed for Current attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_Current_allowed(TANGO_UNUSED(Tango::AttReqType type))
+{
+	//	Not any excluded states for Current attribute in Write access.
+	/*----- PROTECTED REGION ID(E2Corrector::CurrentStateAllowed_WRITE) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::CurrentStateAllowed_WRITE
+
+	//	Not any excluded states for Current attribute in read access.
+	/*----- PROTECTED REGION ID(E2Corrector::CurrentStateAllowed_READ) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::CurrentStateAllowed_READ
+	return true;
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_BeamEnergy_allowed()
+ * Description:  Execution allowed for BeamEnergy attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_BeamEnergy_allowed(TANGO_UNUSED(Tango::AttReqType type))
+{
+	//	Not any excluded states for BeamEnergy attribute in Write access.
+	/*----- PROTECTED REGION ID(E2Corrector::BeamEnergyStateAllowed_WRITE) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::BeamEnergyStateAllowed_WRITE
+
+	//	Not any excluded states for BeamEnergy attribute in read access.
+	/*----- PROTECTED REGION ID(E2Corrector::BeamEnergyStateAllowed_READ) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::BeamEnergyStateAllowed_READ
+	return true;
+}
+
+
+//=================================================
+//		Commands Allowed Methods
+//=================================================
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_Reset_allowed()
+ * Description:  Execution allowed for Reset attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any))
+{
+	//	Not any excluded states for Reset command.
+	/*----- PROTECTED REGION ID(E2Corrector::ResetStateAllowed) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::ResetStateAllowed
+	return true;
+}
+
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::is_ResetResonanceStrength_allowed()
+ * Description:  Execution allowed for ResetResonanceStrength attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_ResetResonanceStrength_allowed(TANGO_UNUSED(const CORBA::Any &any))
+{
+	//	Not any excluded states for ResetResonanceStrength command.
+	/*----- PROTECTED REGION ID(E2Corrector::ResetResonanceStrengthStateAllowed) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::ResetResonanceStrengthStateAllowed
+	return true;
+}
+
+
+/*----- PROTECTED REGION ID(E2Corrector::E2CorrectorStateAllowed.AdditionalMethods) ENABLED START -----*/
+/* clang-format on */
+//	Additional Methods
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::E2CorrectorStateAllowed.AdditionalMethods
+
+}	//	End of namespace
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..624cfae
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,89 @@
+/*----- PROTECTED REGION ID(E2Corrector::main.cpp) ENABLED START -----*/
+/* clang-format on */
+//=============================================================================
+//
+// file :        main.cpp
+//
+// description : C++ source for the E2Corrector device server main.
+//               The main rule is to initialise (and create) the Tango
+//               system and to create the DServerClass singleton.
+//               The main should be the same for every Tango device server.
+//
+// project :     Elettra 2.0 pure corrector magnet device
+//
+// This file is part of Tango device class.
+//
+// Tango is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Tango is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
+//
+//
+// Elettra - Sincrotrone Trieste S.c.p.A.
+//
+//=============================================================================
+//                This file is generated by POGO
+//        (Program Obviously used to Generate tango Object)
+//=============================================================================
+#include <tango/tango.h>
+
+// Check if crash reporting is used.
+#if defined(ENABLE_CRASH_REPORT)
+#  include <crashreporting/crash_report.h>
+#else
+#  define DECLARE_CRASH_HANDLER
+#  define INSTALL_CRASH_HANDLER
+#endif
+
+DECLARE_CRASH_HANDLER
+
+int main(int argc,char *argv[])
+{
+	INSTALL_CRASH_HANDLER
+	Tango::Util *tg;
+	try
+	{
+		// Initialise the device server
+		//----------------------------------------
+		tg = Tango::Util::init(argc,argv);
+
+		// Create the device server singleton
+		//	which will create everything
+		//----------------------------------------
+		tg->server_init(false);
+
+		// Run the endless loop
+		//----------------------------------------
+		std::cout << "Ready to accept request" << std::endl;
+		tg->server_run();
+	}
+	catch (std::bad_alloc &)
+	{
+		std::cout << "Can't allocate memory to store device object !!!" << std::endl;
+		std::cout << "Exiting" << std::endl;
+	}
+	catch (CORBA::Exception &e)
+	{
+		Tango::Except::print_exception(e);
+
+		std::cout << "Received a CORBA_Exception" << std::endl;
+		std::cout << "Exiting" << std::endl;
+	}
+
+	if(tg)
+	{
+		tg->server_cleanup();
+	}
+	return(0);
+}
+
+/* clang-format off */
+/*----- PROTECTED REGION END -----*/	//	E2Corrector::main.cpp
-- 
GitLab


From 22c52572df42e38a6dcdde40d41114c223beb04d Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Thu, 29 Feb 2024 13:49:13 +0100
Subject: [PATCH 02/14] handle current ad state of power supply device with
 Tango events

---
 Makefile            |  3 +-
 src/E2Corrector.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++-
 src/E2Corrector.h   | 32 ++++++++++++++-
 src/main.cpp        |  2 +-
 4 files changed, 127 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index edaad1d..2b21c08 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
 NAME_SRV = e2corrector-srv
-
+CXXFLAGS += -I /usr/include/eigen3 -I /runtime/include
+LDFLAGS += -L /runtime/lib -lMagnetModel
 include ../makefiles/Make-9.3.6.in
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index 0530359..fe3f29a 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -135,6 +135,9 @@ void E2Corrector::delete_device()
 	/* clang-format on */
 	//	Delete device allocated objects
 	/* clang-format off */
+	delete attr_Current_read;
+	if(current_event_id) current_dev->unsubscribe_event(current_event_id);
+	if (current_dev) delete current_dev;
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::delete_device
 	delete[] attr_Strength_read;
 	delete[] attr_BeamEnergy_read;
@@ -153,6 +156,9 @@ void E2Corrector::init_device()
 	/* clang-format on */
 	//	Initialization before get_device_property() call
 	/* clang-format off */
+	set_state(Tango::INIT);
+	set_status("Init");
+	attr_Current_read = new Tango::DevDouble[1];
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device_before
 
 
@@ -165,8 +171,47 @@ void E2Corrector::init_device()
 	/* clang-format on */
 	//	Initialize device
 	/* clang-format off */
-	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device
+
+	// get power supply device proxy
+	current_dev = nullptr;
+	current_event_id = 0;
+	current_set_event_id = 0;
+	state_event_id = 0;
+	try{
+		current_dev = new Tango::DeviceProxy(currentDevice);
+	}
+	catch (Tango::DevFailed &ex){
+		ERROR_STREAM << "failed to create Tango device proxy for " << currentDevice;
+		set_state(Tango::UNKNOWN);
+		set_status("failed to create Tango device proxy for CurrentDevice");
+		return;
+	}
+
+	// init energy
+	*attr_BeamEnergy_read = default_beam_energy;
+	Tango::WAttribute &cat = get_device_attr()->get_w_attr_by_name("BeamEnergy");
+	cat.set_write_value(default_beam_energy);
+	calc_rigidity(default_beam_energy);
+
+	cursetwattr = &(get_device_attr()->get_w_attr_by_name("Current"));
+	//cursetwattr->set_write_value(0.0);
+	set_current_write(0.0);
+	// register callaback for current
+	try{
+		current_cb = new CurrentEventCallback(this);
+		current_event_id = current_dev->subscribe_event("current",Tango::CHANGE_EVENT,current_cb);
+		current_set_event_id = current_dev->subscribe_event("currentSet",Tango::CHANGE_EVENT,current_cb);
+		state_event_id = current_dev->subscribe_event("State",Tango::CHANGE_EVENT,current_cb);
+	}
+	catch(Tango::DevFailed &ex){
+		ERROR_STREAM << "failed to subscribe Tango  events for " << currentDevice;
+		set_state(Tango::UNKNOWN);
+		set_status("failed to subscribe Tango  events for CurrentDevice");
+		return;
+	}
 }
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device
+
 
 //--------------------------------------------------------
 /**
@@ -484,6 +529,8 @@ void E2Corrector::write_Current(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_Current) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	Tango::DeviceAttribute watt("Current",w_val);
+	current_dev->write_attribute(watt);
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Current
 }
@@ -524,6 +571,8 @@ void E2Corrector::write_BeamEnergy(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_BeamEnergy) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	*attr_BeamEnergy_read = w_val;
+	calc_rigidity(w_val);
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_BeamEnergy
 }
@@ -600,5 +649,48 @@ void E2Corrector::add_dynamic_commands()
 /* clang-format on */
 //	Additional Methods
 /* clang-format off */
+void E2Corrector::calc_rigidity(const double& energy)
+{
+	//claculate magnet ridity for electrons at energy (a.k.a. Brho)
+	magnet_rigidity = sqrt(energy*energy - E0*E0)/c_light;
+	magnet_rigidity_inv = 1.0/magnet_rigidity;
+	//std::cout << magnet_rigidity << " simplified:" << (energy/1e9)*3.3356 << std::endl;
+}
+
+void E2Corrector::set_current_write(const double& curr)
+{
+	cursetwattr->set_write_value(curr);
+	set_current = curr;
+}
+
+CurrentEventCallback::CurrentEventCallback(E2Corrector* corr)
+{
+	e2_corr = corr;
+}
+void CurrentEventCallback::push_event(Tango::EventData* ev)
+{
+	if (ev->err) {
+		//TODO hanlde error
+		return;
+	}
+    //TODO add method to update the corrector when on value changes
+	std::string fullattrname = ev->attr_name;
+	std::size_t pos = fullattrname.find_last_of("/");
+	std::string attrname = fullattrname.substr(pos+1);
+	if(attrname == "current") *(ev->attr_value) >> *(e2_corr->attr_Current_read);
+	if(attrname == "currentset"){
+		Tango::DevDouble newcurr;
+		*(ev->attr_value) >> newcurr;
+		e2_corr->set_current_write(newcurr);
+	}
+	if(attrname == "state") {
+		Tango::DevState st;
+		*(ev->attr_value) >> st;
+		e2_corr->set_state(st);
+	}
+	//std::cout << "CurrentEventCallaback " << *(e2_corr->attr_Current_read) << std::endl;
+
+
+}
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::namespace_ending
 } //	namespace
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index df8ce45..e3d4f54 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -36,6 +36,7 @@
 #define E2Corrector_H
 
 #include <tango/tango.h>
+#include <Corrector.h>
 
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector.h
@@ -65,15 +66,29 @@ namespace E2Corrector_ns
 /*----- PROTECTED REGION ID(E2Corrector::Additional Class Declarations) ENABLED START -----*/
 /* clang-format on */
 //	Additional Class Declarations
+const double default_beam_energy = 2.4e9; // default electron  beam energy in GeV
+const double E0 =  510998.94999999995; // electron rest mass in eV
+const double c_light = 299792458.0; // speed of light  m/s
+class Corrector;
+class CurrentEventCallback;
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Class Declarations
-
 class E2Corrector : public TANGO_BASE_CLASS
 {
 
 /*----- PROTECTED REGION ID(E2Corrector::Data Members) ENABLED START -----*/
 /* clang-format on */
 //	Add your own data members
+	Corrector* corrector;  //magnet model
+	double magnet_rigidity;
+	double magnet_rigidity_inv;
+	Tango::DeviceProxy *current_dev;
+	CurrentEventCallback *current_cb;
+	int current_event_id;
+	int current_set_event_id;
+	int state_event_id;
+	Tango::WAttribute *cursetwattr;
+	double set_current; //tha actual set point of the current (from the power supply)  used for strength calculations
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Data Members
 
@@ -259,6 +274,8 @@ public:
 /*----- PROTECTED REGION ID(E2Corrector::Additional Method prototypes) ENABLED START -----*/
 /* clang-format on */
 //	Additional Method prototypes
+	void calc_rigidity(const double& energy);
+	void set_current_write(const double& curr);
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Method prototypes
 };
@@ -267,6 +284,19 @@ public:
 /* clang-format on */
 //	Additional Classes Definitions
 /* clang-format off */
+
+
+/*----- PROTECTED REGION ID(E2Corrector::Data Members) ENABLED START -----*/
+/* clang-format on */
+//	Add your own data members
+class CurrentEventCallback : public Tango::CallBack
+{
+public:
+	CurrentEventCallback(E2Corrector*);
+	void push_event(Tango::EventData* ev);
+protected:
+	E2Corrector* e2_corr;
+};
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Classes Definitions
 
 }	//	End of namespace
diff --git a/src/main.cpp b/src/main.cpp
index 624cfae..ae08f1a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -48,7 +48,7 @@ DECLARE_CRASH_HANDLER
 int main(int argc,char *argv[])
 {
 	INSTALL_CRASH_HANDLER
-	Tango::Util *tg;
+	Tango::Util *tg = nullptr;
 	try
 	{
 		// Initialise the device server
-- 
GitLab


From b5c6151137abc690a537b88de28a01802f945c78 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Thu, 29 Feb 2024 17:17:21 +0100
Subject: [PATCH 03/14] corrector calibration inserted

---
 TODO                     |   1 +
 src/E2Corrector.cpp      | 133 +++++++++++++++++++++++++++++++++++----
 src/E2Corrector.h        |  30 ++++++---
 src/E2Corrector.xmi      |  23 +++++--
 src/E2CorrectorClass.cpp |  65 ++++++++++++++++---
 src/E2CorrectorClass.h   |   2 +
 6 files changed, 220 insertions(+), 34 deletions(-)
 create mode 100644 TODO

diff --git a/TODO b/TODO
new file mode 100644
index 0000000..cd207e2
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
+check: aumentando l' energia la strength deve diminuire
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index fe3f29a..8da29a5 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -38,6 +38,7 @@
 
 #include "E2Corrector.h"
 #include "E2CorrectorClass.h"
+#include <Corrector.h>
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector.cpp
 
@@ -134,10 +135,14 @@ void E2Corrector::delete_device()
 	/*----- PROTECTED REGION ID(E2Corrector::delete_device) ENABLED START -----*/
 	/* clang-format on */
 	//	Delete device allocated objects
+
 	/* clang-format off */
-	delete attr_Current_read;
+	if(state_event_id) current_dev->unsubscribe_event(current_event_id);
+	if(current_set_event_id) current_dev->unsubscribe_event(current_set_event_id);
 	if(current_event_id) current_dev->unsubscribe_event(current_event_id);
+	delete attr_Current_read;
 	if (current_dev) delete current_dev;
+	if (corrector) delete corrector;
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::delete_device
 	delete[] attr_Strength_read;
 	delete[] attr_BeamEnergy_read;
@@ -167,6 +172,10 @@ void E2Corrector::init_device()
 
 	attr_Strength_read = new Tango::DevDouble[1];
 	attr_BeamEnergy_read = new Tango::DevDouble[1];
+	//	No longer if mandatory property not set.
+	if (mandatoryNotDefined)
+		return;
+
 	/*----- PROTECTED REGION ID(E2Corrector::init_device) ENABLED START -----*/
 	/* clang-format on */
 	//	Initialize device
@@ -177,13 +186,36 @@ void E2Corrector::init_device()
 	current_event_id = 0;
 	current_set_event_id = 0;
 	state_event_id = 0;
+	set_current.resize(1, 0.0);
+	set_strength.resize(1,0.0);
 	try{
 		current_dev = new Tango::DeviceProxy(currentDevice);
 	}
 	catch (Tango::DevFailed &ex){
-		ERROR_STREAM << "failed to create Tango device proxy for " << currentDevice;
+		ERROR_STREAM << "failed to create Tango device proxy for "
+				<< currentDevice;
 		set_state(Tango::UNKNOWN);
-		set_status("failed to create Tango device proxy for CurrentDevice");
+		std::string st = get_status();
+		st += "\nfailed to create Tango device proxy for CurrentDevice";
+		set_status(st);
+		return;
+	}
+
+	//create MagnetModel::Correctro - handles calibration tables and interpolations
+	// we do not use teh EBS shehme with global proprties... yet
+	//TODO: fix/determine format and handling of Elettra 2.0 calibrations
+
+	corrector = nullptr;
+	try {
+		std::string meas_strength_file_name = calibrationPath + "/" + calibrationFileName;
+		std::string param_file_name = calibrationPath + "/" + parameterFileName;
+		corrector = new MagnetModel::Corrector();
+		corrector->init(true,1.0, meas_strength_file_name, param_file_name, magnetName);
+	} catch (std::exception &e) {
+		std::cerr << "fatalerror "<< e.what() << std::endl;
+		ERROR_STREAM << "failed to create correcto model " << currentDevice;
+		set_state(Tango::UNKNOWN);
+		set_status("failed to create corrector model CurrentDevice");
 		return;
 	}
 
@@ -209,9 +241,9 @@ void E2Corrector::init_device()
 		set_status("failed to subscribe Tango  events for CurrentDevice");
 		return;
 	}
-}
-	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device
 
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device
+}
 
 //--------------------------------------------------------
 /**
@@ -227,6 +259,7 @@ void E2Corrector::get_device_property()
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::get_device_property_before
 
+	mandatoryNotDefined = false;
 
 	//	Read device properties from database.
 	Tango::DbData	dev_prop;
@@ -235,7 +268,9 @@ void E2Corrector::get_device_property()
 	dev_prop.push_back(Tango::DbDatum("SerialNumber"));
 	dev_prop.push_back(Tango::DbDatum("Type"));
 	dev_prop.push_back(Tango::DbDatum("MagnetName"));
-	dev_prop.push_back(Tango::DbDatum("CalibrationName"));
+	dev_prop.push_back(Tango::DbDatum("CalibrationFileName"));
+	dev_prop.push_back(Tango::DbDatum("CalibrationPath"));
+	dev_prop.push_back(Tango::DbDatum("ParameterFileName"));
 
 	//	is there at least one property to be read ?
 	if (dev_prop.size()>0)
@@ -305,16 +340,42 @@ void E2Corrector::get_device_property()
 		//	And try to extract MagnetName value from database
 		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  magnetName;
 
-		//	Try to initialize CalibrationName from class property
+		//	Try to initialize CalibrationFileName from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  calibrationFileName;
+		else {
+			//	Try to initialize CalibrationFileName from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  calibrationFileName;
+		}
+		//	And try to extract CalibrationFileName value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  calibrationFileName;
+		//	Property StartDsPath is mandatory, check if has been defined in database.
+		check_mandatory_property(cl_prop, dev_prop[i]);
+
+		//	Try to initialize CalibrationPath from class property
+		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+		if (cl_prop.is_empty()==false)	cl_prop  >>  calibrationPath;
+		else {
+			//	Try to initialize CalibrationPath from default device value
+			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+			if (def_prop.is_empty()==false)	def_prop  >>  calibrationPath;
+		}
+		//	And try to extract CalibrationPath value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  calibrationPath;
+
+		//	Try to initialize ParameterFileName from class property
 		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
-		if (cl_prop.is_empty()==false)	cl_prop  >>  calibrationName;
+		if (cl_prop.is_empty()==false)	cl_prop  >>  parameterFileName;
 		else {
-			//	Try to initialize CalibrationName from default device value
+			//	Try to initialize ParameterFileName from default device value
 			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
-			if (def_prop.is_empty()==false)	def_prop  >>  calibrationName;
+			if (def_prop.is_empty()==false)	def_prop  >>  parameterFileName;
 		}
-		//	And try to extract CalibrationName value from database
-		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  calibrationName;
+		//	And try to extract ParameterFileName value from database
+		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  parameterFileName;
+		//	Property StartDsPath is mandatory, check if has been defined in database.
+		check_mandatory_property(cl_prop, dev_prop[i]);
 
 	}
 
@@ -324,6 +385,33 @@ void E2Corrector::get_device_property()
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::get_device_property_after
 }
+//--------------------------------------------------------
+/**
+ *	Method      : E2Corrector::check_mandatory_property()
+ * Description:  For mandatory properties check if defined in database.
+ */
+//--------------------------------------------------------
+void E2Corrector::check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop)
+{
+	//	Check if all properties are empty
+	if (class_prop.is_empty() && dev_prop.is_empty())
+	{
+		TangoSys_OMemStream	tms;
+		tms << std::endl <<"Property \'" << dev_prop.name;
+		if (Tango::Util::instance()->_UseDb==true)
+			tms << "\' is mandatory but not defined in database";
+		else
+			tms << "\' is mandatory but cannot be defined without database";
+		append_status(tms.str());
+		mandatoryNotDefined = true;
+		/*----- PROTECTED REGION ID(E2Corrector::check_mandatory_property) ENABLED START -----*/
+		/* clang-format on */
+		std::cerr << tms.str() << " for " << device_name << std::endl;
+		/* clang-format off */
+		/*----- PROTECTED REGION END -----*/	//	E2Corrector::check_mandatory_property
+	}
+}
+
 
 //--------------------------------------------------------
 /**
@@ -334,6 +422,13 @@ void E2Corrector::get_device_property()
 void E2Corrector::always_executed_hook()
 {
 	DEBUG_STREAM << "E2Corrector::always_executed_hook()  " << device_name << std::endl;
+	if (mandatoryNotDefined)
+	{
+		Tango::Except::throw_exception(
+					(const char *)"PROPERTY_NOT_SET",
+					get_status().c_str(),
+					(const char *)"E2Corrector::always_executed_hook()");
+	}
 	/*----- PROTECTED REGION ID(E2Corrector::always_executed_hook) ENABLED START -----*/
 	/* clang-format on */
 	//	code always executed before all requests
@@ -649,6 +744,10 @@ void E2Corrector::add_dynamic_commands()
 /* clang-format on */
 //	Additional Methods
 /* clang-format off */
+
+
+
+//--------------------------------------------------------
 void E2Corrector::calc_rigidity(const double& energy)
 {
 	//claculate magnet ridity for electrons at energy (a.k.a. Brho)
@@ -660,7 +759,14 @@ void E2Corrector::calc_rigidity(const double& energy)
 void E2Corrector::set_current_write(const double& curr)
 {
 	cursetwattr->set_write_value(curr);
-	set_current = curr;
+	set_current[0] = curr;
+}
+
+//------------------------------------------------------------
+void E2Corrector::update_values(void)
+{
+	corrector->compute_strengths(magnet_rigidity,set_current,set_strength);
+	*attr_Strength_read = set_strength[0];
 }
 
 CurrentEventCallback::CurrentEventCallback(E2Corrector* corr)
@@ -688,6 +794,7 @@ void CurrentEventCallback::push_event(Tango::EventData* ev)
 		*(ev->attr_value) >> st;
 		e2_corr->set_state(st);
 	}
+	e2_corr->update_values();
 	//std::cout << "CurrentEventCallaback " << *(e2_corr->attr_Current_read) << std::endl;
 
 
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index e3d4f54..20eb421 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -69,17 +69,18 @@ namespace E2Corrector_ns
 const double default_beam_energy = 2.4e9; // default electron  beam energy in GeV
 const double E0 =  510998.94999999995; // electron rest mass in eV
 const double c_light = 299792458.0; // speed of light  m/s
-class Corrector;
+//class Corrector;
 class CurrentEventCallback;
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Class Declarations
+
 class E2Corrector : public TANGO_BASE_CLASS
 {
 
 /*----- PROTECTED REGION ID(E2Corrector::Data Members) ENABLED START -----*/
 /* clang-format on */
 //	Add your own data members
-	Corrector* corrector;  //magnet model
+	MagnetModel::Corrector* corrector;  //magnet model
 	double magnet_rigidity;
 	double magnet_rigidity_inv;
 	Tango::DeviceProxy *current_dev;
@@ -88,24 +89,32 @@ class E2Corrector : public TANGO_BASE_CLASS
 	int current_set_event_id;
 	int state_event_id;
 	Tango::WAttribute *cursetwattr;
-	double set_current; //tha actual set point of the current (from the power supply)  used for strength calculations
+	std::vector<double> set_current; //the actual set point of the current (from the power supply)  used for strength calculations
+	std::vector<double> set_strength; //the strngth set point
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Data Members
 
 //	Device property data members
 public:
-	//	CurrentDevice:	power supply device name
+	//	CurrentDevice:	power supply tango device name
 	std::string	currentDevice;
-	//	Model:	corrector model
+	//	Model:	corrector model (part number)
 	std::string	model;
-	//	SerialNumber:	
+	//	SerialNumber:	serial number of the magnet
 	std::string	serialNumber;
 	//	Type:	corrector type (H or V)
 	std::string	type;
 	//	MagnetName:	Name of magnet
 	std::string	magnetName;
-	//	CalibrationName:	name of calibration table
-	std::string	calibrationName;
+	//	CalibrationFileName:	name of calibration table file name
+	std::string	calibrationFileName;
+	//	CalibrationPath:	path of calibration and parameter files
+	std::string	calibrationPath;
+	//	ParameterFileName:	name of auxiliary parametr file name
+	//  (EBSmagnet compatibility)
+	std::string	parameterFileName;
+
+	bool	mandatoryNotDefined;
 
 //	Attribute data members
 public:
@@ -164,6 +173,10 @@ public:
 	 */
 	virtual void always_executed_hook();
 
+	/*
+	 *	Check if mandatory property has been set
+	 */
+	 void check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop);
 
 //	Attribute methods
 public:
@@ -276,6 +289,7 @@ public:
 //	Additional Method prototypes
 	void calc_rigidity(const double& energy);
 	void set_current_write(const double& curr);
+	void update_values(void); //update internal calculated values
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Method prototypes
 };
diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
index 0fb0f75..436b203 100644
--- a/src/E2Corrector.xmi
+++ b/src/E2Corrector.xmi
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ASCII"?>
 <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
   <classes name="E2Corrector" pogoRevision="9.8">
-    <description description="Elettra 2.0 pure corrector magnet device&#xA;Use calibration table handle current/strgenght converstions.&#xA;The magnet device is connected to a power supply tango device , real or simulated.&#xA;&#xA;Based on ESRF EBSmagnet concepts and libraries." title="Elettra 2.0 pure corrector magnet device" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/e2corrector/src" language="Cpp" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="Elettra - Sincrotrone Trieste S.c.p.A." hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
+    <description description="Elettra 2.0 pure corrector magnet device&#xA;Use calibration table handle current/strgenght converstions.&#xA;The magnet device is connected to a power supply tango device , real or simulated.&#xA;&#xA;Based on ESRF EBSmagnet concepts and libraries." title="Elettra 2.0 pure corrector magnet device" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/e2corrector/src" language="Cpp" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="Elettra - Sincrotrone Trieste S.c.p.A." hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
       <inheritances classname="Device_Impl" sourcePath=""/>
       <identification contact="at elettra.eu - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.eu" classFamily="MagneticDevices" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference="">
         <keyWords>magnet</keyWords>
@@ -16,15 +16,19 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <DefaultPropValue>2.4</DefaultPropValue>
     </classProperties>
-    <deviceProperties name="CurrentDevice" description="power supply device name">
+    <classProperties name="CalibrationPath" description="path of calibration and parameter files">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </classProperties>
+    <deviceProperties name="CurrentDevice" description="power supply tango device name">
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </deviceProperties>
-    <deviceProperties name="Model" description="corrector model">
+    <deviceProperties name="Model" description="corrector model (part number)">
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </deviceProperties>
-    <deviceProperties name="SerialNumber" description="">
+    <deviceProperties name="SerialNumber" description="serial number of the magnet">
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </deviceProperties>
@@ -36,10 +40,17 @@
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </deviceProperties>
-    <deviceProperties name="CalibrationName" description="name of calibration table">
+    <deviceProperties name="CalibrationFileName" mandatory="true" description="name of calibration table file name">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="CalibrationPath" description="path of calibration and parameter files">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
+    <deviceProperties name="ParameterFileName" mandatory="true" description="name of auxiliary parametr file name&#xA;(EBSmagnet compatibility)">
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <DefaultPropValue>name of cvs file containg calibration</DefaultPropValue>
     </deviceProperties>
     <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
       <argin description="none">
diff --git a/src/E2CorrectorClass.cpp b/src/E2CorrectorClass.cpp
index d322445..2b12388 100644
--- a/src/E2CorrectorClass.cpp
+++ b/src/E2CorrectorClass.cpp
@@ -256,6 +256,7 @@ void E2CorrectorClass::get_class_property()
 	/*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::get_class_property_before
 	//	Read class properties from database.
 	cl_prop.push_back(Tango::DbDatum("BeamEnergy"));
+	cl_prop.push_back(Tango::DbDatum("CalibrationPath"));
 
 	//	Call database and extract values
 	if (Tango::Util::instance()->_UseDb==true)
@@ -275,6 +276,18 @@ void E2CorrectorClass::get_class_property()
 			cl_prop[i]  <<  beamEnergy;
 		}
 	}
+	//	Try to extract CalibrationPath value
+	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  calibrationPath;
+	else
+	{
+		//	Check default value for CalibrationPath
+		def_prop = get_default_class_property(cl_prop[i].name);
+		if (def_prop.is_empty()==false)
+		{
+			def_prop    >>  calibrationPath;
+			cl_prop[i]  <<  calibrationPath;
+		}
+	}
 	/*----- PROTECTED REGION ID(E2CorrectorClass::get_class_property_after) ENABLED START -----*/
 	/* clang-format on */
 	//	Check class property data members init
@@ -312,12 +325,25 @@ void E2CorrectorClass::set_default_property()
 		cl_def_prop.push_back(data);
 		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
 	}
+	else
+		add_wiz_class_prop(prop_name, prop_desc);
+	prop_name = "CalibrationPath";
+	prop_desc = "path of calibration and parameter files";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		cl_def_prop.push_back(data);
+		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
+	}
 	else
 		add_wiz_class_prop(prop_name, prop_desc);
 
 	//	Set Default device Properties
 	prop_name = "CurrentDevice";
-	prop_desc = "power supply device name";
+	prop_desc = "power supply tango device name";
 	prop_def  = "";
 	vect_data.clear();
 	if (prop_def.length()>0)
@@ -330,7 +356,7 @@ void E2CorrectorClass::set_default_property()
 	else
 		add_wiz_dev_prop(prop_name, prop_desc);
 	prop_name = "Model";
-	prop_desc = "corrector model";
+	prop_desc = "corrector model (part number)";
 	prop_def  = "";
 	vect_data.clear();
 	if (prop_def.length()>0)
@@ -343,7 +369,7 @@ void E2CorrectorClass::set_default_property()
 	else
 		add_wiz_dev_prop(prop_name, prop_desc);
 	prop_name = "SerialNumber";
-	prop_desc = "";
+	prop_desc = "serial number of the magnet";
 	prop_def  = "";
 	vect_data.clear();
 	if (prop_def.length()>0)
@@ -381,11 +407,36 @@ void E2CorrectorClass::set_default_property()
 	}
 	else
 		add_wiz_dev_prop(prop_name, prop_desc);
-	prop_name = "CalibrationName";
-	prop_desc = "name of calibration table";
-	prop_def  = "name of cvs file containg calibration";
+	prop_name = "CalibrationFileName";
+	prop_desc = "name of calibration table file name";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "CalibrationPath";
+	prop_desc = "path of calibration and parameter files";
+	prop_def  = "";
+	vect_data.clear();
+	if (prop_def.length()>0)
+	{
+		Tango::DbDatum	data(prop_name);
+		data << vect_data ;
+		dev_def_prop.push_back(data);
+		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
+	}
+	else
+		add_wiz_dev_prop(prop_name, prop_desc);
+	prop_name = "ParameterFileName";
+	prop_desc = "name of auxiliary parametr file name\n(EBSmagnet compatibility)";
+	prop_def  = "";
 	vect_data.clear();
-	vect_data.push_back("name of cvs file containg calibration");
 	if (prop_def.length()>0)
 	{
 		Tango::DbDatum	data(prop_name);
diff --git a/src/E2CorrectorClass.h b/src/E2CorrectorClass.h
index 7915dc2..792df7c 100644
--- a/src/E2CorrectorClass.h
+++ b/src/E2CorrectorClass.h
@@ -204,6 +204,8 @@ class E2CorrectorClass : public Tango::DeviceClass
 		//	BeamEnergy:	default electron beam energy, in GeV.
 		//  Use to initialize all magnet istances BeamEnergy attribute.
 		Tango::DevDouble	beamEnergy;
+		//	CalibrationPath:	path of calibration and parameter files
+		std::string	calibrationPath;
 		//	write class properties data members
 		Tango::DbData	cl_prop;
 		Tango::DbData	cl_def_prop;
-- 
GitLab


From 24adb1cc9e0a91cb379bf0f605e4880ea60183fe Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Fri, 1 Mar 2024 09:22:57 +0100
Subject: [PATCH 04/14] read and set strength

---
 TODO                |  2 +-
 src/E2Corrector.cpp | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/TODO b/TODO
index cd207e2..71be0ca 100644
--- a/TODO
+++ b/TODO
@@ -1 +1 @@
-check: aumentando l' energia la strength deve diminuire
+check: aumentando l' energia la strength deve diminuire: CORRETTO
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index 8da29a5..a68045a 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -504,6 +504,15 @@ void E2Corrector::write_Strength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_Strength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	std::vector<double> req_strength;
+	std::vector<double> curr_out;
+	req_strength.push_back(w_val);
+	{
+		corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
+		Tango::DeviceAttribute watt("Current",curr_out[0]);
+		current_dev->write_attribute(watt);
+	}
+	//catch(std::excpetion &ex){}
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Strength
 }
@@ -765,7 +774,7 @@ void E2Corrector::set_current_write(const double& curr)
 //------------------------------------------------------------
 void E2Corrector::update_values(void)
 {
-	corrector->compute_strengths(magnet_rigidity,set_current,set_strength);
+	corrector->compute_strengths(magnet_rigidity_inv, set_current, set_strength);
 	*attr_Strength_read = set_strength[0];
 }
 
-- 
GitLab


From a0ce4284730f6b157f5182415bdee750978c9024 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Fri, 1 Mar 2024 16:02:57 +0100
Subject: [PATCH 05/14] strength is in radians

---
 src/E2Corrector.cpp      | 4 ++--
 src/E2Corrector.h        | 2 +-
 src/E2Corrector.xmi      | 2 +-
 src/E2CorrectorClass.cpp | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index a68045a..cdc2f64 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -470,7 +470,7 @@ void E2Corrector::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list)
 //--------------------------------------------------------
 /**
  *	Read attribute Strength related method
- *
+ * Description:  corrrector kick in radians
  *
  *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
@@ -489,7 +489,7 @@ void E2Corrector::read_Strength(Tango::Attribute &attr)
 //--------------------------------------------------------
 /**
  *	Write attribute Strength related method
- *
+ * Description:  corrrector kick in radians
  *
  *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index 20eb421..009f9d8 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -197,7 +197,7 @@ public:
 
 /**
  *	Attribute Strength related methods
- *
+ * Description:  corrrector kick in radians
  *
  *	Data type:  Tango::DevDouble
  *	Attr type:	Scalar
diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
index 436b203..37b5a06 100644
--- a/src/E2Corrector.xmi
+++ b/src/E2Corrector.xmi
@@ -94,7 +94,7 @@
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="" label="" unit="m-1" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="corrrector kick in radians" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
     <attributes name="CorrectionStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
diff --git a/src/E2CorrectorClass.cpp b/src/E2CorrectorClass.cpp
index 2b12388..020e639 100644
--- a/src/E2CorrectorClass.cpp
+++ b/src/E2CorrectorClass.cpp
@@ -558,9 +558,9 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	//	Attribute : Strength
 	StrengthAttrib	*strength = new StrengthAttrib();
 	Tango::UserDefaultAttrProp	strength_prop;
-	//	description	not set for Strength
+	strength_prop.set_description("corrrector kick in radians");
 	//	label	not set for Strength
-	strength_prop.set_unit("m-1");
+	strength_prop.set_unit("rad");
 	//	standard_unit	not set for Strength
 	//	display_unit	not set for Strength
 	//	format	not set for Strength
-- 
GitLab


From 29de79139df8d1a01c7c115757181efa098a15a6 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Wed, 6 Mar 2024 17:25:58 +0100
Subject: [PATCH 06/14] progress in handdling correctionStrength

---
 TODO                |  15 ++++++
 src/E2Corrector.cpp | 111 ++++++++++++++++++++++++++++++++++++++++----
 src/E2Corrector.h   |  11 ++++-
 3 files changed, 125 insertions(+), 12 deletions(-)

diff --git a/TODO b/TODO
index 71be0ca..40326c9 100644
--- a/TODO
+++ b/TODO
@@ -1 +1,16 @@
 check: aumentando l' energia la strength deve diminuire: CORRETTO
+
+strengh = CorrectionStrength + resonanceStrength 
+ allo startup resonanceStrength = 0, strength = correctionStrength
+ 
+ write strenght -> aggiorna anche correctionStrength, read e write
+ write resonanceStrngth -> aggiorna anche strength, read e write
+ write correctionStrength -> aggiorna anche strength
+ 
+ fix write_ResonanceStrength like write_CorrectionStrength
+ 
+wrtite_current --> mettere posto la parte write di strength
+
+
+
+le parti read degli strength vanno aggiornate come la parte read di current
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index cdc2f64..cea2363 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -140,6 +140,7 @@ void E2Corrector::delete_device()
 	if(state_event_id) current_dev->unsubscribe_event(current_event_id);
 	if(current_set_event_id) current_dev->unsubscribe_event(current_set_event_id);
 	if(current_event_id) current_dev->unsubscribe_event(current_event_id);
+	sleep(1);
 	delete attr_Current_read;
 	if (current_dev) delete current_dev;
 	if (corrector) delete corrector;
@@ -172,6 +173,8 @@ void E2Corrector::init_device()
 
 	attr_Strength_read = new Tango::DevDouble[1];
 	attr_BeamEnergy_read = new Tango::DevDouble[1];
+	attr_CorrectionStrength_read = new Tango::DevDouble[1];
+	attr_ResonanceStrength_read = new Tango::DevDouble[1];
 	//	No longer if mandatory property not set.
 	if (mandatoryNotDefined)
 		return;
@@ -225,9 +228,13 @@ void E2Corrector::init_device()
 	cat.set_write_value(default_beam_energy);
 	calc_rigidity(default_beam_energy);
 
-	cursetwattr = &(get_device_attr()->get_w_attr_by_name("Current"));
-	//cursetwattr->set_write_value(0.0);
-	set_current_write(0.0);
+	//get WAtrirbute for handling cross dependencies
+	strengthAtt =  &get_device_attr()->get_w_attr_by_name("Strength");
+	correctionAtt = &get_device_attr()->get_w_attr_by_name("CorrectionStrength");
+	resonanceAtt = &get_device_attr()->get_w_attr_by_name("ResonanceStrength");
+	cursetAtt = &(get_device_attr()->get_w_attr_by_name("Current"));
+	init_strengths();
+
 	// register callaback for current
 	try{
 		current_cb = new CurrentEventCallback(this);
@@ -504,6 +511,7 @@ void E2Corrector::write_Strength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_Strength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	omni_mutex_lock guardio(iomutex);
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
 	req_strength.push_back(w_val);
@@ -553,6 +561,24 @@ void E2Corrector::write_CorrectionStrength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_CorrectionStrength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* TODO : implement is_set_point valid and exploit it!
+		if(!is_setpoint_valid(w_val)) {
+		    attr.rollback();
+		    return;
+		  }
+	 */
+	omni_mutex_lock guardio(iomutex);
+	Tango::DevDouble _resStrength,newStrength;
+	resonanceAtt->get_write_value(_resStrength);
+	newStrength = w_val + _resStrength;
+	std::vector<double> req_strength;
+	std::vector<double> curr_out;
+	req_strength.push_back(newStrength);
+	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
+	Tango::DeviceAttribute watt("Current", curr_out[0]);
+	current_dev->write_attribute(watt);
+	strengthAtt->set_write_value(newStrength);
+	//update_correction_strength();
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_CorrectionStrength
 }
@@ -593,6 +619,25 @@ void E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_ResonanceStrength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* TODO : implement is_set_point valid and exploit it!
+	if(!is_setpoint_valid(w_val)) {
+	    attr.rollback();
+	    return;
+	  }
+	*/
+	omni_mutex_lock guardio(iomutex);
+	Tango::DevDouble newStrength;
+	correctionAtt->get_write_value(newStrength);
+	newStrength += w_val;
+	std::vector<double> req_strength;
+	std::vector<double> curr_out;
+	req_strength.push_back(newStrength);
+	{
+		corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
+		Tango::DeviceAttribute watt("Current", curr_out[0]);
+		current_dev->write_attribute(watt);
+	}
+	update_correction_strength();
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_ResonanceStrength
 }
@@ -767,27 +812,76 @@ void E2Corrector::calc_rigidity(const double& energy)
 
 void E2Corrector::set_current_write(const double& curr)
 {
-	cursetwattr->set_write_value(curr);
+	cursetAtt->set_write_value(curr);
 	set_current[0] = curr;
 }
 
+//------------------------------------------------------------
+void E2Corrector::init_strengths(void) // initialize strengths from power supply value
+{
+	Tango::DeviceAttribute da;
+	try {
+		da = current_dev->read_attribute("Current");
+		vector<Tango::DevDouble> outval;
+		da >> outval;
+		std::vector<Tango::DevDouble> _current;
+		std::vector<Tango::DevDouble> _strength;
+		_current.push_back(outval[1]);
+		corrector->compute_strengths(magnet_rigidity_inv, _current, _strength);
+		*attr_Strength_read = _strength[0];
+		*attr_CorrectionStrength_read = _strength[0];
+		*attr_ResonanceStrength_read = 0.0;
+		cursetAtt->set_write_value(_current[0]);
+		set_current[0] = _current[0];
+		correctionAtt->set_write_value(_strength[0]);
+		strengthAtt->set_write_value(_strength[0]);
+		resonanceAtt->set_write_value(0.0); // start with resonance strength always at 0!
+
+	} catch (Tango::DevFailed &e) {
+		Tango::Except::print_exception(e);
+	}
+}
+
 //------------------------------------------------------------
 void E2Corrector::update_values(void)
 {
 	corrector->compute_strengths(magnet_rigidity_inv, set_current, set_strength);
-	*attr_Strength_read = set_strength[0];
+	attr_Strength_read[0] = set_strength[0];
+	Tango::DevDouble cstrength;
+	Tango::DevDouble rsStrength;
+	correctionAtt->get_write_value(cstrength);
+	resonanceAtt->get_write_value(rsStrength);
+	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - attr_ResonanceStrength_read[0];
+
+
+}
+//------------------------------------------------------------
+
+void E2Corrector::update_correction_strength() {
+	Tango::DevDouble strength;
+	Tango::DevDouble cstrength;
+	Tango::DevDouble rsStrength;
+	strengthAtt->get_write_value(strength);
+	correctionAtt->get_write_value(cstrength);
+	resonanceAtt->get_write_value(rsStrength);
+	correctionAtt->set_write_value(strength - rsStrength);
+	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - attr_ResonanceStrength_read[0];
+	attr_ResonanceStrength_read[0] = rsStrength;
 }
 
-CurrentEventCallback::CurrentEventCallback(E2Corrector* corr)
+//------------------------------------------------------------
+
+CurrentEventCallback::CurrentEventCallback(E2Corrector* corr) //callback constructor
 {
 	e2_corr = corr;
 }
-void CurrentEventCallback::push_event(Tango::EventData* ev)
+void CurrentEventCallback::push_event(Tango::EventData* ev) //callback core method
 {
 	if (ev->err) {
 		//TODO hanlde error
 		return;
 	}
+	omni_mutex_lock guardio(e2_corr->iomutex);
     //TODO add method to update the corrector when on value changes
 	std::string fullattrname = ev->attr_name;
 	std::size_t pos = fullattrname.find_last_of("/");
@@ -804,9 +898,6 @@ void CurrentEventCallback::push_event(Tango::EventData* ev)
 		e2_corr->set_state(st);
 	}
 	e2_corr->update_values();
-	//std::cout << "CurrentEventCallaback " << *(e2_corr->attr_Current_read) << std::endl;
-
-
 }
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::namespace_ending
 } //	namespace
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index 009f9d8..a77a825 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -88,9 +88,14 @@ class E2Corrector : public TANGO_BASE_CLASS
 	int current_event_id;
 	int current_set_event_id;
 	int state_event_id;
-	Tango::WAttribute *cursetwattr;
+	Tango::WAttribute *cursetAtt;
+	Tango::WAttribute *strengthAtt;
+	Tango::WAttribute *correctionAtt;
+	Tango::WAttribute *resonanceAtt;
 	std::vector<double> set_current; //the actual set point of the current (from the power supply)  used for strength calculations
-	std::vector<double> set_strength; //the strngth set point
+	std::vector<double> set_strength; //the strength set point
+public:
+	omni_mutex iomutex; //guard for event and write interference
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Data Members
 
@@ -290,6 +295,8 @@ public:
 	void calc_rigidity(const double& energy);
 	void set_current_write(const double& curr);
 	void update_values(void); //update internal calculated values
+	void init_strengths(void); // initialize strengths from power supply values
+	void update_correction_strength(void); // arrange balance of strenghts (internal values usfeul for machine handling)
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Method prototypes
 };
-- 
GitLab


From fef443ff84144746c426c8f95d790f9470236d4b Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Wed, 6 Mar 2024 17:27:17 +0100
Subject: [PATCH 07/14] for eclipse

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 563ccc8..155b405 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ obj
 .cproject
 .project
 .settings
+*.launch
-- 
GitLab


From 8c1ee434f3a69b0b54ea0019e059a6323e8b7d57 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Thu, 7 Mar 2024 12:02:50 +0100
Subject: [PATCH 08/14] fix unit of measure, read data member

---
 src/E2Corrector.cpp      | 4 +++-
 src/E2Corrector.xmi      | 8 ++++----
 src/E2CorrectorClass.cpp | 4 ++--
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index cea2363..013859a 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -146,6 +146,8 @@ void E2Corrector::delete_device()
 	if (corrector) delete corrector;
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::delete_device
 	delete[] attr_Strength_read;
+	delete[] attr_CorrectionStrength_read;
+	delete[] attr_ResonanceStrength_read;
 	delete[] attr_BeamEnergy_read;
 }
 
@@ -172,9 +174,9 @@ void E2Corrector::init_device()
 	get_device_property();
 
 	attr_Strength_read = new Tango::DevDouble[1];
-	attr_BeamEnergy_read = new Tango::DevDouble[1];
 	attr_CorrectionStrength_read = new Tango::DevDouble[1];
 	attr_ResonanceStrength_read = new Tango::DevDouble[1];
+	attr_BeamEnergy_read = new Tango::DevDouble[1];
 	//	No longer if mandatory property not set.
 	if (mandatoryNotDefined)
 		return;
diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
index 37b5a06..6520d3a 100644
--- a/src/E2Corrector.xmi
+++ b/src/E2Corrector.xmi
@@ -96,21 +96,21 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <properties description="corrrector kick in radians" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="CorrectionStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+    <attributes name="CorrectionStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="" label="" unit="m-1" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="ResonanceStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+    <attributes name="ResonanceStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="" label="" unit="m-1" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
     <attributes name="Current" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
diff --git a/src/E2CorrectorClass.cpp b/src/E2CorrectorClass.cpp
index 020e639..ceeed95 100644
--- a/src/E2CorrectorClass.cpp
+++ b/src/E2CorrectorClass.cpp
@@ -583,7 +583,7 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	Tango::UserDefaultAttrProp	correctionstrength_prop;
 	//	description	not set for CorrectionStrength
 	//	label	not set for CorrectionStrength
-	correctionstrength_prop.set_unit("m-1");
+	correctionstrength_prop.set_unit("rad");
 	//	standard_unit	not set for CorrectionStrength
 	//	display_unit	not set for CorrectionStrength
 	//	format	not set for CorrectionStrength
@@ -606,7 +606,7 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	Tango::UserDefaultAttrProp	resonancestrength_prop;
 	//	description	not set for ResonanceStrength
 	//	label	not set for ResonanceStrength
-	resonancestrength_prop.set_unit("m-1");
+	resonancestrength_prop.set_unit("rad");
 	//	standard_unit	not set for ResonanceStrength
 	//	display_unit	not set for ResonanceStrength
 	//	format	not set for ResonanceStrength
-- 
GitLab


From 4b2bafba14979a7191c5d90a551e9d478a7f3392 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Thu, 7 Mar 2024 15:31:37 +0100
Subject: [PATCH 09/14] setting of strengths

---
 TODO                | 12 ++-----
 src/E2Corrector.cpp | 80 ++++++++++++++++++++-------------------------
 src/E2Corrector.h   |  3 +-
 3 files changed, 41 insertions(+), 54 deletions(-)

diff --git a/TODO b/TODO
index 40326c9..8ec489c 100644
--- a/TODO
+++ b/TODO
@@ -3,14 +3,8 @@ check: aumentando l' energia la strength deve diminuire: CORRETTO
 strengh = CorrectionStrength + resonanceStrength 
  allo startup resonanceStrength = 0, strength = correctionStrength
  
- write strenght -> aggiorna anche correctionStrength, read e write
- write resonanceStrngth -> aggiorna anche strength, read e write
- write correctionStrength -> aggiorna anche strength
+ settings dei vari strength OK
  
- fix write_ResonanceStrength like write_CorrectionStrength
- 
-wrtite_current --> mettere posto la parte write di strength
-
-
+le parti read degli strength vanno aggiornate come la parte read di current (noise)
+compute_currents e compute_strenggths : rendee polimorifche per acceatare  DevDouble o duble
 
-le parti read degli strength vanno aggiornate come la parte read di current
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index 013859a..9e5bc6e 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -517,11 +517,12 @@ void E2Corrector::write_Strength(Tango::WAttribute &attr)
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
 	req_strength.push_back(w_val);
-	{
-		corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
-		Tango::DeviceAttribute watt("Current",curr_out[0]);
-		current_dev->write_attribute(watt);
-	}
+	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
+	Tango::DeviceAttribute watt("Current",curr_out[0]);
+	current_dev->write_attribute(watt);
+	set_strength[0] = w_val;
+	wValCorrStrength = w_val - wValResStrength;
+	correctionAtt->set_write_value(wValCorrStrength);
 	//catch(std::excpetion &ex){}
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Strength
@@ -570,17 +571,18 @@ void E2Corrector::write_CorrectionStrength(Tango::WAttribute &attr)
 		  }
 	 */
 	omni_mutex_lock guardio(iomutex);
-	Tango::DevDouble _resStrength,newStrength;
-	resonanceAtt->get_write_value(_resStrength);
-	newStrength = w_val + _resStrength;
+	Tango::DevDouble newStrength;
+	//resonanceAtt->get_write_value(_resStrength);
+	newStrength = w_val + wValResStrength;
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
 	req_strength.push_back(newStrength);
 	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
 	Tango::DeviceAttribute watt("Current", curr_out[0]);
 	current_dev->write_attribute(watt);
-	strengthAtt->set_write_value(newStrength);
-	//update_correction_strength();
+	wValCorrStrength = w_val;
+	set_strength[0] = newStrength;
+	strengthAtt->set_write_value(set_strength[0]);
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_CorrectionStrength
 }
@@ -622,24 +624,23 @@ void E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr)
 	/* clang-format on */
 	//	Add your own code
 	/* TODO : implement is_set_point valid and exploit it!
-	if(!is_setpoint_valid(w_val)) {
-	    attr.rollback();
-	    return;
-	  }
-	*/
+			if(!is_setpoint_valid(w_val)) {
+			    attr.rollback();
+			    return;
+			  }
+	 */
 	omni_mutex_lock guardio(iomutex);
 	Tango::DevDouble newStrength;
-	correctionAtt->get_write_value(newStrength);
-	newStrength += w_val;
+	newStrength = w_val + wValCorrStrength;
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
 	req_strength.push_back(newStrength);
-	{
-		corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
-		Tango::DeviceAttribute watt("Current", curr_out[0]);
-		current_dev->write_attribute(watt);
-	}
-	update_correction_strength();
+	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
+	Tango::DeviceAttribute watt("Current", curr_out[0]);
+	current_dev->write_attribute(watt);
+	wValResStrength = w_val;
+	set_strength[0] = newStrength;
+	strengthAtt->set_write_value(set_strength[0]);
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_ResonanceStrength
 }
@@ -830,14 +831,21 @@ void E2Corrector::init_strengths(void) // initialize strengths from power supply
 		std::vector<Tango::DevDouble> _strength;
 		_current.push_back(outval[1]);
 		corrector->compute_strengths(magnet_rigidity_inv, _current, _strength);
-		*attr_Strength_read = _strength[0];
-		*attr_CorrectionStrength_read = _strength[0];
-		*attr_ResonanceStrength_read = 0.0;
+
 		cursetAtt->set_write_value(_current[0]);
 		set_current[0] = _current[0];
-		correctionAtt->set_write_value(_strength[0]);
+
 		strengthAtt->set_write_value(_strength[0]);
+		*attr_Strength_read = _strength[0];
+		set_strength[0] = _strength[0];
+
+		correctionAtt->set_write_value(_strength[0]);
+		*attr_CorrectionStrength_read = _strength[0];
+		wValCorrStrength = _strength[0];
+
 		resonanceAtt->set_write_value(0.0); // start with resonance strength always at 0!
+		*attr_ResonanceStrength_read = 0.0;
+		wValResStrength = 0.0;
 
 	} catch (Tango::DevFailed &e) {
 		Tango::Except::print_exception(e);
@@ -849,27 +857,11 @@ void E2Corrector::update_values(void)
 {
 	corrector->compute_strengths(magnet_rigidity_inv, set_current, set_strength);
 	attr_Strength_read[0] = set_strength[0];
-	Tango::DevDouble cstrength;
-	Tango::DevDouble rsStrength;
-	correctionAtt->get_write_value(cstrength);
-	resonanceAtt->get_write_value(rsStrength);
+	attr_ResonanceStrength_read[0] = attr_Strength_read[0] - wValCorrStrength;
 	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - attr_ResonanceStrength_read[0];
 
 
 }
-//------------------------------------------------------------
-
-void E2Corrector::update_correction_strength() {
-	Tango::DevDouble strength;
-	Tango::DevDouble cstrength;
-	Tango::DevDouble rsStrength;
-	strengthAtt->get_write_value(strength);
-	correctionAtt->get_write_value(cstrength);
-	resonanceAtt->get_write_value(rsStrength);
-	correctionAtt->set_write_value(strength - rsStrength);
-	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - attr_ResonanceStrength_read[0];
-	attr_ResonanceStrength_read[0] = rsStrength;
-}
 
 //------------------------------------------------------------
 
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index a77a825..524ae91 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -96,6 +96,8 @@ class E2Corrector : public TANGO_BASE_CLASS
 	std::vector<double> set_strength; //the strength set point
 public:
 	omni_mutex iomutex; //guard for event and write interference
+	Tango::DevDouble wValCorrStrength; //last CorrectionStrength write value
+	Tango::DevDouble wValResStrength;  //last ResonanceStrength write value
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Data Members
 
@@ -296,7 +298,6 @@ public:
 	void set_current_write(const double& curr);
 	void update_values(void); //update internal calculated values
 	void init_strengths(void); // initialize strengths from power supply values
-	void update_correction_strength(void); // arrange balance of strenghts (internal values usfeul for machine handling)
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Method prototypes
 };
-- 
GitLab


From 644ed33a3bfd3cc9be7474e345b12103211d5262 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Mon, 11 Mar 2024 11:25:36 +0100
Subject: [PATCH 10/14] reset_resonace_strength, reading part of strngths basde
 on reading part of current

---
 TODO                |  1 -
 src/E2Corrector.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/TODO b/TODO
index 8ec489c..216d4ae 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,5 @@ strengh = CorrectionStrength + resonanceStrength
  
  settings dei vari strength OK
  
-le parti read degli strength vanno aggiornate come la parte read di current (noise)
 compute_currents e compute_strenggths : rendee polimorifche per acceatare  DevDouble o duble
 
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index 9e5bc6e..40b63e6 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -778,6 +778,22 @@ void E2Corrector::reset_resonance_strength()
 
 	//	Add your own code
 
+	//force to 0 resonance strength
+
+	omni_mutex_lock guardio(iomutex);
+	Tango::DevDouble newStrength;
+	newStrength = wValCorrStrength;
+	std::vector<double> req_strength;
+	std::vector<double> curr_out;
+	req_strength.push_back(newStrength);
+	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
+	Tango::DeviceAttribute watt("Current", curr_out[0]);
+	current_dev->write_attribute(watt);
+	wValResStrength = 0.0;
+	set_strength[0] = newStrength;
+	strengthAtt->set_write_value(set_strength[0]);
+	resonanceAtt->set_write_value(0.0);
+
 	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::reset_resonance_strength
 }
@@ -855,11 +871,41 @@ void E2Corrector::init_strengths(void) // initialize strengths from power supply
 //------------------------------------------------------------
 void E2Corrector::update_values(void)
 {
+	/*
 	corrector->compute_strengths(magnet_rigidity_inv, set_current, set_strength);
 	attr_Strength_read[0] = set_strength[0];
 	attr_ResonanceStrength_read[0] = attr_Strength_read[0] - wValCorrStrength;
 	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - attr_ResonanceStrength_read[0];
-
+	*/
+	//----------------------------------------------
+	std::vector<Tango::DevDouble> read_curr;
+	std::vector<Tango::DevDouble> read_strength;
+	read_curr.push_back(*attr_Current_read);
+	corrector->compute_strengths(magnet_rigidity_inv, read_curr, read_strength);
+	attr_Strength_read[0] =  read_strength[0];
+	attr_ResonanceStrength_read[0] = attr_Strength_read[0] - wValCorrStrength;
+	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - wValResStrength;
+
+	//handle state - status
+	switch (get_state()) {
+	case Tango::ON:
+		set_status("On");
+		break;
+	case Tango::OFF:
+		set_status("Off");
+		break;
+	case Tango::FAULT:
+		set_status("Fault");
+		break;
+	case Tango::RUNNING:
+		set_status("Running");
+		break;
+	case Tango::MOVING:
+		set_status("Moving");
+		break;
+	default:
+		set_status("Unknown");
+	}
 
 }
 
-- 
GitLab


From 041b1ffd20e8f6b8bcbd05779cf526cf7c8414cf Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Wed, 17 Apr 2024 17:13:05 +0200
Subject: [PATCH 11/14] initial README with minimal information

---
 README.md | 92 ++-----------------------------------------------------
 1 file changed, 3 insertions(+), 89 deletions(-)

diff --git a/README.md b/README.md
index be8fc84..6179f7f 100644
--- a/README.md
+++ b/README.md
@@ -1,92 +1,6 @@
 # E2Corrector
 
+Elettra 2.0 pure corrector magnet device
 
-
-## Getting started
-
-To make it easy for you to get started with GitLab, here's a list of recommended next steps.
-
-Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
-
-## Add your files
-
-- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
-- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
-
-```
-cd existing_repo
-git remote add origin https://gitlab.elettra.eu/dt/ds/e2corrector.git
-git branch -M main
-git push -uf origin main
-```
-
-## Integrate with your tools
-
-- [ ] [Set up project integrations](https://gitlab.elettra.eu/dt/ds/e2corrector/-/settings/integrations)
-
-## Collaborate with your team
-
-- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
-- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
-- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
-- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
-- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
-
-## Test and Deploy
-
-Use the built-in continuous integration in GitLab.
-
-- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
-- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
-- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
-- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
-- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
-
-***
-
-# Editing this README
-
-When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
-
-## Suggestions for a good README
-Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
-
-## Name
-Choose a self-explaining name for your project.
-
-## Description
-Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
-
-## Badges
-On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
-
-## Visuals
-Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
-
-## Installation
-Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
-
-## Usage
-Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
-
-## Support
-Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
-
-## Roadmap
-If you have ideas for releases in the future, it is a good idea to list them in the README.
-
-## Contributing
-State if you are open to contributions and what your requirements are for accepting them.
-
-For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
-
-You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
-
-## Authors and acknowledgment
-Show your appreciation to those who have contributed to the project.
-
-## License
-For open source projects, say how it is licensed.
-
-## Project status
-If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+##
+calibration is a a csv file
-- 
GitLab


From dfce1914eea34cf27e0e1f4ed010f0caa4d2cc21 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Wed, 9 Oct 2024 17:06:01 +0200
Subject: [PATCH 12/14] pogo9

---
 src/E2Corrector.xmi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
index 6520d3a..3dce843 100644
--- a/src/E2Corrector.xmi
+++ b/src/E2Corrector.xmi
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ASCII"?>
-<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
+<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://tango.org/pogo/PogoDsl">
   <classes name="E2Corrector" pogoRevision="9.8">
     <description description="Elettra 2.0 pure corrector magnet device&#xA;Use calibration table handle current/strgenght converstions.&#xA;The magnet device is connected to a power supply tango device , real or simulated.&#xA;&#xA;Based on ESRF EBSmagnet concepts and libraries." title="Elettra 2.0 pure corrector magnet device" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/e2corrector/src" language="Cpp" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="Elettra - Sincrotrone Trieste S.c.p.A." hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
       <inheritances classname="Device_Impl" sourcePath=""/>
@@ -130,4 +130,4 @@
     </attributes>
     <preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.3.6/share/pogo/preferences"/>
   </classes>
-</pogoDsl:PogoSystem>
+</pogoDsl:PogoSystem>
\ No newline at end of file
-- 
GitLab


From 28b9fa784ccd89c2d98f5a64a3e5ae96e52c9555 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Mon, 4 Nov 2024 14:43:16 +0100
Subject: [PATCH 13/14] fix hadling of DesignStrength

---
 doc/Class.res                   |  11 +
 doc/test.res                    |  42 ++++
 src/E2Corrector.cpp             | 359 +++++++++++++++++++++-----------
 src/E2Corrector.h               |  74 ++++---
 src/E2Corrector.xmi             |  37 ++--
 src/E2CorrectorClass.cpp        | 242 ++++++++++++---------
 src/E2CorrectorClass.h          |  70 +++++--
 src/E2CorrectorStateMachine.cpp |  66 ++++--
 8 files changed, 604 insertions(+), 297 deletions(-)
 create mode 100644 doc/Class.res
 create mode 100644 doc/test.res

diff --git a/doc/Class.res b/doc/Class.res
new file mode 100644
index 0000000..df0bbf9
--- /dev/null
+++ b/doc/Class.res
@@ -0,0 +1,11 @@
+CLASS/E2Corrector->CalibrationPath: "/homelocal/claudio/src/gitlab/dt/machine/calibration/magnetmodel"
+CLASS/E2Corrector->Description: "Elettra 2.0 pure corrector magnet device",\ 
+                                "Use calibration table handle current/strgenght converstions.",\ 
+                                "The magnet device is connected to a power supply tango device , real or simulated.",\ 
+                                "",\ 
+                                "Based on ESRF EBSmagnet concepts and libraries."
+CLASS/E2Corrector->InheritedFrom: TANGO_BASE_CLASS
+CLASS/E2Corrector->ProjectTitle: "Elettra 2.0 pure corrector magnet device"
+
+# CLASS E2Corrector attribute properties
+
diff --git a/doc/test.res b/doc/test.res
new file mode 100644
index 0000000..c67b8c2
--- /dev/null
+++ b/doc/test.res
@@ -0,0 +1,42 @@
+#
+# Resource backup , created Fri Oct 18 15:35:26 CEST 2024
+#
+
+#---------------------------------------------------------
+# SERVER e2corrector-srv/test, E2Corrector device declaration
+#---------------------------------------------------------
+
+e2corrector-srv/test/DEVICE/E2Corrector: "test/magnet/che16"
+
+
+# --- test/magnet/che16 properties
+
+test/magnet/che16->CalibrationFileName: Cstrength.csv
+test/magnet/che16->CurrentDevice: "test/power_supply/psceh16"
+test/magnet/che16->MagnetName: 0
+test/magnet/che16->Model: not_relevant
+test/magnet/che16->ParameterFileName: MAG_params.csv
+test/magnet/che16->SerialNumber: 1
+test/magnet/che16->Type: H
+test/magnet/che16->__SubDevices: "test/power_supply/psceh16",\ 
+                                 "dserver/simulatede2ps-srv/test"
+
+# --- test/magnet/che16 attribute properties
+
+
+#---------------------------------------------------------
+# CLASS E2Corrector properties
+#---------------------------------------------------------
+
+CLASS/E2Corrector->CalibrationPath: "/homelocal/claudio/src/gitlab/dt/machine/calibration/magnetmodel"
+CLASS/E2Corrector->Description: "Elettra 2.0 pure corrector magnet device",\ 
+                                "Use calibration table handle current/strgenght converstions.",\ 
+                                "The magnet device is connected to a power supply tango device , real or simulated.",\ 
+                                "",\ 
+                                "Based on ESRF EBSmagnet concepts and libraries."
+CLASS/E2Corrector->InheritedFrom: TANGO_BASE_CLASS
+CLASS/E2Corrector->ProjectTitle: "Elettra 2.0 pure corrector magnet device"
+
+# CLASS E2Corrector attribute properties
+
+
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index 40b63e6..774a0ce 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -38,13 +38,12 @@
 
 #include "E2Corrector.h"
 #include "E2CorrectorClass.h"
-#include <Corrector.h>
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector.cpp
 
 /**
  *  E2Corrector class description:
- *    Elettra 2.0 pure corrector magnet device
+ *    Elettra 2.0 corrector magnet device
  *    Use calibration table handle current/strgenght converstions.
  *    The magnet device is connected to a power supply tango device , real or simulated.
  *    
@@ -61,6 +60,7 @@
 //  Status                  |  Inherited (no method)
 //  Reset                   |  reset
 //  ResetResonanceStrength  |  reset_resonance_strength
+//  ApplyDesignStrength     |  apply_design_strength
 //================================================================
 
 //================================================================
@@ -71,6 +71,7 @@
 //  ResonanceStrength   |  Tango::DevDouble	Scalar
 //  Current             |  Tango::DevDouble	Scalar
 //  BeamEnergy          |  Tango::DevDouble	Scalar
+//  DesignStrength      |  Tango::DevDouble	Scalar
 //================================================================
 
 namespace E2Corrector_ns
@@ -83,8 +84,8 @@ namespace E2Corrector_ns
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::E2Corrector()
- * Description:  Constructors for a Tango device
+ *	Method     : E2Corrector::E2Corrector()
+ *	Description: Constructors for a Tango device
  *                implementing the classE2Corrector
  */
 //--------------------------------------------------------
@@ -125,8 +126,8 @@ E2Corrector::~E2Corrector()
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::delete_device()
- * Description:  will be called at device destruction or at init command
+ *	Method     : E2Corrector::delete_device()
+ *	Description: will be called at device destruction or at init command
  */
 //--------------------------------------------------------
 void E2Corrector::delete_device()
@@ -136,25 +137,26 @@ void E2Corrector::delete_device()
 	/* clang-format on */
 	//	Delete device allocated objects
 
-	/* clang-format off */
-	if(state_event_id) current_dev->unsubscribe_event(current_event_id);
+	if(state_event_id) current_dev->unsubscribe_event(state_event_id);
 	if(current_set_event_id) current_dev->unsubscribe_event(current_set_event_id);
 	if(current_event_id) current_dev->unsubscribe_event(current_event_id);
-	sleep(1);
+	if(current_cb) delete current_cb;
 	delete attr_Current_read;
 	if (current_dev) delete current_dev;
 	if (corrector) delete corrector;
+	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::delete_device
 	delete[] attr_Strength_read;
 	delete[] attr_CorrectionStrength_read;
 	delete[] attr_ResonanceStrength_read;
 	delete[] attr_BeamEnergy_read;
+	delete[] attr_DesignStrength_read;
 }
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::init_device()
- * Description:  will be called at device initialization.
+ *	Method     : E2Corrector::init_device()
+ *	Description: will be called at device initialization.
  */
 //--------------------------------------------------------
 void E2Corrector::init_device()
@@ -164,9 +166,11 @@ void E2Corrector::init_device()
 	/* clang-format on */
 	//	Initialization before get_device_property() call
 	/* clang-format off */
+
 	set_state(Tango::INIT);
 	set_status("Init");
 	attr_Current_read = new Tango::DevDouble[1];
+	design_strength_initialized = false;
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device_before
 
 
@@ -177,6 +181,7 @@ void E2Corrector::init_device()
 	attr_CorrectionStrength_read = new Tango::DevDouble[1];
 	attr_ResonanceStrength_read = new Tango::DevDouble[1];
 	attr_BeamEnergy_read = new Tango::DevDouble[1];
+	attr_DesignStrength_read = new Tango::DevDouble[1];
 	//	No longer if mandatory property not set.
 	if (mandatoryNotDefined)
 		return;
@@ -185,9 +190,8 @@ void E2Corrector::init_device()
 	/* clang-format on */
 	//	Initialize device
 	/* clang-format off */
-
-	// get power supply device proxy
 	current_dev = nullptr;
+	current_cb = nullptr;
 	current_event_id = 0;
 	current_set_event_id = 0;
 	state_event_id = 0;
@@ -206,8 +210,8 @@ void E2Corrector::init_device()
 		return;
 	}
 
-	//create MagnetModel::Correctro - handles calibration tables and interpolations
-	// we do not use teh EBS shehme with global proprties... yet
+	//create MagnetModel::Corrector - handles calibration tables and interpolations
+	// we do not use teh EBS shehme with global properties... yet
 	//TODO: fix/determine format and handling of Elettra 2.0 calibrations
 
 	corrector = nullptr;
@@ -218,7 +222,7 @@ void E2Corrector::init_device()
 		corrector->init(true,1.0, meas_strength_file_name, param_file_name, magnetName);
 	} catch (std::exception &e) {
 		std::cerr << "fatalerror "<< e.what() << std::endl;
-		ERROR_STREAM << "failed to create correcto model " << currentDevice;
+		ERROR_STREAM << "failed to create corrector model " << currentDevice;
 		set_state(Tango::UNKNOWN);
 		set_status("failed to create corrector model CurrentDevice");
 		return;
@@ -235,29 +239,13 @@ void E2Corrector::init_device()
 	correctionAtt = &get_device_attr()->get_w_attr_by_name("CorrectionStrength");
 	resonanceAtt = &get_device_attr()->get_w_attr_by_name("ResonanceStrength");
 	cursetAtt = &(get_device_attr()->get_w_attr_by_name("Current"));
-	init_strengths();
-
-	// register callaback for current
-	try{
-		current_cb = new CurrentEventCallback(this);
-		current_event_id = current_dev->subscribe_event("current",Tango::CHANGE_EVENT,current_cb);
-		current_set_event_id = current_dev->subscribe_event("currentSet",Tango::CHANGE_EVENT,current_cb);
-		state_event_id = current_dev->subscribe_event("State",Tango::CHANGE_EVENT,current_cb);
-	}
-	catch(Tango::DevFailed &ex){
-		ERROR_STREAM << "failed to subscribe Tango  events for " << currentDevice;
-		set_state(Tango::UNKNOWN);
-		set_status("failed to subscribe Tango  events for CurrentDevice");
-		return;
-	}
-
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::init_device
 }
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::get_device_property()
- * Description:  Read database to initialize property data members.
+ *	Method     : E2Corrector::get_device_property()
+ *	Description: Read database to initialize property data members.
  */
 //--------------------------------------------------------
 void E2Corrector::get_device_property()
@@ -275,7 +263,6 @@ void E2Corrector::get_device_property()
 	dev_prop.push_back(Tango::DbDatum("CurrentDevice"));
 	dev_prop.push_back(Tango::DbDatum("Model"));
 	dev_prop.push_back(Tango::DbDatum("SerialNumber"));
-	dev_prop.push_back(Tango::DbDatum("Type"));
 	dev_prop.push_back(Tango::DbDatum("MagnetName"));
 	dev_prop.push_back(Tango::DbDatum("CalibrationFileName"));
 	dev_prop.push_back(Tango::DbDatum("CalibrationPath"));
@@ -327,17 +314,6 @@ void E2Corrector::get_device_property()
 		//	And try to extract SerialNumber value from database
 		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  serialNumber;
 
-		//	Try to initialize Type from class property
-		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
-		if (cl_prop.is_empty()==false)	cl_prop  >>  type;
-		else {
-			//	Try to initialize Type from default device value
-			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
-			if (def_prop.is_empty()==false)	def_prop  >>  type;
-		}
-		//	And try to extract Type value from database
-		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  type;
-
 		//	Try to initialize MagnetName from class property
 		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
 		if (cl_prop.is_empty()==false)	cl_prop  >>  magnetName;
@@ -396,8 +372,8 @@ void E2Corrector::get_device_property()
 }
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::check_mandatory_property()
- * Description:  For mandatory properties check if defined in database.
+ *	Method     : E2Corrector::check_mandatory_property()
+ *	Description: For mandatory properties check if defined in database.
  */
 //--------------------------------------------------------
 void E2Corrector::check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop)
@@ -424,8 +400,8 @@ void E2Corrector::check_mandatory_property(Tango::DbDatum &class_prop, Tango::Db
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::always_executed_hook()
- * Description:  method always executed before any command is executed
+ *	Method     : E2Corrector::always_executed_hook()
+ *	Description: method always executed before any command is executed
  */
 //--------------------------------------------------------
 void E2Corrector::always_executed_hook()
@@ -447,8 +423,8 @@ void E2Corrector::always_executed_hook()
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::read_attr_hardware()
- * Description:  Hardware acquisition for attributes
+ *	Method     : E2Corrector::read_attr_hardware()
+ *	Description: Hardware acquisition for attributes
  */
 //--------------------------------------------------------
 void E2Corrector::read_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
@@ -462,8 +438,8 @@ void E2Corrector::read_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
 }
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::write_attr_hardware()
- * Description:  Hardware writing for attributes
+ *	Method     : E2Corrector::write_attr_hardware()
+ *	Description: Hardware writing for attributes
  */
 //--------------------------------------------------------
 void E2Corrector::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
@@ -479,7 +455,7 @@ void E2Corrector::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list)
 //--------------------------------------------------------
 /**
  *	Read attribute Strength related method
- * Description:  corrrector kick in radians
+ *	Description: corrector strength 1/m^3 ( m-3)
  *
  *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
@@ -498,7 +474,7 @@ void E2Corrector::read_Strength(Tango::Attribute &attr)
 //--------------------------------------------------------
 /**
  *	Write attribute Strength related method
- * Description:  corrrector kick in radians
+ *	Description: corrector strength 1/m^3 ( m-3)
  *
  *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
@@ -513,6 +489,7 @@ void E2Corrector::write_Strength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_Strength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* clang-format off */
 	omni_mutex_lock guardio(iomutex);
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
@@ -524,7 +501,6 @@ void E2Corrector::write_Strength(Tango::WAttribute &attr)
 	wValCorrStrength = w_val - wValResStrength;
 	correctionAtt->set_write_value(wValCorrStrength);
 	//catch(std::excpetion &ex){}
-	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Strength
 }
 //--------------------------------------------------------
@@ -564,16 +540,17 @@ void E2Corrector::write_CorrectionStrength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_CorrectionStrength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* clang-format off */
 	/* TODO : implement is_set_point valid and exploit it!
-		if(!is_setpoint_valid(w_val)) {
-		    attr.rollback();
-		    return;
-		  }
+			if(!is_setpoint_valid(w_val)) {
+			    attr.rollback();
+			    return;
+			  }
 	 */
 	omni_mutex_lock guardio(iomutex);
 	Tango::DevDouble newStrength;
 	//resonanceAtt->get_write_value(_resStrength);
-	newStrength = w_val + wValResStrength;
+	newStrength = w_val + wValResStrength + *attr_DesignStrength_read;
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
 	req_strength.push_back(newStrength);
@@ -583,7 +560,7 @@ void E2Corrector::write_CorrectionStrength(Tango::WAttribute &attr)
 	wValCorrStrength = w_val;
 	set_strength[0] = newStrength;
 	strengthAtt->set_write_value(set_strength[0]);
-	/* clang-format off */
+
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_CorrectionStrength
 }
 //--------------------------------------------------------
@@ -623,15 +600,16 @@ void E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_ResonanceStrength) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* clang-format off */
 	/* TODO : implement is_set_point valid and exploit it!
-			if(!is_setpoint_valid(w_val)) {
-			    attr.rollback();
-			    return;
-			  }
+				if(!is_setpoint_valid(w_val)) {
+				    attr.rollback();
+				    return;
+				  }
 	 */
 	omni_mutex_lock guardio(iomutex);
 	Tango::DevDouble newStrength;
-	newStrength = w_val + wValCorrStrength;
+	newStrength = w_val + wValCorrStrength + *attr_DesignStrength_read;
 	std::vector<double> req_strength;
 	std::vector<double> curr_out;
 	req_strength.push_back(newStrength);
@@ -639,9 +617,9 @@ void E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr)
 	Tango::DeviceAttribute watt("Current", curr_out[0]);
 	current_dev->write_attribute(watt);
 	wValResStrength = w_val;
+	//*attr_ResonanceStrength_read = w_val;
 	set_strength[0] = newStrength;
 	strengthAtt->set_write_value(set_strength[0]);
-	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_ResonanceStrength
 }
 //--------------------------------------------------------
@@ -681,15 +659,15 @@ void E2Corrector::write_Current(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_Current) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* clang-format off */
 	Tango::DeviceAttribute watt("Current",w_val);
 	current_dev->write_attribute(watt);
-	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_Current
 }
 //--------------------------------------------------------
 /**
  *	Read attribute BeamEnergy related method
- * Description:  Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
+ *	Description: Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
  *
  *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
@@ -708,7 +686,7 @@ void E2Corrector::read_BeamEnergy(Tango::Attribute &attr)
 //--------------------------------------------------------
 /**
  *	Write attribute BeamEnergy related method
- * Description:  Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
+ *	Description: Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
  *
  *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
@@ -723,16 +701,65 @@ void E2Corrector::write_BeamEnergy(Tango::WAttribute &attr)
 	/*----- PROTECTED REGION ID(E2Corrector::write_BeamEnergy) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
+	/* clang-format off */
 	*attr_BeamEnergy_read = w_val;
 	calc_rigidity(w_val);
-	/* clang-format off */
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_BeamEnergy
 }
+//--------------------------------------------------------
+/**
+ *	Read attribute DesignStrength related method
+ *	Description: corrector design strength 1/m^3 ( m-3). The strenght reqiured by the nominal optic
+ *               The attribute is memorized , expert only.
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::read_DesignStrength(Tango::Attribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::read_DesignStrength(Tango::Attribute &attr) entering... " << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::read_DesignStrength) ENABLED START -----*/
+	/* clang-format on */
+	//	Set the attribute value
+	attr.set_value(attr_DesignStrength_read);
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::read_DesignStrength
+}
+//--------------------------------------------------------
+/**
+ *	Write attribute DesignStrength related method
+ *	Description: corrector design strength 1/m^3 ( m-3). The strenght reqiured by the nominal optic
+ *               The attribute is memorized , expert only.
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+//--------------------------------------------------------
+void E2Corrector::write_DesignStrength(Tango::WAttribute &attr)
+{
+	DEBUG_STREAM << "E2Corrector::write_DesignStrength(Tango::WAttribute &attr) entering... " << std::endl;
+	//	Retrieve write value
+	Tango::DevDouble	w_val;
+	attr.get_write_value(w_val);
+	/*----- PROTECTED REGION ID(E2Corrector::write_DesignStrength) ENABLED START -----*/
+	/* clang-format on */
+	//	Add your own code
+	/* clang-format off */
+	*attr_DesignStrength_read = w_val;
+	if (design_strength_initialized == false){ // only with a value of DesignStrength init process can be completed
+		design_strength_initialized = true;
+		init_strengths();
+		subscribe_events();
+	}
+	else init_strengths();
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_DesignStrength
+}
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::add_dynamic_attributes()
- * Description:  Create the dynamic attributes if any
+ *	Method     : E2Corrector::add_dynamic_attributes()
+ *	Description: Create the dynamic attributes if any
  *                for specified device.
  */
 //--------------------------------------------------------
@@ -748,7 +775,7 @@ void E2Corrector::add_dynamic_attributes()
 //--------------------------------------------------------
 /**
  *	Command Reset related method
- * Description:  reset the corrector
+ *	Description: reset the corrector
  *
  */
 //--------------------------------------------------------
@@ -766,7 +793,7 @@ void E2Corrector::reset()
 //--------------------------------------------------------
 /**
  *	Command ResetResonanceStrength related method
- * Description:  Reset ResonanceStrength to 0
+ *	Description: Reset ResonanceStrength to 0
  *
  */
 //--------------------------------------------------------
@@ -778,9 +805,10 @@ void E2Corrector::reset_resonance_strength()
 
 	//	Add your own code
 
+	/* clang-format off */
 	//force to 0 resonance strength
-
 	omni_mutex_lock guardio(iomutex);
+	/*
 	Tango::DevDouble newStrength;
 	newStrength = wValCorrStrength;
 	std::vector<double> req_strength;
@@ -789,18 +817,37 @@ void E2Corrector::reset_resonance_strength()
 	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
 	Tango::DeviceAttribute watt("Current", curr_out[0]);
 	current_dev->write_attribute(watt);
+	*/
+	wValCorrStrength +=  wValResStrength;
 	wValResStrength = 0.0;
-	set_strength[0] = newStrength;
-	strengthAtt->set_write_value(set_strength[0]);
+	//set_strength[0] = newStrength;
+	//strengthAtt->set_write_value(set_strength[0]);
+	correctionAtt->set_write_value(wValCorrStrength);
 	resonanceAtt->set_write_value(0.0);
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::reset_resonance_strength
+}
+//--------------------------------------------------------
+/**
+ *	Command ApplyDesignStrength related method
+ *	Description: Apply the memorized DesignStrength strenght to the magnet.
+ *
+ */
+//--------------------------------------------------------
+void E2Corrector::apply_design_strength()
+{
+	DEBUG_STREAM << "E2Corrector::ApplyDesignStrength()  - " << device_name << std::endl;
+	/*----- PROTECTED REGION ID(E2Corrector::apply_design_strength) ENABLED START -----*/
+	/* clang-format on */
+
+	//	Add your own code
 
 	/* clang-format off */
-	/*----- PROTECTED REGION END -----*/	//	E2Corrector::reset_resonance_strength
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::apply_design_strength
 }
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::add_dynamic_commands()
- * Description:  Create the dynamic commands if any
+ *	Method     : E2Corrector::add_dynamic_commands()
+ *	Description: Create the dynamic commands if any
  *                for specified device.
  */
 //--------------------------------------------------------
@@ -817,9 +864,6 @@ void E2Corrector::add_dynamic_commands()
 /* clang-format on */
 //	Additional Methods
 /* clang-format off */
-
-
-
 //--------------------------------------------------------
 void E2Corrector::calc_rigidity(const double& energy)
 {
@@ -834,9 +878,8 @@ void E2Corrector::set_current_write(const double& curr)
 	cursetAtt->set_write_value(curr);
 	set_current[0] = curr;
 }
-
-//------------------------------------------------------------
-void E2Corrector::init_strengths(void) // initialize strengths from power supply value
+// ------------------------------------------------------------
+void E2Corrector::init_strengths(void) // initialize strengths from power supply value TODO: separate read and set values
 {
 	Tango::DeviceAttribute da;
 	try {
@@ -845,7 +888,7 @@ void E2Corrector::init_strengths(void) // initialize strengths from power supply
 		da >> outval;
 		std::vector<Tango::DevDouble> _current;
 		std::vector<Tango::DevDouble> _strength;
-		_current.push_back(outval[1]);
+		_current.push_back(outval[1]); //use set value of current
 		corrector->compute_strengths(magnet_rigidity_inv, _current, _strength);
 
 		cursetAtt->set_write_value(_current[0]);
@@ -854,10 +897,11 @@ void E2Corrector::init_strengths(void) // initialize strengths from power supply
 		strengthAtt->set_write_value(_strength[0]);
 		*attr_Strength_read = _strength[0];
 		set_strength[0] = _strength[0];
+        Tango::DevDouble corr = _strength[0] - *attr_DesignStrength_read;
 
-		correctionAtt->set_write_value(_strength[0]);
-		*attr_CorrectionStrength_read = _strength[0];
-		wValCorrStrength = _strength[0];
+		correctionAtt->set_write_value(corr);
+		*attr_CorrectionStrength_read = corr;
+		wValCorrStrength = corr;
 
 		resonanceAtt->set_write_value(0.0); // start with resonance strength always at 0!
 		*attr_ResonanceStrength_read = 0.0;
@@ -867,26 +911,49 @@ void E2Corrector::init_strengths(void) // initialize strengths from power supply
 		Tango::Except::print_exception(e);
 	}
 }
-
 //------------------------------------------------------------
-void E2Corrector::update_values(void)
+// handle changes poer poer supply read current (actula current)
+void E2Corrector::update_values_read(void)
 {
-	/*
-	corrector->compute_strengths(magnet_rigidity_inv, set_current, set_strength);
-	attr_Strength_read[0] = set_strength[0];
-	attr_ResonanceStrength_read[0] = attr_Strength_read[0] - wValCorrStrength;
-	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - attr_ResonanceStrength_read[0];
-	*/
-	//----------------------------------------------
+	if (isnan(*attr_Current_read)){ //handle error
+		attr_Strength_read[0] = NAN;
+		return;
+	}
+	//INFO_STREAM << "update values read";
 	std::vector<Tango::DevDouble> read_curr;
 	std::vector<Tango::DevDouble> read_strength;
+	omni_mutex_lock guardio(iomutex);
 	read_curr.push_back(*attr_Current_read);
 	corrector->compute_strengths(magnet_rigidity_inv, read_curr, read_strength);
 	attr_Strength_read[0] =  read_strength[0];
-	attr_ResonanceStrength_read[0] = attr_Strength_read[0] - wValCorrStrength;
-	attr_CorrectionStrength_read[0] = attr_Strength_read[0] - wValResStrength;
+	attr_CorrectionStrength_read[0] = attr_Strength_read[0] -( attr_DesignStrength_read[0] +  attr_ResonanceStrength_read[0]);
+}
+
+//------------------------------------------------------------
+// hndle change of write set point of power supply cunnrent
+void E2Corrector::update_values_write(void)
+{
+	if (isnan(*attr_Current_read)){ //handle error
+		attr_Strength_read[0] = NAN;
+		return;
+	}
 
+	INFO_STREAM << "update values write";
+	std::vector<Tango::DevDouble> read_curr;
+	std::vector<Tango::DevDouble> read_strength;
+	omni_mutex_lock guardio(iomutex);
+	read_curr.push_back(set_current[0]); //must use the write value
+	corrector->compute_strengths(magnet_rigidity_inv, read_curr, read_strength);
+	wValCorrStrength = read_strength[0] - (wValResStrength + *attr_DesignStrength_read);
+	correctionAtt->set_write_value(wValCorrStrength);
+}
+
+//------------------------------------------------------------
+// handel che of power supply state - may just filter values
+void E2Corrector::update_values_state(void)
+{
 	//handle state - status
+	//INFO_STREAM << "update values state";
 	switch (get_state()) {
 	case Tango::ON:
 		set_status("On");
@@ -909,35 +976,79 @@ void E2Corrector::update_values(void)
 
 }
 
+void E2Corrector::subscribe_events(void)
+{
+	try{
+			current_cb = new CurrentEventCallback(this);
+			current_event_id = current_dev->subscribe_event("current",Tango::CHANGE_EVENT,current_cb);
+			current_set_event_id = current_dev->subscribe_event("currentSet",Tango::CHANGE_EVENT,current_cb);
+			state_event_id = current_dev->subscribe_event("State",Tango::CHANGE_EVENT,current_cb);
+		}
+		catch(Tango::DevFailed &ex){
+			current_cb = nullptr;
+			ERROR_STREAM << "failed to subscribe Tango  events for " << currentDevice;
+			set_state(Tango::UNKNOWN);
+			set_status("failed to subscribe Tango  events for CurrentDevice");
+			return;
+		}
+}
+/* trick to start sunbscrition afetr some delay
+void E2Corrector::delayed_subscribe(int delayMs)
+#include <thread>
+#include <chrono>
+{
+	std::thread([this, delayMs]() {
+		std::this_thread::sleep_for(std::chrono::milliseconds(delayMs));
+		this->subscribe_events();  // Call the method after the delay
+	}).detach();  // Detach the thread to run independently
+}
+*/
 //------------------------------------------------------------
-
-CurrentEventCallback::CurrentEventCallback(E2Corrector* corr) //callback constructor
+//------------------------------------------------------------
+CurrentEventCallback::CurrentEventCallback(E2Corrector* quad) //callback constructor
 {
-	e2_corr = corr;
+	e2_quad = quad;
 }
 void CurrentEventCallback::push_event(Tango::EventData* ev) //callback core method
 {
+	bool update_read = false;
+	bool update_write = false;
+	bool update_state = false;
 	if (ev->err) {
-		//TODO hanlde error
+		//std::cerr << ev->err << " " << ev->attr_name << std::endl;
+		e2_quad->set_state(Tango::FAULT);
+		e2_quad->set_status("event error");
+		*e2_quad->attr_Current_read = NAN;
+		e2_quad->update_values_read();
 		return;
 	}
-	omni_mutex_lock guardio(e2_corr->iomutex);
-    //TODO add method to update the corrector when on value changes
-	std::string fullattrname = ev->attr_name;
-	std::size_t pos = fullattrname.find_last_of("/");
-	std::string attrname = fullattrname.substr(pos+1);
-	if(attrname == "current") *(ev->attr_value) >> *(e2_corr->attr_Current_read);
-	if(attrname == "currentset"){
-		Tango::DevDouble newcurr;
-		*(ev->attr_value) >> newcurr;
-		e2_corr->set_current_write(newcurr);
-	}
-	if(attrname == "state") {
-		Tango::DevState st;
-		*(ev->attr_value) >> st;
-		e2_corr->set_state(st);
+	{
+		omni_mutex_lock guardio(e2_quad->iomutex);
+		//TODO add method to update the corrector when on value changes
+		std::string fullattrname = ev->attr_name;
+		std::size_t pos = fullattrname.find_last_of("/");
+		std::string attrname = fullattrname.substr(pos + 1);
+		if (attrname == "current") {
+			*(ev->attr_value) >> *(e2_quad->attr_Current_read);
+			update_read = true;
+		}
+		if (attrname == "currentset") {
+			Tango::DevDouble newcurr;
+			*(ev->attr_value) >> newcurr;
+			e2_quad->set_current_write(newcurr);
+			update_write = true;
+		}
+		if (attrname == "state") {
+			Tango::DevState st;
+			*(ev->attr_value) >> st;
+			e2_quad->set_state(st);
+			update_state = true;
+		}
 	}
-	e2_corr->update_values();
+	if (update_read) e2_quad->update_values_read();
+	if (update_write) e2_quad->update_values_write();
+	if (update_state) e2_quad->update_values_state();
 }
+
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::namespace_ending
 } //	namespace
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index 524ae91..16ab00c 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -37,7 +37,6 @@
 
 #include <tango/tango.h>
 #include <Corrector.h>
-
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector.h
 
@@ -53,7 +52,7 @@
 
 /**
  *  E2Corrector class description:
- *    Elettra 2.0 pure corrector magnet device
+ *    Elettra 2.0 corrector magnet device
  *    Use calibration table handle current/strgenght converstions.
  *    The magnet device is connected to a power supply tango device , real or simulated.
  *    
@@ -94,6 +93,7 @@ class E2Corrector : public TANGO_BASE_CLASS
 	Tango::WAttribute *resonanceAtt;
 	std::vector<double> set_current; //the actual set point of the current (from the power supply)  used for strength calculations
 	std::vector<double> set_strength; //the strength set point
+	bool design_strength_initialized; //true whe design strenfght has been called at least one , first call is to init valude from DB
 public:
 	omni_mutex iomutex; //guard for event and write interference
 	Tango::DevDouble wValCorrStrength; //last CorrectionStrength write value
@@ -109,8 +109,6 @@ public:
 	std::string	model;
 	//	SerialNumber:	serial number of the magnet
 	std::string	serialNumber;
-	//	Type:	corrector type (H or V)
-	std::string	type;
 	//	MagnetName:	Name of magnet
 	std::string	magnetName;
 	//	CalibrationFileName:	name of calibration table file name
@@ -130,6 +128,7 @@ public:
 	Tango::DevDouble	*attr_ResonanceStrength_read;
 	Tango::DevDouble	*attr_Current_read;
 	Tango::DevDouble	*attr_BeamEnergy_read;
+	Tango::DevDouble	*attr_DesignStrength_read;
 
 //	Constructors and destructors
 public:
@@ -189,24 +188,24 @@ public:
 public:
 	//--------------------------------------------------------
 	/*
-	 *	Method      : E2Corrector::read_attr_hardware()
-	 * Description:  Hardware acquisition for attributes.
+	 *	Method     : E2Corrector::read_attr_hardware()
+	 *	Description: Hardware acquisition for attributes.
 	 */
 	//--------------------------------------------------------
 	virtual void read_attr_hardware(std::vector<long> &attr_list);
 	//--------------------------------------------------------
 	/*
-	 *	Method      : E2Corrector::write_attr_hardware()
-	 * Description:  Hardware writing for attributes.
+	 *	Method     : E2Corrector::write_attr_hardware()
+	 *	Description: Hardware writing for attributes.
 	 */
 	//--------------------------------------------------------
 	virtual void write_attr_hardware(std::vector<long> &attr_list);
 
 /**
  *	Attribute Strength related methods
- * Description:  corrrector kick in radians
+ *	Description: corrector strength 1/m^3 ( m-3)
  *
- *	Data type:  Tango::DevDouble
+ *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
  */
 	virtual void read_Strength(Tango::Attribute &attr);
@@ -216,7 +215,7 @@ public:
  *	Attribute CorrectionStrength related methods
  *
  *
- *	Data type:  Tango::DevDouble
+ *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
  */
 	virtual void read_CorrectionStrength(Tango::Attribute &attr);
@@ -226,7 +225,7 @@ public:
  *	Attribute ResonanceStrength related methods
  *
  *
- *	Data type:  Tango::DevDouble
+ *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
  */
 	virtual void read_ResonanceStrength(Tango::Attribute &attr);
@@ -236,7 +235,7 @@ public:
  *	Attribute Current related methods
  *
  *
- *	Data type:  Tango::DevDouble
+ *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
  */
 	virtual void read_Current(Tango::Attribute &attr);
@@ -244,20 +243,31 @@ public:
 	virtual bool is_Current_allowed(Tango::AttReqType type);
 /**
  *	Attribute BeamEnergy related methods
- * Description:  Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
+ *	Description: Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations.
  *
- *	Data type:  Tango::DevDouble
+ *	Data type:	Tango::DevDouble
  *	Attr type:	Scalar
  */
 	virtual void read_BeamEnergy(Tango::Attribute &attr);
 	virtual void write_BeamEnergy(Tango::WAttribute &attr);
 	virtual bool is_BeamEnergy_allowed(Tango::AttReqType type);
+/**
+ *	Attribute DesignStrength related methods
+ *	Description: corrector design strength 1/m^3 ( m-3). The strenght reqiured by the nominal optic
+ *               The attribute is memorized , expert only.
+ *
+ *	Data type:	Tango::DevDouble
+ *	Attr type:	Scalar
+ */
+	virtual void read_DesignStrength(Tango::Attribute &attr);
+	virtual void write_DesignStrength(Tango::WAttribute &attr);
+	virtual bool is_DesignStrength_allowed(Tango::AttReqType type);
 
 
 	//--------------------------------------------------------
 	/**
-	 *	Method      : E2Corrector::add_dynamic_attributes()
-	 * Description:  Add dynamic attributes if any.
+	 *	Method     : E2Corrector::add_dynamic_attributes()
+	 *	Description: Add dynamic attributes if any.
 	 */
 	//--------------------------------------------------------
 	void add_dynamic_attributes();
@@ -269,24 +279,31 @@ public:
 public:
 	/**
 	 *	Command Reset related method
-	 * Description:  reset the corrector
+	 *	Description: reset the corrector
 	 *
 	 */
 	virtual void reset();
 	virtual bool is_Reset_allowed(const CORBA::Any &any);
 	/**
 	 *	Command ResetResonanceStrength related method
-	 * Description:  Reset ResonanceStrength to 0
+	 *	Description: Reset ResonanceStrength to 0
 	 *
 	 */
 	virtual void reset_resonance_strength();
 	virtual bool is_ResetResonanceStrength_allowed(const CORBA::Any &any);
+	/**
+	 *	Command ApplyDesignStrength related method
+	 *	Description: Apply the memorized DesignStrength strenght to the magnet.
+	 *
+	 */
+	virtual void apply_design_strength();
+	virtual bool is_ApplyDesignStrength_allowed(const CORBA::Any &any);
 
 
 	//--------------------------------------------------------
 	/**
-	 *	Method      : E2Corrector::add_dynamic_commands()
-	 * Description:  Add dynamic commands if any.
+	 *	Method     : E2Corrector::add_dynamic_commands()
+	 *	Description: Add dynamic commands if any.
 	 */
 	//--------------------------------------------------------
 	void add_dynamic_commands();
@@ -296,8 +313,12 @@ public:
 //	Additional Method prototypes
 	void calc_rigidity(const double& energy);
 	void set_current_write(const double& curr);
-	void update_values(void); //update internal calculated values
+	void update_values_write(void); //update internal calculated values when current write value is updated;
+	void update_values_read(void); //update internal calculated values when current read value is updated;
+	void update_values_state(void); //update internal calculated values when power supply state is updated;
 	void init_strengths(void); // initialize strengths from power supply values
+	void subscribe_events(void); //subcribe events to power supply
+	//void delayed_subscribe(int delayedMs);
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Method prototypes
 };
@@ -305,20 +326,15 @@ public:
 /*----- PROTECTED REGION ID(E2Corrector::Additional Classes Definitions) ENABLED START -----*/
 /* clang-format on */
 //	Additional Classes Definitions
-/* clang-format off */
-
-
-/*----- PROTECTED REGION ID(E2Corrector::Data Members) ENABLED START -----*/
-/* clang-format on */
-//	Add your own data members
 class CurrentEventCallback : public Tango::CallBack
 {
 public:
 	CurrentEventCallback(E2Corrector*);
 	void push_event(Tango::EventData* ev);
 protected:
-	E2Corrector* e2_corr;
+	E2Corrector* e2_quad;
 };
+/* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2Corrector::Additional Classes Definitions
 
 }	//	End of namespace
diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
index 3dce843..8e0c18b 100644
--- a/src/E2Corrector.xmi
+++ b/src/E2Corrector.xmi
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ASCII"?>
 <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://tango.org/pogo/PogoDsl">
-  <classes name="E2Corrector" pogoRevision="9.8">
-    <description description="Elettra 2.0 pure corrector magnet device&#xA;Use calibration table handle current/strgenght converstions.&#xA;The magnet device is connected to a power supply tango device , real or simulated.&#xA;&#xA;Based on ESRF EBSmagnet concepts and libraries." title="Elettra 2.0 pure corrector magnet device" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/e2corrector/src" language="Cpp" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="Elettra - Sincrotrone Trieste S.c.p.A." hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
+  <classes name="E2Corrector" pogoRevision="9.9">
+    <description description="Elettra 2.0 corrector magnet device&#xA;Use calibration table handle current/strgenght converstions.&#xA;The magnet device is connected to a power supply tango device , real or simulated.&#xA;&#xA;Based on ESRF EBSmagnet concepts and libraries." title="Elettra 2.0 pure corrector magnet device" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/e2corrector/src" language="Cpp" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="Elettra - Sincrotrone Trieste S.c.p.A." hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
       <inheritances classname="Device_Impl" sourcePath=""/>
       <identification contact="at elettra.eu - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.eu" classFamily="MagneticDevices" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference="">
         <keyWords>magnet</keyWords>
@@ -32,10 +32,6 @@
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </deviceProperties>
-    <deviceProperties name="Type" description="corrector type (H or V)">
-      <type xsi:type="pogoDsl:StringType"/>
-      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-    </deviceProperties>
     <deviceProperties name="MagnetName" description="Name of magnet">
       <type xsi:type="pogoDsl:StringType"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
@@ -88,13 +84,22 @@
       </argout>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </commands>
+    <commands name="ApplyDesignStrength" description="Apply the memorized DesignStrength strenght to the magnet." execMethod="apply_design_strength" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
+      <argin description="">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argin>
+      <argout description="">
+        <type xsi:type="pogoDsl:VoidType"/>
+      </argout>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </commands>
     <attributes name="Strength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="corrrector kick in radians" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="corrector strength 1/m^3 ( m-3)" label="strength" unit="m-3" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
     <attributes name="CorrectionStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
@@ -102,7 +107,7 @@
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="" label="correction strength" unit="m-3" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
     <attributes name="ResonanceStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
@@ -110,7 +115,7 @@
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="" label="" unit="rad" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="" label="resonance strength" unit="m-3" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
     <attributes name="Current" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
@@ -118,7 +123,7 @@
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
-      <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+      <properties description="" label="" unit="A" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
     <attributes name="BeamEnergy" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:DoubleType"/>
@@ -128,6 +133,14 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <properties description="Electron beam energy in eV. Used to calculate magnetic rigidity in strength calculations." label="electron beam ebergy [eV]" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.3.6/share/pogo/preferences"/>
+    <attributes name="DesignStrength" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="corrector design strength 1/m^3 ( m-3). The strenght reqiured by the nominal optic&#xA;The attribute is memorized , expert only." label="design strength" unit="m-3" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/>
   </classes>
-</pogoDsl:PogoSystem>
\ No newline at end of file
+</pogoDsl:PogoSystem>
diff --git a/src/E2CorrectorClass.cpp b/src/E2CorrectorClass.cpp
index ceeed95..21f7ea9 100644
--- a/src/E2CorrectorClass.cpp
+++ b/src/E2CorrectorClass.cpp
@@ -145,7 +145,7 @@ E2CorrectorClass *E2CorrectorClass::instance()
 {
 	if (_instance == NULL)
 	{
-		std::cerr << "Class is not initialised !!" << std::endl;
+		std::cerr << "Class is not initialized !!" << std::endl;
 		exit(-1);
 	}
 	return _instance;
@@ -192,14 +192,32 @@ CORBA::Any *ResetResonanceStrengthClass::execute(Tango::DeviceImpl *device, TANG
 	return new CORBA::Any();
 }
 
+//--------------------------------------------------------
+/**
+ * method : 		ApplyDesignStrengthClass::execute()
+ * description : 	method to trigger the execution of the command.
+ *
+ * @param	device	The device on which the command must be executed
+ * @param	in_any	The command input data
+ *
+ *	returns The command output data (packed in the Any object)
+ */
+//--------------------------------------------------------
+CORBA::Any *ApplyDesignStrengthClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
+{
+	TANGO_LOG_INFO << "ApplyDesignStrengthClass::execute(): arrived" << std::endl;
+	((static_cast<E2Corrector *>(device))->apply_design_strength());
+	return new CORBA::Any();
+}
+
 
 //===================================================================
 //	Properties management
 //===================================================================
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::get_class_property()
- * Description:  Get the class property for specified name.
+ *	Method     : E2CorrectorClass::get_class_property()
+ *	Description: Get the class property for specified name.
  */
 //--------------------------------------------------------
 Tango::DbDatum E2CorrectorClass::get_class_property(std::string &prop_name)
@@ -213,8 +231,8 @@ Tango::DbDatum E2CorrectorClass::get_class_property(std::string &prop_name)
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::get_default_device_property()
- * Description:  Return the default value for device property.
+ *	Method     : E2CorrectorClass::get_default_device_property()
+ *	Description: Return the default value for device property.
  */
 //--------------------------------------------------------
 Tango::DbDatum E2CorrectorClass::get_default_device_property(std::string &prop_name)
@@ -228,8 +246,8 @@ Tango::DbDatum E2CorrectorClass::get_default_device_property(std::string &prop_n
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::get_default_class_property()
- * Description:  Return the default value for class property.
+ *	Method     : E2CorrectorClass::get_default_class_property()
+ *	Description: Return the default value for class property.
  */
 //--------------------------------------------------------
 Tango::DbDatum E2CorrectorClass::get_default_class_property(std::string &prop_name)
@@ -243,8 +261,8 @@ Tango::DbDatum E2CorrectorClass::get_default_class_property(std::string &prop_na
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::get_class_property()
- * Description:  Read database to initialize class property data members.
+ *	Method     : E2CorrectorClass::get_class_property()
+ *	Description: Read database to initialize class property data members.
  */
 //--------------------------------------------------------
 void E2CorrectorClass::get_class_property()
@@ -298,8 +316,8 @@ void E2CorrectorClass::get_class_property()
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::set_default_property()
- * Description:  Set default property (class and device) for wizard.
+ *	Method     : E2CorrectorClass::set_default_property()
+ *	Description: Set default property (class and device) for wizard.
  *                For each property, add to wizard property name and description.
  *                If default value has been set, add it to wizard property and
  *                store it in a DbDatum.
@@ -379,19 +397,6 @@ void E2CorrectorClass::set_default_property()
 		dev_def_prop.push_back(data);
 		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
 	}
-	else
-		add_wiz_dev_prop(prop_name, prop_desc);
-	prop_name = "Type";
-	prop_desc = "corrector type (H or V)";
-	prop_def  = "";
-	vect_data.clear();
-	if (prop_def.length()>0)
-	{
-		Tango::DbDatum	data(prop_name);
-		data << vect_data ;
-		dev_def_prop.push_back(data);
-		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
-	}
 	else
 		add_wiz_dev_prop(prop_name, prop_desc);
 	prop_name = "MagnetName";
@@ -450,46 +455,46 @@ void E2CorrectorClass::set_default_property()
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::write_class_property()
- * Description:  Set class description fields as property in database
+ *	Method     : E2CorrectorClass::write_class_property()
+ *	Description: Set class description fields as property in database
  */
 //--------------------------------------------------------
 void E2CorrectorClass::write_class_property()
 {
-//	First time, check if database used
-if (Tango::Util::_UseDb == false)
-	return;
-
-Tango::DbData	data;
-std::string	classname = get_name();
-std::string	header;
-
-//	Put title
-Tango::DbDatum	title("ProjectTitle");
-std::string	str_title("Elettra 2.0 pure corrector magnet device");
-title << str_title;
-data.push_back(title);
-
-//	Put Description
-Tango::DbDatum	description("Description");
-std::vector<std::string>	str_desc;
-str_desc.push_back("Elettra 2.0 pure corrector magnet device");
-str_desc.push_back("Use calibration table handle current/strgenght converstions.");
-str_desc.push_back("The magnet device is connected to a power supply tango device , real or simulated.");
-str_desc.push_back("");
-str_desc.push_back("Based on ESRF EBSmagnet concepts and libraries.");
-description << str_desc;
-data.push_back(description);
-
-//  Put inheritance
-Tango::DbDatum	inher_datum("InheritedFrom");
-std::vector<std::string> inheritance;
-inheritance.push_back("TANGO_BASE_CLASS");
-inher_datum << inheritance;
-data.push_back(inher_datum);
-
-//	Call database and and values
-get_db_class()->put_property(data);
+	//	First time, check if database used
+	if (Tango::Util::_UseDb == false)
+		return;
+
+	Tango::DbData	data;
+	std::string	classname = get_name();
+	std::string	header;
+
+	//	Put title
+	Tango::DbDatum	title("ProjectTitle");
+	std::string	str_title("Elettra 2.0 pure corrector magnet device");
+	title << str_title;
+	data.push_back(title);
+
+	//	Put Description
+	Tango::DbDatum	description("Description");
+	std::vector<std::string>	str_desc;
+	str_desc.push_back("Elettra 2.0 corrector magnet device");
+	str_desc.push_back("Use calibration table handle current/strgenght converstions.");
+	str_desc.push_back("The magnet device is connected to a power supply tango device , real or simulated.");
+	str_desc.push_back("");
+	str_desc.push_back("Based on ESRF EBSmagnet concepts and libraries.");
+	description << str_desc;
+	data.push_back(description);
+
+	//  Put inheritance
+	Tango::DbDatum	inher_datum("InheritedFrom");
+	std::vector<std::string> inheritance;
+	inheritance.push_back("TANGO_BASE_CLASS");
+	inher_datum << inheritance;
+	data.push_back(inher_datum);
+
+	//	Call database and and values
+	get_db_class()->put_property(data);
 }
 
 //===================================================================
@@ -498,44 +503,44 @@ get_db_class()->put_property(data);
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::device_factory()
- * Description:  Create the device object(s)
+ *	Method     : E2CorrectorClass::device_factory()
+ *	Description: Create the device object(s)
  *                and store them in the device list
  */
 //--------------------------------------------------------
 void E2CorrectorClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)
 {
-/*----- PROTECTED REGION ID(E2CorrectorClass::device_factory_before) ENABLED START -----*/
+	/*----- PROTECTED REGION ID(E2CorrectorClass::device_factory_before) ENABLED START -----*/
 /* clang-format on */
 //	Add your own code
 /* clang-format off */
 /*----- PROTECTED REGION END -----*/	//	E2CorrectorClass::device_factory_before
 
-//	Create devices and add it into the device list
-for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
-{
-	TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << std::endl;
-	device_list.push_back(new E2Corrector(this, (*devlist_ptr)[i]));
-}
-
-//	Manage dynamic attributes if any
-erase_dynamic_attributes(devlist_ptr, get_class_attr()->get_attr_list());
+	//	Create devices and add it into the device list
+	for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
+	{
+		TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << std::endl;
+		device_list.push_back(new E2Corrector(this, (*devlist_ptr)[i]));
+	}
 
-//	Export devices to the outside world
-for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
-{
-	//	Add dynamic attributes if any
-	E2Corrector *dev = static_cast<E2Corrector *>(device_list[device_list.size()-i]);
-	dev->add_dynamic_attributes();
+	//	Manage dynamic attributes if any
+	erase_dynamic_attributes(devlist_ptr, get_class_attr()->get_attr_list());
 
-	//	Check before if database used.
-	if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
-		export_device(dev);
-	else
-		export_device(dev, dev->get_name().c_str());
-}
+	//	Export devices to the outside world
+	for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
+	{
+		//	Add dynamic attributes if any
+		E2Corrector *dev = static_cast<E2Corrector *>(device_list[device_list.size()-i]);
+		dev->add_dynamic_attributes();
+
+		//	Check before if database used.
+		if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
+			export_device(dev);
+		else
+			export_device(dev, dev->get_name().c_str());
+	}
 
-/*----- PROTECTED REGION ID(E2CorrectorClass::device_factory_after) ENABLED START -----*/
+	/*----- PROTECTED REGION ID(E2CorrectorClass::device_factory_after) ENABLED START -----*/
 /* clang-format on */
 //	Add your own code
 /* clang-format off */
@@ -543,8 +548,8 @@ for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
 }
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::attribute_factory()
- * Description:  Create the attribute object(s)
+ *	Method     : E2CorrectorClass::attribute_factory()
+ *	Description: Create the attribute object(s)
  *                and store them in the attribute list
  */
 //--------------------------------------------------------
@@ -558,9 +563,9 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	//	Attribute : Strength
 	StrengthAttrib	*strength = new StrengthAttrib();
 	Tango::UserDefaultAttrProp	strength_prop;
-	strength_prop.set_description("corrrector kick in radians");
-	//	label	not set for Strength
-	strength_prop.set_unit("rad");
+	strength_prop.set_description("corrector strength 1/m^3 ( m-3)");
+	strength_prop.set_label("strength");
+	strength_prop.set_unit("m-3");
 	//	standard_unit	not set for Strength
 	//	display_unit	not set for Strength
 	//	format	not set for Strength
@@ -582,8 +587,8 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	CorrectionStrengthAttrib	*correctionstrength = new CorrectionStrengthAttrib();
 	Tango::UserDefaultAttrProp	correctionstrength_prop;
 	//	description	not set for CorrectionStrength
-	//	label	not set for CorrectionStrength
-	correctionstrength_prop.set_unit("rad");
+	correctionstrength_prop.set_label("correction strength");
+	correctionstrength_prop.set_unit("m-3");
 	//	standard_unit	not set for CorrectionStrength
 	//	display_unit	not set for CorrectionStrength
 	//	format	not set for CorrectionStrength
@@ -605,8 +610,8 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	ResonanceStrengthAttrib	*resonancestrength = new ResonanceStrengthAttrib();
 	Tango::UserDefaultAttrProp	resonancestrength_prop;
 	//	description	not set for ResonanceStrength
-	//	label	not set for ResonanceStrength
-	resonancestrength_prop.set_unit("rad");
+	resonancestrength_prop.set_label("resonance strength");
+	resonancestrength_prop.set_unit("m-3");
 	//	standard_unit	not set for ResonanceStrength
 	//	display_unit	not set for ResonanceStrength
 	//	format	not set for ResonanceStrength
@@ -629,7 +634,7 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	Tango::UserDefaultAttrProp	current_prop;
 	//	description	not set for Current
 	//	label	not set for Current
-	//	unit	not set for Current
+	current_prop.set_unit("A");
 	//	standard_unit	not set for Current
 	//	display_unit	not set for Current
 	//	format	not set for Current
@@ -670,6 +675,30 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 	//	Not Memorized
 	att_list.push_back(beamenergy);
 
+	//	Attribute : DesignStrength
+	DesignStrengthAttrib	*designstrength = new DesignStrengthAttrib();
+	Tango::UserDefaultAttrProp	designstrength_prop;
+	designstrength_prop.set_description("corrector design strength 1/m^3 ( m-3). The strenght reqiured by the nominal optic\nThe attribute is memorized , expert only.");
+	designstrength_prop.set_label("design strength");
+	designstrength_prop.set_unit("m-3");
+	//	standard_unit	not set for DesignStrength
+	//	display_unit	not set for DesignStrength
+	//	format	not set for DesignStrength
+	//	max_value	not set for DesignStrength
+	//	min_value	not set for DesignStrength
+	//	max_alarm	not set for DesignStrength
+	//	min_alarm	not set for DesignStrength
+	//	max_warning	not set for DesignStrength
+	//	min_warning	not set for DesignStrength
+	//	delta_t	not set for DesignStrength
+	//	delta_val	not set for DesignStrength
+	designstrength->set_default_properties(designstrength_prop);
+	//	Not Polled
+	designstrength->set_disp_level(Tango::EXPERT);
+	designstrength->set_memorized();
+	designstrength->set_memorized_init(true);
+	att_list.push_back(designstrength);
+
 
 	//	Create a list of static attributes
 	create_static_attribute_list(get_class_attr()->get_attr_list());
@@ -681,8 +710,8 @@ void E2CorrectorClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
 }
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::pipe_factory()
- * Description:  Create the pipe object(s)
+ *	Method     : E2CorrectorClass::pipe_factory()
+ *	Description: Create the pipe object(s)
  *                and store them in the pipe list
  */
 //--------------------------------------------------------
@@ -701,8 +730,8 @@ void E2CorrectorClass::pipe_factory()
 }
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::command_factory()
- * Description:  Create the command object(s)
+ *	Method     : E2CorrectorClass::command_factory()
+ *	Description: Create the command object(s)
  *                and store them in the command list
  */
 //--------------------------------------------------------
@@ -733,6 +762,15 @@ void E2CorrectorClass::command_factory()
 			Tango::OPERATOR);
 	command_list.push_back(pResetResonanceStrengthCmd);
 
+	//	Command ApplyDesignStrength
+	ApplyDesignStrengthClass	*pApplyDesignStrengthCmd =
+		new ApplyDesignStrengthClass("ApplyDesignStrength",
+			Tango::DEV_VOID, Tango::DEV_VOID,
+			"",
+			"",
+			Tango::OPERATOR);
+	command_list.push_back(pApplyDesignStrengthCmd);
+
 	/*----- PROTECTED REGION ID(E2CorrectorClass::command_factory_after) ENABLED START -----*/
 	/* clang-format on */
 	//	Add your own code
@@ -757,7 +795,7 @@ void E2CorrectorClass::create_static_attribute_list(std::vector<Tango::Attr *> &
 	for (unsigned long i=0 ; i<att_list.size() ; i++)
 	{
 		std::string att_name(att_list[i]->get_name());
-		transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower);
+		std::transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower);
 		defaultAttList.push_back(att_name);
 	}
 
@@ -813,8 +851,8 @@ void E2CorrectorClass::erase_dynamic_attributes(const Tango::DevVarStringArray *
 
 //--------------------------------------------------------
 /**
- *	Method      : E2CorrectorClass::get_attr_object_by_name()
- * Description:  returns Tango::Attr * object found by name
+ *	Method     : E2CorrectorClass::get_attr_object_by_name()
+ *	Description: returns Tango::Attr * object found by name
  */
 //--------------------------------------------------------
 Tango::Attr *E2CorrectorClass::get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname)
diff --git a/src/E2CorrectorClass.h b/src/E2CorrectorClass.h
index 792df7c..73595d2 100644
--- a/src/E2CorrectorClass.h
+++ b/src/E2CorrectorClass.h
@@ -62,8 +62,8 @@ class StrengthAttrib: public Tango::Attr
 {
 public:
 	StrengthAttrib():Attr("Strength",
-			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
-	~StrengthAttrib() {};
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
+	~StrengthAttrib() {}
 	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
 		{(static_cast<E2Corrector *>(dev))->read_Strength(att);}
 	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
@@ -77,8 +77,8 @@ class CorrectionStrengthAttrib: public Tango::Attr
 {
 public:
 	CorrectionStrengthAttrib():Attr("CorrectionStrength",
-			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
-	~CorrectionStrengthAttrib() {};
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
+	~CorrectionStrengthAttrib() {}
 	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
 		{(static_cast<E2Corrector *>(dev))->read_CorrectionStrength(att);}
 	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
@@ -92,8 +92,8 @@ class ResonanceStrengthAttrib: public Tango::Attr
 {
 public:
 	ResonanceStrengthAttrib():Attr("ResonanceStrength",
-			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
-	~ResonanceStrengthAttrib() {};
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
+	~ResonanceStrengthAttrib() {}
 	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
 		{(static_cast<E2Corrector *>(dev))->read_ResonanceStrength(att);}
 	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
@@ -107,8 +107,8 @@ class CurrentAttrib: public Tango::Attr
 {
 public:
 	CurrentAttrib():Attr("Current",
-			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
-	~CurrentAttrib() {};
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
+	~CurrentAttrib() {}
 	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
 		{(static_cast<E2Corrector *>(dev))->read_Current(att);}
 	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
@@ -122,8 +122,8 @@ class BeamEnergyAttrib: public Tango::Attr
 {
 public:
 	BeamEnergyAttrib():Attr("BeamEnergy",
-			Tango::DEV_DOUBLE, Tango::READ_WRITE) {};
-	~BeamEnergyAttrib() {};
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
+	~BeamEnergyAttrib() {}
 	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
 		{(static_cast<E2Corrector *>(dev))->read_BeamEnergy(att);}
 	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
@@ -132,6 +132,21 @@ public:
 		{return (static_cast<E2Corrector *>(dev))->is_BeamEnergy_allowed(ty);}
 };
 
+//	Attribute DesignStrength class definition
+class DesignStrengthAttrib: public Tango::Attr
+{
+public:
+	DesignStrengthAttrib():Attr("DesignStrength",
+			Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
+	~DesignStrengthAttrib() {}
+	virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
+		{(static_cast<E2Corrector *>(dev))->read_DesignStrength(att);}
+	virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
+		{(static_cast<E2Corrector *>(dev))->write_DesignStrength(att);}
+	virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
+		{return (static_cast<E2Corrector *>(dev))->is_DesignStrength_allowed(ty);}
+};
+
 
 //=========================================
 //	Define classes for commands
@@ -146,13 +161,13 @@ public:
 				   const char        *in_desc,
 				   const char        *out_desc,
 				   Tango::DispLevel  level)
-	:Command(cmd_name,in,out,in_desc,out_desc, level)	{};
+	:Command(cmd_name,in,out,in_desc,out_desc, level)	{}
 
 	ResetClass(const char   *cmd_name,
 	               Tango::CmdArgType in,
 				   Tango::CmdArgType out)
-	:Command(cmd_name,in,out)	{};
-	~ResetClass() {};
+	:Command(cmd_name,in,out)	{}
+	~ResetClass() {}
 
 	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
 	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
@@ -169,19 +184,42 @@ public:
 				   const char        *in_desc,
 				   const char        *out_desc,
 				   Tango::DispLevel  level)
-	:Command(cmd_name,in,out,in_desc,out_desc, level)	{};
+	:Command(cmd_name,in,out,in_desc,out_desc, level)	{}
 
 	ResetResonanceStrengthClass(const char   *cmd_name,
 	               Tango::CmdArgType in,
 				   Tango::CmdArgType out)
-	:Command(cmd_name,in,out)	{};
-	~ResetResonanceStrengthClass() {};
+	:Command(cmd_name,in,out)	{}
+	~ResetResonanceStrengthClass() {}
 
 	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
 	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
 	{return (static_cast<E2Corrector *>(dev))->is_ResetResonanceStrength_allowed(any);}
 };
 
+//	Command ApplyDesignStrength class definition
+class ApplyDesignStrengthClass : public Tango::Command
+{
+public:
+	ApplyDesignStrengthClass(const char   *cmd_name,
+	               Tango::CmdArgType in,
+				   Tango::CmdArgType out,
+				   const char        *in_desc,
+				   const char        *out_desc,
+				   Tango::DispLevel  level)
+	:Command(cmd_name,in,out,in_desc,out_desc, level)	{}
+
+	ApplyDesignStrengthClass(const char   *cmd_name,
+	               Tango::CmdArgType in,
+				   Tango::CmdArgType out)
+	:Command(cmd_name,in,out)	{}
+	~ApplyDesignStrengthClass() {}
+
+	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
+	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
+	{return (static_cast<E2Corrector *>(dev))->is_ApplyDesignStrength_allowed(any);}
+};
+
 
 /**
  *	The E2CorrectorClass singleton definition
diff --git a/src/E2CorrectorStateMachine.cpp b/src/E2CorrectorStateMachine.cpp
index a0ad2cf..56a0ac5 100644
--- a/src/E2CorrectorStateMachine.cpp
+++ b/src/E2CorrectorStateMachine.cpp
@@ -49,8 +49,8 @@ namespace E2Corrector_ns
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_Strength_allowed()
- * Description:  Execution allowed for Strength attribute
+ *	Method     : E2Corrector::is_Strength_allowed()
+ *	Description: Execution allowed for Strength attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_Strength_allowed(TANGO_UNUSED(Tango::AttReqType type))
@@ -71,8 +71,8 @@ bool E2Corrector::is_Strength_allowed(TANGO_UNUSED(Tango::AttReqType type))
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_CorrectionStrength_allowed()
- * Description:  Execution allowed for CorrectionStrength attribute
+ *	Method     : E2Corrector::is_CorrectionStrength_allowed()
+ *	Description: Execution allowed for CorrectionStrength attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_CorrectionStrength_allowed(TANGO_UNUSED(Tango::AttReqType type))
@@ -93,8 +93,8 @@ bool E2Corrector::is_CorrectionStrength_allowed(TANGO_UNUSED(Tango::AttReqType t
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_ResonanceStrength_allowed()
- * Description:  Execution allowed for ResonanceStrength attribute
+ *	Method     : E2Corrector::is_ResonanceStrength_allowed()
+ *	Description: Execution allowed for ResonanceStrength attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_ResonanceStrength_allowed(TANGO_UNUSED(Tango::AttReqType type))
@@ -115,8 +115,8 @@ bool E2Corrector::is_ResonanceStrength_allowed(TANGO_UNUSED(Tango::AttReqType ty
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_Current_allowed()
- * Description:  Execution allowed for Current attribute
+ *	Method     : E2Corrector::is_Current_allowed()
+ *	Description: Execution allowed for Current attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_Current_allowed(TANGO_UNUSED(Tango::AttReqType type))
@@ -137,8 +137,8 @@ bool E2Corrector::is_Current_allowed(TANGO_UNUSED(Tango::AttReqType type))
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_BeamEnergy_allowed()
- * Description:  Execution allowed for BeamEnergy attribute
+ *	Method     : E2Corrector::is_BeamEnergy_allowed()
+ *	Description: Execution allowed for BeamEnergy attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_BeamEnergy_allowed(TANGO_UNUSED(Tango::AttReqType type))
@@ -157,6 +157,28 @@ bool E2Corrector::is_BeamEnergy_allowed(TANGO_UNUSED(Tango::AttReqType type))
 	return true;
 }
 
+//--------------------------------------------------------
+/**
+ *	Method     : E2Corrector::is_DesignStrength_allowed()
+ *	Description: Execution allowed for DesignStrength attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_DesignStrength_allowed(TANGO_UNUSED(Tango::AttReqType type))
+{
+	//	Not any excluded states for DesignStrength attribute in Write access.
+	/*----- PROTECTED REGION ID(E2Corrector::DesignStrengthStateAllowed_WRITE) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::DesignStrengthStateAllowed_WRITE
+
+	//	Not any excluded states for DesignStrength attribute in read access.
+	/*----- PROTECTED REGION ID(E2Corrector::DesignStrengthStateAllowed_READ) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::DesignStrengthStateAllowed_READ
+	return true;
+}
+
 
 //=================================================
 //		Commands Allowed Methods
@@ -164,8 +186,8 @@ bool E2Corrector::is_BeamEnergy_allowed(TANGO_UNUSED(Tango::AttReqType type))
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_Reset_allowed()
- * Description:  Execution allowed for Reset attribute
+ *	Method     : E2Corrector::is_Reset_allowed()
+ *	Description: Execution allowed for Reset attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any))
@@ -180,8 +202,8 @@ bool E2Corrector::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any))
 
 //--------------------------------------------------------
 /**
- *	Method      : E2Corrector::is_ResetResonanceStrength_allowed()
- * Description:  Execution allowed for ResetResonanceStrength attribute
+ *	Method     : E2Corrector::is_ResetResonanceStrength_allowed()
+ *	Description: Execution allowed for ResetResonanceStrength attribute
  */
 //--------------------------------------------------------
 bool E2Corrector::is_ResetResonanceStrength_allowed(TANGO_UNUSED(const CORBA::Any &any))
@@ -194,6 +216,22 @@ bool E2Corrector::is_ResetResonanceStrength_allowed(TANGO_UNUSED(const CORBA::An
 	return true;
 }
 
+//--------------------------------------------------------
+/**
+ *	Method     : E2Corrector::is_ApplyDesignStrength_allowed()
+ *	Description: Execution allowed for ApplyDesignStrength attribute
+ */
+//--------------------------------------------------------
+bool E2Corrector::is_ApplyDesignStrength_allowed(TANGO_UNUSED(const CORBA::Any &any))
+{
+	//	Not any excluded states for ApplyDesignStrength command.
+	/*----- PROTECTED REGION ID(E2Corrector::ApplyDesignStrengthStateAllowed) ENABLED START -----*/
+	/* clang-format on */
+	/* clang-format off */
+	/*----- PROTECTED REGION END -----*/	//	E2Corrector::ApplyDesignStrengthStateAllowed
+	return true;
+}
+
 
 /*----- PROTECTED REGION ID(E2Corrector::E2CorrectorStateAllowed.AdditionalMethods) ENABLED START -----*/
 /* clang-format on */
-- 
GitLab


From 7a0e24c7b8cd1dc3333d11e7fa96047c60de17b2 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Tue, 28 Jan 2025 15:52:20 +0100
Subject: [PATCH 14/14] fix resosnace strength, clarify and fix
 ResetResonanceStrength command

---
 TODO                |  1 -
 src/E2Corrector.cpp | 22 +++++++---------------
 src/E2Corrector.h   |  2 +-
 src/E2Corrector.xmi |  2 +-
 4 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/TODO b/TODO
index 216d4ae..d187242 100644
--- a/TODO
+++ b/TODO
@@ -5,5 +5,4 @@ strengh = CorrectionStrength + resonanceStrength
  
  settings dei vari strength OK
  
-compute_currents e compute_strenggths : rendee polimorifche per acceatare  DevDouble o duble
 
diff --git a/src/E2Corrector.cpp b/src/E2Corrector.cpp
index 774a0ce..bf8f797 100644
--- a/src/E2Corrector.cpp
+++ b/src/E2Corrector.cpp
@@ -617,7 +617,7 @@ void E2Corrector::write_ResonanceStrength(Tango::WAttribute &attr)
 	Tango::DeviceAttribute watt("Current", curr_out[0]);
 	current_dev->write_attribute(watt);
 	wValResStrength = w_val;
-	//*attr_ResonanceStrength_read = w_val;
+	*attr_ResonanceStrength_read = w_val;
 	set_strength[0] = newStrength;
 	strengthAtt->set_write_value(set_strength[0]);
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::write_ResonanceStrength
@@ -793,7 +793,7 @@ void E2Corrector::reset()
 //--------------------------------------------------------
 /**
  *	Command ResetResonanceStrength related method
- *	Description: Reset ResonanceStrength to 0
+ *	Description: Transfer ResonanceStranght to CorrectionStrength and set ResonanceStrength to 0. Strngth is not modified
  *
  */
 //--------------------------------------------------------
@@ -806,24 +806,16 @@ void E2Corrector::reset_resonance_strength()
 	//	Add your own code
 
 	/* clang-format off */
-	//force to 0 resonance strength
+	//transfer resonance strength to correction strength and than force to 0 resonance strength
 	omni_mutex_lock guardio(iomutex);
-	/*
-	Tango::DevDouble newStrength;
-	newStrength = wValCorrStrength;
-	std::vector<double> req_strength;
-	std::vector<double> curr_out;
-	req_strength.push_back(newStrength);
-	corrector->compute_currents(magnet_rigidity, req_strength, curr_out);
-	Tango::DeviceAttribute watt("Current", curr_out[0]);
-	current_dev->write_attribute(watt);
-	*/
+
 	wValCorrStrength +=  wValResStrength;
 	wValResStrength = 0.0;
-	//set_strength[0] = newStrength;
-	//strengthAtt->set_write_value(set_strength[0]);
+
 	correctionAtt->set_write_value(wValCorrStrength);
+	*attr_CorrectionStrength_read = wValCorrStrength;
 	resonanceAtt->set_write_value(0.0);
+	*attr_ResonanceStrength_read = 0.0;
 	/*----- PROTECTED REGION END -----*/	//	E2Corrector::reset_resonance_strength
 }
 //--------------------------------------------------------
diff --git a/src/E2Corrector.h b/src/E2Corrector.h
index 16ab00c..bbfd90f 100644
--- a/src/E2Corrector.h
+++ b/src/E2Corrector.h
@@ -286,7 +286,7 @@ public:
 	virtual bool is_Reset_allowed(const CORBA::Any &any);
 	/**
 	 *	Command ResetResonanceStrength related method
-	 *	Description: Reset ResonanceStrength to 0
+	 *	Description: Transfer ResonanceStranght to CorrectionStrength and set ResonanceStrength to 0. Strngth is not modified
 	 *
 	 */
 	virtual void reset_resonance_strength();
diff --git a/src/E2Corrector.xmi b/src/E2Corrector.xmi
index 8e0c18b..89355d8 100644
--- a/src/E2Corrector.xmi
+++ b/src/E2Corrector.xmi
@@ -75,7 +75,7 @@
       </argout>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
     </commands>
-    <commands name="ResetResonanceStrength" description="Reset ResonanceStrength to 0" execMethod="reset_resonance_strength" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
+    <commands name="ResetResonanceStrength" description="Transfer ResonanceStranght to CorrectionStrength and set ResonanceStrength to 0. Strngth is not modified" execMethod="reset_resonance_strength" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
       <argin description="">
         <type xsi:type="pogoDsl:VoidType"/>
       </argin>
-- 
GitLab