From bff1f45e33a1d1f793f6172270ae77bcb491da80 Mon Sep 17 00:00:00 2001 From: ELATTAOUI <xavier.elattaoui@synchrotron-soleil.fr> Date: Mon, 9 Dec 2024 11:37:05 +0100 Subject: [PATCH] PROBLEM-2573: range fixed using yat::XString --- CMakeLists.txt | 2 + conanfile.py | 46 +++++++++++- include/N_PhotoConducteur.h | 0 include/N_PhotoVoltaique.h | 0 include/Novelec_MCCE2.h | 0 pom.xml | 6 +- src/AbstractElectrometerClass.cpp | 6 +- src/Keithley_485.cpp | 16 ++-- src/Keithley_486.cpp | 52 ++++++------- src/Keithley_487.cpp | 54 ++++++------- src/Keithley_617.cpp | 80 ++++++++++---------- src/Keithley_6485.cpp | 6 +- src/Keithley_6487.cpp | 6 +- src/Keithley_6512.cpp | 34 ++++----- src/Keithley_6514.cpp | 12 +-- src/Keithley_6517.cpp | 121 +++++++++++++++++++----------- src/N_PhotoConducteur.cpp | 1 - src/N_PhotoVoltaique.cpp | 1 - src/NovelecProtocol.cpp | 16 ++-- src/Novelec_MCCE2.cpp | 6 +- 20 files changed, 273 insertions(+), 192 deletions(-) mode change 100755 => 100644 include/N_PhotoConducteur.h mode change 100755 => 100644 include/N_PhotoVoltaique.h mode change 100755 => 100644 include/Novelec_MCCE2.h mode change 100755 => 100644 pom.xml mode change 100755 => 100644 src/N_PhotoConducteur.cpp mode change 100755 => 100644 src/N_PhotoVoltaique.cpp mode change 100755 => 100644 src/Novelec_MCCE2.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d4ea865..58c8700 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(electrometers) option(BUILD_SHARED_LIBS "Build using shared libraries" ON) +find_package(yat CONFIG REQUIRED) find_package(cpptango CONFIG REQUIRED) add_compile_definitions( @@ -22,6 +23,7 @@ set(includedirs add_library(electrometers ${sources}) target_include_directories(electrometers PRIVATE ${includedirs}) +target_link_libraries(${EXECUTABLE_NAME} PRIVATE yat::yat) target_link_libraries(electrometers PRIVATE cpptango::cpptango) if (MAJOR_VERSION) diff --git a/conanfile.py b/conanfile.py index 99f78b9..09c3372 100644 --- a/conanfile.py +++ b/conanfile.py @@ -2,11 +2,12 @@ from conan import ConanFile class electrometersRecipe(ConanFile): name = "electrometers" - version = "2.8.0" + version = "2.8.1" package_type = "library" user = "soleil" - python_requires = "base/[>=1.0]@soleil/stable" - python_requires_extend = "base.Library" + + # python_requires = "base/[>=1.0]@soleil/stable" + # python_requires_extend = "base.Library" license = "GPL-2" author = "Xavier Elattaoui" @@ -22,3 +23,42 @@ class electrometersRecipe(ConanFile): def requirements(self): self.requires("cpptango/9.2.5@soleil/stable") + self.requires("yat/[>=1.0]@soleil/stable") + if self.settings.os == "Linux": + self.requires("crashreporting2/[>=1.0]@soleil/stable") + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + # def layout(self): + # cmake_layout(self) + + # def generate(self): + # deps = CMakeDeps(self) + # deps.generate() + # tc = CMakeToolchain(self) + # major, minor, patch = map(int, self.version.split('.')) + # tc.variables["PROJECT_NAME"] = self.name + # tc.variables["PROJECT_VERSION"] = self.version + # tc.variables["MAJOR_VERSION"] = major + # tc.variables["MINOR_VERSION"] = minor + # tc.variables["PATCH_VERSION"] = patch + # tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["electrometers"] + diff --git a/include/N_PhotoConducteur.h b/include/N_PhotoConducteur.h old mode 100755 new mode 100644 diff --git a/include/N_PhotoVoltaique.h b/include/N_PhotoVoltaique.h old mode 100755 new mode 100644 diff --git a/include/Novelec_MCCE2.h b/include/Novelec_MCCE2.h old mode 100755 new mode 100644 diff --git a/pom.xml b/pom.xml old mode 100755 new mode 100644 index 8f4b98d..c60485b --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ </parent> <groupId>fr.soleil.lib</groupId> <artifactId>Electrometers-${aol}-${library}-${mode}</artifactId> - <version>2.8.0</version> + <version>2.8.1</version> <packaging>nar</packaging> <name>Electrometers library</name> <description>Electrometers library</description> @@ -38,6 +38,10 @@ </plugins> </build> <dependencies> + <dependency> + <groupId>fr.soleil.lib</groupId> + <artifactId>YAT-${aol}-${library}-${mode}</artifactId> + </dependency> </dependencies> <developers> <developer> diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp index f1e4c0e..a8903b6 100644 --- a/src/AbstractElectrometerClass.cpp +++ b/src/AbstractElectrometerClass.cpp @@ -136,7 +136,7 @@ #include <iostream> #include <sstream> #include <string> -#include <Xstring.h> +#include <yat/utils/XString.h> #include "AbstractElectrometerClass.h" #include "ElectrometerException.h" @@ -517,7 +517,7 @@ std::string AbstractElectrometerClass::electrometer_status (void) { argout = _electrometerProtocol->get_raw_status( ); //- if no error the error code is 0 - if( XString<short>::convertFromString(&argout[0]) != ON) + if( yat::XString<short>::to_num(&argout[0]) != ON) set_electroState(ALARM); else set_electroState(ON); @@ -550,7 +550,7 @@ short AbstractElectrometerClass::get_buffer_size () { std::string size = _electrometerProtocol->get_buffer_size(); - return XString<short>::convertFromString(size); + return yat::XString<short>::to_num(size); } // ============================================================================ diff --git a/src/Keithley_485.cpp b/src/Keithley_485.cpp index f972ddf..f627e57 100644 --- a/src/Keithley_485.cpp +++ b/src/Keithley_485.cpp @@ -18,7 +18,7 @@ #include <stdexcept> #include <sstream> #include <string> -#include <Xstring.h> +#include <yat/utils/XString.h> #include "KeithleyDDCProtocol.h" #include "Keithley_485.h" @@ -227,36 +227,36 @@ std::string Keithley_485::electrometer_status (void) argout = "Keithley Type : " + modelNum + "\n"; //- Zero check state tmp = _kstatus.substr(3,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Check : ON\n"; else argout += "Zero Check : OFF\n"; //- Log state tmp = _kstatus.substr(4,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Log : ON\n"; else argout += "Log : OFF\n"; //- Range tmp = _kstatus.substr(5,1); - _range = XString<short>::convertFromString(tmp); + _range = yat::XString<short>::to_num(tmp); _rangeStr = K485_rangeValue[_range]; argout += "Range : " + _rangeStr + "\n"; //- Relative (baseline suppress) tmp = _kstatus.substr(6,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Relative ON\n"; else argout += "Relative OFF\n"; //- Relative (baseline suppress) tmp = _kstatus.substr(7,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "EOI : Send\n"; else argout += "EOI : Do Not Send\n"; //- Trigger tmp = _kstatus.substr(8,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(!trigg) argout += "Trigger : Continuous on Talk\n"; else @@ -276,7 +276,7 @@ std::string Keithley_485::electrometer_status (void) argout += "Trigger :One-Shot on \"X\"\n"; //- SRQ Data Mask tmp = _kstatus.substr(6,2); - short srqInfo = XString<short>::convertFromString(tmp); + short srqInfo = yat::XString<short>::to_num(tmp); if(!srqInfo) argout += "SRQ Data Mask : SRQ Disabled\n"; else diff --git a/src/Keithley_486.cpp b/src/Keithley_486.cpp index a8cb2db..f625bf0 100644 --- a/src/Keithley_486.cpp +++ b/src/Keithley_486.cpp @@ -19,7 +19,7 @@ #include <sstream> #include <string> #include <math.h> //- for ceil -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_486.h" #include "KeithleyDDCProtocol.h" @@ -299,35 +299,35 @@ std::string Keithley_486::electrometer_status (void) //- IDDC Error : Set when an illegal device dependent command (IDDC) such as HlX is received ("H" is illegal). tmp = kconfig.substr(3,1); - short iddc = XString<short>::convertFromString(tmp); + short iddc = yat::XString<short>::to_num(tmp); if(iddc) { argout += "IDDC error : illegal device dependent command received.\n"; } //- IDDCO Error : Set when an illegal device-dependent command option (IDDCO) such as T9X is received ("9" is illegal). tmp = kconfig.substr(4,1); - short iddco = XString<short>::convertFromString(tmp); + short iddco = yat::XString<short>::to_num(tmp); if(iddco) { argout += "IDDCO error : an illegal device-dependent command option received.\n"; } //- Remote Error : Set when a programming command is received when REN is false. tmp = kconfig.substr(5,1); - short remote = XString<short>::convertFromString(tmp); + short remote = yat::XString<short>::to_num(tmp); if(remote) { argout += "REMOTE error : programming command is received when REN is false.\n"; } //- Self-Test Error : Set when a self-test failure (RAM and/or ROM) occurs. tmp = kconfig.substr(6,1); - short selfT = XString<short>::convertFromString(tmp); + short selfT = yat::XString<short>::to_num(tmp); if(selfT) { argout += "SELF-TEST error : Set when a self-test failure (RAM and/or ROM) occurs.\n"; } //- Trigger Overrun Error : Set when a trigger is received when the instrument is still processing a reading from a previous trigger. tmp = kconfig.substr(7,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(trigg) { argout += "Trigger error : Trigger received while instrument is still processing a reading from a previous trigger.\n"; @@ -335,21 +335,21 @@ std::string Keithley_486::electrometer_status (void) //- Conflict Error : Set when trying to send a calibration value with the instrument on a measurement //- range that is too small to accommodate the value.. tmp = kconfig.substr(8,1); - short conflict = XString<short>::convertFromString(tmp); + short conflict = yat::XString<short>::to_num(tmp); if(conflict) { argout += "CONFLICT error : Calibration value with the instrument on a measurement range that is too small.\n"; } //- CAL LOCKED Error : Set when calibrating the instrument with the calibration switch in the locked (disabled) position. tmp = kconfig.substr(9,1); - short calL = XString<short>::convertFromString(tmp); + short calL = yat::XString<short>::to_num(tmp); if(calL) { argout += "CAL LOCKED error : Set when calibrating the instrument with the calibration switch in the locked (disabled) position..\n"; } //- Zero Check Error : Set when trying to calibrate the instrument with zero check enabled. tmp = kconfig.substr(10,1); - short zchk = XString<short>::convertFromString(tmp); + short zchk = yat::XString<short>::to_num(tmp); if(zchk) { argout += "ZERO CHECK error : Set when trying to calibrate the instrument with zero check enabled.\n"; @@ -358,21 +358,21 @@ std::string Keithley_486::electrometer_status (void) //- limits. Repeated failure may indicate that the Model 486/487 is defective. See service information //- in this manual. tmp = kconfig.substr(11,1); - short calib = XString<short>::convertFromString(tmp); + short calib = yat::XString<short>::to_num(tmp); if(calib) { argout += "CALIBRATION error : Set when calibration results in a cal constant value that is not within allowable limits.\n"; } //- E2PROM DEFAULTS Error : Set when power-up checksum test on defaults fail. tmp = kconfig.substr(12,1); - short e2prom = XString<short>::convertFromString(tmp); + short e2prom = yat::XString<short>::to_num(tmp); if(e2prom) { argout += "E2PROM DEFAULTS error : Set when power-up checksum test on defaults fail.\n"; } //- E2pROM CAL CONSTANTS Error : Set when power-up checksum test on cal constants fail. tmp = kconfig.substr(13,1); - short e2prcalL = XString<short>::convertFromString(tmp); + short e2prcalL = yat::XString<short>::to_num(tmp); if(e2prcalL) { argout += "E2pROM CAL CONSTANTS error : Set when power-up checksum test on cal constants fail.\n"; @@ -381,14 +381,14 @@ std::string Keithley_486::electrometer_status (void) //- exceeds the maxim um limit of the currently selected voltage sauce range. On the Model 486, //- this bit is always reset to "0". tmp = kconfig.substr(14,1); - short vsconf = XString<short>::convertFromString(tmp); + short vsconf = yat::XString<short>::to_num(tmp); if(vsconf) { argout += "V-SOURCE CONFLICT error : On the Model 486 this bit is always reset to \"0\".\n"; } //- V-SOURCE Error : On the Model 486, this bit is always reset to "0". tmp = kconfig.substr(15,1); - short vsrc = XString<short>::convertFromString(tmp); + short vsrc = yat::XString<short>::to_num(tmp); if(vsrc) { argout += "V-SOURCE error : On the Model 486, this bit is always reset to \"0\".\n"; @@ -440,7 +440,7 @@ std::string Keithley_486::get_configuration (void) argout = "Keithley Type : " + modelNum + "\n"; //- Display Intensity ('A') tmp = _kstatus.substr(_kstatus.find('A')+1,1); - short dintensity = XString<short>::convertFromString(tmp); + short dintensity = yat::XString<short>::to_num(tmp); if(!dintensity) argout += "Display Intensity : NORMAL\n"; else @@ -451,7 +451,7 @@ std::string Keithley_486::get_configuration (void) argout += "Display Intensity : OFF\n"; //- Reading Source ('B') tmp = _kstatus.substr(_kstatus.find('B')+1,1); - short rSource = XString<short>::convertFromString(tmp); + short rSource = yat::XString<short>::to_num(tmp); if(!rSource) argout += "Reading Source : A/D Reading\n"; else @@ -468,13 +468,13 @@ std::string Keithley_486::get_configuration (void) argout += "Reading Source : Min Data Store Reading\n"; //- Zero check state ('C') tmp = _kstatus.substr(_kstatus.find('C')+1,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Check : Enabled\n"; else argout += "Zero Check : Disabled\n"; //- Data Format ('G') tmp = _kstatus.substr(_kstatus.find('G')+1,1); - short dformat = XString<short>::convertFromString(tmp); + short dformat = yat::XString<short>::to_num(tmp); if(!dformat) argout += "Data Format : Reading With Prefix (ASCII)\n"; else @@ -500,7 +500,7 @@ std::string Keithley_486::get_configuration (void) argout += "Data Format : Binary Reading - counts and exponent, bytes in normal order for Motorola CPUs\n"; //- Self Test ('J') tmp = _kstatus.substr(_kstatus.find('J')+1,1); - short stest = XString<short>::convertFromString(tmp); + short stest = yat::XString<short>::to_num(tmp); if(!stest) argout += "Self Test : No Errors\n"; else @@ -514,7 +514,7 @@ std::string Keithley_486::get_configuration (void) argout += "Self Test : ROM and RAM Error\n"; //- EOI & Bus Hold Off ('K') tmp = _kstatus.substr(_kstatus.find('J')+1,1); - short ebhoff = XString<short>::convertFromString(tmp); + short ebhoff = yat::XString<short>::to_num(tmp); if(!ebhoff) argout += "EOI & Bus Hold Off : EOI and Hold-Off\n"; else @@ -528,7 +528,7 @@ std::string Keithley_486::get_configuration (void) argout += "EOI & Bus Hold Off : No EOI and no Hold-Off\n"; //- SRQ ('M') tmp = _kstatus.substr(_kstatus.find('M')+1,3); - short srqInfo = XString<short>::convertFromString(tmp); + short srqInfo = yat::XString<short>::to_num(tmp); if(!srqInfo) argout += "SRQ : Disabled\n"; else @@ -554,13 +554,13 @@ std::string Keithley_486::get_configuration (void) argout += "SRQ : Voltage Source Error\n"; //- Data Store Size ('N') tmp = _kstatus.substr(_kstatus.find('N')+1,3); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Data Store Size : Wrap Around\n"; else argout += "Data Store Size : " + tmp + "\n"; //- Filters ('P') tmp = _kstatus.substr(_kstatus.find('P')+1,1); - short filters = XString<short>::convertFromString(tmp); + short filters = yat::XString<short>::to_num(tmp); if(!filters) argout += "Filters : Both Filters Disabled\n"; else @@ -585,13 +585,13 @@ std::string Keithley_486::get_configuration (void) argout += _rangeStr + "\n"; //- Integration Period ('S') tmp = _kstatus.substr(_kstatus.find('S')+1,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Integration Period : Fast (4-1/2d)\n"; else argout += "Integration Period : Line Cycle (5-1/2d)\n"; //- Trigger ('T') tmp = _kstatus.substr(_kstatus.find('T')+1,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(!trigg) argout += "Trigger : Multiple On Talk\n"; else @@ -623,7 +623,7 @@ std::string Keithley_486::get_configuration (void) argout += "Trigger : One-shot On Operate\n"; //- Relative ('Z') (baseline suppress) tmp = _kstatus.substr(_kstatus.find('Z')+1,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Relative : Current Rel Disabled\n"; else argout += "Relative : Current Rel Enabled\n"; diff --git a/src/Keithley_487.cpp b/src/Keithley_487.cpp index 8a78ead..91d7f90 100644 --- a/src/Keithley_487.cpp +++ b/src/Keithley_487.cpp @@ -19,7 +19,7 @@ #include <sstream> #include <string> #include <math.h> //- for ceil -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_487.h" #include "KeithleyDDCProtocol.h" @@ -329,35 +329,35 @@ std::string Keithley_487::electrometer_status (void) //- IDDC Error : Set when an illegal device dependent command (IDDC) such as HlX is received ("H" is illegal). tmp = kconfig.substr(3,1); - short iddc = XString<short>::convertFromString(tmp); + short iddc = yat::XString<short>::to_num(tmp); if(iddc) { argout += "IDDC error : illegal device dependent command received.\n"; } //- IDDCO Error : Set when an illegal device-dependent command option (IDDCO) such as T9X is received ("9" is illegal). tmp = kconfig.substr(4,1); - short iddco = XString<short>::convertFromString(tmp); + short iddco = yat::XString<short>::to_num(tmp); if(iddco) { argout += "IDDCO error : an illegal device-dependent command option received.\n"; } //- Remote Error : Set when a programming command is received when REN is false. tmp = kconfig.substr(5,1); - short remote = XString<short>::convertFromString(tmp); + short remote = yat::XString<short>::to_num(tmp); if(remote) { argout += "REMOTE error : programming command is received when REN is false.\n"; } //- Self-Test Error : Set when a self-test failure (RAM and/or ROM) occurs. tmp = kconfig.substr(6,1); - short selfT = XString<short>::convertFromString(tmp); + short selfT = yat::XString<short>::to_num(tmp); if(selfT) { argout += "SELF-TEST error : Set when a self-test failure (RAM and/or ROM) occurs.\n"; } //- Trigger Overrun Error : Set when a trigger is received when the instrument is still processing a reading from a previous trigger. tmp = kconfig.substr(7,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(trigg) { argout += "Trigger error : Trigger received while instrument is still processing a reading from a previous trigger.\n"; @@ -365,21 +365,21 @@ std::string Keithley_487::electrometer_status (void) //- Conflict Error : Set when trying to send a calibration value with the instrument on a measurement //- range that is too small to accommodate the value.. tmp = kconfig.substr(8,1); - short conflict = XString<short>::convertFromString(tmp); + short conflict = yat::XString<short>::to_num(tmp); if(conflict) { argout += "CONFLICT error : Calibration value with the instrument on a measurement range that is too small.\n"; } //- CAL LOCKED Error : Set when calibrating the instrument with the calibration switch in the locked (disabled) position. tmp = kconfig.substr(9,1); - short calL = XString<short>::convertFromString(tmp); + short calL = yat::XString<short>::to_num(tmp); if(calL) { argout += "CAL LOCKED error : Set when calibrating the instrument with the calibration switch in the locked (disabled) position..\n"; } //- Zero Check Error : Set when trying to calibrate the instrument with zero check enabled. tmp = kconfig.substr(10,1); - short zchk = XString<short>::convertFromString(tmp); + short zchk = yat::XString<short>::to_num(tmp); if(zchk) { argout += "ZERO CHECK error : Set when trying to calibrate the instrument with zero check enabled.\n"; @@ -388,21 +388,21 @@ std::string Keithley_487::electrometer_status (void) //- limits. Repeated failure may indicate that the Model 486/487 is defective. See service information //- in this manual. tmp = kconfig.substr(11,1); - short calib = XString<short>::convertFromString(tmp); + short calib = yat::XString<short>::to_num(tmp); if(calib) { argout += "CALIBRATION error : Set when calibration results in a cal constant value that is not within allowable limits.\n"; } //- E2PROM DEFAULTS Error : Set when power-up checksum test on defaults fail. tmp = kconfig.substr(12,1); - short e2prom = XString<short>::convertFromString(tmp); + short e2prom = yat::XString<short>::to_num(tmp); if(e2prom) { argout += "E2PROM DEFAULTS error : Set when power-up checksum test on defaults fail.\n"; } //- E2pROM CAL CONSTANTS Error : Set when power-up checksum test on cal constants fail. tmp = kconfig.substr(13,1); - short e2prcalL = XString<short>::convertFromString(tmp); + short e2prcalL = yat::XString<short>::to_num(tmp); if(e2prcalL) { argout += "E2pROM CAL CONSTANTS error : Set when power-up checksum test on cal constants fail.\n"; @@ -411,7 +411,7 @@ std::string Keithley_487::electrometer_status (void) //- exceeds the maxim um limit of the currently selected voltage sauce range. On the Model 486, //- this bit is always reset to "0". tmp = kconfig.substr(14,1); - short vsconf = XString<short>::convertFromString(tmp); + short vsconf = yat::XString<short>::to_num(tmp); if(vsconf) { argout += "V-SOURCE CONFLICT error : Voltage source value exceeds the maxim um limit of the currently selected voltage sauce range.\n"; @@ -419,7 +419,7 @@ std::string Keithley_487::electrometer_status (void) //- V-SOURCE Error : The Model 487, this bit is set when trying to place the voltage source in operate //- while the enabled interlock is open. tmp = kconfig.substr(15,1); - short vsrc = XString<short>::convertFromString(tmp); + short vsrc = yat::XString<short>::to_num(tmp); if(vsrc) { argout += "V-SOURCE error : Trying to place the voltage source in operate while the enabled interlock is open.\n"; @@ -469,7 +469,7 @@ std::string Keithley_487::get_configuration (void) argout = "Keithley Type : " + modelNum + "\n"; //- Display Intensity ('A') tmp = _kstatus.substr(_kstatus.find('A')+1,1); - short dintensity = XString<short>::convertFromString(tmp); + short dintensity = yat::XString<short>::to_num(tmp); if(!dintensity) argout += "Display Intensity : NORMAL\n"; else @@ -480,7 +480,7 @@ std::string Keithley_487::get_configuration (void) argout += "Display Intensity : OFF\n"; //- Reading Source ('B') tmp = _kstatus.substr(_kstatus.find('B'),1); - short rsource = XString<short>::convertFromString(tmp); + short rsource = yat::XString<short>::to_num(tmp); if(!rsource) argout += "Reading Source : A/D Reading\n"; else @@ -497,13 +497,13 @@ std::string Keithley_487::get_configuration (void) argout += "Reading Source : Min Data Store Reading\n"; //- Zero check state ('C') tmp = _kstatus.substr(_kstatus.find('C')+1,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Check : Enabled\n"; else argout += "Zero Check : Disabled\n"; //- V/I Ohms ('F') tmp = _kstatus.substr(_kstatus.find('F')+1,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) { argout += "V/I Ohms : Enabled\n"; _mode = "V/I Ohms"; @@ -515,7 +515,7 @@ std::string Keithley_487::get_configuration (void) } //- Data Format ('G') tmp = _kstatus.substr(_kstatus.find('G')+1,1); - short dformat = XString<short>::convertFromString(tmp); + short dformat = yat::XString<short>::to_num(tmp); if(!dformat) argout += "Data Format : Reading With Prefix (ASCII)\n"; else @@ -541,7 +541,7 @@ std::string Keithley_487::get_configuration (void) argout += "Data Format : Binary Reading - counts and exponent, bytes in normal order for Motorola CPUs\n"; //- Self Test ('J') tmp = _kstatus.substr(_kstatus.find('J')+1,1); - short stest = XString<short>::convertFromString(tmp); + short stest = yat::XString<short>::to_num(tmp); if(!stest) argout += "Self Test : No Errors\n"; else @@ -555,7 +555,7 @@ std::string Keithley_487::get_configuration (void) argout += "Self Test : ROM and RAM Error\n"; //- EOI & Bus Hold Off ('K') tmp = _kstatus.substr(_kstatus.find('K')+1,1); - short ebhoff = XString<short>::convertFromString(tmp); + short ebhoff = yat::XString<short>::to_num(tmp); if(!ebhoff) argout += "EOI & Bus Hold Off : EOI and Hold-Off\n"; else @@ -569,7 +569,7 @@ std::string Keithley_487::get_configuration (void) argout += "EOI & Bus Hold Off : No EOI and no Hold-Off\n"; //- SRQ ('M') tmp = _kstatus.substr(_kstatus.find('M')+1,3); - short srqInfo = XString<short>::convertFromString(tmp); + short srqInfo = yat::XString<short>::to_num(tmp); if(!srqInfo) argout += "SRQ : Disabled\n"; else @@ -595,13 +595,13 @@ std::string Keithley_487::get_configuration (void) argout += "SRQ : Voltage Source Error\n"; //- Data Store Size ('N') tmp = _kstatus.substr(_kstatus.find('N')+1,3); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Data Store Size : Wrap Around\n"; else argout += "Data Store Size : " + tmp + "\n"; //- Filters ('P') tmp = _kstatus.substr(_kstatus.find('P')+1,1); - short filters = XString<short>::convertFromString(tmp); + short filters = yat::XString<short>::to_num(tmp); if(!filters) argout += "Filters : Both Filters Disabled\n"; else @@ -626,13 +626,13 @@ std::string Keithley_487::get_configuration (void) argout += _rangeStr + "\n"; //- Integration Period ('S') tmp = _kstatus.substr(_kstatus.find('S')+1,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Integration Period : Fast (4-1/2d)\n"; else argout += "Integration Period : Line Cycle (5-1/2d)\n"; //- Trigger ('T') tmp = _kstatus.substr(_kstatus.find('T')+1,1); - _trigMod = XString<short>::convertFromString(tmp); + _trigMod = yat::XString<short>::to_num(tmp); if(!_trigMod) argout += "Trigger : Multiple On Talk\n"; else @@ -664,7 +664,7 @@ std::string Keithley_487::get_configuration (void) argout += "Trigger : One-shot On Operate\n"; //- Relative ('Z') (baseline suppress) tmp = _kstatus.substr(_kstatus.find('Z')+1,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Relative : Current Rel Disabled\n"; else argout += "Relative : Current Rel Enabled\n"; diff --git a/src/Keithley_617.cpp b/src/Keithley_617.cpp index 1718830..359b995 100644 --- a/src/Keithley_617.cpp +++ b/src/Keithley_617.cpp @@ -18,7 +18,7 @@ #include <stdexcept> #include <sstream> #include <string> -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_617.h" #include "KeithleyDDCProtocol.h" @@ -355,35 +355,35 @@ std::string Keithley_617::electrometer_status (void) //- IDDC Error : Set when an illegal device dependent command (IDDC) such as HlX is received ("H" is illegal). tmp = kconfig.substr(3,1); - short iddc = XString<short>::convertFromString(tmp); + short iddc = yat::XString<short>::to_num(tmp); if(iddc) { argout += "IDDC error : illegal device dependent command received.\n"; } //- IDDCO Error : Set when an illegal device-dependent command option (IDDCO) such as T9X is received ("9" is illegal). tmp = kconfig.substr(4,1); - short iddco = XString<short>::convertFromString(tmp); + short iddco = yat::XString<short>::to_num(tmp); if(iddco) { argout += "IDDCO error : an illegal device-dependent command option received.\n"; } //- Remote Error : Set when a programming command is received when REN is false. tmp = kconfig.substr(5,1); - short remote = XString<short>::convertFromString(tmp); + short remote = yat::XString<short>::to_num(tmp); if(remote) { argout += "REMOTE error : programming command is received when REN is false\n"; } //- Trigger Overrun Error : Set when a trigger is received when the instrument is still processing a reading from a previous trigger. tmp = kconfig.substr(6,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(trigg) { argout += "Trigger error : Trigger received while instrument is still processing a reading from a previous trigger.\n"; } //- Number Error : Set when an Out of range calibration or voltage source value is received. tmp = kconfig.substr(7,1); - short numErr = XString<short>::convertFromString(tmp); + short numErr = yat::XString<short>::to_num(tmp); if(numErr) { argout += "Number error : Out of range calibration or voltage source value is received.\n"; @@ -434,10 +434,10 @@ std::string Keithley_617::get_configuration (void) argout = "Keithley Type : " + modelNum + "\n"; //- Functions and associate range : tmp = _kstatus.substr(3,1); - short func = XString<short>::convertFromString(tmp); + short func = yat::XString<short>::to_num(tmp); //- Range : tmp = _kstatus.substr(4,2); - _range = XString<short>::convertFromString(tmp); + _range = yat::XString<short>::to_num(tmp); _rangeStr = K617_VoltRangeValue[_range]; if(!func) { @@ -473,25 +473,25 @@ std::string Keithley_617::get_configuration (void) argout += "RANGE : " + _rangeStr + "\n"; //- Zero check state tmp = _kstatus.substr(6,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Check : ON\n"; else argout += "Zero Check : OFF\n"; //- Zero correct state tmp = _kstatus.substr(7,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Correct : ON\n"; else argout += "Zero Correct : OFF\n"; //- Suppress tmp = _kstatus.substr(8,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Suppress : ON\n"; else argout += "Suppress : OFF\n"; //- Trigger tmp = _kstatus.substr(9,1); - _trigMod = XString<short>::convertFromString(tmp); + _trigMod = yat::XString<short>::to_num(tmp); if(!_trigMod) argout += "Trigger : Continuous on Talk\n"; else @@ -517,98 +517,98 @@ std::string Keithley_617::get_configuration (void) argout += "Trigger :One-Shot on External\n"; //- Voltage Source tmp = _kstatus.substr(10,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Voltage Source Operate : ON\n"; else argout += "Voltage Source Operate : OFF\n"; //- Read Mode tmp = _kstatus.substr(11,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Read Mode : Electrometer\n"; else - if(XString<short>::convertFromString(tmp) == 1) + if(yat::XString<short>::to_num(tmp) == 1) argout += "Read Mode : Data Store\n"; else - if(XString<short>::convertFromString(tmp) == 2) + if(yat::XString<short>::to_num(tmp) == 2) argout += "Read Mode : Maximum\n"; else - if(XString<short>::convertFromString(tmp) == 3) + if(yat::XString<short>::to_num(tmp) == 3) argout += "Read Mode : Minimum\n"; else - if(XString<short>::convertFromString(tmp) == 4) + if(yat::XString<short>::to_num(tmp) == 4) argout += "Read Mode :Voltage Source\n"; //- Data prefix : tmp = _kstatus.substr(12,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Data prefix : Prefix, no suffix\n"; else - if(XString<short>::convertFromString(tmp) == 1) + if(yat::XString<short>::to_num(tmp) == 1) argout += "Data prefix : No prefix or suffix\n"; else - if(XString<short>::convertFromString(tmp) == 2) + if(yat::XString<short>::to_num(tmp) == 2) argout += "Data prefix : Prefix and suffix\n"; //- Display : tmp = _kstatus.substr(13,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Display : Electrometer\n"; else argout += "Display : Voltage Source\n"; //- Data Store tmp = _kstatus.substr(14,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "Data Store : Conversion Rate\n"; else - if(XString<short>::convertFromString(tmp) == 1) + if(yat::XString<short>::to_num(tmp) == 1) argout += "Data Store : 1 RDG/Sec\n"; else - if(XString<short>::convertFromString(tmp) == 2) + if(yat::XString<short>::to_num(tmp) == 2) argout += "Data Store : 1 RDG/10Sec\n"; else - if(XString<short>::convertFromString(tmp) == 3) + if(yat::XString<short>::to_num(tmp) == 3) argout += "Data Store : 1 RDG/Min\n"; else - if(XString<short>::convertFromString(tmp) == 4) + if(yat::XString<short>::to_num(tmp) == 4) argout += "Data Store : 1 RDG/10Min\n"; else - if(XString<short>::convertFromString(tmp) == 5) + if(yat::XString<short>::to_num(tmp) == 5) argout += "Data Store : 1 RDG/1Hr\n"; else - if(XString<short>::convertFromString(tmp) == 6) + if(yat::XString<short>::to_num(tmp) == 6) argout += "Data Store : Trig Button\n"; else - if(XString<short>::convertFromString(tmp) == 7) + if(yat::XString<short>::to_num(tmp) == 7) argout += "Data Store : Disabled\n"; //- SRQ Mask tmp = _kstatus.substr(15,2); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "SRQ Data Mask : SRQ Disabled\n"; else - if(XString<short>::convertFromString(tmp) == 1) + if(yat::XString<short>::to_num(tmp) == 1) argout += "SRQ Data Mask : Reading Overflow\n"; else - if(XString<short>::convertFromString(tmp) == 2) + if(yat::XString<short>::to_num(tmp) == 2) argout += "SRQ Data Mask : Data Store Full\n"; else - if(XString<short>::convertFromString(tmp) == 8) + if(yat::XString<short>::to_num(tmp) == 8) argout += "SRQ Data Mask : Reading Done\n"; else - if(XString<short>::convertFromString(tmp) == 16) + if(yat::XString<short>::to_num(tmp) == 16) argout += "SRQ Data Mask : Ready\n"; else - if(XString<short>::convertFromString(tmp) == 32) + if(yat::XString<short>::to_num(tmp) == 32) argout += "SRQ Data Mask : Error\n"; //- EOI & Bus Hold Off tmp = _kstatus.substr(17,1); - if(!XString<short>::convertFromString(tmp)) + if(!yat::XString<short>::to_num(tmp)) argout += "EOI & Bus Hold Off : EOI and Hold-Off\n"; else - if(XString<short>::convertFromString(tmp) == 1) + if(yat::XString<short>::to_num(tmp) == 1) argout += "EOI & Bus Hold Off : No EOI and Hold-Off\n"; else - if(XString<short>::convertFromString(tmp) == 2) + if(yat::XString<short>::to_num(tmp) == 2) argout += "EOI & Bus Hold Off : EOI and no Hold-Off\n"; else - if(XString<short>::convertFromString(tmp) == 3) + if(yat::XString<short>::to_num(tmp) == 3) argout += "EOI & Bus Hold Off : No EOI and no Hold-Off\n"; } catch(std::out_of_range) diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp index 86e8b10..9c4400f 100644 --- a/src/Keithley_6485.cpp +++ b/src/Keithley_6485.cpp @@ -18,7 +18,7 @@ #include <sstream> #include <string> #include <math.h> //- for ceil -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_6485.h" #include "KeithleySCPIProtocol.h" /* @@ -167,13 +167,13 @@ std::string Keithley_6485::get_ElectroMeterRange (void) //- get range from hardware std::string range_str = _electrometerProtocol->get_range( ); //- convert range in decimal value - double rangeValueReturned = XString<double>::convertFromString(range_str); + double rangeValueReturned = yat::XString<double>::to_num(range_str); //- find and return the index short idx = 0; for(idx=0; idx<K6485_rangeLimit ; idx++) { - double rangeValueCalculated = XString<double>::convertFromString(K6485_rangeValue[idx]); + double rangeValueCalculated = yat::XString<double>::to_num(K6485_rangeValue[idx]); double delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp index a56009c..d9400f4 100644 --- a/src/Keithley_6487.cpp +++ b/src/Keithley_6487.cpp @@ -18,7 +18,7 @@ #include <sstream> #include <string> #include <math.h> //- for ceil -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_6487.h" #include "KeithleySCPIProtocol.h" /* @@ -227,13 +227,13 @@ std::string Keithley_6487::get_ElectroMeterRange (void) //- get range from hardware std::string range_str = _electrometerProtocol->get_range( ); //- convert range in decimal value - double rangeValueReturned = XString<double>::convertFromString(range_str); + double rangeValueReturned = yat::XString<double>::to_num(range_str); //- find and return the index short idx = 0; for(idx=0; idx<K6487_rangeLimit ; idx++) { - double rangeValueCalculated = XString<double>::convertFromString(K6487_rangeValue[idx]); + double rangeValueCalculated = yat::XString<double>::to_num(K6487_rangeValue[idx]); double delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; diff --git a/src/Keithley_6512.cpp b/src/Keithley_6512.cpp index f8aef9c..e23f818 100644 --- a/src/Keithley_6512.cpp +++ b/src/Keithley_6512.cpp @@ -18,7 +18,7 @@ #include <stdexcept> #include <sstream> #include <string> -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_6512.h" #include "KeithleyDDCProtocol.h" @@ -354,35 +354,35 @@ std::string Keithley_6512::electrometer_status (void) //- IDDC Error : Set when an illegal device dependent command (IDDC) such as HlX is received ("H" is illegal). tmp = kconfig.substr(44,1); - short iddc = XString<short>::convertFromString(tmp); + short iddc = yat::XString<short>::to_num(tmp); if(iddc) { argout += "IDDC error : illegal device dependent command received.\n"; } //- IDDCO Error : Set when an illegal device-dependent command option (IDDCO) such as T9X is received ("9" is illegal). tmp = kconfig.substr(5,1); - short iddco = XString<short>::convertFromString(tmp); + short iddco = yat::XString<short>::to_num(tmp); if(iddco) { argout += "IDDCO error : an illegal device-dependent command option received.\n"; } //- Remote Error : Set when a programming command is received when REN is false. tmp = kconfig.substr(6,1); - short remote = XString<short>::convertFromString(tmp); + short remote = yat::XString<short>::to_num(tmp); if(remote) { argout += "REMOTE error : programming command is received when REN is false\n"; } //- Trigger Overrun Error : Set when a trigger is received when the instrument is still processing a reading from a previous trigger. tmp = kconfig.substr(8,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(trigg) { argout += "Trigger error : Trigger received while instrument is still processing a reading from a previous trigger.\n"; } //- Number Error : Set when an Out of range calibration or voltage source value is received. tmp = kconfig.substr(9,1); - short numErr = XString<short>::convertFromString(tmp); + short numErr = yat::XString<short>::to_num(tmp); if(numErr) { argout += "Number error : Out of range calibration or voltage source value is received.\n"; @@ -434,10 +434,10 @@ std::string Keithley_6512::get_configuration (void) argout = "Keithley Type : " + modelNum + "\n"; //- Functions and associate range : tmp = _kstatus.substr(4,1); - short func = XString<short>::convertFromString(tmp); + short func = yat::XString<short>::to_num(tmp); //- Range : tmp = _kstatus.substr(5,2); - _range = XString<short>::convertFromString(tmp); + _range = yat::XString<short>::to_num(tmp); if(!func) { _mode = "Function : VOLTS"; @@ -473,25 +473,25 @@ std::string Keithley_6512::get_configuration (void) argout += "RANGE : " + _rangeStr + "\n"; //- Zero check state tmp = _kstatus.substr(7,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Check : ON\n"; else argout += "Zero Check : OFF\n"; //- Zero correct state tmp = _kstatus.substr(8,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Zero Correct : ON\n"; else argout += "Zero Correct : OFF\n"; //- Suppress tmp = _kstatus.substr(9,1); - if(XString<short>::convertFromString(tmp)) + if(yat::XString<short>::to_num(tmp)) argout += "Suppress : ON\n"; else argout += "Suppress : OFF\n"; //- Trigger tmp = _kstatus.substr(10,1); - short trigg = XString<short>::convertFromString(tmp); + short trigg = yat::XString<short>::to_num(tmp); if(!trigg) argout += "Trigger : Continuous on Talk\n"; else @@ -517,7 +517,7 @@ std::string Keithley_6512::get_configuration (void) argout += "Trigger :One-Shot on External\n"; //- Read Mode tmp = _kstatus.substr(12,1); - short readingMode = XString<short>::convertFromString(tmp); + short readingMode = yat::XString<short>::to_num(tmp); if(!readingMode) argout += "Read Mode : Electrometer\n"; else @@ -534,7 +534,7 @@ std::string Keithley_6512::get_configuration (void) argout += "Read Mode :Voltage Source\n"; //- Data prefix tmp = _kstatus.substr(13,1); - short dataPrefix = XString<short>::convertFromString(tmp); + short dataPrefix = yat::XString<short>::to_num(tmp); if(!dataPrefix) argout += "Data prefix : Prefix, no suffix\n"; else @@ -545,7 +545,7 @@ std::string Keithley_6512::get_configuration (void) argout += "Data prefix : Prefix and suffix\n"; //- Data Store tmp = _kstatus.substr(15,1); - short dstore = XString<short>::convertFromString(tmp); + short dstore = yat::XString<short>::to_num(tmp); if(!dstore) argout += "Data Store : Conversion Rate\n"; else @@ -571,7 +571,7 @@ std::string Keithley_6512::get_configuration (void) argout += "Data Store : Disabled\n"; //- SRQ Mask tmp = _kstatus.substr(16,2); - short srqInfo = XString<short>::convertFromString(tmp); + short srqInfo = yat::XString<short>::to_num(tmp); if(!srqInfo) argout += "SRQ Data Mask : SRQ Disabled\n"; else @@ -591,7 +591,7 @@ std::string Keithley_6512::get_configuration (void) argout += "SRQ Data Mask : Error\n"; //- EOI & Bus Hold Off tmp = _kstatus.substr(18,1); - short ebhoff = XString<short>::convertFromString(tmp); + short ebhoff = yat::XString<short>::to_num(tmp); if(!ebhoff) argout += "EOI & Bus Hold Off : EOI and Hold-Off\n"; else diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp index a2427d1..ebf1af6 100644 --- a/src/Keithley_6514.cpp +++ b/src/Keithley_6514.cpp @@ -18,7 +18,7 @@ #include <sstream> #include <string> #include <math.h> //- for ceil -#include <Xstring.h> +#include <yat/utils/XString.h> #include <tango.h> //- Tango exceptions #include "Keithley_6514.h" #include "KeithleySCPIProtocol.h" @@ -369,7 +369,7 @@ double delta = 0; //- get range from hardware range_str = _electrometerProtocol->get_range( ); //- convert range in decimal value - rangeValueReturned = XString<double>::convertFromString(range_str); + rangeValueReturned = yat::XString<double>::to_num(range_str); //- find and return the index short idx = 0; @@ -393,28 +393,28 @@ double delta = 0; { if( _kmode.find("CURR") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6514_AMP_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6514_AMP_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } else if ( _kmode.find("VOLT") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6514_VOLT_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6514_VOLT_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } else if ( _kmode.find("RES") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6514_OHM_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6514_OHM_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } else if ( _kmode.find("CHAR") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6514_COU_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6514_COU_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; diff --git a/src/Keithley_6517.cpp b/src/Keithley_6517.cpp index dc5a673..16cb4d6 100644 --- a/src/Keithley_6517.cpp +++ b/src/Keithley_6517.cpp @@ -18,7 +18,7 @@ #include <sstream> #include <string> #include <math.h> //- for ceil -#include <Xstring.h> +#include <yat/utils/XString.h> #include "Keithley_6517.h" #include "KeithleySCPIProtocol.h" /* @@ -167,9 +167,11 @@ std::stringstream cmd_to_send; _rangeStr = K6517_COU_rangeStr[_range]; } else + { throw electrometer::ElectrometerException("UNKNOWN_MODE", "Unable to find the electrometer mode used.", "Keithley_6517::range_up( )."); + } //- build and send the command cmd_to_send << _rangeStr << std::endl; @@ -181,40 +183,49 @@ std::stringstream cmd_to_send; // ============================================================================ void Keithley_6517::range_down (void) { - std::stringstream cmd_to_send; - //- update range value from hardware - this->get_ElectroMeterRange( ); + //- update range value from hardware + this->get_ElectroMeterRange( ); - _range -= 1; + _range -= 1; - if(_range < 0) - { - _range = 0; + if(_range < 0) + { + _range = 0; - throw electrometer::ElectrometerException("OUT_OF_RANGE", - "Range down limit reached.", - "Keithley_6517::range_down( )."); - } + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Range down limit reached.", + "Keithley_6517::range_down( )."); + } - //- check range validity - if(_kmode.find("CURR") != std::string::npos) - cmd_to_send << K6517_AMP_rangeStr[_range] << std::endl; - else if (_kmode.find("VOLT") != std::string::npos) - cmd_to_send << K6517_VOLT_rangeStr[_range] << std::endl; - else if (_kmode.find("RES") != std::string::npos) - cmd_to_send << K6517_OHM_rangeStr[_range] << std::endl; - else if (_kmode.find("CHAR") != std::string::npos) - cmd_to_send << K6517_COU_rangeStr[_range] << std::endl; - else - throw electrometer::ElectrometerException("UNKNOWN_MODE", - "Unable to find the electrometer mode used.", - "Keithley_6517::range_down( )."); + //- check range validity + if(_kmode.find("CURR") != std::string::npos) + { + cmd_to_send << K6517_AMP_rangeStr[_range] << std::endl; + } + else if (_kmode.find("VOLT") != std::string::npos) + { + cmd_to_send << K6517_VOLT_rangeStr[_range] << std::endl; + } + else if (_kmode.find("RES") != std::string::npos) + { + cmd_to_send << K6517_OHM_rangeStr[_range] << std::endl; + } + else if (_kmode.find("CHAR") != std::string::npos) + { + cmd_to_send << K6517_COU_rangeStr[_range] << std::endl; + } + else + { + throw electrometer::ElectrometerException("UNKNOWN_MODE", + "Unable to find the electrometer mode used.", + "Keithley_6517::range_down( )."); + } - //- build and send the command - _electrometerProtocol->set_range(cmd_to_send.str()); + //- build and send the command + _electrometerProtocol->set_range(cmd_to_send.str()); } // ============================================================================ @@ -223,7 +234,7 @@ std::stringstream cmd_to_send; std::vector<std::string> Keithley_6517::ranges_list (void) { std::vector<std::string> vrangeslist; - std::size_t nb_ranges = 0; + // std::size_t nb_ranges = 0; //- get device mode _kmode = AbstractElectrometerClass::get_ElectroMeterMode(); @@ -231,28 +242,30 @@ std::vector<std::string> Keithley_6517::ranges_list (void) //- check range validity if(_kmode.find("CURR") != std::string::npos) { - nb_ranges = K6517_AMP_rangeLimit; + // nb_ranges = K6517_AMP_rangeLimit; vrangeslist = K6517_AMP_rangeStr; } else if (_kmode.find("VOLT") != std::string::npos) { - nb_ranges = K6517_VOLT_rangeLimit; + // nb_ranges = K6517_VOLT_rangeLimit; vrangeslist = K6517_VOLT_rangeStr; } else if (_kmode.find("RES") != std::string::npos) { - nb_ranges = K6517_OHM_rangeLimit; + // nb_ranges = K6517_OHM_rangeLimit; vrangeslist = K6517_OHM_rangeStr; } else if (_kmode.find("CHAR") != std::string::npos) { - nb_ranges = K6517_COU_rangeLimit; + // nb_ranges = K6517_COU_rangeLimit; vrangeslist = K6517_COU_rangeStr; } else + { throw electrometer::ElectrometerException("UNKNOWN_MODE", "Unable to find the electrometer mode used.", "Keithley_6517::ranges_list( )."); + } return vrangeslist; } @@ -272,22 +285,34 @@ void Keithley_6517::set_ElectroMeterRange (std::size_t rangeIdx) if(_kmode.find("CURR") != std::string::npos) { range_limit = K6517_AMP_rangeLimit; - range_str = K6517_AMP_rangeStr[rangeIdx]; + if(range_limit < rangeIdx) + { + range_str = K6517_AMP_rangeStr[rangeIdx]; + } } else if (_kmode.find("VOLT") != std::string::npos) { range_limit = K6517_VOLT_rangeLimit; - range_str = K6517_VOLT_rangeStr[rangeIdx]; + if(range_limit < rangeIdx) + { + range_str = K6517_VOLT_rangeStr[rangeIdx]; + } } else if (_kmode.find("RES") != std::string::npos) { range_limit = K6517_OHM_rangeLimit; - range_str = K6517_OHM_rangeStr[rangeIdx]; + if(range_limit < rangeIdx) + { + range_str = K6517_OHM_rangeStr[rangeIdx]; + } } else if (_kmode.find("CHAR") != std::string::npos) { range_limit = K6517_COU_rangeLimit; - range_str = K6517_COU_rangeStr[rangeIdx]; + if(range_limit < rangeIdx) + { + range_str = K6517_COU_rangeStr[rangeIdx]; + } } if ( rangeIdx >= range_limit ) @@ -390,7 +415,7 @@ double Keithley_6517::get_VSourceValue (void) if(_kscpi) response = _kscpi->getVSourceValue(); - volts = XString<double>::convertFromString(response); + volts = yat::XString<double>::to_num(response); return volts; } @@ -415,24 +440,34 @@ double delta = 0; //- get range from hardware range_str = _electrometerProtocol->get_range( ); //- convert range in decimal value - rangeValueReturned = XString<double>::convertFromString(range_str); + rangeValueReturned = yat::XString<double>::to_num(range_str); //- find and return the index short idx = 0; short idx_limit = 0; if(_kmode.find("CURR") != std::string::npos) + { idx_limit = K6517_AMP_rangeLimit; + } else if (_kmode.find("VOLT") != std::string::npos) + { idx_limit = K6517_VOLT_rangeLimit; + } else if (_kmode.find("RES") != std::string::npos) + { idx_limit = K6517_OHM_rangeLimit; + } else if (_kmode.find("CHAR") != std::string::npos) + { idx_limit = K6517_COU_rangeLimit; + } else + { throw electrometer::ElectrometerException("UNKNOWN_MODE", "Unable to find the electrometer mode used.", "Keithley_6517::get_ElectroMeterRange( )."); + } //- find the range index @@ -440,28 +475,28 @@ double delta = 0; { if( _kmode.find("CURR") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6517_AMP_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6517_AMP_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } else if ( _kmode.find("VOLT") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6517_VOLT_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6517_VOLT_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } else if ( _kmode.find("RES") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6517_OHM_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6517_OHM_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } else if ( _kmode.find("CHAR") != std::string::npos ) { - rangeValueCalculated = XString<double>::convertFromString(K6517_COU_rangeStr[idx]); + rangeValueCalculated = yat::XString<double>::to_num(K6517_COU_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; @@ -470,9 +505,11 @@ double delta = 0; //- throw if index not found if( idx == idx_limit ) + { throw electrometer::ElectrometerException("INTERNAL_ERROR", "Failed to get range index.", "Keithley_6517::get_ElectroMeterRange( )."); + } //- update the range with the index found this->_range = idx; diff --git a/src/N_PhotoConducteur.cpp b/src/N_PhotoConducteur.cpp old mode 100755 new mode 100644 index 96f0c6b..b38d8c0 --- a/src/N_PhotoConducteur.cpp +++ b/src/N_PhotoConducteur.cpp @@ -18,7 +18,6 @@ #include <iostream> #include <sstream> #include <string> -#include <Xstring.h> #include "N_PhotoConducteur.h" #include "NovelecProtocol.h" /* diff --git a/src/N_PhotoVoltaique.cpp b/src/N_PhotoVoltaique.cpp old mode 100755 new mode 100644 index b281def..d7a840a --- a/src/N_PhotoVoltaique.cpp +++ b/src/N_PhotoVoltaique.cpp @@ -18,7 +18,6 @@ #include <iostream> #include <sstream> #include <string> -#include <Xstring.h> #include "N_PhotoVoltaique.h" #include "NovelecProtocol.h" /* diff --git a/src/NovelecProtocol.cpp b/src/NovelecProtocol.cpp index 92483c4..ba152a8 100644 --- a/src/NovelecProtocol.cpp +++ b/src/NovelecProtocol.cpp @@ -24,7 +24,7 @@ #include <iostream> #include <sstream> #include <string> -#include <Xstring.h> +#include <yat/utils/XString.h> #include "NovelecProtocol.h" //- commands numbers @@ -109,7 +109,7 @@ bool NovelecProtocol::build_communicationLink() //- find the connected electrometer type and its ranges std::string eType = this->check_electrotype(); - this->_novType = XString<short>::convertFromString(eType); + this->_novType = yat::XString<short>::to_num(eType); this->_rangeParameterNum = _novType + 2; // NOTE : +2 means => the range command number is the novelec type + 2 ! return true; @@ -183,7 +183,7 @@ std::string NovelecProtocol::get_mode (void) //- check what is the response mode type if( !_is_explicite_resp_enabled ) { - short idx = XString<short>::convertFromString(argout); + short idx = yat::XString<short>::to_num(argout); _function = mode_str[idx]; } else @@ -393,7 +393,7 @@ std::string NovelecProtocol::get_range (void) //- check what is the response mode type if( _is_explicite_resp_enabled == false ) { - short idx = XString<short>::convertFromString(argout); + short idx = yat::XString<short>::to_num(argout); argout = range_str[_novType-1][idx]; } @@ -441,7 +441,7 @@ std::string NovelecProtocol::get_polarity (void) //- check what is the response mode type if( _is_explicite_resp_enabled == false ) { - short idx = XString<short>::convertFromString(argout); + short idx = yat::XString<short>::to_num(argout); if(idx < 0) argout = "negative"; else @@ -500,7 +500,7 @@ std::string NovelecProtocol::get_frequency (void) //- check what is the response mode type if( _is_explicite_resp_enabled == false ) { - short idx = XString<short>::convertFromString(argout); + short idx = yat::XString<short>::to_num(argout); argout = frequency_str[idx]; } @@ -548,7 +548,7 @@ std::string NovelecProtocol::get_gain (void) //- check what is the response mode type if( _is_explicite_resp_enabled == false ) { - short idx = XString<short>::convertFromString(argout); + short idx = yat::XString<short>::to_num(argout); argout = gain_str[idx]; } else @@ -751,7 +751,7 @@ std::string NovelecProtocol::check_and_extract_data (std::string response, short std::string data; std::string cmd_sentStr; - cmd_sentStr = XString<short>::convertToString(cmd_sent); + cmd_sentStr = yat::XString<short>::to_string(cmd_sent); //- A correct response is : // -> "address AWR ReadNum = data " : if there is a returned value diff --git a/src/Novelec_MCCE2.cpp b/src/Novelec_MCCE2.cpp old mode 100755 new mode 100644 index ab39025..47cd58e --- a/src/Novelec_MCCE2.cpp +++ b/src/Novelec_MCCE2.cpp @@ -17,7 +17,7 @@ #include <iostream> #include <sstream> #include <string> -#include <Xstring.h> +#include <yat/utils/XString.h> #include "NovelecProtocol.h" #include "Novelec_MCCE2.h" @@ -291,7 +291,7 @@ std::string Novelec_MCCE2::electrometer_status (void) //- read novelec status from HW tmp = _electrometerProtocol->get_raw_status(); - status = XString<short>::convertFromString(tmp); + status = yat::XString<short>::to_num(tmp); } catch(...) { @@ -337,7 +337,7 @@ std::string Novelec_MCCE2::electrometer_status (void) { //- read novelec error(s) from HW tmp = nproto->get_errors(); - errors= XString<short>::convertFromString(tmp); + errors= yat::XString<short>::to_num(tmp); } catch(...) { -- GitLab