 |
THM1176InstrumentDriver
1.0
C++ API for Metrolab THM1176
|
Go to the documentation of this file.
19 #define __LITTLE_ENDIAN__ 1
24 #if __BYTE_ORDER == __LITTLE_ENDIAN
25 #define __LITTLE_ENDIAN__ 1
27 #define __BIG_ENDIAN__ 1
34 namespace Instrument {
35 namespace THM1176Types {
40 const char Binary16_Out[2] = { pBinary[1], pBinary[0] };
41 return *(
I16*)Binary16_Out;
43 return *(
I16*)pBinary;
45 #error Neither __LITTLE_ENDIAN__ nor __BIG_ENDIAN__ is defined.
51 const char Binary32_Out[4] = { pBinary[3], pBinary[2], pBinary[1], pBinary[0] };
52 return *(
I32*)Binary32_Out;
54 return *(
I32*)pBinary;
56 #error Neither __LITTLE_ENDIAN__ nor __BIG_ENDIAN__ is defined.
61 if (SUnits ==
"T") rUnits =
kT;
62 else if (SUnits ==
"MT") rUnits =
kmT;
63 else if (SUnits ==
"UT") rUnits =
kuT;
64 else if (SUnits ==
"NT") rUnits =
knT;
65 else if (SUnits ==
"GAUSs") rUnits =
kGauss;
66 else if (SUnits ==
"KGAUss") rUnits =
kkGauss;
67 else if (SUnits ==
"MGAUss") rUnits =
kmGauss;
68 else if (SUnits ==
"MAHZp") rUnits =
kMHzp;
75 return Units ==
kT ?
"T" :
79 Units ==
kGauss ?
"GAUSs" :
82 Units ==
kMHzp ?
"MAHZP" :
"";
95 char Binary16[2] = {
'\x12',
'\xF3' };
97 throw "Invalid I16 conversion";
98 char Binary32[4] = {
'\x12',
'\x34',
'\x56',
'\xF7' };
100 throw "Invalid I32 conversion";
102 catch (
const char * ErrorMsg)
104 std::cout <<
"Error! :" << ErrorMsg << std::endl;
107 std::cout << MTL__FUNCTION_NAME__ <<
" Success" << std::endl;
eUnits
Enumeration of possible measurement units.
Collection of utility macros for error messages.
short I16
16-bit signed integer.
bool StringToUnits(std::string SUnits, eUnits &rUnits)
Convert measurement units from string to enumeration.
std::string UnitsToString(eUnits Units)
Convert measurement units from enumeration to string.
bool TestTHM1176Types()
Test the conversion routines.
I32 BinaryToI32(const char pBinary[4])
Convert binary to I32, taking into account endedness.
int I32
32-bit signed integer.
@ kMHzp
Equivalent proton NMR resonant frequency, in Mega-Hertz.
I16 BinaryToI16(const char pBinary[2])
Convert binary to I16, taking into account endedness.
Platform Dependent Definitions.
IEEE488.2 / SCPI instrument I/O: Instrument buffer management.
Type conversion routines for C++ API for Metrolab THM1176/TFM1186.