C++ Instrument Catalog
PT2026.cpp
Go to the documentation of this file.
1 // Standard includes
2 #include <sstream>
3 #include <iomanip>
4 #include <locale>
5 // Personal includes
6 #include "PT2026.h"
7 #include "OSDefines.h"
8 #include "Helpers.h"
9 #include "Exception.h"
10 #include "PT2026TypeConversions.h"
11 #include "SCPIParsing.h"
12 // External tools includes
13 #include "date.h"
14 
15 //----------------------------------------------------------------------//
16 // Definitions //
17 //----------------------------------------------------------------------//
18 #define DEBUG_MTL_INSTRUMENT_PT2026 1
19 #define DEBUG_MTL_INSTRUMENT_PT2026_ERRORS_ONLY 1
20 #if (defined(_DEBUG) && defined(DEBUG_MTL_INSTRUMENT_PT2026) && DEBUG_MTL_INSTRUMENT_PT2026)
21 #if (defined(DEBUG_MTL_INSTRUMENT_PT2026_ERRORS_ONLY) && DEBUG_MTL_INSTRUMENT_PT2026_ERRORS_ONLY)
22 #define MTL_INSTRUMENT_PT2026_DEBUG_COUT(__X__)
23 #else
24 #define MTL_INSTRUMENT_PT2026_DEBUG_COUT(__X__) COUT(__X__)
25 #endif
26 #define MTL_INSTRUMENT_PT2026_DEBUG_CERR(__X__) CERR(__X__)
27 #else
28 #define MTL_INSTRUMENT_PT2026_DEBUG_COUT(__X__)
29 #define MTL_INSTRUMENT_PT2026_DEBUG_CERR(__X__)
30 #endif
31 
32 #define MTL_WRITE_AND_READ_STB_POLLING_PERIOD_MS 50
33 #define MTL_ERROR_LIST_HISTORY_LEN 20
34 #define MTL_ERROR_BUFFER_LEN 4096
35 #if defined(_WIN32)
36  #define MTL_F64_CONVERSION_LOCALE "en-US"
37 #elif defined(__APPLE__)
38  #define MTL_F64_CONVERSION_LOCALE "en_US"
39 #else
40  #error "Selecting the locale format: unknown OS environment"
41 #endif
42 #define MTL_F64_CONVERSION_PRECISION 15
43 
44 using namespace MTL::Instrument;
45 using namespace MTL::SCPI;
46 using namespace MTL::Instrument::PT2026Types;
47 
48 //----------------------------------------------------------------------//
49 // Exceptions //
50 //----------------------------------------------------------------------//
52 
53 //----------------------------------------------------------------------//
54 // Utilities //
55 //----------------------------------------------------------------------//
56 void l_ParseErrorString(std::string & rErrStr, const std::string & rContext, sError & rError)
57 {
58  // Get code
59  size_t l_Coma = rErrStr.find_first_of(',');
60  rError.Code = std::stoi(rErrStr.substr(0, l_Coma));
61  // Get description
62  size_t l_OpenQuote = rErrStr.find_first_of('"', l_Coma + 1);
63  size_t l_CloseQuote = rErrStr.find_last_of('"');
64  rError.Description = rErrStr.substr(l_OpenQuote + 1, l_CloseQuote - (l_OpenQuote + 1));
65  rError.Context = rContext;
66 }
68 {
69  return std::to_string(Addr.Member.A) + '.' +
70  std::to_string(Addr.Member.B) + '.' +
71  std::to_string(Addr.Member.C) + '.' +
72  std::to_string(Addr.Member.D);
73 }
74 std::string l_ToString(F64 number, std::streamsize precision = MTL_F64_CONVERSION_PRECISION, const char * locale = MTL_F64_CONVERSION_LOCALE)
75 {
76  std::ostringstream l_oss;
77 
78  l_oss.imbue(std::locale(locale));
79  l_oss << std::scientific << std::setprecision(precision);
80  l_oss << number;
81 
82  return l_oss.str();
83 }
84 bool CPT2026Instrument::l_GetErrorList(const std::string & rContext)
85 {
86  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
87 
88  try {
89  uStatusByte l_STB;
90  // Read STB
91  if (!ReadSTB(l_STB.RawSTB))
92  throw CPT2026InsException("Failed reading STB", MTL__LOCATION__);
93 
94  // While there is an error
96  while (l_STB.StatusByte.EAV)
97  {
98  // Try to read error string
99  enum eRetry { kRetryErrorRetrieving };
100  try {
101  if (!Write(":SYST:ERR?"))
102  throw kRetryErrorRetrieving;
103  if (!Read(l_Error))
104  throw kRetryErrorRetrieving;
105  }
106  catch (eRetry & rRetry)
107  {
108  if (rRetry == kRetryErrorRetrieving)
109  {
110  // Clear
111  if (!Clear())
112  throw CPT2026InsException("Could not clear device", MTL__LOCATION__);
113  // Retry reading error
114  if (!Write(":SYST:ERR?"))
115  throw CPT2026InsException("Failed getting error list", MTL__LOCATION__);
116  if (!Read(l_Error))
117  throw CPT2026InsException("Failed getting error list", MTL__LOCATION__);
118  }
119  }
120  // Parse Error
121  std::string l_ErrStr = std::string(l_Error.data(), l_Error.size());
122  sError l_Err;
123  l_ParseErrorString(l_ErrStr, rContext, l_Err);
124 #if (defined(_DEBUG))
125  CERR("PT2026Error " << l_Err.Code << " : " << l_Err.Description << " in " << l_Err.Context << std::endl);
126 #endif
127  // Append to the error list
128  m_ErrorList.push(l_Err);
129  while (m_ErrorList.size() > MTL_ERROR_LIST_HISTORY_LEN)
130  m_ErrorList.pop();
131  // Read STB
132  if (!ReadSTB(l_STB.RawSTB))
133  throw CPT2026InsException("Failed reading STB", MTL__LOCATION__);
134  }
135  }
136  catch (CPT2026InsException & rE)
137  {
139  MTL_Unused(rE);
140  return false;
141  }
142  return true;
143 }
144 
145 bool CPT2026Instrument::l_WriteAndRead(const std::string & rWriteStr, CVISABuffer & rReadBuffer, bool WaitForMAV)
146 {
147  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
148  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
149 
150  try
151  {
152  rReadBuffer.clear();
153 
154  // Acquire VISA lock
155  if (!LockExclusive(m_Timeout_ms))
156  throw CPT2026InsException("Failed acquiring lock", MTL__LOCATION__);
157 
158  // Append *OPC ? if command does not include "*IDN?" (which is the only command to return an indefinite - length response, and can therefore not be followed by another query).
159  // Match a string which contains "*IDN?"
160  bool l_OPCAppended = !std::regex_match(rWriteStr, std::regex("\\*IDN\\?"));
161  std::string l_Query;
162  if (l_OPCAppended)
163  l_Query = rWriteStr + ";*OPC?";
164  else
165  l_Query = rWriteStr;
166 
167  // Write
168  if (!Write(reinterpret_cast<ViBuf>(const_cast<char *>(l_Query.data())), static_cast<ViUInt32>(l_Query.size())))
169  throw CPT2026InsException("Could not write", MTL__LOCATION__);
170 
171  // Check status
172  uStatusByte l_STB;
173  if (!ReadSTB(l_STB.RawSTB))
174  throw CPT2026InsException("Failed reading STB", MTL__LOCATION__);
175  if (l_STB.StatusByte.EAV)
176  throw CPT2026InsException("Error available", MTL__LOCATION__);
177 
178  // If preparing the answer can take time, we can request to wait for MAV being set before reading answer.
179  // This prevents from getting a read timeout is answer is not ready in the expected amount of time.
180  if (WaitForMAV)
181  {
182  for (; l_OPCAppended && !l_STB.StatusByte.MAV; MTL_SleepMs(MTL_WRITE_AND_READ_STB_POLLING_PERIOD_MS))
183  {
184  if (!ReadSTB(l_STB.RawSTB))
185  throw CPT2026InsException("Failed reading STB", MTL__LOCATION__);
186  if (l_STB.StatusByte.EAV)
187  throw CPT2026InsException("Error available", MTL__LOCATION__);
188  }
189  }
190 
191  // Repeat while there is a message available
192  // There is always at least the *IDN? or the *OPC? answer
193  // TEMPORARY: Since PT2026 firmware has a bug, (MAV may stay true after reading whole message) we do not check for MAV anymore here
194  //do
195  //{
196  // Read
197  if (!Read(rReadBuffer, true))
198  throw CPT2026InsException("Could not read", MTL__LOCATION__);
199  // Read STB
200  if (!ReadSTB(l_STB.RawSTB))
201  throw CPT2026InsException("Failed reading STB", MTL__LOCATION__);
202  if (l_STB.StatusByte.EAV)
203  throw CPT2026InsException("Error available", MTL__LOCATION__);
204  //} while (l_STB.StatusByte.MAV);
205 
206  // Remove *OPC? result if given
207  if (l_OPCAppended)
208  {
209  size_t l_MaxSizeToMatch = sizeof(";1\n") - 1; // It is unnecessary to perform a regex on more characters than this
210  std::match_results<std::vector<char>::iterator> m;
211  // Match a string that ends with an optional ';', a '1', and an optional '\n'
212  if (std::regex_match((rReadBuffer.size() <= l_MaxSizeToMatch) ? rReadBuffer.begin() : rReadBuffer.end() - static_cast<std::vector<char>::difference_type>(l_MaxSizeToMatch), rReadBuffer.end(), m, std::regex(";?1\\n?$")))
213  rReadBuffer.resize(rReadBuffer.size() - static_cast<size_t>(m.length()));
214  }
215 
216  // Release VISA lock
217  if (!Unlock())
218  throw CPT2026InsException("Could not unlock", MTL__LOCATION__);
219  }
220  catch (CPT2026InsException & rE)
221  {
223  MTL_Unused(rE);
224 
225  // Try to read whatever data is available.
226  uStatusByte l_STB;
227  while (ReadSTB(l_STB.RawSTB) && l_STB.StatusByte.MAV)
228  Read(rReadBuffer, true);
229 
230  // Try to get errors
231  l_GetErrorList(rWriteStr);
232 
233  // Try to release the lock
234  Unlock();
235 
236  return false;
237  }
238  return true;
239 }
240 
241 
242 //----------------------------------------------------------------------//
243 // Constructors / destructors //
244 //----------------------------------------------------------------------//
246  : CVISAInstrument(rRM, Rsrc), m_Timeout_ms(5000), m_ReadBuffer(65535)
247 {
248 
249 }
251 {
252  Abort(true);
253  UnlockInterface();
254  Disconnect();
255 }
256 
257 //----------------------------------------------------------------------//
258 // General Information //
259 //----------------------------------------------------------------------//
260 const std::vector<sError> CPT2026Instrument::ErrorList()
261 {
262  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
263  std::vector<sError> l_ErrList;
264  while (!m_ErrorList.empty())
265  {
266  l_ErrList.push_back(m_ErrorList.front());
267  m_ErrorList.pop();
268  }
269  return l_ErrList;
270 }
271 
272 //----------------------------------------------------------------------//
273 // Open / Close //
274 //----------------------------------------------------------------------//
275 bool CPT2026Instrument::Connect(U32 InitialTimeout)
276 {
277  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
278  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
279  try
280  {
281  m_Timeout_ms = InitialTimeout;
283  throw CPT2026InsException("Could not open", MTL__LOCATION__);
284  if (!CVISAInstrument::SetTimeout(m_Timeout_ms))
285  throw CPT2026InsException("Could not set timeout", MTL__LOCATION__);
286  if (!CVISAInstrument::Clear())
287  throw CPT2026InsException("Could not clear", MTL__LOCATION__);
288  if (!l_WriteAndRead("*CLS", m_ReadBuffer))
289  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
290  }
291  catch (CPT2026InsException & rE)
292  {
294  MTL_Unused(rE);
295  // Try to close resource (in case Open succeeded)
297  return false;
298  }
299  return true;
300 }
301 
303 {
304  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
305  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
306 
308 }
309 
310 //----------------------------------------------------------------------//
311 // Interface Lock //
312 //----------------------------------------------------------------------//
314 {
315  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
316  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
317 
318  try {
319  if (!l_WriteAndRead(":SYST:LOCK:REQ?", m_ReadBuffer))
320  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
321  if (m_ReadBuffer[0] != '1')
322  throw CPT2026InsException("Failed Locking interface", MTL__LOCATION__);
323  }
324  catch (CPT2026InsException & rE)
325  {
327  MTL_Unused(rE);
328  return false;
329  }
330  return true;
331 }
332 
334 {
335  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
336  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
337 
338  try{
339  if (!l_WriteAndRead(":SYST:LOCK:REL", m_ReadBuffer))
340  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
341  }
342  catch (CPT2026InsException & rE)
343  {
345  MTL_Unused(rE);
346  return false;
347  }
348  return true;
349 }
350 
351 //----------------------------------------------------------------------//
352 // Channels //
353 //----------------------------------------------------------------------//
355 {
356  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
357  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
358 
359  try {
360  if (!l_WriteAndRead(":ROUT:PROB:SCAN?", m_ReadBuffer, true))
361  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
362 
363  size_t l_Start, l_Len;
364  if (IsArbitraryBlock(m_ReadBuffer.begin(), m_ReadBuffer.end(), l_Start, l_Len))
365  FromBinaryChannelList(m_ReadBuffer.data() + l_Start, l_Len, rChanList);
366  else
367  FromStringChannelList(m_ReadBuffer.data(), m_ReadBuffer.data() + m_ReadBuffer.size(), rChanList);
368  }
369  catch (CPT2026InsException & rE)
370  {
372  MTL_Unused(rE);
373  return false;
374  }
375  return true;
376 }
377 
379 {
380  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
381  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
382 
383  try {
384  if (!l_WriteAndRead(":ROUT:ESCAN?", m_ReadBuffer, true))
385  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
386 
387  if (!StringToExtendedChannelList(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end()), rChanList))
388  throw CPT2026InsException(std::string("Invalid answer format in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
389  }
390  catch (CPT2026InsException & rE)
391  {
393  MTL_Unused(rE);
394  return false;
395  }
396  return true;
397 }
398 
400 {
401  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
402  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
403 
404  try {
405  if (!l_WriteAndRead(":ROUT:CLOS:STAT?;ACT?", m_ReadBuffer))
406  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
407 
408  size_t l_Start, l_Len;
409  if (IsArbitraryBlock(m_ReadBuffer.begin(), m_ReadBuffer.end(), l_Start, l_Len))
410  {
411  FromBinaryChannelList(m_ReadBuffer.data() + l_Start, l_Len, rSelChanList);
412  std::vector<char>::iterator Separator = std::find(m_ReadBuffer.begin(), m_ReadBuffer.end(), ';');
413  FromBinaryChannelList(&*Separator + 1, static_cast<size_t>(m_ReadBuffer.end() - Separator), rActiveChan);
414  }
415  else
416  {
417  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
418  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
419  if (l_Tokens.size() != 2)
420  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
421  FromStringChannelList(l_Tokens[0].begin, l_Tokens[0].end, rSelChanList);
422  FromStringChannelList(l_Tokens[1].begin, l_Tokens[1].end, rActiveChan);
423  }
424  }
425  catch (CPT2026InsException & rE)
426  {
428  MTL_Unused(rE);
429  return false;
430  }
431  return true;
432 }
433 
435 {
436  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
437  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
438 
439  try {
440  std::string l_Command = ":ROUT:CLOS:LLIS";
441  l_Command += (State ? " 1" : " 0");
442  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
443  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
444  }
445  catch (CPT2026InsException & rE)
446  {
448  MTL_Unused(rE);
449  return false;
450  }
451  return true;
452 }
453 
455 {
456  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
457  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
458 
459  try {
460  if (!l_WriteAndRead(":ROUT:CLOS:LLIS?", m_ReadBuffer))
461  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
462 
463  std::string l_Answer(m_ReadBuffer.begin(), m_ReadBuffer.end());
464  if (l_Answer == "1")
465  rState = true;
466  else if (l_Answer == "0")
467  rState = false;
468  else
469  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
470  }
471  catch (CPT2026InsException & rE)
472  {
474  MTL_Unused(rE);
475  return false;
476  }
477  return true;
478 }
479 
481 {
482  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
483  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
484 
485  try {
486  std::string l_ChanList;
487  ToStringChannelList(rChanList, l_ChanList);
488  std::string l_Command = ":ROUT:CLOS " + l_ChanList;
489  if (!l_WriteAndRead(l_Command, m_ReadBuffer, true))
490  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
491  }
492  catch (CPT2026InsException & rE)
493  {
495  MTL_Unused(rE);
496  return false;
497  }
498  return true;
499 }
500 
501 bool CPT2026Instrument::ChannelsGetInfo(const tChannelList & rChanList, std::vector<sChannelIformation> & rChanInfo)
502 {
503  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
504  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
505 
506  rChanInfo.clear();
507 
508  try {
509  std::string l_ChanList;
510  ToStringChannelList(rChanList, l_ChanList);
511  std::string l_Command = ":ROUT:PROB:MOD? " + l_ChanList +
512  ";SER? " + l_ChanList +
513  ";DES? " + l_ChanList +
514  ";FWV? " + l_ChanList;
515  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
516  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
517 
518  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
519  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
520  if (l_Tokens.size() != 4)
521  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
522 
523  // Models
524  std::vector<std::string> l_Models;
525  SplitString(std::string(l_Tokens[0].begin, l_Tokens[0].end), l_Models, ',');
526  if (l_Models.size() != rChanList.size())
527  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
528  // Serial Numbers
529  std::vector<std::string> l_SNs;
530  SplitString(std::string(l_Tokens[1].begin, l_Tokens[1].end), l_SNs, ',');
531  if (l_SNs.size() != rChanList.size())
532  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
533  // Designations
534  std::vector<std::string> l_Des;
535  SplitString(std::string(l_Tokens[2].begin, l_Tokens[2].end), l_Des, ',');
536  if (l_Des.size() != rChanList.size())
537  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
538  // Firmware versions
539  std::vector<std::string> l_FWVs;
540  SplitString(std::string(l_Tokens[3].begin, l_Tokens[3].end), l_FWVs, ',');
541  if (l_FWVs.size() != rChanList.size())
542  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
543 
544  // Fill information
545  for (size_t l_ChanNo = 0; l_ChanNo < rChanList.size(); l_ChanNo++)
546  {
547  sChannelIformation ChanInfo(static_cast<tModel>(std::stoul(l_Models[l_ChanNo])), static_cast<tSerialNumber>(std::stoul(l_SNs[l_ChanNo])), l_Des[l_ChanNo], static_cast<tFirmwareVersion>(std::stoul(l_FWVs[l_ChanNo], nullptr, 16)));
548  rChanInfo.push_back(ChanInfo);
549  }
550  }
551  catch (CPT2026InsException & rE)
552  {
554  MTL_Unused(rE);
555  return false;
556  }
557  return true;
558 }
559 bool CPT2026Instrument::ChannelsGetLimits(const MTL::SCPI::tChannelList & rChanList, std::vector<F64> & rLowLimit_UNITS, std::vector<F64> & rHighLimit_UNITS)
560 {
561  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
562  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
563 
564  rLowLimit_UNITS.clear();
565  rHighLimit_UNITS.clear();
566 
567  try {
568  std::string l_ChanList;
569  ToStringChannelList(rChanList, l_ChanList);
570  std::string l_Command = ":ROUT:PROB:MIN? " + l_ChanList +
571  ";MAX? " + l_ChanList;
572  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
573  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
574 
575  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
576  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
577  if (l_Tokens.size() != 2)
578  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
579 
580  // Low Lomits
581  std::vector<std::string> l_LowLimits;
582  SplitString(std::string(l_Tokens[0].begin, l_Tokens[0].end), l_LowLimits, ',');
583  if (l_LowLimits.size() != rChanList.size())
584  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
585  // High Limits
586  std::vector<std::string> l_HighLimits;
587  SplitString(std::string(l_Tokens[1].begin, l_Tokens[1].end), l_HighLimits, ',');
588  if (l_HighLimits.size() != rChanList.size())
589  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
590 
591  // Fill information
592  for (size_t l_ChanNo = 0; l_ChanNo < rChanList.size(); l_ChanNo++)
593  {
594  rLowLimit_UNITS.push_back(std::stod(l_LowLimits[l_ChanNo]));
595  rHighLimit_UNITS.push_back(std::stod(l_HighLimits[l_ChanNo]));
596  }
597  }
598  catch (CPT2026InsException & rE)
599  {
601  MTL_Unused(rE);
602  return false;
603  }
604  return true;
605 }
607 {
608  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
609  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
610 
611  rRawHall.clear();
612 
613  try {
614  if (!l_WriteAndRead(":ROUT:PROB:HALL:RAW?", m_ReadBuffer, true))
615  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
616 
617  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
618  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize(',');
619  if (l_Tokens.size() != 4)
620  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
621 
622  rRawHall.Bx = static_cast<U8>(std::stoul(std::string(l_Tokens[0].begin, l_Tokens[0].end)));
623  rRawHall.Bz = static_cast<U8>(std::stoul(std::string(l_Tokens[2].begin, l_Tokens[2].end)));
624  rRawHall.By = static_cast<U8>(std::stoul(std::string(l_Tokens[1].begin, l_Tokens[1].end)));
625  rRawHall.T = static_cast<U8>(std::stoul(std::string(l_Tokens[3].begin, l_Tokens[3].end)));
626  }
627  catch (CPT2026InsException & rE)
628  {
630  MTL_Unused(rE);
631  return false;
632  }
633  return true;
634 }
636 {
637  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
638  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
639 
640  rHall.clear();
641 
642  try {
643  if (!l_WriteAndRead(":ROUT:PROB:HALL:CAL?", m_ReadBuffer, true))
644  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
645 
646  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
647  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize(',');
648  if (l_Tokens.size() != 4)
649  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
650 
651  rHall.Bx = std::stod(std::string(l_Tokens[0].begin, l_Tokens[0].end));
652  rHall.By = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
653  rHall.Bz = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
654  rHall.B = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
655  }
656  catch (CPT2026InsException & rE)
657  {
659  MTL_Unused(rE);
660  return false;
661  }
662  return true;
663 }
665 {
666  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
667  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
668 
669  try {
670  if (!l_WriteAndRead(":ROUT:PROB:REM:LEDM?", m_ReadBuffer))
671  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
672 
673  U8 l_ModeNumber = static_cast<U8>(std::stoul(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end())));
674  if (l_ModeNumber > MAX_BUSY_LED_MODE)
675  throw CPT2026InsException("Unexpected busy LED mode has been returned", MTL__LOCATION__);
676 
677  rMode = static_cast<eRemoteBusyLEDmode>(l_ModeNumber);
678  }
679  catch (CPT2026InsException & rE)
680  {
682  MTL_Unused(rE);
683  return false;
684  }
685  return true;
686 }
688 {
689  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
690  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
691 
692  std::string l_Command = ":ROUT:PROB:REM:LEDM " + std::to_string(Mode);
693  return l_WriteAndRead(l_Command, m_ReadBuffer);
694 }
695 
696 //----------------------------------------------------------------------//
697 // Parameters //
698 //----------------------------------------------------------------------//
700 {
701  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
702  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
703 
704  std::string l_Command;
705  switch (rSearch.Mode)
706  {
707  case kSearchAuto:
708  l_Command = ":CONF:SEAR:MODE AUTO"; // Mode
709  break;
710  case kSearchCustom:
711  l_Command = ":CONF:SEAR:MODE CUST"; // Mode
712  l_Command += ";LEV " + l_ToString(rSearch.DetectionLevel_V) + "V"; // Detection Level
713  l_Command += ";FSTE " + l_ToString(rSearch.FrequencyStep_Hz) + "HZ"; // Frequency Step
714  break;
715  case kSearchManual:
716  l_Command = ":CONF:SEAR:MODE MAN"; // Mode
717  l_Command += ";LEV " + l_ToString(rSearch.DetectionLevel_V) + "V"; // Detection Level
718  l_Command += ";VAL " + l_ToString(rSearch.ManualValue_UNITS); // Manual Value
719  break;
720  default:
721  MTL_Assert(false);
722  break;
723  }
724  l_Command += ";LOW " + l_ToString(rSearch.LowLimit_UNITS); // Low Limit
725  l_Command += ";HIGH " + l_ToString(rSearch.HighLimit_UNITS); // High Limit
726 
727  return l_WriteAndRead(l_Command, m_ReadBuffer);
728 }
730 {
731  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
732  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
733 
734  try {
735  if (!l_WriteAndRead( ":CONF:SEAR:MODE?"
736  ";LEV?"
737  ";FSTE?"
738  ";HIGH?"
739  ";LOW?"
740  ";VAL?",
741  m_ReadBuffer))
742  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
743 
744  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
745  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
746  if (l_Tokens.size() != 6)
747  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
748 
749  // Mode
750  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
751  if (l_Mode == "AUTO")
752  rSearch.Mode = kSearchAuto;
753  else if (l_Mode == "CUSTom")
754  rSearch.Mode = kSearchCustom;
755  else if (l_Mode == "MANual")
756  rSearch.Mode = kSearchManual;
757  else
758  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
759  // Detection Level
760  rSearch.DetectionLevel_V = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
761  // Frequency Step
762  rSearch.FrequencyStep_Hz = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
763  // High Limit
764  rSearch.HighLimit_UNITS = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
765  // Low Limit
766  rSearch.LowLimit_UNITS = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
767  // Manual Value
768  rSearch.ManualValue_UNITS = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
769  }
770  catch (CPT2026InsException & rE)
771  {
773  MTL_Unused(rE);
774  return false;
775  }
776  return true;
777 }
779 {
780  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
781  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
782 
783  try {
784  if (!l_WriteAndRead( ":CONF:SEAR:MODE?"
785  ";LEV?;LEV? MIN;LEV? MAX;LEV? DEF"
786  ";FSTE?;FSTE? MIN;FSTE? MAX;FSTE? DEF"
787  ";HIGH?;HIGH? MIN;HIGH? MAX;HIGH? DEF"
788  ";LOW?;LOW? MIN;LOW? MAX;LOW? DEF"
789  ";VAL?;VAL? MIN;VAL? MAX;VAL? DEF",
790  m_ReadBuffer))
791  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
792 
793  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
794  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
795  if (l_Tokens.size() != 21)
796  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
797 
798  // Mode
799  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
800  if (l_Mode == "AUTO")
801  rSearch.Mode = kSearchAuto;
802  else if (l_Mode == "CUSTom")
803  rSearch.Mode = kSearchCustom;
804  else if (l_Mode == "MANual")
805  rSearch.Mode = kSearchManual;
806  else
807  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
808  // Detection Level
809  rSearch.DetectionLevel_V.Val = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
810  rSearch.DetectionLevel_V.Min = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
811  rSearch.DetectionLevel_V.Max = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
812  rSearch.DetectionLevel_V.Def = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
813  // Frequency Step
814  rSearch.FrequencyStep_Hz.Val = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
815  rSearch.FrequencyStep_Hz.Min = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
816  rSearch.FrequencyStep_Hz.Max = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
817  rSearch.FrequencyStep_Hz.Def = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
818  // High Limit
819  rSearch.HighLimit_UNITS.Val = std::stod(std::string(l_Tokens[9].begin, l_Tokens[9].end));
820  rSearch.HighLimit_UNITS.Min = std::stod(std::string(l_Tokens[10].begin, l_Tokens[10].end));
821  rSearch.HighLimit_UNITS.Max = std::stod(std::string(l_Tokens[11].begin, l_Tokens[11].end));
822  rSearch.HighLimit_UNITS.Def = std::stod(std::string(l_Tokens[12].begin, l_Tokens[12].end));
823  // Low Limit
824  rSearch.LowLimit_UNITS.Val = std::stod(std::string(l_Tokens[13].begin, l_Tokens[13].end));
825  rSearch.LowLimit_UNITS.Min = std::stod(std::string(l_Tokens[14].begin, l_Tokens[14].end));
826  rSearch.LowLimit_UNITS.Max = std::stod(std::string(l_Tokens[15].begin, l_Tokens[15].end));
827  rSearch.LowLimit_UNITS.Def = std::stod(std::string(l_Tokens[16].begin, l_Tokens[16].end));
828  // Manual Value
829  rSearch.ManualValue_UNITS.Val = std::stod(std::string(l_Tokens[17].begin, l_Tokens[17].end));
830  rSearch.ManualValue_UNITS.Min = std::stod(std::string(l_Tokens[18].begin, l_Tokens[18].end));
831  rSearch.ManualValue_UNITS.Max = std::stod(std::string(l_Tokens[19].begin, l_Tokens[19].end));
832  rSearch.ManualValue_UNITS.Def = std::stod(std::string(l_Tokens[20].begin, l_Tokens[20].end));
833  }
834  catch (CPT2026InsException & rE)
835  {
837  MTL_Unused(rE);
838  return false;
839  }
840  return true;
841 }
843 {
844  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
845  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
846 
847  std::string l_Command = ":CONF:SEAR:VAL " + l_ToString(ManualValue_UNITS);
848 
849  return l_WriteAndRead(l_Command, m_ReadBuffer);
850 }
851 bool CPT2026Instrument::ParmSearchSetLimits(F64 LowLimit_UNITS, F64 HighLimit_UNITS)
852 {
853  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
854  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
855 
856  std::string l_Command = ":CONF:SEAR:LIM";
857  l_Command += ":LOW " + l_ToString(LowLimit_UNITS);
858  l_Command += ";HIGH " + l_ToString(HighLimit_UNITS);
859 
860  return l_WriteAndRead(l_Command, m_ReadBuffer);
861 }
863 {
864  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
865  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
866 
867  std::string l_Command = std::string(":CONF:SEAR:HALL ") + (Enabled ? "1" : "0");
868 
869  return l_WriteAndRead(l_Command, m_ReadBuffer);
870 }
872 {
873  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
874  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
875 
876  try {
877  if (!l_WriteAndRead(":CONF:SEAR:HALL?", m_ReadBuffer))
878  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
879 
880  std::string l_Answer(m_ReadBuffer.begin(), m_ReadBuffer.end());
881  if (l_Answer == "1")
882  rEnabled = true;
883  else if (l_Answer == "0")
884  rEnabled = false;
885  else
886  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
887  }
888  catch (CPT2026InsException & rE)
889  {
891  MTL_Unused(rE);
892  return false;
893  }
894  return true;
895 }
897 {
898  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
899  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
900 
901  std::string l_Command;
902  switch (rMeasure.Mode)
903  {
904  case kMeasureAuto:
905  l_Command = ":CONF:MEAS:MODE AUTO"; // Mode
906  break;
907  case kMeasureManual:
908  l_Command = ":CONF:MEAS:MODE MAN"; // Mode
909  l_Command += ";LEV " + l_ToString(rMeasure.DetectionLevel_V); // Detection Level
910  l_Command += ";HYST " + std::to_string(rMeasure.AllowedMissMeas); // Allowed Missing Measurements
911  l_Command += rMeasure.Reject ? ";REJ ON" : ";REJ OFF"; // Spurious Rejection
912  l_Command += ";BAND " + l_ToString(rMeasure.Bandwidth_Hz); // Spectrum Bandwidth
913  l_Command += ";POIN " + std::to_string(rMeasure.NoFitPoints); // Spectrum Points
914  l_Command += ";:CONF:TRAC:HYST " + std::to_string(rMeasure.Tracking.AllowedMissMeas); // Tracking Allowed Lost
915  l_Command += ";LOW " + l_ToString(rMeasure.Tracking.MinIF_Hz); // Tracking Low IF
916  l_Command += ";HIGH " + l_ToString(rMeasure.Tracking.MaxIF_Hz); // Tracking High IF
917  break;
918  default:
919  MTL_Assert(false);
920  break;
921  }
922 
923  return l_WriteAndRead(l_Command, m_ReadBuffer);
924 }
926 {
927  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
928  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
929 
930  try {
931  if (!l_WriteAndRead( ":CONF:MEAS:MODE?"
932  ";REJ?"
933  ";LEV?"
934  ";BAND?"
935  ";POIN?"
936  ";HYST?"
937  ";:CONF:TRAC:HYST?"
938  ";LOW?"
939  ";HIGH?",
940  m_ReadBuffer))
941  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
942 
943  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
944  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
945  if (l_Tokens.size() != 9)
946  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
947 
948  // Mode
949  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
950  if (l_Mode == "AUTO")
951  rMeasure.Mode = kMeasureAuto;
952  else if (l_Mode == "MANual")
953  rMeasure.Mode = kMeasureManual;
954  else
955  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
956  // Rejection
957  std::string l_Rejection(l_Tokens[1].begin, l_Tokens[1].end);
958  if (l_Rejection == "1")
959  rMeasure.Reject = true;
960  else if (l_Rejection == "0")
961  rMeasure.Reject = false;
962  else
963  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
964  // Detection Level
965  rMeasure.DetectionLevel_V = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
966  // Bandwidth
967  rMeasure.Bandwidth_Hz = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
968  // Fitting Points
969  rMeasure.NoFitPoints = static_cast<U32>(std::stol(std::string(l_Tokens[4].begin, l_Tokens[4].end)));
970  // Allowed Missing Measurements
971  rMeasure.AllowedMissMeas = static_cast<U32>(std::stol(std::string(l_Tokens[5].begin, l_Tokens[5].end)));
972  // Tracking Missing Measurements
973  rMeasure.Tracking.AllowedMissMeas = static_cast<U32>(std::stol(std::string(l_Tokens[6].begin, l_Tokens[6].end)));
974  // Tracking Min IF
975  rMeasure.Tracking.MinIF_Hz = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
976  // Tracking Max IF
977  rMeasure.Tracking.MaxIF_Hz = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
978  }
979  catch (CPT2026InsException & rE)
980  {
982  MTL_Unused(rE);
983  return false;
984  }
985  return true;
986 }
988 {
989  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
990  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
991 
992  try {
993  if (!l_WriteAndRead( ":CONF:MEAS:MODE?"
994  ";REJ?"
995  ";LEV?;LEV? MIN;LEV? MAX;LEV? DEF"
996  ";BAND?;BAND? MIN;BAND? MAX;BAND? DEF"
997  ";POIN?;POIN? MIN;POIN? MAX;POIN? DEF"
998  ";HYST?;HYST? MIN;HYST? MAX;HYST? DEF"
999  ";:CONF:TRAC:HYST?;HYST? MIN;HYST? MAX;HYST? DEF"
1000  ";LOW?;LOW? MIN;LOW? MAX;LOW? DEF"
1001  ";HIGH?;HIGH? MIN;HIGH? MAX;HIGH? DEF",
1002  m_ReadBuffer))
1003  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1004 
1005  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1006  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1007  if (l_Tokens.size() != 30)
1008  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1009 
1010  // Mode
1011  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
1012  if (l_Mode == "AUTO")
1013  rMeasure.Mode = kMeasureAuto;
1014  else if (l_Mode == "MANual")
1015  rMeasure.Mode = kMeasureManual;
1016  else
1017  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1018  // Rejection
1019  std::string l_Rejection(l_Tokens[1].begin, l_Tokens[1].end);
1020  if (l_Rejection == "1")
1021  rMeasure.Reject = true;
1022  else if (l_Rejection == "0")
1023  rMeasure.Reject = false;
1024  else
1025  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1026  // Detection Level
1027  rMeasure.DetectionLevel_V.Val = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1028  rMeasure.DetectionLevel_V.Min = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1029  rMeasure.DetectionLevel_V.Max = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
1030  rMeasure.DetectionLevel_V.Def = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
1031  // Bandwidth
1032  rMeasure.Bandwidth_Hz.Val = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
1033  rMeasure.Bandwidth_Hz.Min = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
1034  rMeasure.Bandwidth_Hz.Max = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
1035  rMeasure.Bandwidth_Hz.Def = std::stod(std::string(l_Tokens[9].begin, l_Tokens[9].end));
1036  // Fitting Points
1037  rMeasure.NoFitPoints.Val = static_cast<U32>(std::stol(std::string(l_Tokens[10].begin, l_Tokens[10].end)));
1038  rMeasure.NoFitPoints.Min = static_cast<U32>(std::stol(std::string(l_Tokens[11].begin, l_Tokens[11].end)));
1039  rMeasure.NoFitPoints.Max = static_cast<U32>(std::stol(std::string(l_Tokens[12].begin, l_Tokens[12].end)));
1040  rMeasure.NoFitPoints.Def = static_cast<U32>(std::stol(std::string(l_Tokens[13].begin, l_Tokens[13].end)));
1041  // Allowed Missing Measurements
1042  rMeasure.AllowedMissMeas.Val = static_cast<U32>(std::stol(std::string(l_Tokens[14].begin, l_Tokens[14].end)));
1043  rMeasure.AllowedMissMeas.Min = static_cast<U32>(std::stol(std::string(l_Tokens[15].begin, l_Tokens[15].end)));
1044  rMeasure.AllowedMissMeas.Max = static_cast<U32>(std::stol(std::string(l_Tokens[16].begin, l_Tokens[16].end)));
1045  rMeasure.AllowedMissMeas.Def = static_cast<U32>(std::stol(std::string(l_Tokens[17].begin, l_Tokens[17].end)));
1046  // Tracking Missing Measurements
1047  rMeasure.Tracking.AllowedMissMeas.Val = static_cast<U32>(std::stol(std::string(l_Tokens[18].begin, l_Tokens[18].end)));
1048  rMeasure.Tracking.AllowedMissMeas.Min = static_cast<U32>(std::stol(std::string(l_Tokens[19].begin, l_Tokens[19].end)));
1049  rMeasure.Tracking.AllowedMissMeas.Max = static_cast<U32>(std::stol(std::string(l_Tokens[20].begin, l_Tokens[20].end)));
1050  rMeasure.Tracking.AllowedMissMeas.Def = static_cast<U32>(std::stol(std::string(l_Tokens[21].begin, l_Tokens[21].end)));
1051  // Tracking Min IF
1052  rMeasure.Tracking.MinIF_Hz.Val = std::stod(std::string(l_Tokens[22].begin, l_Tokens[22].end));
1053  rMeasure.Tracking.MinIF_Hz.Min = std::stod(std::string(l_Tokens[23].begin, l_Tokens[23].end));
1054  rMeasure.Tracking.MinIF_Hz.Max = std::stod(std::string(l_Tokens[24].begin, l_Tokens[24].end));
1055  rMeasure.Tracking.MinIF_Hz.Def = std::stod(std::string(l_Tokens[25].begin, l_Tokens[25].end));
1056  // Tracking Max IF
1057  rMeasure.Tracking.MaxIF_Hz.Val = std::stod(std::string(l_Tokens[26].begin, l_Tokens[26].end));
1058  rMeasure.Tracking.MaxIF_Hz.Min = std::stod(std::string(l_Tokens[27].begin, l_Tokens[27].end));
1059  rMeasure.Tracking.MaxIF_Hz.Max = std::stod(std::string(l_Tokens[28].begin, l_Tokens[28].end));
1060  rMeasure.Tracking.MaxIF_Hz.Def = std::stod(std::string(l_Tokens[29].begin, l_Tokens[29].end));
1061  }
1062  catch (CPT2026InsException & rE)
1063  {
1065  MTL_Unused(rE);
1066  return false;
1067  }
1068  return true;
1069 }
1071 {
1072  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1073  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1074 
1075  std::string l_Command = ":AVERage1:STAT ";
1076  switch (rSigAvg.Type)
1077  {
1078  case kSigNone:
1079  l_Command += "OFF";
1080  break;
1081  case kSigExponential:
1082  l_Command += "ON" ";:AVERage1:TCON EXP";
1083  l_Command += ";:AVERage1:COUN " + std::to_string(rSigAvg.NoPoints);
1084  break;
1085  case kSigRepeat:
1086  l_Command += "ON" ";:AVERage1:TCON REP";
1087  l_Command += ";:AVERage1:COUN " + std::to_string(rSigAvg.NoPoints);
1088  break;
1089  default:
1090  MTL_Assert(false);
1091  break;
1092  }
1093 
1094  return l_WriteAndRead(l_Command, m_ReadBuffer);
1095 }
1097 {
1098  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1099  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1100 
1101  try {
1102  if (!l_WriteAndRead( ":AVERage1:STAT?"
1103  ";:AVERage1:TCON?"
1104  ";:AVERage1:COUN?",
1105  m_ReadBuffer))
1106  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1107 
1108  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1109  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1110  if (l_Tokens.size() != 3)
1111  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1112 
1113  // State
1114  std::string l_State(l_Tokens[0].begin, l_Tokens[0].end);
1115  enum { kInactive, kActive } l_eState;
1116  if (l_State == "0")
1117  l_eState = kInactive;
1118  else if (l_State == "1")
1119  l_eState = kActive;
1120  else
1121  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1122  // Type
1123  std::string l_Type(l_Tokens[1].begin, l_Tokens[1].end);
1124  enum { kExponential, kRepeat } l_eType;
1125  if (l_Type == "EXPonential")
1126  l_eType = kExponential;
1127  else if (l_Type == "REPeat")
1128  l_eType = kRepeat;
1129  else
1130  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1131 
1132  if (l_eState == kInactive)
1133  rSigAvg.Type = kSigNone;
1134  else if (l_eState == kActive)
1135  {
1136  if (l_eType == kExponential)
1137  rSigAvg.Type = kSigExponential;
1138  else if (l_eType == kRepeat)
1139  rSigAvg.Type = kSigRepeat;
1140  else
1141  MTL_Assert(false);
1142  }
1143  else
1144  MTL_Assert(false);
1145  // Count
1146  rSigAvg.NoPoints = static_cast<U32>(std::stoi(std::string(l_Tokens[2].begin, l_Tokens[2].end)));
1147  }
1148  catch (CPT2026InsException & rE)
1149  {
1151  MTL_Unused(rE);
1152  return false;
1153  }
1154  return true;
1155 }
1157 {
1158  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1159  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1160 
1161  try {
1162  if (!l_WriteAndRead( ":AVERage1:STAT?"
1163  ";:AVERage1:TCON?"
1164  ";:AVERage1:COUN?;:AVERage1:COUN? MIN;:AVERage1:COUN? MAX;:AVERage1:COUN? DEF",
1165  m_ReadBuffer))
1166  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1167 
1168  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1169  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1170  if (l_Tokens.size() != 6)
1171  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1172 
1173  // State
1174  std::string l_State(l_Tokens[0].begin, l_Tokens[0].end);
1175  enum { kInactive, kActive } l_eState;
1176  if (l_State == "0")
1177  l_eState = kInactive;
1178  else if (l_State == "1")
1179  l_eState = kActive;
1180  else
1181  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1182  // Type
1183  std::string l_Type(l_Tokens[1].begin, l_Tokens[1].end);
1184  enum { kExponential, kRepeat } l_eType;
1185  if (l_Type == "EXPonential")
1186  l_eType = kExponential;
1187  else if (l_Type == "REPeat")
1188  l_eType = kRepeat;
1189  else
1190  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1191 
1192  if (l_eState == kInactive)
1193  rSigAvg.Type = kSigNone;
1194  else if (l_eState == kActive)
1195  {
1196  if (l_eType == kExponential)
1197  rSigAvg.Type = kSigExponential;
1198  else if (l_eType == kRepeat)
1199  rSigAvg.Type = kSigRepeat;
1200  else
1201  MTL_Assert(false);
1202  }
1203  else
1204  MTL_Assert(false);
1205  // Count
1206  rSigAvg.NoPoints.Val = static_cast<U32>(std::stoi(std::string(l_Tokens[2].begin, l_Tokens[2].end)));
1207  rSigAvg.NoPoints.Min = static_cast<U32>(std::stoi(std::string(l_Tokens[3].begin, l_Tokens[3].end)));
1208  rSigAvg.NoPoints.Max = static_cast<U32>(std::stoi(std::string(l_Tokens[4].begin, l_Tokens[4].end)));
1209  rSigAvg.NoPoints.Def = static_cast<U32>(std::stoi(std::string(l_Tokens[5].begin, l_Tokens[5].end)));
1210  }
1211  catch (CPT2026InsException & rE)
1212  {
1214  MTL_Unused(rE);
1215  return false;
1216  }
1217  return true;
1218 }
1220 {
1221  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1222  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1223 
1224  std::string l_Command = ":AVERage2:STAT ";
1225  switch (rMeasAvg.Type)
1226  {
1227  case kMeasNone:
1228  l_Command += "OFF";
1229  break;
1230  case kMeasExponential:
1231  l_Command += "ON" ";:AVERage2:TCON EXP";
1232  l_Command += ";:AVERage2:COUN " + std::to_string(rMeasAvg.NoPoints);
1233  break;
1234  case kMeasMoving:
1235  l_Command += "ON" ";:AVERage2:TCON EXP";
1236  l_Command += ";:AVERage2:COUN " + std::to_string(rMeasAvg.NoPoints);
1237  break;
1238  case kMeasRepeat:
1239  l_Command += "ON" ";:AVERage2:TCON REP";
1240  l_Command += ";:AVERage2:COUN " + std::to_string(rMeasAvg.NoPoints);
1241  break;
1242  default:
1243  MTL_Assert(false);
1244  break;
1245  }
1246 
1247  return l_WriteAndRead(l_Command, m_ReadBuffer);
1248 }
1250 {
1251  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1252  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1253 
1254  try {
1255  if (!l_WriteAndRead( ":AVERage2:STAT?"
1256  ";:AVERage2:TCON?"
1257  ";:AVERage2:COUN?",
1258  m_ReadBuffer))
1259  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1260 
1261 
1262  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1263  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1264  if (l_Tokens.size() != 3)
1265  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1266 
1267  // State
1268  std::string l_State(l_Tokens[0].begin, l_Tokens[0].end);
1269  enum { kInactive, kActive } l_eState;
1270  if (l_State == "0")
1271  l_eState = kInactive;
1272  else if (l_State == "1")
1273  l_eState = kActive;
1274  else
1275  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1276  // Type
1277  std::string l_Type(l_Tokens[1].begin, l_Tokens[1].end);
1278  enum { kExponential, kMoving, kRepeat } l_eType;
1279  if (l_Type == "EXPonential")
1280  l_eType = kExponential;
1281  else if (l_Type == "MOVing")
1282  l_eType = kMoving;
1283  else if (l_Type == "REPeat")
1284  l_eType = kRepeat;
1285  else
1286  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1287 
1288  if (l_eState == kInactive)
1289  rMeasAvg.Type = kMeasNone;
1290  else if (l_eState == kActive)
1291  {
1292  if (l_eType == kExponential)
1293  rMeasAvg.Type = kMeasExponential;
1294  else if (l_eType == kMoving)
1295  rMeasAvg.Type = kMeasMoving;
1296  else if (l_eType == kRepeat)
1297  rMeasAvg.Type = kMeasRepeat;
1298  else
1299  MTL_Assert(false);
1300  }
1301  else
1302  MTL_Assert(false);
1303  // Count
1304  rMeasAvg.NoPoints = std::stoi(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1305  }
1306  catch (CPT2026InsException & rE)
1307  {
1309  MTL_Unused(rE);
1310  return false;
1311  }
1312  return true;
1313 }
1315 {
1316  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1317  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1318 
1319  try {
1320  if (!l_WriteAndRead( ":AVERage2:STAT?"
1321  ";:AVERage2:TCON?"
1322  ";:AVERage2:COUN?;:AVERage2:COUN? MIN;:AVERage2:COUN? MAX;:AVERage2:COUN? DEF",
1323  m_ReadBuffer))
1324  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1325 
1326  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1327  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1328  if (l_Tokens.size() != 6)
1329  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1330 
1331  // State
1332  std::string l_State(l_Tokens[0].begin, l_Tokens[0].end);
1333  enum { kInactive, kActive } l_eState;
1334  if (l_State == "0")
1335  l_eState = kInactive;
1336  else if (l_State == "1")
1337  l_eState = kActive;
1338  else
1339  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1340  // Type
1341  std::string l_Type(l_Tokens[1].begin, l_Tokens[1].end);
1342  enum { kExponential, kMoving, kRepeat } l_eType;
1343  if (l_Type == "EXPonential")
1344  l_eType = kExponential;
1345  else if (l_Type == "MOVing")
1346  l_eType = kMoving;
1347  else if (l_Type == "REPeat")
1348  l_eType = kRepeat;
1349  else
1350  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1351 
1352  if (l_eState == kInactive)
1353  rMeasAvg.Type = kMeasNone;
1354  else if (l_eState == kActive)
1355  {
1356  if (l_eType == kExponential)
1357  rMeasAvg.Type = kMeasExponential;
1358  else if (l_eType == kMoving)
1359  rMeasAvg.Type = kMeasMoving;
1360  else if (l_eType == kRepeat)
1361  rMeasAvg.Type = kMeasRepeat;
1362  else
1363  MTL_Assert(false);
1364  }
1365  else
1366  MTL_Assert(false);
1367  // Count
1368  rMeasAvg.NoPoints.Val = std::stoi(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1369  rMeasAvg.NoPoints.Min = std::stoi(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1370  rMeasAvg.NoPoints.Max = std::stoi(std::string(l_Tokens[4].begin, l_Tokens[4].end));
1371  rMeasAvg.NoPoints.Def = std::stoi(std::string(l_Tokens[5].begin, l_Tokens[5].end));
1372  }
1373  catch (CPT2026InsException & rE)
1374  {
1376  MTL_Unused(rE);
1377  return false;
1378  }
1379  return true;
1380 }
1382 {
1383  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1384  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1385 
1386  std::string l_Command = ":TRIG:SEQuence1:SOUR ";
1387  switch (rInputTrig.Source)
1388  {
1390  l_Command += "IMM";
1391  l_Command += ";COUN " + std::to_string(rInputTrig.Count);
1392  break;
1393  case kInputTrigSrceTimer:
1394  l_Command += "TIM";
1395  l_Command += ";COUN " + std::to_string(rInputTrig.Count);
1396  l_Command += ";TIM " + l_ToString(rInputTrig.Period_s);
1397  break;
1398  case kInputTrigSrceBus:
1399  l_Command += "BUS";
1400  l_Command += ";COUN " + std::to_string(rInputTrig.Count);
1401  break;
1403  l_Command += "EXT";
1404  l_Command += ";COUN " + std::to_string(rInputTrig.Count);
1405  switch (rInputTrig.Edge)
1406  {
1407  case kInputTrigEdgeRising:
1408  l_Command += ";SLOP POS";
1409  break;
1410  case kInputTrigEdgeFalling:
1411  l_Command += ";SLOP NEG";
1412  break;
1413  case kInputTrigEdgeBoth:
1414  l_Command += ";SLOP EITH";
1415  break;
1416  default:
1417  MTL_Assert(false);
1418  break;
1419  }
1420  break;
1421  default:
1422  MTL_Assert(false);
1423  break;
1424  }
1425 
1426  return l_WriteAndRead(l_Command, m_ReadBuffer);
1427 }
1429 {
1430  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1431  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1432 
1433  try {
1434  if (!l_WriteAndRead( ":TRIG:SEQuence1:SOUR?"
1435  ";TIM?"
1436  ";COUN?"
1437  ";SLOP?",
1438  m_ReadBuffer))
1439  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1440 
1441  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1442  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1443  if (l_Tokens.size() != 4)
1444  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1445 
1446  // Source
1447  std::string l_Source(l_Tokens[0].begin, l_Tokens[0].end);
1448  if (l_Source == "IMMediate")
1449  rInputTrig.Source = kInputTrigSrceImmediate;
1450  else if (l_Source == "TIMer")
1451  rInputTrig.Source = kInputTrigSrceTimer;
1452  else if (l_Source == "BUS")
1453  rInputTrig.Source = kInputTrigSrceBus;
1454  else if (l_Source == "EXTernal")
1455  rInputTrig.Source = kInputTrigSrceExternal;
1456  else
1457  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1458  // Period
1459  rInputTrig.Period_s = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
1460  // Trigger Count
1461  rInputTrig.Count = std::stoi(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1462  // Slope
1463  std::string l_Slope(l_Tokens[3].begin, l_Tokens[3].end);
1464  if (l_Slope == "POSitive")
1465  rInputTrig.Edge = kInputTrigEdgeRising;
1466  else if (l_Slope == "NEGative")
1467  rInputTrig.Edge = kInputTrigEdgeFalling;
1468  else if (l_Slope == "EITHer")
1469  rInputTrig.Edge = kInputTrigEdgeBoth;
1470  else
1471  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1472  }
1473  catch (CPT2026InsException & rE)
1474  {
1476  MTL_Unused(rE);
1477  return false;
1478  }
1479  return true;
1480 }
1482 {
1483  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1484  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1485 
1486  try {
1487  if (!l_WriteAndRead( ":TRIG:SEQuence1:SOUR?"
1488  ";TIM?;TIM? MIN;TIM? MAX;TIM? DEF"
1489  ";COUN?;COUN? MIN;COUN? MAX;COUN? DEF"
1490  ";SLOP?",
1491  m_ReadBuffer))
1492  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1493 
1494  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1495  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1496  if (l_Tokens.size() != 10)
1497  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1498 
1499  // Source
1500  std::string l_Source(l_Tokens[0].begin, l_Tokens[0].end);
1501  if (l_Source == "IMMediate")
1502  rInputTrig.Source = kInputTrigSrceImmediate;
1503  else if (l_Source == "TIMer")
1504  rInputTrig.Source = kInputTrigSrceTimer;
1505  else if (l_Source == "BUS")
1506  rInputTrig.Source = kInputTrigSrceBus;
1507  else if (l_Source == "EXTernal")
1508  rInputTrig.Source = kInputTrigSrceExternal;
1509  else
1510  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1511  // Period
1512  rInputTrig.Period_s.Val = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
1513  rInputTrig.Period_s.Min = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1514  rInputTrig.Period_s.Max = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1515  rInputTrig.Period_s.Def = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
1516  // Trigger Count
1517  rInputTrig.Count.Val = std::stoi(std::string(l_Tokens[5].begin, l_Tokens[5].end));
1518  rInputTrig.Count.Min = std::stoi(std::string(l_Tokens[6].begin, l_Tokens[6].end));
1519  rInputTrig.Count.Max = std::stoi(std::string(l_Tokens[7].begin, l_Tokens[7].end));
1520  rInputTrig.Count.Def = std::stoi(std::string(l_Tokens[8].begin, l_Tokens[8].end));
1521  // Slope
1522  std::string l_Slope(l_Tokens[9].begin, l_Tokens[9].end);
1523  if (l_Slope == "POSitive")
1524  rInputTrig.Edge = kInputTrigEdgeRising;
1525  else if (l_Slope == "NEGative")
1526  rInputTrig.Edge = kInputTrigEdgeFalling;
1527  else if (l_Slope == "EITHer")
1528  rInputTrig.Edge = kInputTrigEdgeBoth;
1529  else
1530  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1531  }
1532  catch (CPT2026InsException & rE)
1533  {
1535  MTL_Unused(rE);
1536  return false;
1537  }
1538  return true;
1539 }
1541 {
1542  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1543  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1544 
1545  std::string l_Command;
1546  switch (rOutputTrig.Mode)
1547  {
1548  case kOutputTrigShapeOFF:
1549  l_Command = ":OUTP:TRIG:STAT OFF";
1550  break;
1552  // Set trigerring conditions
1553  l_Command = ":TRIG:SEQuence2:LEV " + l_ToString(rOutputTrig.Level_UNITS);
1554  l_Command += ";:SLOP POS";
1555  // Set output signal parameters
1556  l_Command += ";:OUTP:TRIG:STAT ON"; // State
1557  l_Command += ";SHAP DC"; // Shape
1558  l_Command += (rOutputTrig.InvertedPolarity ? ";POL INV" : ";POL NORM"); // Polarity
1559  // Pulse Width
1560  l_Command += ";DEL " + l_ToString(rOutputTrig.OutputDelay_s); // Delay
1561  break;
1563  // Set trigerring conditions
1564  l_Command = ":TRIG:SEQuence2:LEV " + l_ToString(rOutputTrig.Level_UNITS);
1565  l_Command += ";:SLOP NEG";
1566  // Set output signal parameters
1567  l_Command += ";:OUTP:TRIG:STAT ON"; // State
1568  l_Command += ";SHAP DC"; // Shape
1569  l_Command += (rOutputTrig.InvertedPolarity ? ";POL INV" : ";POL NORM"); // Polarity
1570  // Pulse Width
1571  l_Command += ";DEL " + l_ToString(rOutputTrig.OutputDelay_s); // Delay
1572  break;
1574  // Set trigerring conditions
1575  l_Command = ":TRIG:SEQuence2:LEV " + l_ToString(rOutputTrig.Level_UNITS);
1576  l_Command += ";:SLOP POS";
1577  // Set output signal parameters
1578  l_Command += ";:OUTP:TRIG:STAT ON"; // State
1579  l_Command += ";SHAP PULS"; // Shape
1580  l_Command += (rOutputTrig.InvertedPolarity ? ";POL INV" : ";POL NORM"); // Polarity
1581  l_Command += ";WIDT " + l_ToString(rOutputTrig.PulseWidth_s); // Pulse Width
1582  l_Command += ";DEL " + l_ToString(rOutputTrig.OutputDelay_s); // Delay
1583  break;
1585  // Set trigerring conditions
1586  l_Command = ":TRIG:SEQuence2:LEV " + l_ToString(rOutputTrig.Level_UNITS);
1587  l_Command += ";:SLOP NEG";
1588  // Set output signal parameters
1589  l_Command += ";:OUTP:TRIG:STAT ON"; // State
1590  l_Command += ";SHAP PULS"; // Shape
1591  l_Command += (rOutputTrig.InvertedPolarity ? ";POL INV" : ";POL NORM"); // Polarity
1592  l_Command += ";WIDT " + l_ToString(rOutputTrig.PulseWidth_s); // Pulse Width
1593  l_Command += ";DEL " + l_ToString(rOutputTrig.OutputDelay_s); // Delay
1594  break;
1596  // Set trigerring conditions
1597  l_Command = ":TRIG:SEQuence2:LEV " + l_ToString(rOutputTrig.Level_UNITS);
1598  l_Command += ";:SLOP EITH";
1599  // Set output signal parameters
1600  l_Command += ";:OUTP:TRIG:STAT ON"; // State
1601  l_Command += ";SHAP PULS"; // Shape
1602  l_Command += (rOutputTrig.InvertedPolarity ? ";POL INV" : ";POL NORM"); // Polarity
1603  l_Command += ";WIDT " + l_ToString(rOutputTrig.PulseWidth_s); // Pulse Width
1604  l_Command += ";DEL " + l_ToString(rOutputTrig.OutputDelay_s); // Delay
1605  break;
1606  default:
1607  MTL_Assert(false);
1608  break;
1609  }
1610 
1611  return l_WriteAndRead(l_Command, m_ReadBuffer);
1612 }
1614 {
1615  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1616  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1617 
1618  try {
1619  if (!l_WriteAndRead( ":OUTP:TRIG:STAT?"
1620  ";POL?"
1621  ";WIDT?"
1622  ";DEL?"
1623  ";SHAP?"
1624  ";:TRIG:SEQuence2:SLOP?"
1625  ";LEV?",
1626  m_ReadBuffer))
1627  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1628 
1629  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1630  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1631  if (l_Tokens.size() != 7)
1632  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1633 
1634  // State
1635  std::string l_State(l_Tokens[0].begin, l_Tokens[0].end);
1636  enum {kInactive, kActive} l_eActive;
1637  if (l_State == "0")
1638  l_eActive = kInactive;
1639  else if (l_State == "1")
1640  l_eActive = kActive;
1641  else
1642  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1643  // Polarity
1644  std::string l_Polarity(l_Tokens[1].begin, l_Tokens[1].end);
1645  if (l_Polarity == "INVerted")
1646  rOutputTrig.InvertedPolarity = true;
1647  else if (l_Polarity == "NORMal")
1648  rOutputTrig.InvertedPolarity = false;
1649  else
1650  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1651  // Pulse Width
1652  rOutputTrig.PulseWidth_s = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1653  // Output Delay
1654  rOutputTrig.OutputDelay_s = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1655  // Shape
1656  std::string l_Shape(l_Tokens[4].begin, l_Tokens[4].end);
1657  enum { kDC, kPulse } l_eShape;
1658  if (l_Shape == "DC")
1659  l_eShape = kDC;
1660  else if (l_Shape == "PULSe")
1661  l_eShape = kPulse;
1662  else
1663  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1664  // Slope
1665  std::string l_Slope(l_Tokens[5].begin, l_Tokens[5].end);
1666  enum { kRising, kFalling, kEither } l_eSlope;
1667  if (l_Slope == "POSitive")
1668  l_eSlope = kRising;
1669  else if (l_Slope == "NEGative")
1670  l_eSlope = kFalling;
1671  else if (l_Slope == "EITHer")
1672  l_eSlope = kEither;
1673  else
1674  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1675  // Level
1676  rOutputTrig.Level_UNITS = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
1677  // Mode
1678  if (l_eActive == kActive)
1679  {
1680  if (l_eShape == kDC)
1681  {
1682  if (l_eSlope == kRising || l_eSlope == kEither)
1683  rOutputTrig.Mode = kOutputTrigShapeDCBGreaterThan;
1684  else
1685  rOutputTrig.Mode = kOutputTrigShapeDCBLowerThan;
1686  }
1687  else
1688  {
1689  if (l_eSlope == kRising)
1690  rOutputTrig.Mode = kOutputTrigShapePulseBRising;
1691  else if (l_eSlope == kFalling)
1692  rOutputTrig.Mode = kOutputTrigShapePulseBFalling;
1693  else
1694  rOutputTrig.Mode = kOutputTrigShapePulseBCrossing;
1695  }
1696  }
1697  else
1698  rOutputTrig.Mode = kOutputTrigShapeOFF;
1699  }
1700  catch (CPT2026InsException & rE)
1701  {
1703  MTL_Unused(rE);
1704  return false;
1705  }
1706  return true;
1707 }
1709 {
1710  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1711  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1712 
1713  try {
1714  if (!l_WriteAndRead( ":OUTP:TRIG:STAT?"
1715  ";POL?"
1716  ";WIDT?;WIDT? MIN;WIDT? MAX;WIDT? DEF"
1717  ";DEL?;DEL? MIN;DEL? MAX;DEL? DEF"
1718  ";SHAP?"
1719  ";:TRIG:SEQuence2:SLOP?"
1720  ";LEV?;LEV? MIN ;LEV? MAX;LEV? DEF",
1721  m_ReadBuffer))
1722  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1723 
1724  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1725  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1726  if (l_Tokens.size() != 16)
1727  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1728 
1729  // State
1730  std::string l_State(l_Tokens[0].begin, l_Tokens[0].end);
1731  enum { kInactive, kActive } l_eActive;
1732  if (l_State == "0")
1733  l_eActive = kInactive;
1734  else if (l_State == "1")
1735  l_eActive = kActive;
1736  else
1737  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1738  // Polarity
1739  std::string l_Polarity(l_Tokens[1].begin, l_Tokens[1].end);
1740  if (l_Polarity == "INVerted")
1741  rOutputTrig.InvertedPolarity = true;
1742  else if (l_Polarity == "NORMal")
1743  rOutputTrig.InvertedPolarity = false;
1744  else
1745  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1746  // Pulse Width
1747  rOutputTrig.PulseWidth_s.Val = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1748  rOutputTrig.PulseWidth_s.Min = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1749  rOutputTrig.PulseWidth_s.Max = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
1750  rOutputTrig.PulseWidth_s.Def = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
1751  // Output Delay
1752  rOutputTrig.OutputDelay_s.Val = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
1753  rOutputTrig.OutputDelay_s.Min = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
1754  rOutputTrig.OutputDelay_s.Max = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
1755  rOutputTrig.OutputDelay_s.Def = std::stod(std::string(l_Tokens[9].begin, l_Tokens[9].end));
1756  // Shape
1757  std::string l_Shape(l_Tokens[10].begin, l_Tokens[10].end);
1758  enum { kDC, kPulse } l_eShape;
1759  if (l_Shape == "DC")
1760  l_eShape = kDC;
1761  else if (l_Shape == "PULSe")
1762  l_eShape = kPulse;
1763  else
1764  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1765  // Slope
1766  std::string l_Slope(l_Tokens[11].begin, l_Tokens[11].end);
1767  enum { kRising, kFalling, kEither } l_eSlope;
1768  if (l_Slope == "POSitive")
1769  l_eSlope = kRising;
1770  else if (l_Slope == "NEGative")
1771  l_eSlope = kFalling;
1772  else if (l_Slope == "EITHer")
1773  l_eSlope = kEither;
1774  else
1775  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1776  // Level
1777  rOutputTrig.Level_UNITS.Val = std::stod(std::string(l_Tokens[12].begin, l_Tokens[12].end));
1778  rOutputTrig.Level_UNITS.Min = std::stod(std::string(l_Tokens[13].begin, l_Tokens[13].end));
1779  rOutputTrig.Level_UNITS.Max = std::stod(std::string(l_Tokens[14].begin, l_Tokens[14].end));
1780  rOutputTrig.Level_UNITS.Def = std::stod(std::string(l_Tokens[15].begin, l_Tokens[15].end));
1781  // Mode
1782  if (l_eActive == kActive)
1783  {
1784  if (l_eShape == kDC)
1785  {
1786  if (l_eSlope == kRising || l_eSlope == kEither)
1787  rOutputTrig.Mode = kOutputTrigShapeDCBGreaterThan;
1788  else
1789  rOutputTrig.Mode = kOutputTrigShapeDCBLowerThan;
1790  }
1791  else
1792  {
1793  if (l_eSlope == kRising)
1794  rOutputTrig.Mode = kOutputTrigShapePulseBRising;
1795  else if (l_eSlope == kFalling)
1796  rOutputTrig.Mode = kOutputTrigShapePulseBFalling;
1797  else
1798  rOutputTrig.Mode = kOutputTrigShapePulseBCrossing;
1799  }
1800  }
1801  else
1802  rOutputTrig.Mode = kOutputTrigShapeOFF;
1803  }
1804  catch (CPT2026InsException & rE)
1805  {
1807  MTL_Unused(rE);
1808  return false;
1809  }
1810  return true;
1811 }
1813 {
1814  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1815  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1816 
1817  std::string l_Command;
1818  switch (rPulse.Mode)
1819  {
1820  case kPulseAuto:
1821  l_Command = ":SOUR:PULS:MODE AUTO";
1822  break;
1823  case kPulseManual:
1824  l_Command = ":SOUR:PULS:MODE MAN";
1825  l_Command += ";PER " + l_ToString(rPulse.Period_s); // Period
1826  l_Command += ";WIDT " + l_ToString(rPulse.Width_s); // Width
1827  break;
1828  default:
1829  MTL_Assert(false);
1830  break;
1831  }
1832 
1833  return l_WriteAndRead(l_Command, m_ReadBuffer);
1834 }
1836 {
1837  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1838  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1839 
1840  try {
1841  if (!l_WriteAndRead( ":SOUR:PULS:MODE?"
1842  ";PER?"
1843  ";WIDT?",
1844  m_ReadBuffer))
1845  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1846 
1847  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1848  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1849  if (l_Tokens.size() != 3)
1850  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1851 
1852  // Mode
1853  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
1854  if (l_Mode == "AUTO")
1855  rPulse.Mode = kPulseAuto;
1856  else if (l_Mode == "MANual")
1857  rPulse.Mode = kPulseManual;
1858  else
1859  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1860  // Period
1861  rPulse.Period_s = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
1862  // Width
1863  rPulse.Width_s = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1864  }
1865  catch (CPT2026InsException & rE)
1866  {
1868  MTL_Unused(rE);
1869  return false;
1870  }
1871  return true;
1872 }
1874 {
1875  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1876  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1877 
1878  try {
1879  if (!l_WriteAndRead( ":SOUR:PULS:MODE?"
1880  ";PER?;PER? MIN;PER? MAX;PER? DEF"
1881  ";WIDT?;WIDT? MIN;WIDT? MAX;WIDT? DEF",
1882  m_ReadBuffer))
1883  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1884 
1885  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1886  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1887  if (l_Tokens.size() != 9)
1888  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1889 
1890  // Mode
1891  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
1892  if (l_Mode == "AUTO")
1893  rPulse.Mode = kPulseAuto;
1894  else if (l_Mode == "MANual")
1895  rPulse.Mode = kPulseManual;
1896  else
1897  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1898  // Period
1899  rPulse.Period_s.Val = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
1900  rPulse.Period_s.Min = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1901  rPulse.Period_s.Max = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1902  rPulse.Period_s.Def = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
1903  // Width
1904  rPulse.Width_s.Val = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
1905  rPulse.Width_s.Min = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
1906  rPulse.Width_s.Max = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
1907  rPulse.Width_s.Def = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
1908  }
1909  catch (CPT2026InsException & rE)
1910  {
1912  MTL_Unused(rE);
1913  return false;
1914  }
1915  return true;
1916 }
1918 {
1919  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1920  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1921 
1922  std::string l_Command;
1923  switch (rDigitization.Mode)
1924  {
1925  case kDigitizationAuto:
1926  l_Command = ":SENS:SWE:MODE AUTO"; // Mode
1927  break;
1928  case kDigitizationManual:
1929  l_Command = ":SENS:SWE:MODE MAN"; // Mode
1930  l_Command += "TIME " + l_ToString(rDigitization.SweepTime_s); // Sweep Time
1931  l_Command += "FREQ " + l_ToString(rDigitization.Rate_Hz); // Dead Time// Rate
1932  l_Command += "OFFS:TIME " + l_ToString(rDigitization.DeadTime_s); // Dead Time
1933  break;
1934  default:
1935  MTL_Assert(false);
1936  break;
1937  }
1938 
1939  return l_WriteAndRead(l_Command, m_ReadBuffer);
1940 }
1942 {
1943  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1944  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1945 
1946  try {
1947  if (!l_WriteAndRead( ":SENS:SWE:MODE?"
1948  ";TIME?"
1949  ";FREQ?"
1950  ";OFFS:TIME?",
1951  m_ReadBuffer))
1952  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1953 
1954  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1955  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1956  if (l_Tokens.size() != 4)
1957  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1958 
1959  // Mode
1960  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
1961  if (l_Mode == "AUTO")
1962  rDigitization.Mode = kDigitizationAuto;
1963  else if (l_Mode == "MANual")
1964  rDigitization.Mode = kDigitizationManual;
1965  else
1966  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
1967  // Sweep Time
1968  rDigitization.SweepTime_s = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
1969  // Digitization rate
1970  rDigitization.Rate_Hz = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
1971  // Hold Off
1972  rDigitization.DeadTime_s = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
1973  }
1974  catch (CPT2026InsException & rE)
1975  {
1977  MTL_Unused(rE);
1978  return false;
1979  }
1980  return true;
1981 }
1983 {
1984  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
1985  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
1986 
1987  try {
1988  if (!l_WriteAndRead( ":SENS:SWE:MODE?"
1989  ";TIME?;TIME? MIN;TIME? MAX;TIME? DEF"
1990  ";FREQ?;FREQ? MIN;FREQ? MAX;FREQ? DEF"
1991  ";OFFS:TIME?;TIME? MIN;TIME? MAX;TIME? DEF",
1992  m_ReadBuffer))
1993  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
1994 
1995  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
1996  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
1997  if (l_Tokens.size() != 13)
1998  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
1999 
2000  // Mode
2001  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
2002  if (l_Mode == "AUTO")
2003  rDigitization.Mode = kDigitizationAuto;
2004  else if (l_Mode == "MANual")
2005  rDigitization.Mode = kDigitizationManual;
2006  else
2007  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2008  // Sweep Time
2009  rDigitization.SweepTime_s.Val = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
2010  rDigitization.SweepTime_s.Min = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
2011  rDigitization.SweepTime_s.Max = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
2012  rDigitization.SweepTime_s.Def = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
2013  // Digitization rate
2014  rDigitization.Rate_Hz.Val = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
2015  rDigitization.Rate_Hz.Min = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
2016  rDigitization.Rate_Hz.Max = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
2017  rDigitization.Rate_Hz.Def = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
2018  // Hold Off
2019  rDigitization.DeadTime_s.Val = std::stod(std::string(l_Tokens[9].begin, l_Tokens[9].end));
2020  rDigitization.DeadTime_s.Min = std::stod(std::string(l_Tokens[10].begin, l_Tokens[10].end));
2021  rDigitization.DeadTime_s.Max = std::stod(std::string(l_Tokens[11].begin, l_Tokens[11].end));
2022  rDigitization.DeadTime_s.Def = std::stod(std::string(l_Tokens[12].begin, l_Tokens[12].end));
2023  }
2024  catch (CPT2026InsException & rE)
2025  {
2027  MTL_Unused(rE);
2028  return false;
2029  }
2030  return true;
2031 }
2033 {
2034  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2035  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2036 
2037  std::string l_Command = ":CONF:PROB:MODE ";
2038  switch (rMatchingTuning.Mode)
2039  {
2040  case kMatchTunAuto:
2041  l_Command += "AUTO";
2042  break;
2043  case kMatchTunManual:
2044  l_Command += "MAN;MATC " + l_ToString(rMatchingTuning.Matching) + ";TUN " + l_ToString(rMatchingTuning.Tuning) + " V";
2045  break;
2046  default:
2047  MTL_Assert(false);
2048  break;
2049  }
2050 
2051  return l_WriteAndRead(l_Command, m_ReadBuffer);
2052 }
2054 {
2055  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2056  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2057 
2058  try {
2059  if (!l_WriteAndRead( ":CONF:PROB:MODE?"
2060  ";MATC?"
2061  ";TUN?",
2062  m_ReadBuffer))
2063  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2064 
2065  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2066  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
2067  if (l_Tokens.size() != 3)
2068  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
2069 
2070  // Mode
2071  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
2072  if (l_Mode == "AUTO")
2073  rMatchingTuning.Mode = kMatchTunAuto;
2074  else if (l_Mode == "MANual")
2075  rMatchingTuning.Mode = kMatchTunManual;
2076  else
2077  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2078  // Matching
2079  rMatchingTuning.Matching = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
2080  // Tuning
2081  rMatchingTuning.Tuning = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
2082  }
2083  catch (CPT2026InsException & rE)
2084  {
2086  MTL_Unused(rE);
2087  return false;
2088  }
2089  return true;
2090 }
2092 {
2093  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2094  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2095 
2096  try {
2097  if (!l_WriteAndRead( ":CONF:PROB:MODE?"
2098  ";MATC?;MATC? MIN;MATC? MAX;MATC? DEF"
2099  ";TUN?;TUN? MIN;TUN? MAX;TUN? DEF",
2100  m_ReadBuffer))
2101  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2102 
2103  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2104  CVISABufferParser::tTokens l_Tokens = l_BP.Tokenize();
2105  if (l_Tokens.size() != 9)
2106  throw CPT2026InsException("Invalid number of tokens in answer", MTL__LOCATION__);
2107 
2108  // Mode
2109  std::string l_Mode(l_Tokens[0].begin, l_Tokens[0].end);
2110  if (l_Mode == "AUTO")
2111  rMatchingTuning.Mode = kMatchTunAuto;
2112  else if (l_Mode == "MANual")
2113  rMatchingTuning.Mode = kMatchTunManual;
2114  else
2115  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2116  // Matching
2117  rMatchingTuning.Matching.Val = std::stod(std::string(l_Tokens[1].begin, l_Tokens[1].end));
2118  rMatchingTuning.Matching.Min = std::stod(std::string(l_Tokens[2].begin, l_Tokens[2].end));
2119  rMatchingTuning.Matching.Max = std::stod(std::string(l_Tokens[3].begin, l_Tokens[3].end));
2120  rMatchingTuning.Matching.Def = std::stod(std::string(l_Tokens[4].begin, l_Tokens[4].end));
2121  // Tuning
2122  rMatchingTuning.Tuning.Val = std::stod(std::string(l_Tokens[5].begin, l_Tokens[5].end));
2123  rMatchingTuning.Tuning.Min = std::stod(std::string(l_Tokens[6].begin, l_Tokens[6].end));
2124  rMatchingTuning.Tuning.Max = std::stod(std::string(l_Tokens[7].begin, l_Tokens[7].end));
2125  rMatchingTuning.Tuning.Def = std::stod(std::string(l_Tokens[8].begin, l_Tokens[8].end));
2126  }
2127  catch (CPT2026InsException & rE)
2128  {
2130  MTL_Unused(rE);
2131  return false;
2132  }
2133  return true;
2134 }
2136 {
2137  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2138  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2139 
2140  std::string l_Command = ":UNIT " + UnitsToString(Units);
2141 
2142  return l_WriteAndRead(l_Command, m_ReadBuffer);
2143 }
2145 {
2146  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2147  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2148 
2149  std::string l_Command = ":UNIT:PPMR " + l_ToString(Ref);
2150 
2151  return l_WriteAndRead(l_Command, m_ReadBuffer);
2152 }
2154 {
2155  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2156  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2157 
2158  try {
2159  if (!l_WriteAndRead(":UNIT?;:UNIT:PPMR?", m_ReadBuffer))
2160  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2161 
2162  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2163  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
2164  // Units
2165  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2166  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2167  std::string l_Answer(l_tokenbeg, l_tokenend);
2168  if (!StringToUnits(l_Answer, rUnits))
2169  throw CPT2026InsException("Invalid response format", MTL__LOCATION__);
2170  // PPM Reference
2171  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2172  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2173  l_Answer.assign(l_tokenbeg, l_tokenend);
2174  rRef = std::stod(l_Answer);
2175  }
2176  catch (CPT2026InsException & rE)
2177  {
2179  MTL_Unused(rE);
2180  return false;
2181  }
2182  return true;
2183 }
2185 {
2186  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2187  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2188 
2189  std::string l_Command = ":INP:CLOC ";
2190  switch (RefClock)
2191  {
2192  case kRefClockInternal:
2193  l_Command += "INT";
2194  break;
2195  case kRefClockExternal:
2196  l_Command += "EXT";
2197  break;
2198  default:
2199  MTL_Assert(false);
2200  break;
2201  }
2202 
2203  return l_WriteAndRead(l_Command, m_ReadBuffer);
2204 }
2206 {
2207  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2208  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2209 
2210  try {
2211  if (!l_WriteAndRead(":INP:CLOC:SOUR?",m_ReadBuffer))
2212  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2213 
2214  // Clock source
2215  std::string l_Answer(m_ReadBuffer.begin(), m_ReadBuffer.end());
2216  if (l_Answer == "INTernal")
2217  rRefClock = kRefClockInternal;
2218  else if (l_Answer == "EXTernal")
2219  rRefClock = kRefClockExternal;
2220  else
2221  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2222  }
2223  catch (CPT2026InsException & rE)
2224  {
2226  MTL_Unused(rE);
2227  return false;
2228  }
2229  return true;
2230 }
2232 {
2233  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2234  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2235 
2236  try {
2237  std::string l_Command = std::string(":SYST:COMM:USBT:ENAB ") + (Enabled ? "1" : "0");
2238  if (!l_WriteAndRead(l_Command , m_ReadBuffer))
2239  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2240  }
2241  catch (CPT2026InsException & rE)
2242  {
2244  MTL_Unused(rE);
2245  return false;
2246  }
2247  return true;
2248 }
2250 {
2251  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2252  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2253 
2254  try {
2255  if (!l_WriteAndRead(":SYST:COMM:USBT:ENAB?", m_ReadBuffer))
2256  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2257 
2258  std::string l_Answer(m_ReadBuffer.begin(), m_ReadBuffer.end());
2259  if (l_Answer.empty())
2260  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2261  else if (l_Answer[0] == '0')
2262  rEnabled = false;
2263  else if (l_Answer[0] == '1')
2264  rEnabled = true;
2265  else
2266  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2267  }
2268  catch (CPT2026InsException & rE)
2269  {
2271  MTL_Unused(rE);
2272  return false;
2273  }
2274  return true;
2275 }
2277 {
2278  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2279  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2280 
2281  try {
2282  std::string l_Command(":SYST:COMM:ETH");
2283  l_Command += rSettings.Enabled ? ":ENAB 1" : ":ENAB 0";
2284  l_Command += ";ADDR " + uIPAddress_to_string(rSettings.IP);
2285  l_Command += ";MASK " + uIPAddress_to_string(rSettings.Mask);
2286  l_Command += ";DOM " + rSettings.Domain;
2287  l_Command += ";BRO " + uIPAddress_to_string(rSettings.Broadcast);
2288  l_Command += ";GAT " + uIPAddress_to_string(rSettings.Gateway);
2289  l_Command += ";DNSS " + uIPAddress_to_string(rSettings.DNSServer);
2290  l_Command += std::string(";NBNS ") + (rSettings.NBNSEnabled ? "1" : "0");
2291  l_Command += ";IDEN " + rSettings.Identifier;
2292 
2293  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2294  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2295  }
2296  catch (CPT2026InsException & rE)
2297  {
2299  MTL_Unused(rE);
2300  return false;
2301  }
2302  return true;
2303 }
2305 {
2306  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2307  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2308 
2309  try {
2310  if (!l_WriteAndRead( ":SYST:COMM:ETH:ENAB?"
2311  ";ADDR?"
2312  ";MASK?"
2313  ";DOM?"
2314  ";BRO?"
2315  ";GAT?"
2316  ";DNSS?"
2317  ";NBNS?"
2318  ";IDEN?"
2319  , m_ReadBuffer))
2320  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2321 
2322  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2323  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
2324  // Enable
2325  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2326  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2327  std::string l_Enable(l_tokenbeg, l_tokenend);
2328  if (l_Enable.empty())
2329  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2330  else if (l_Enable[0] == '0')
2331  rSettings.Enabled = false;
2332  else if (l_Enable[0] == '1')
2333  rSettings.Enabled = true;
2334  else
2335  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2336  // IP Address
2337  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2338  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2339  std::string l_IPAddress(l_tokenbeg, l_tokenend);
2340  std::match_results<std::string::const_iterator> l_IPmatch;
2341  if (!std::regex_match(l_IPAddress, l_IPmatch, std::regex("^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})")))
2342  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2343  rSettings.IP.Member.A = static_cast<U8>(std::stoul(l_IPmatch[1]));
2344  rSettings.IP.Member.B = static_cast<U8>(std::stoul(l_IPmatch[2]));
2345  rSettings.IP.Member.C = static_cast<U8>(std::stoul(l_IPmatch[3]));
2346  rSettings.IP.Member.D = static_cast<U8>(std::stoul(l_IPmatch[4]));
2347  // Mask
2348  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2349  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2350  std::string l_Mask(l_tokenbeg, l_tokenend);
2351  std::match_results<std::string::const_iterator> l_Maskmatch;
2352  if (!std::regex_match(l_Mask, l_Maskmatch, std::regex("^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})")))
2353  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2354  rSettings.Mask.Member.A = static_cast<U8>(std::stoul(l_Maskmatch[1]));
2355  rSettings.Mask.Member.B = static_cast<U8>(std::stoul(l_Maskmatch[2]));
2356  rSettings.Mask.Member.C = static_cast<U8>(std::stoul(l_Maskmatch[3]));
2357  rSettings.Mask.Member.D = static_cast<U8>(std::stoul(l_Maskmatch[4]));
2358  // Domain
2359  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2360  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2361  rSettings.Domain = std::string(l_tokenbeg, l_tokenend);
2362  // Broadcast
2363  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2364  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2365  std::string l_Broadcast(l_tokenbeg, l_tokenend);
2366  std::match_results<std::string::const_iterator> l_Broadcastmatch;
2367  if (!std::regex_match(l_Broadcast, l_Broadcastmatch, std::regex("^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})")))
2368  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2369  rSettings.Broadcast.Member.A = static_cast<U8>(std::stoul(l_Broadcastmatch[1]));
2370  rSettings.Broadcast.Member.B = static_cast<U8>(std::stoul(l_Broadcastmatch[2]));
2371  rSettings.Broadcast.Member.C = static_cast<U8>(std::stoul(l_Broadcastmatch[3]));
2372  rSettings.Broadcast.Member.D = static_cast<U8>(std::stoul(l_Broadcastmatch[4]));
2373  // Gateway
2374  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2375  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2376  std::string l_Gateway(l_tokenbeg, l_tokenend);
2377  std::match_results<std::string::const_iterator> l_Gatewaymatch;
2378  if (!std::regex_match(l_Gateway, l_Gatewaymatch, std::regex("^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})")))
2379  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2380  rSettings.Gateway.Member.A = static_cast<U8>(std::stoul(l_Gatewaymatch[1]));
2381  rSettings.Gateway.Member.B = static_cast<U8>(std::stoul(l_Gatewaymatch[2]));
2382  rSettings.Gateway.Member.C = static_cast<U8>(std::stoul(l_Gatewaymatch[3]));
2383  rSettings.Gateway.Member.D = static_cast<U8>(std::stoul(l_Gatewaymatch[4]));
2384  // DNS Server
2385  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2386  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2387  std::string l_DNS(l_tokenbeg, l_tokenend);
2388  std::match_results<std::string::const_iterator> l_DNSmatch;
2389  if (!std::regex_match(l_DNS, l_DNSmatch, std::regex("^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})")))
2390  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2391  rSettings.DNSServer.Member.A = static_cast<U8>(std::stoul(l_DNSmatch[1]));
2392  rSettings.DNSServer.Member.B = static_cast<U8>(std::stoul(l_DNSmatch[2]));
2393  rSettings.DNSServer.Member.C = static_cast<U8>(std::stoul(l_DNSmatch[3]));
2394  rSettings.DNSServer.Member.D = static_cast<U8>(std::stoul(l_DNSmatch[4]));
2395  // NBNS Enable
2396  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2397  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2398  std::string l_NBNSEnab(l_tokenbeg, l_tokenend);
2399  if (l_NBNSEnab.empty())
2400  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2401  else if (l_NBNSEnab[0] == '0')
2402  rSettings.NBNSEnabled = false;
2403  else if (l_NBNSEnab[0] == '1')
2404  rSettings.NBNSEnabled = true;
2405  else
2406  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2407  // Identifier
2408  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2409  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2410  rSettings.Identifier = std::string(l_tokenbeg, l_tokenend);
2411  }
2412  catch (CPT2026InsException & rE)
2413  {
2415  MTL_Unused(rE);
2416  return false;
2417  }
2418  return true;
2419 }
2421 {
2422  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2423  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2424 
2425  try {
2426  std::string l_Command = std::string(":SYST:COMM:VXI11:ENAB ") + (Enabled ? "1" : "0");
2427  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2428  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2429  }
2430  catch (CPT2026InsException & rE)
2431  {
2433  MTL_Unused(rE);
2434  return false;
2435  }
2436  return true;
2437 }
2439 {
2440  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2441  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2442 
2443  try {
2444  if (!l_WriteAndRead(":SYST:COMM:VXI11:ENAB?", m_ReadBuffer))
2445  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2446 
2447  std::string l_Answer(m_ReadBuffer.begin(), m_ReadBuffer.end());
2448  if (l_Answer.empty())
2449  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2450  else if (l_Answer[0] == '0')
2451  rEnabled = false;
2452  else if (l_Answer[0] == '1')
2453  rEnabled = true;
2454  else
2455  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
2456  }
2457  catch (CPT2026InsException & rE)
2458  {
2460  MTL_Unused(rE);
2461  return false;
2462  }
2463  return true;
2464 }
2465 
2466 //----------------------------------------------------------------------//
2467 // Settings / Files //
2468 //----------------------------------------------------------------------//
2469 bool CPT2026Instrument::ReadFileDirectory(U32 & rUsedBytes, U32 & rAvailableBytes, tFileList & rFileList)
2470 {
2471  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2472  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2473 
2474  rFileList.clear();
2475 
2476  try {
2477  if (!l_WriteAndRead(":MMEM:CAT?", m_ReadBuffer))
2478  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2479 
2480  // Parse results
2481  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2482  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
2483 
2484  // Used Bytes
2485  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
2486  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2487  rUsedBytes = static_cast<U32>(std::stoul(std::string(l_tokenbeg, l_tokenend)));
2488  // Available Bytes
2489  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
2490  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2491  rAvailableBytes = static_cast<U32>(std::stoul(std::string(l_tokenbeg, l_tokenend)));
2492  // File List
2493  while (l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
2494  {
2495  sFile l_File;
2496  // Path
2497  l_File.Path = std::string(l_tokenbeg, l_tokenend);
2498  // Type
2499  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
2500  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2501  l_File.Type = std::string(l_tokenbeg, l_tokenend);
2502  // Size
2503  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
2504  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2505  l_File.Size = std::stoul(std::string(l_tokenbeg, l_tokenend));
2506  // Add file to the list
2507  rFileList.push_back(l_File);
2508  }
2509  } // try
2510  catch (CPT2026InsException & rE)
2511  {
2513  MTL_Unused(rE);
2514  return false;
2515  }
2516  return true;
2517 }
2518 bool CPT2026Instrument::ReadFile(std::string Path, std::string & rContent)
2519 {
2520  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2521  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2522 
2523  try {
2524  std::string l_Command;
2525  l_Command = ":MMEM:DATA? " "\"" + Path + "\"";
2526  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2527  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2528 
2529  rContent = std::string(m_ReadBuffer.begin(), m_ReadBuffer.end());
2530  } // try
2531  catch (CPT2026InsException & rE)
2532  {
2534  MTL_Unused(rE);
2535  return false;
2536  }
2537  return true;
2538 }
2539 bool CPT2026Instrument::WriteFile(std::string Path, const std::string & rContent)
2540 {
2541  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2542  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2543 
2544  try {
2545  std::string l_BinaryFileContent;
2546  ToArbitraryBlock(rContent, l_BinaryFileContent);
2547  std::string l_Command;
2548  l_Command = ":MMEM:DATA " "\"" + Path + "\"" "," + l_BinaryFileContent;
2549  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2550  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2551  } // try
2552  catch (CPT2026InsException & rE)
2553  {
2555  MTL_Unused(rE);
2556  return false;
2557  }
2558  return true;
2559 }
2560 bool CPT2026Instrument::DeleteFile(std::string Path)
2561 {
2562  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2563  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2564 
2565  try {
2566  std::string l_Command;
2567  l_Command = ":MMEM:DEL " "\"" + Path + "\"";
2568  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2569  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2570  } // try
2571  catch (CPT2026InsException & rE)
2572  {
2574  MTL_Unused(rE);
2575  return false;
2576  }
2577  return true;
2578 }
2579 bool CPT2026Instrument::GetSettingFileList(std::vector<std::string> & rSettingFileList)
2580 {
2581  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2582  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2583 
2584  rSettingFileList.clear();
2585 
2586  try {
2587  U32 l_Dummy;
2588  tFileList l_FileList;
2589  if (!ReadFileDirectory(l_Dummy, l_Dummy, l_FileList))
2590  throw CPT2026InsException("Could not retrieve file list", MTL__LOCATION__);
2591  // For each file, check if it is a setting
2592  for (tFileList::const_iterator it = l_FileList.begin(); it != l_FileList.end(); it++)
2593  {
2594  // Match a string that starts with "/yaffs/settings/"
2595  if (std::regex_match(it->Path, std::regex("^/yaffs/settings/.+")))
2596  rSettingFileList.push_back(it->Path);
2597  }
2598  } // try
2599  catch (CPT2026InsException & rE)
2600  {
2602  MTL_Unused(rE);
2603  return false;
2604  }
2605  return true;
2606 }
2607 bool CPT2026Instrument::SaveSettings(eSettingType Type, std::string Name)
2608 {
2609  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2610  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2611 
2612  try {
2613  std::string l_Command;
2614  l_Command = ":MMEM:STOR 0" ",\"" + Name + "\"";
2615  switch (Type)
2616  {
2617  case kAll:
2618  l_Command += ",ALL";
2619  break;
2620  case kCommunication:
2621  l_Command += ",COMM";
2622  break;
2623  case kMeasure:
2624  l_Command += ",MEAS";
2625  break;
2626  case kTriggers:
2627  l_Command += ",TRIG";
2628  break;
2629  case kReferenceClock:
2630  l_Command += ",REFC";
2631  break;
2632  case kUnits:
2633  l_Command += ",UNIT";
2634  break;
2635  default:
2636  MTL_Assert("Unhandled setting type");
2637  throw CPT2026InsException(std::string("Unhandled setting type in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2638  break;
2639  }
2640  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2641  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2642  } // try
2643  catch (CPT2026InsException & rE)
2644  {
2646  MTL_Unused(rE);
2647  return false;
2648  }
2649  return true;
2650 }
2652 {
2653  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2654  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2655 
2656  try {
2657  std::string l_Command;
2658  l_Command = ":MMEM:LOAD 0," "\"" + Name + "\"";
2659  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2660  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2661  } // try
2662  catch (CPT2026InsException & rE)
2663  {
2665  MTL_Unused(rE);
2666  return false;
2667  }
2668  return true;
2669 }
2670 
2671 //----------------------------------------------------------------------//
2672 // Initiate / Abort / Trigger //
2673 //----------------------------------------------------------------------//
2674 bool CPT2026Instrument::Initiate(bool Continuous)
2675 {
2676  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2677  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2678 
2679  std::string l_Command = Continuous ? ":INIT:CONT 1" : ":INIT:CONT 0;:INIT";
2680  return l_WriteAndRead(l_Command, m_ReadBuffer);
2681 }
2682 
2683 bool CPT2026Instrument::Abort(bool CancelContinuous)
2684 {
2685  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2686  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2687 
2688  std::string l_Command = CancelContinuous ? ":INIT:CONT 0;:ABOR" : ":ABOR";
2689  return l_WriteAndRead(l_Command, m_ReadBuffer);
2690 }
2691 
2693 {
2694  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2695  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2696 
2698 }
2699 
2701 {
2702  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2703  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2704 
2705  std::string l_Command = ":OUTP:TRIG:IMM";
2706  return l_WriteAndRead(l_Command, m_ReadBuffer);
2707 }
2708 
2709 //----------------------------------------------------------------------//
2710 // Measurements / Data //
2711 //----------------------------------------------------------------------//
2712 bool CPT2026Instrument::MeasurementsGet(U32 NoMeasurements, std::vector<tFlux> & rFlux, eUnits & rUnits)
2713 {
2714  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2715  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2716 
2717  try {
2718  std::string l_Command = ":UNIT?;:FETC:ARR:FLUX? " + std::to_string(NoMeasurements);
2719  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2720  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2721 
2722  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2723  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
2724  // Units
2725  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2726  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2727  if (!StringToUnits(std::string(l_tokenbeg, l_tokenend), rUnits))
2728  throw CPT2026InsException("Could not parse units", MTL__LOCATION__);
2729  // Flux
2730  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2731  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2732  size_t l_Start, l_Len;
2733  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), l_Start, l_Len))
2734  {
2735  for (auto l_it = l_tokenbeg + l_Start; l_it < l_tokenbeg + l_Start + l_Len; l_it += sizeof(F64))
2736  rFlux.push_back(BinaryToF64(&*l_it));
2737  }
2738  else
2739  {
2740  std::vector<char>::const_iterator fluxbeg, fluxend;
2741  CVISABufferParser l_FluxParser(l_tokenbeg, l_tokenend);
2742  bool l_GetNextRet;
2743  for (l_GetNextRet = l_FluxParser.GetNext(fluxbeg, fluxend, ','); l_GetNextRet && fluxbeg != l_tokenend; l_GetNextRet = l_FluxParser.GetNext(fluxbeg, fluxend, ','))
2744  rFlux.push_back(std::stof(std::string(fluxbeg, fluxend)));
2745  }
2746 
2747  if (rFlux.size() != NoMeasurements)
2748  throw CPT2026InsException("Parsed size doesn't match required size", MTL__LOCATION__);
2749  }
2750  catch (CPT2026InsException & rE)
2751  {
2753  MTL_Unused(rE);
2754  return false;
2755  }
2756  return true;
2757 }
2758 
2759 bool CPT2026Instrument::MeasurementsGet(U32 NoMeasurements, sArbitraryMeasurements ArbSelect, sAllMeasurements & rMeas, eUnits & rUnits)
2760 {
2761  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
2762  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
2763 
2764  rMeas.clear();
2765  try
2766  {
2767  // Build command
2768  std::string l_Command = ":UNIT?";
2769  if (ArbSelect.Flux) l_Command += ";:FETC:ARR:FLUX? " + std::to_string(NoMeasurements);
2770  if (ArbSelect.Deviation) l_Command += ";:FETC:ARR:SIGM? " + std::to_string(NoMeasurements);
2771  if (ArbSelect.Uniformity) l_Command += ";:FETC:ARR:UNIF? " + std::to_string(NoMeasurements);
2772  if (ArbSelect.Channel) l_Command += ";:FETC:ARR:CHAN? " + std::to_string(NoMeasurements);
2773  if (ArbSelect.Timestamp) l_Command += ";:FETC:ARR:TIM? " + std::to_string(NoMeasurements);
2774  if (ArbSelect.Status) l_Command += ";:FETC:ARR:STAT? " + std::to_string(NoMeasurements);
2775  if (ArbSelect.NbValidMeas) l_Command += ";:FETC:ARR:VLM? " + std::to_string(NoMeasurements);
2776  if (ArbSelect.IF) l_Command += ";:FETC:SCAL:IFR?";
2777  if (ArbSelect.RelaxationTime) l_Command += ";:FETC:SCAL:REL?";
2778  if (ArbSelect.RadioFrequency) l_Command += ";:FETC:SCAL:RFFR?";
2779  if (ArbSelect.NoNMRSamples) l_Command += ";:FETC:ARR:NMRS? " + std::to_string(ArbSelect.NoNMRSamples);
2780  if (ArbSelect.NoFFTSamples) l_Command += ";:FETC:ARR:FFTB? " + std::to_string(ArbSelect.NoFFTSamples);
2781  if (ArbSelect.NoSpectrumSamples) l_Command += ";:FETC:ARR:SPEC? " + std::to_string(ArbSelect.NoSpectrumSamples);
2782  if (ArbSelect.PolynomDegree) l_Command += ";:FETC:ARR:FIT? " + std::to_string(ArbSelect.PolynomDegree);
2783 
2784  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
2785  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
2786 
2787  // Parse results
2788  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
2789  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
2790  // Units
2791  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2792  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2793  if (!StringToUnits(std::string(l_tokenbeg, l_tokenend), rUnits))
2794  throw CPT2026InsException("Could not parse units", MTL__LOCATION__);
2795 
2796  // Reserve memory for the new basic results (if any)
2797  if (ArbSelect.Flux ||
2798  ArbSelect.Deviation ||
2799  ArbSelect.Uniformity ||
2800  ArbSelect.Channel ||
2801  ArbSelect.Timestamp ||
2802  ArbSelect.Status ||
2803  ArbSelect.NbValidMeas)
2804  rMeas.AdvMeas.Basic.resize(NoMeasurements);
2805 
2806  // Get basic results (if any)
2807  if (ArbSelect.Flux)
2808  {
2809  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2810  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2811  size_t Start, Len;
2812  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2813  {
2814  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2815  for (size_t index = 0; Len >= sizeof(F64); Len -= sizeof(F64), Start += sizeof(F64), index++)
2816  rMeas.AdvMeas.Basic[index].Flux_UNITS = BinaryToF64(&*l_tokenbeg + Start);
2817  }
2818  else
2819  {
2820  std::vector<char>::const_iterator fluxbeg, fluxend;
2821  CVISABufferParser l_FluxParser(l_tokenbeg, l_tokenend);
2822  if (!l_FluxParser.GetNext(fluxbeg, fluxend, ','))
2823  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2824  bool l_GetNextRet = true;
2825  for (size_t index = 0; l_GetNextRet && fluxbeg != l_tokenend; l_GetNextRet = l_FluxParser.GetNext(fluxbeg, fluxend, ','), index++)
2826  rMeas.AdvMeas.Basic[index].Flux_UNITS = std::stod(std::string(fluxbeg, fluxend));
2827  }
2828  }
2829  if (ArbSelect.Deviation)
2830  {
2831  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2832  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2833  size_t Start, Len;
2834  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2835  {
2836  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2837  for (size_t index = 0; Len >= sizeof(F32); Len -= sizeof(F32), Start += sizeof(F32), index++)
2838  rMeas.AdvMeas.Basic[index].Deviation_ppm = BinaryToF32(&*l_tokenbeg + Start);
2839  }
2840  else
2841  {
2842  std::vector<char>::const_iterator devbeg, devend;
2843  CVISABufferParser l_DevParser(l_tokenbeg, l_tokenend);
2844  if (!l_DevParser.GetNext(devbeg, devend, ','))
2845  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2846  bool l_GetNextRet = true;
2847  for (size_t index = 0; l_GetNextRet && devbeg != l_tokenend; l_GetNextRet = l_DevParser.GetNext(devbeg, devend, ','), index++)
2848  rMeas.AdvMeas.Basic[index].Deviation_ppm = std::stof(std::string(devbeg, devend));
2849  }
2850  }
2851  if (ArbSelect.Uniformity)
2852  {
2853  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2854  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2855  size_t Start, Len;
2856  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2857  {
2858  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2859  for (size_t index = 0; Len >= sizeof(F32); Len -= sizeof(F32), Start += sizeof(F32), index++)
2860  rMeas.AdvMeas.Basic[index].Uniformity = BinaryToF32(&*l_tokenbeg + Start);
2861  }
2862  else
2863  {
2864  std::vector<char>::const_iterator unifbeg, unifend;
2865  CVISABufferParser l_UnifParser(l_tokenbeg, l_tokenend);
2866  if (!l_UnifParser.GetNext(unifbeg, unifend, ','))
2867  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2868  bool l_GetNextRet = true;
2869  for (size_t index = 0; l_GetNextRet && unifbeg != l_tokenend; l_GetNextRet = l_UnifParser.GetNext(unifbeg, unifend, ','), index++)
2870  rMeas.AdvMeas.Basic[index].Uniformity = std::stof(std::string(unifbeg, unifend));
2871 
2872  }
2873  }
2874  if (ArbSelect.Channel)
2875  {
2876  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2877  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2878  size_t Start, Len;
2879  tChannelList l_ChanList;
2880  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2881  FromBinaryChannelList(&*l_tokenbeg + Start, Len, l_ChanList);
2882  else
2883  FromStringChannelList(&*l_tokenbeg, &*l_tokenend, l_ChanList);
2884 
2885  for (size_t index = 0; index < l_ChanList.size() && index < rMeas.AdvMeas.Basic.size(); index++)
2886  rMeas.AdvMeas.Basic[index].Channel = l_ChanList[index];
2887  }
2888  if (ArbSelect.Timestamp)
2889  {
2890  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2891  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2892  size_t Start, Len;
2893  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2894  {
2895  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2896  for (size_t index = 0; Len >= sizeof(U64); Len -= sizeof(U64), Start += sizeof(U64), index++)
2897  rMeas.AdvMeas.Basic[index].Timestamp = BinaryToU64(&*l_tokenbeg + Start);
2898  }
2899  else
2900  {
2901  std::vector<char>::const_iterator timbeg, timend;
2902  CVISABufferParser l_TimParser(l_tokenbeg, l_tokenend);
2903  if (!l_TimParser.GetNext(timbeg, timend, ','))
2904  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2905  bool l_GetNextRet = true;
2906  for (size_t index = 0; l_GetNextRet && timbeg != l_tokenend; l_GetNextRet = l_TimParser.GetNext(timbeg, timend, ','), index++)
2907  rMeas.AdvMeas.Basic[index].Timestamp = std::stoull(std::string(timbeg, timend));
2908  }
2909  }
2910  if (ArbSelect.Status)
2911  {
2912  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2913  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2914  size_t Start, Len;
2915  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2916  {
2917  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2918  for (size_t index = 0; Len >= sizeof(U8); Len -= sizeof(U8), Start += sizeof(U8), index++)
2919  rMeas.AdvMeas.Basic[index].Status.StatusByte = *(&*l_tokenbeg + Start);
2920  }
2921  else
2922  {
2923  std::vector<char>::const_iterator statbeg, statend;
2924  CVISABufferParser l_StatParser(l_tokenbeg, l_tokenend);
2925  if (!l_StatParser.GetNext(statbeg, statend, ','))
2926  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2927  bool l_GetNextRet = true;
2928  for (size_t index = 0; l_GetNextRet && statbeg != l_tokenend; l_GetNextRet = l_StatParser.GetNext(statbeg, statend, ','), index++)
2929  rMeas.AdvMeas.Basic[index].Status.StatusByte = static_cast<U8>(std::stoul(std::string(statbeg, statend)));
2930  }
2931  }
2932  if (ArbSelect.NbValidMeas)
2933  {
2934  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2935  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2936  size_t Start, Len;
2937  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2938  {
2939  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2940  for (size_t index = 0; Len >= sizeof(U32); Len -= sizeof(U32), Start += sizeof(U32), index++)
2941  rMeas.AdvMeas.Basic[index].NbValidMeas = BinaryToU32(&*l_tokenbeg + Start);
2942  }
2943  else
2944  {
2945  std::vector<char>::const_iterator timbeg, timend;
2946  CVISABufferParser l_NbValidParser(l_tokenbeg, l_tokenend);
2947  if (!l_NbValidParser.GetNext(timbeg, timend, ','))
2948  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2949  bool l_GetNextRet = true;
2950  for (size_t index = 0; l_GetNextRet && timbeg != l_tokenend; l_GetNextRet = l_NbValidParser.GetNext(timbeg, timend, ','), index++)
2951  rMeas.AdvMeas.Basic[index].NbValidMeas = std::stoul(std::string(timbeg, timend));
2952  }
2953  }
2954  if (ArbSelect.IF)
2955  {
2956  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2957  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2958  size_t Start, Len;
2959  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2960  {
2961  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2962  rMeas.AdvMeas.IntermediateFrequency_Hz = BinaryToF64(&*l_tokenbeg + Start);
2963  }
2964  else
2965  {
2966  rMeas.AdvMeas.IntermediateFrequency_Hz = std::stod(std::string(l_tokenbeg, l_tokenend));
2967  }
2968  }
2969  if (ArbSelect.RelaxationTime)
2970  {
2971  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2972  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2973  size_t Start, Len;
2974  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2975  {
2976  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2977  rMeas.AdvMeas.RelaxationTime_s = BinaryToF32(&*l_tokenbeg + Start);
2978  }
2979  else
2980  {
2981  rMeas.AdvMeas.RelaxationTime_s = std::stof(std::string(l_tokenbeg, l_tokenend));
2982  }
2983  }
2984  if (ArbSelect.RadioFrequency)
2985  {
2986  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
2987  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
2988  size_t Start, Len;
2989  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
2990  {
2991  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
2992  rMeas.AdvMeas.RadioFrequency_Hz = BinaryToF64(&*l_tokenbeg + Start);
2993  }
2994  else
2995  {
2996  rMeas.AdvMeas.RadioFrequency_Hz = std::stod(std::string(l_tokenbeg, l_tokenend));
2997  }
2998  }
2999  if (ArbSelect.NoNMRSamples)
3000  {
3001  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3002  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3003  size_t Start, Len;
3004  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
3005  {
3006  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
3007  // Get Sample Period
3008  rMeas.NMR.SamplePeriod_s = BinaryToF32(&*l_tokenbeg + Start);
3009  std::vector<char>::const_iterator NmrSampbeg = l_tokenbeg + Start + sizeof(rMeas.NMR.SamplePeriod_s);
3010  size_t NmrSampLen = Len - sizeof(rMeas.NMR.SamplePeriod_s);
3011  size_t NmrSampStart = 0;
3012  // Get Samples
3013  for (size_t index = 0; NmrSampLen >= sizeof(F32); NmrSampLen -= sizeof(F32), NmrSampStart += sizeof(F32), index++)
3014  rMeas.NMR.Samples_V.push_back(BinaryToF32(&*NmrSampbeg + NmrSampStart));
3015  }
3016  else
3017  {
3018  std::vector<char>::const_iterator nmrbeg, nmrend;
3019  CVISABufferParser l_NmrParser(l_tokenbeg, l_tokenend);
3020  if (!l_NmrParser.GetNext(nmrbeg, nmrend, ','))
3021  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3022  bool l_GetNextRes = true;
3023  for (size_t index = 0; l_GetNextRes && nmrbeg != l_tokenend; l_GetNextRes = l_NmrParser.GetNext(nmrbeg, nmrend, ','), index++)
3024  rMeas.NMR.Samples_V.push_back(std::stof(std::string(nmrbeg, nmrend)));
3025  }
3026  }
3027  if (ArbSelect.NoFFTSamples)
3028  {
3029  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3030  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3031  size_t Start, Len;
3032  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
3033  {
3034  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
3035  // Get Frequency Resolution
3036  rMeas.FFT.FrequencyResolution_Hz = BinaryToF32(&*l_tokenbeg + Start);
3037  std::vector<char>::const_iterator FFTSampbeg = l_tokenbeg + Start + sizeof(rMeas.FFT.FrequencyResolution_Hz);
3038  size_t FFTSampLen = Len - sizeof(rMeas.FFT.FrequencyResolution_Hz);
3039  size_t FFTSampStart = 0;
3040  // Get Samples
3041  for (size_t index = 0; FFTSampLen >= sizeof(F32); FFTSampLen -= sizeof(F32), FFTSampStart += sizeof(F32), index++)
3042  rMeas.FFT.Samples_V.push_back(BinaryToF32(&*FFTSampbeg + FFTSampStart));
3043  }
3044  else
3045  {
3046  std::vector<char>::const_iterator fftbeg, fftend;
3047  CVISABufferParser l_FftParser(l_tokenbeg, l_tokenend);
3048  if (!l_FftParser.GetNext(fftbeg, fftend, ','))
3049  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3050  bool l_GetNextRes = true;
3051  for (size_t index = 0; l_GetNextRes && fftbeg != l_tokenend; l_GetNextRes = l_FftParser.GetNext(fftbeg, fftend, ','), index++)
3052  rMeas.FFT.Samples_V.push_back(std::stof(std::string(fftbeg, fftend)));
3053  }
3054  }
3055  if (ArbSelect.NoSpectrumSamples)
3056  {
3057  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3058  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3059  size_t Start, Len;
3060  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
3061  {
3062  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
3063  // Get Center Frequency and Frequency Resolution
3064  rMeas.Spectrum.CenterFrequency_Hz = BinaryToF32(&*l_tokenbeg + Start);
3065  rMeas.Spectrum.FrequencyResolution_Hz = BinaryToF32(&*l_tokenbeg + Start + sizeof(rMeas.Spectrum.CenterFrequency_Hz));
3066  std::vector<char>::const_iterator SpecSampbeg = l_tokenbeg + Start + sizeof(rMeas.Spectrum.CenterFrequency_Hz) + sizeof(rMeas.Spectrum.FrequencyResolution_Hz);
3067  size_t SpecSampLen = Len - sizeof(rMeas.Spectrum.CenterFrequency_Hz) + sizeof(rMeas.Spectrum.FrequencyResolution_Hz);
3068  size_t SpecSampStart = 0;
3069  // Get Samples
3070  for (size_t index = 0; SpecSampLen >= sizeof(F32); SpecSampLen -= sizeof(F32), SpecSampStart += sizeof(F32), index++)
3071  rMeas.Spectrum.Samples_V.push_back(BinaryToF32(&*SpecSampbeg + SpecSampStart));
3072  }
3073  else
3074  {
3075  std::vector<char>::const_iterator specbeg, specend;
3076  CVISABufferParser l_SpecParser(l_tokenbeg, l_tokenend);
3077  if (!l_SpecParser.GetNext(specbeg, specend, ','))
3078  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3079  bool l_GetNextRes = true;
3080  for (size_t index = 0; l_GetNextRes && specbeg != l_tokenend; l_GetNextRes = l_SpecParser.GetNext(specbeg, specend, ','), index++)
3081  rMeas.Spectrum.Samples_V.push_back(std::stof(std::string(specbeg, specend)));
3082  }
3083  }
3084  if (ArbSelect.PolynomDegree)
3085  {
3086  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3087  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3088  size_t Start, Len;
3089  if (IsArbitraryBlock(l_tokenbeg, l_BP.end(), Start, Len))
3090  {
3091  l_BP.SetNextOffset(l_tokenbeg + Start + Len + 1); // Set next offset after the end of the arbitrary block
3092  // Get Residue
3093  rMeas.FitPolynom.Residue = BinaryToF32(&*l_tokenbeg + Start);
3094  std::vector<char>::const_iterator PolyCoefbeg = l_tokenbeg + Start + sizeof(rMeas.FitPolynom.Residue);
3095  size_t PolyCoefLen = Len - sizeof(rMeas.FitPolynom.Residue);
3096  size_t PolyCoefStart = 0;
3097  // Get Samples
3098  for (size_t index = 0; PolyCoefLen >= sizeof(F32); PolyCoefLen -= sizeof(F32), PolyCoefStart += sizeof(F32), index++)
3099  rMeas.FitPolynom.Coeffs.push_back(BinaryToF32(&*PolyCoefbeg + PolyCoefStart));
3100  }
3101  else
3102  {
3103  std::vector<char>::const_iterator polybeg, polyend;
3104  CVISABufferParser l_PolyParser(l_tokenbeg, l_tokenend);
3105  if (!l_PolyParser.GetNext(polybeg, polyend, ','))
3106  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3107  rMeas.FitPolynom.Residue = std::stof(std::string(polybeg, polyend));
3108  if (!l_PolyParser.GetNext(polybeg, polyend, ','))
3109  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3110  bool l_GetNextRes = true;
3111  for (size_t index = 0; l_GetNextRes && polybeg != l_tokenend; l_GetNextRes = l_PolyParser.GetNext(polybeg, polyend, ','), index++)
3112  rMeas.FitPolynom.Coeffs.push_back(std::stof(std::string(polybeg, polyend)));
3113  }
3114  }
3115  } // try
3116  catch (CPT2026InsException & rE)
3117  {
3119  MTL_Unused(rE);
3120  return false;
3121  }
3122  return true;
3123 }
3124 
3125 bool CPT2026Instrument::GetSearchProgress(U8 & rSPR, F64 & rHallMeasurement_UNITS)
3126 {
3127  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3128  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3129 
3130  try {
3131  if (!l_WriteAndRead(":FETC:SPR?", m_ReadBuffer))
3132  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3133 
3134  size_t l_Start, l_Len;
3135  if (IsArbitraryBlock(m_ReadBuffer.begin(), m_ReadBuffer.end(), l_Start, l_Len))
3136  {
3137  rSPR = *(m_ReadBuffer.data() + l_Start);
3138  rHallMeasurement_UNITS = BinaryToF64(m_ReadBuffer.data() + l_Start + 1);
3139  }
3140  else
3141  {
3142  // Parse results
3143  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
3144  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
3145  // Search Progress
3146  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
3147  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3148  rSPR = std::stoi(std::string(l_tokenbeg, l_tokenend));
3149  // Hall Measurement
3150  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ','))
3151  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3152  rHallMeasurement_UNITS = std::stod(std::string(l_tokenbeg, l_tokenend));
3153  }
3154  }
3155  catch (CPT2026InsException & rE)
3156  {
3158  MTL_Unused(rE);
3159  return false;
3160  }
3161  return true;
3162 }
3163 
3165 {
3166  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3167  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3168 
3169  std::string l_Command;
3170 
3171  switch (Format)
3172  {
3173  case kComFormatAscii:
3174  l_Command += ":FORM:DATA ASC";
3175  break;
3176  case kComFormatInteger:
3177  l_Command += ":FORM:DATA INT";
3178  break;
3179  default:
3180  MTL_Assert(false);
3181  break;
3182  }
3183  return l_WriteAndRead(l_Command, m_ReadBuffer);
3184 }
3185 
3186 //----------------------------------------------------------------------//
3187 // Status Handling //
3188 //----------------------------------------------------------------------//
3190 {
3191  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3192  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3193 
3194  return l_WriteAndRead(":STAT:PRES", m_ReadBuffer);
3195 }
3196 
3198 {
3199  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3200  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3201 
3202  std::string l_Command;
3203 
3204  // Prepare register set
3205  switch (Reg.Set)
3206  {
3207  case kStatusQestionable:
3208  l_Command += ":STAT:QUES";
3209  break;
3210  case kStatusOperation:
3211  l_Command += ":STAT:OPER";
3212  break;
3213  case kStatusOperationBit11:
3214  l_Command += ":STAT:OPER:BIT11";
3215  break;
3216  case kStatusOperationBit12:
3217  l_Command += ":STAT:OPER:BIT12";
3218  break;
3220  l_Command += ":STAT:QUES:BIT12";
3221  break;
3222  default:
3223  MTL_Assert(false);
3224  break;
3225  }
3226  // Prepare register type
3227  switch (Reg.Type)
3228  {
3229  case kStatusEvent:
3230  l_Command += ":EVEN?";
3231  break;
3232  case kStatusCondition:
3233  l_Command += ":COND?";
3234  break;
3235  case kStatusEnable:
3236  l_Command += ":ENAB?";
3237  break;
3238  default:
3239  MTL_Assert(false);
3240  break;
3241  }
3242 
3243  try {
3244  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3245  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3246 
3247  rStatus = std::stoi(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end()));
3248  } // try
3249  catch (CPT2026InsException & rE)
3250  {
3252  MTL_Unused(rE);
3253  rStatus = 0;
3254  return false;
3255  }
3256  return true;
3257 }
3258 
3259 bool CPT2026Instrument::StatusGet(std::vector<sStatusRegister> Regs, std::vector<U16> & rStatus)
3260 {
3261  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3262  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3263 
3264  rStatus.clear();
3265  std::string l_Command;
3266 
3267  for (std::vector<sStatusRegister>::const_iterator it = Regs.begin(); it != Regs.end(); it++)
3268  {
3269  if (it != Regs.begin())
3270  l_Command += ";";
3271  switch (it->Set)
3272  {
3273  case kStatusQestionable:
3274  l_Command += ":STAT:QUES";
3275  break;
3276  case kStatusOperation:
3277  l_Command += ":STAT:OPER";
3278  break;
3279  case kStatusOperationBit11:
3280  l_Command += ":STAT:OPER:BIT11";
3281  break;
3282  case kStatusOperationBit12:
3283  l_Command += ":STAT:OPER:BIT12";
3284  break;
3286  l_Command += ":STAT:QUES:BIT12";
3287  break;
3288  default:
3289  MTL_Assert(false);
3290  break;
3291  }
3292  switch (it->Type)
3293  {
3294  case kStatusEvent:
3295  l_Command += ":EVEN?";
3296  break;
3297  case kStatusCondition:
3298  l_Command += ":COND?";
3299  break;
3300  case kStatusEnable:
3301  l_Command += ":ENAB?";
3302  break;
3303  default:
3304  MTL_Assert(false);
3305  break;
3306  }
3307  }
3308 
3309  try {
3310  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3311  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3312 
3313  // Parse results
3314  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
3315  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
3316 
3317  for (size_t i = Regs.size(); i > 0; i--)
3318  {
3319  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3320  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3321  rStatus.push_back(std::stoi(std::string(l_tokenbeg, l_tokenend)));
3322  }
3323  } // try
3324  catch (CPT2026InsException & rE)
3325  {
3327  MTL_Unused(rE);
3328  return false;
3329  }
3330  return true;
3331 }
3332 
3333 bool CPT2026Instrument::StatusSetEnableRegister(eStatusRegisterSet Set, U16 DisableMask, U16 EnableMask)
3334 {
3335  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3336  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3337 
3338  std::string l_RegSet, l_Command;
3339 
3340  switch (Set)
3341  {
3342  case kStatusQestionable:
3343  l_RegSet += ":STAT:QUES";
3344  break;
3345  case kStatusOperation:
3346  l_RegSet += ":STAT:OPER";
3347  break;
3348  case kStatusOperationBit11:
3349  l_RegSet += ":STAT:OPER:BIT11";
3350  break;
3351  case kStatusOperationBit12:
3352  l_RegSet += ":STAT:OPER:BIT12";
3353  break;
3355  l_RegSet += ":STAT:QUES:BIT12";
3356  break;
3357  default:
3358  MTL_Assert(false);
3359  break;
3360  }
3361 
3362  try {
3363  // Read current enable register
3364  l_Command = l_RegSet + ":ENAB?";
3365  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3366  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3367 
3368  U16 l_StatusEnab = static_cast<U16>(std::stoi(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end())));
3369 
3370  // Compute new enable register
3371  l_StatusEnab |= EnableMask;
3372  l_StatusEnab &= ~DisableMask;
3373 
3374  // Set new enable register
3375  l_Command = l_RegSet + ":ENAB" + " " + std::to_string(l_StatusEnab);
3376  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3377  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3378  } // try
3379  catch (CPT2026InsException & rE)
3380  {
3382  MTL_Unused(rE);
3383  return false;
3384  }
3385  return true;
3386 }
3387 
3388 bool CPT2026Instrument::StatusSetTransitionFilter(eStatusRegisterSet Set, eTransition Transition, U16 ClearMask, U16 SetMask)
3389 {
3391  FUNCTION_NAME__ << std::endl);
3392  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3393 
3394  std::string l_RegSet, l_Command;
3395 
3396  switch (Set)
3397  {
3398  case kStatusQestionable:
3399  l_RegSet += ":STAT:QUES";
3400  break;
3401  case kStatusOperation:
3402  l_RegSet += ":STAT:OPER";
3403  break;
3404  case kStatusOperationBit11:
3405  l_RegSet += ":STAT:OPER:BIT11";
3406  break;
3407  case kStatusOperationBit12:
3408  l_RegSet += ":STAT:OPER:BIT12";
3409  break;
3411  l_RegSet += ":STAT:QUES:BIT12";
3412  break;
3413  default:
3414  MTL_Assert(false);
3415  break;
3416  }
3417 
3418  try {
3419  // Read current transition filter
3420  switch (Transition)
3421  {
3422  case kPositive:
3423  l_Command = l_RegSet + ":PTR?";
3424  break;
3425  case kNegative:
3426  l_Command = l_RegSet + ":NTR?";
3427  break;
3428  default:
3429  MTL_Assert(false);
3430  break;
3431  }
3432  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3433  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3434 
3435  U16 l_TransFilter = std::stoi(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end()));
3436 
3437  // Compute new transition filter
3438  l_TransFilter |= SetMask;
3439  l_TransFilter &= ~ClearMask;
3440 
3441  // Set new transition filter
3442  switch (Transition)
3443  {
3444  case kPositive:
3445  l_Command = l_RegSet + ":PTR";
3446  break;
3447  case kNegative:
3448  l_Command = l_RegSet + ":NTR";
3449  break;
3450  default:
3451  MTL_Assert(false);
3452  break;
3453  }
3454  l_Command += " " + std::to_string(l_TransFilter);
3455  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3456  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3457  } // try
3458  catch (CPT2026InsException & rE)
3459  {
3461  MTL_Unused(rE);
3462  return false;
3463  }
3464  return true;
3465 }
3466 
3468 {
3469  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3470  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3471 
3472  std::string l_Command;
3473 
3474  switch (Set)
3475  {
3477  l_Command += "*ESE";
3478  break;
3480  l_Command += "*SRE";
3481  break;
3482  default:
3483  MTL_Assert(false);
3484  break;
3485  }
3486 
3487  try {
3488  // Read current enable register
3489  if (!l_WriteAndRead(l_Command + "?", m_ReadBuffer))
3490  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3491 
3492  U16 l_StatusEnab = std::stoi(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end()));
3493 
3494  // Compute new enable register
3495  l_StatusEnab |= EnableMask;
3496  l_StatusEnab &= ~DisableMask;
3497 
3498  // Set new enable register
3499  l_Command += " " + std::to_string(l_StatusEnab);
3500  if (!l_WriteAndRead(l_Command, m_ReadBuffer))
3501  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3502  } // try
3503  catch (CPT2026InsException & rE)
3504  {
3506  MTL_Unused(rE);
3507  return false;
3508  }
3509  return true;
3510 }
3511 
3512 //----------------------------------------------------------------------//
3513 // Utilities //
3514 //----------------------------------------------------------------------//
3515 bool CPT2026Instrument::GetIdentification(std::string & rIdentification)
3516 {
3517  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3518  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3519 
3520  try {
3521  if (!l_WriteAndRead("*IDN?", m_ReadBuffer))
3522  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3523 
3524  rIdentification = std::string(m_ReadBuffer.begin(), m_ReadBuffer.end());
3525  } // try
3526  catch (CPT2026InsException & rE)
3527  {
3529  MTL_Unused(rE);
3530  rIdentification.clear();
3531  return false;
3532  }
3533  return true;
3534 }
3536 {
3537  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3538  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3539 
3540  std::string l_Command(":SYST:POFF ");
3541  l_Command += (Reboot ? "1" : "0");
3542 
3543  return l_WriteAndRead(l_Command, m_ReadBuffer);
3544 }
3546 {
3547  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3548  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3549 
3550  return Write("*RST");
3551 }
3552 bool CPT2026Instrument::ReadCaseTemperature(F32 & rTemperatureDegC)
3553 {
3554  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3555  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3556 
3557  try {
3558  if (!l_WriteAndRead(":SYST:TEMP?", m_ReadBuffer, true))
3559  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3560 
3561  rTemperatureDegC = std::stof(std::string(m_ReadBuffer.begin(), m_ReadBuffer.end()));
3562  } // try
3563  catch (CPT2026InsException & rE)
3564  {
3566  MTL_Unused(rE);
3567  rTemperatureDegC = SPqNaN;
3568  return false;
3569  }
3570  return true;
3571 }
3573 {
3574  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3575  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3576 
3577  return Write(":DIAG:UPGR");
3578 }
3579 bool CPT2026Instrument::ReadDebugLog(std::string & rDebugLog)
3580 {
3581  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3582  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3583 
3584  rDebugLog.clear();
3585  try {
3586  if (!l_WriteAndRead(":DIAG:LOG?", m_ReadBuffer))
3587  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3588 
3589  rDebugLog = std::string(m_ReadBuffer.begin(), m_ReadBuffer.end());
3590  } // try
3591  catch (CPT2026InsException & rE)
3592  {
3594  MTL_Unused(rE);
3595  return false;
3596  }
3597  return true;
3598 }
3599 bool CPT2026Instrument::ReadInformationDates(std::string & rSManufacturingDate, std::time_t & rManufacturingDate, std::string & rSCalibrationDate, std::time_t & rCalibrationDate)
3600 {
3601  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3602  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3603 
3604  try {
3605  if (!l_WriteAndRead(":SYST:MDAT?;CDAT?", m_ReadBuffer))
3606  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3607 
3608  // Parse results
3609  CVISABufferParser l_BP(m_ReadBuffer.begin(), m_ReadBuffer.end());
3610  std::vector<char>::const_iterator l_tokenbeg, l_tokenend;
3611 
3612  // Get Manufacturing Date (UTC)
3613  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3614  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3615  rSManufacturingDate = std::string(l_tokenbeg, l_tokenend);
3616  std::match_results<std::string::const_iterator> l_Mm;
3617  // Match 3 groups of 2 digits
3618  if (!std::regex_match(rSManufacturingDate, l_Mm, std::regex("^([0-9]{2})([0-9]{2})([0-9]{2})")))
3619  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
3620  std::stringstream l_DateStream;
3621  std::chrono::system_clock::time_point l_TimePointUTC;
3622  // we consider date in years 2000 to 2099
3623  l_DateStream << "20" + l_Mm[1].str() + "-" + l_Mm[2].str() + "-" + l_Mm[3].str() + " 00:00:00";
3624  l_DateStream >> date::parse("%F %T", l_TimePointUTC); // parse string (UTC) date to time_point UTC
3625  rManufacturingDate = std::chrono::system_clock::to_time_t(l_TimePointUTC); // convert to time_t (UTC)
3626 
3627  // Get Calibration Date (UTC)
3628  if (!l_BP.GetNext(l_tokenbeg, l_tokenend, ';'))
3629  throw CPT2026InsException("Could not find next token", MTL__LOCATION__);
3630  rSCalibrationDate = std::string(l_tokenbeg, l_tokenend);
3631  std::match_results<std::string::const_iterator> l_Cm;
3632  // Match 3 groups of 2 digits
3633  if (!std::regex_match(rSCalibrationDate, l_Cm, std::regex("^([0-9]{2})([0-9]{2})([0-9]{2})")))
3634  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
3635  // we consider date in years 2000 to 2099
3636  l_DateStream.clear();
3637  std::chrono::system_clock::time_point l_TimePointCalUTC;
3638  l_DateStream << "20" + l_Cm[1].str() + "-" + l_Cm[2].str() + "-" + l_Cm[3].str() + " 00:00:00";
3639  l_DateStream >> date::parse("%F %T", l_TimePointCalUTC); // parse string (UTC) date to time_point UTC
3640  rCalibrationDate = std::chrono::system_clock::to_time_t(l_TimePointCalUTC); // convert to time_t (UTC)
3641  } // try
3642  catch (CPT2026InsException & rE)
3643  {
3645  MTL_Unused(rE);
3646  rSManufacturingDate.clear();
3647  rManufacturingDate = -1;
3648  rSCalibrationDate.clear();
3649  rCalibrationDate = -1;
3650  return false;
3651  }
3652  return true;
3653 }
3654 
3655 //----------------------------------------------------------------------//
3656 // Low Level Utilities //
3657 //----------------------------------------------------------------------//
3658 bool CPT2026Instrument::DeviceROMRead(const tChannel & rChannel, std::vector<U8> & rROMContent)
3659 {
3660  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3661  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3662 
3663  // Convert channel to a string channel list
3664  tChannelList l_SingleChannelList;
3665  l_SingleChannelList.push_back(rChannel);
3666  std::string l_StrChannelList;
3667  ToStringChannelList(l_SingleChannelList, l_StrChannelList);
3668 
3669  std::string l_Command = ":ROUT:MMEM:DATA? " + l_StrChannelList;
3670 
3671  try {
3672  if (!l_WriteAndRead(l_Command, m_ReadBuffer, true))
3673  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3674 
3675  size_t l_Start, l_Len;
3676  if (!IsArbitraryBlock(m_ReadBuffer.begin(), m_ReadBuffer.end(), l_Start, l_Len))
3677  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
3678 
3679  rROMContent.assign(m_ReadBuffer.data() + l_Start, m_ReadBuffer.data() + l_Start + l_Len);
3680  } // try
3681  catch (CPT2026InsException & rE)
3682  {
3684  MTL_Unused(rE);
3685  return false;
3686  }
3687  return true;
3688 }
3689 bool CPT2026Instrument::DeviceROMWrite(const tChannel & rChannel, const std::vector<U8> & rROMContent)
3690 {
3691  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3692  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3693 
3694  // Convert channel to a string channel list
3695  tChannelList l_SingleChannelList;
3696  l_SingleChannelList.push_back(rChannel);
3697  std::string l_StrChannelList;
3698  ToStringChannelList(l_SingleChannelList, l_StrChannelList);
3699  // Convert ROM block to arbitrary block
3700  std::string l_StrROMContent;
3701  l_StrROMContent.assign(rROMContent.begin(), rROMContent.end());
3702  std::string l_StrROMArbBlock;
3703  ToArbitraryBlock(l_StrROMContent, l_StrROMArbBlock);
3704 
3705  std::string l_Command = ":ROUT:MMEM:DATA " + l_StrChannelList + "," + l_StrROMArbBlock;
3706 
3707  return l_WriteAndRead(l_Command, m_ReadBuffer, true);
3708 }
3710 {
3711  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3712  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3713 
3714  // Convert channel to a string channel list
3715  tChannelList l_SingleChannelList;
3716  l_SingleChannelList.push_back(rChannel);
3717  std::string l_StrChannelList;
3718  ToStringChannelList(l_SingleChannelList, l_StrChannelList);
3719 
3720  std::string l_Command = ":ROUT:MMEM:NORM? " + l_StrChannelList;
3721 
3722  try {
3723  if (!l_WriteAndRead(l_Command, m_ReadBuffer, true))
3724  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3725 
3726  size_t l_Start, l_Len;
3727  if (!IsArbitraryBlock(m_ReadBuffer.begin(), m_ReadBuffer.end(), l_Start, l_Len))
3728  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
3729 
3730  for (auto l_it = m_ReadBuffer.begin() + l_Start; l_it < m_ReadBuffer.begin() + l_Start + l_Len; l_it += sizeof(tNormalizationFactor_Hz))
3731  rNormalizationTable.push_back(BinaryToF32(&*l_it));
3732  } // try
3733  catch (CPT2026InsException & rE)
3734  {
3736  MTL_Unused(rE);
3737  return false;
3738  }
3739  return true;
3740 }
3741 bool CPT2026Instrument::NormalizationSet(const MTL::SCPI::tChannel & rChannel, const tNormalizationTable & rNormalizationTable)
3742 {
3743  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3744  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3745 
3746  // Convert channel to a string channel list
3747  tChannelList l_SingleChannelList;
3748  l_SingleChannelList.push_back(rChannel);
3749  std::string l_StrChannelList;
3750  ToStringChannelList(l_SingleChannelList, l_StrChannelList);
3751  // Convert Normalization table to arbitrary block
3752  std::vector<U8> l_RawNormalizationTable;
3753  l_RawNormalizationTable.resize(rNormalizationTable.size() * sizeof(tNormalizationFactor_Hz));
3754  std::memcpy(l_RawNormalizationTable.data(), rNormalizationTable.data(), l_RawNormalizationTable.size());
3755  std::string l_StrNormTableArbBlock;
3756  ToArbitraryBlock(std::string(l_RawNormalizationTable.begin(), l_RawNormalizationTable.end()), l_StrNormTableArbBlock);
3757 
3758  std::string l_Command = ":ROUT:MMEM:NORM " + l_StrChannelList + "," + l_StrNormTableArbBlock;
3759 
3760  return l_WriteAndRead(l_Command, m_ReadBuffer, true);
3761 }
3762 bool CPT2026Instrument::LowLevelTransfer(const std::vector<U8> & rDataToSend, std::vector<U8> & rRcvdData, U8 & rReturnedStatus)
3763 {
3764  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3765  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3766 
3767  std::string l_Command = ":ROUT:LOWL? ";
3768  std::string l_DataToSend;
3769  l_DataToSend.assign(rDataToSend.begin(), rDataToSend.end());
3770  l_Command += l_DataToSend;
3771 
3772  try {
3773  if (!l_WriteAndRead(l_Command, m_ReadBuffer, true))
3774  throw CPT2026InsException(std::string("Failed W&R in ") + MTL__FUNCTION_NAME__, MTL__LOCATION__);
3775 
3776  size_t l_Start, l_Len;
3777  if (!IsArbitraryBlock(m_ReadBuffer.begin(), m_ReadBuffer.end(), l_Start, l_Len))
3778  throw CPT2026InsException("Invalid answer format", MTL__LOCATION__);
3779 
3780  rReturnedStatus = *(m_ReadBuffer.data() + l_Start);
3781  rRcvdData.assign(m_ReadBuffer.data() + l_Start + 1, m_ReadBuffer.data() + l_Start + l_Len);
3782  } // try
3783  catch (CPT2026InsException & rE)
3784  {
3786  MTL_Unused(rE);
3787  rReturnedStatus = 0;
3788  rRcvdData.clear();
3789  return false;
3790  }
3791  return true;
3792 }
3793 bool CPT2026Instrument::WriteCustomCommand(const std::string & rWriteStr)
3794 {
3795  MTL_INSTRUMENT_PT2026_DEBUG_COUT(MTL__FUNCTION_NAME__ << std::endl);
3796  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
3797 
3798  return l_WriteAndRead(rWriteStr, m_ReadBuffer, true);
3799 }
MTL::Instrument::PT2026Types::kStatusEvent
@ kStatusEvent
Definition: PT2026Types.h:30
MTL::SCPI::ToArbitraryBlock
void ToArbitraryBlock(const std::string &rStr, std::string &rArbitraryBlock, bool InfiniteFormat=false)
Package data as an arbitrary block.
Definition: SCPIParsing.h:132
MTL::Instrument::PT2026Types::sDigitization
Definition: PT2026Types.h:229
MTL::Instrument::CPT2026Instrument::ParmSearchSet
bool ParmSearchSet(const sSearch< uParm > &rSearch)
Configure the search operation, including detection level, frequency steps and the search bounds spec...
Definition: PT2026.cpp:699
MTL::Instrument::PT2026Types::kReferenceClock
@ kReferenceClock
Definition: PT2026Types.h:530
MTL::Instrument::PT2026Types::uIPAddress::B
U8 B
Definition: PT2026Types.h:366
MTL::Instrument::CPT2026Instrument::ChannelGetRemoteLEDMode
bool ChannelGetRemoteLEDMode(eRemoteBusyLEDmode &rMode)
Definition: PT2026.cpp:664
MTL::Instrument::CPT2026Instrument::~CPT2026Instrument
virtual ~CPT2026Instrument()
Definition: PT2026.cpp:250
MTL_INSTRUMENT_PT2026_DEBUG_CERR
#define MTL_INSTRUMENT_PT2026_DEBUG_CERR(__X__)
Definition: PT2026.cpp:29
MTL::Instrument::PT2026Types::sStatusRegister
Definition: PT2026Types.h:34
CERR
#define CERR(__X__)
Definition: Helpers.h:28
MTL::Instrument::CPT2026Instrument::PowerOff
bool PowerOff(bool Reboot=false)
Sending this command will shut the instrument down. Setting the reboot parameter to true will initiat...
Definition: PT2026.cpp:3535
MTL::Instrument::CPT2026Instrument::CPT2026Instrument
CPT2026Instrument(CVISAResourceManager &rRM, tResourceName Rsrc)
Constructors / destructors.
Definition: PT2026.cpp:245
MTL::Instrument::PT2026Types::sProbeHall
Definition: PT2026Types.h:479
MTL::Instrument::PT2026Types::kInputTrigEdgeRising
@ kInputTrigEdgeRising
Definition: PT2026Types.h:245
MTL::Instrument::PT2026Types::sChannelIformation
Definition: PT2026Types.h:469
MTL::Instrument::CPT2026Instrument::DeviceROMWrite
bool DeviceROMWrite(const MTL::SCPI::tChannel &rChannel, const std::vector< U8 > &rROMContent)
Definition: PT2026.cpp:3689
MTL::Instrument::PT2026Types::sEthernet::Broadcast
uIPAddress Broadcast
Definition: PT2026Types.h:376
MTL::Instrument::PT2026Types::kSearchCustom
@ kSearchCustom
Definition: PT2026Types.h:329
MTL::Instrument::CVISABuffer::clear
void clear()
Definition: VISAInstrumentBuffer.h:61
MTL::Instrument::eEventType::Clear
@ Clear
MTL::Instrument::PT2026Types::sInputTrigger::Source
eInputTriggerSource Source
Definition: PT2026Types.h:251
MTL::Instrument::PT2026Types::kComFormatAscii
@ kComFormatAscii
Definition: PT2026Types.h:356
MTL::Instrument::PT2026Types::sArbitraryMeasurements::NoNMRSamples
U32 NoNMRSamples
Definition: PT2026Types.h:628
MTL::Instrument::PT2026Types::sMeasure::AllowedMissMeas
ParmType< U32 > AllowedMissMeas
Definition: PT2026Types.h:295
MTL::Instrument::PT2026Types::sProbeHall::clear
void clear()
Definition: PT2026Types.h:484
MTL::Instrument::PT2026Types::sSearch::HighLimit_UNITS
ParmType< F64 > HighLimit_UNITS
Definition: PT2026Types.h:339
MTL::Instrument::CPT2026Instrument::ParmUnitsGet
bool ParmUnitsGet(eUnits &rUnits, tPPMReference_UNITS &rRef)
Definition: PT2026.cpp:2153
MTL::Instrument::PT2026Types::sProbeHall::B
F64 B
Definition: PT2026Types.h:480
MTL::Instrument::PT2026Types::sArbitraryMeasurements::Channel
bool Channel
Definition: PT2026Types.h:621
MTL::Instrument::PT2026Types::sProbeHall::Bx
F64 Bx
Definition: PT2026Types.h:481
MTL::Instrument::CPT2026Instrument::ParmUnitsSetPPMRef
bool ParmUnitsSetPPMRef(tPPMReference_UNITS Ref)
Definition: PT2026.cpp:2144
MTL::SCPI::tChannelList
std::vector< tChannel > tChannelList
SCPI channel list
Definition: SCPIParsing.h:26
MTL::Instrument::CPT2026Instrument::ParmSearchSetLimits
bool ParmSearchSetLimits(F64 LowLimit_UNITS, F64 HighLimit_UNITS)
Set the search bounds in the selected unit.
Definition: PT2026.cpp:851
MTL::Instrument::CPT2026Instrument::ParmComEthernetGet
bool ParmComEthernetGet(sEthernet &rSettings)
Definition: PT2026.cpp:2304
PT2026TypeConversions.h
MTL::Instrument::PT2026Types::kPulseAuto
@ kPulseAuto
Definition: PT2026Types.h:315
MTL::Instrument::PT2026Types::sDigitization::SweepTime_s
ParmType< F64 > SweepTime_s
Definition: PT2026Types.h:232
MTL::Instrument::CPT2026Instrument::GetIdentification
bool GetIdentification(std::string &rIdentification)
Returns the instrument identification string including its serial number and make....
Definition: PT2026.cpp:3515
MTL::Instrument::PT2026Types::sEthernet
Definition: PT2026Types.h:371
MTL::Instrument::PT2026Types::kPositive
@ kPositive
Definition: PT2026Types.h:41
MTL::Instrument::CPT2026Instrument::GetSettingFileList
bool GetSettingFileList(std::vector< std::string > &rSettingFileList)
Definition: PT2026.cpp:2579
MTL::Instrument::PT2026Types::uIPAddress
Definition: PT2026Types.h:362
MTL::Instrument::PT2026Types::sOutputTrigger::Mode
eOutputTriggerMode Mode
Definition: PT2026Types.h:269
MTL::Instrument::CPT2026Instrument::ParmAveragingSignalGet
bool ParmAveragingSignalGet(sSignalAveraging< uParm > &rSigAvg)
Definition: PT2026.cpp:1096
MTL::Instrument::PT2026Types::sMatchingTuning::Tuning
ParmType< F64 > Tuning
Definition: PT2026Types.h:309
MTL::Instrument::PT2026Types::kOutputTrigShapeOFF
@ kOutputTrigShapeOFF
Definition: PT2026Types.h:260
MTL::Instrument::PT2026Types::sDigitization::Rate_Hz
ParmType< F64 > Rate_Hz
Definition: PT2026Types.h:233
MTL::Instrument::PT2026Types::sEthernet::DNSServer
uIPAddress DNSServer
Definition: PT2026Types.h:378
MTL::Instrument::CPT2026Instrument::ReadFile
bool ReadFile(std::string Path, std::string &rContent)
Definition: PT2026.cpp:2518
MTL::Instrument::PT2026Types::kSigExponential
@ kSigExponential
Definition: PT2026Types.h:201
MTL::Instrument::PT2026Types::eSettingType
eSettingType
Definition: PT2026Types.h:525
MTL::Instrument::CPT2026Instrument::SetFormat
bool SetFormat(eCommunicationFormat Format)
One can request the data in ASCII or binary format. The binary format, which needs extra operation to...
Definition: PT2026.cpp:3164
MTL::Instrument::PT2026Types::sSearch::DetectionLevel_V
ParmType< F64 > DetectionLevel_V
Definition: PT2026Types.h:335
MTL::Instrument::CPT2026Instrument::ParmComUsbSet
bool ParmComUsbSet(bool Enabled)
Definition: PT2026.cpp:2231
MTL::Instrument::PT2026Types::kSigNone
@ kSigNone
Definition: PT2026Types.h:200
MTL::Instrument::CPT2026Instrument::ParmSearchSetManualValue
bool ParmSearchSetManualValue(F64 ManualValue_UNITS)
Ask the instrument to perform a measurement at fixed frequency. Automatic search mode is left.
Definition: PT2026.cpp:842
MTL::Instrument::CPT2026Instrument::ReadDebugLog
bool ReadDebugLog(std::string &rDebugLog)
Returns a long string containing all the operations that were processed before the last proper instru...
Definition: PT2026.cpp:3579
MTL::Instrument::CPT2026Instrument::Disconnect
void Disconnect()
Definition: PT2026.cpp:302
MTL::Instrument::PT2026Types::kRefClockExternal
@ kRefClockExternal
Definition: PT2026Types.h:350
MTL::Instrument::PT2026Types
Definition: PT2026TypeConversions.h:13
MTL::Instrument::PT2026Types::kOutputTrigShapePulseBFalling
@ kOutputTrigShapePulseBFalling
Definition: PT2026Types.h:264
MTL::Instrument::PT2026Types::sStatusRegister::Set
eStatusRegisterSet Set
Definition: PT2026Types.h:35
MTL::Instrument::PT2026Types::eStatusRegisterSet
eStatusRegisterSet
Definition: PT2026Types.h:22
MTL::Instrument::CPT2026Instrument::ChannelsGetState
bool ChannelsGetState(MTL::SCPI::tChannelList &rSelChanList, MTL::SCPI::tChannelList &rActiveChan)
Definition: PT2026.cpp:399
MTL::Instrument::PT2026Types::sMeasure::Mode
eMeasureMode Mode
Definition: PT2026Types.h:290
MTL::Instrument::PT2026Types::sEthernet::Mask
uIPAddress Mask
Definition: PT2026Types.h:374
MTL::Instrument::CPT2026Instrument::StandardStatusSetEnableRegister
bool StandardStatusSetEnableRegister(eStandardStatusRegister Set, U16 DisableMask, U16 EnableMask)
Definition: PT2026.cpp:3467
date::parse
auto parse(const std::basic_string< CharT, Traits, Alloc > &format, Parsable &tp) -> decltype(from_stream(std::declval< std::basic_istream< CharT, Traits > & >(), format.c_str(), tp), parse_manip< Parsable, CharT, Traits, Alloc >
Definition: date.h:7837
MTL::Instrument::PT2026Types::kInputTrigSrceImmediate
@ kInputTrigSrceImmediate
Definition: PT2026Types.h:239
MTL::SCPI
Definition: SCPIParsing.h:17
MTL::Instrument::PT2026Types::sSearch
Definition: PT2026Types.h:333
MTL::Instrument::PT2026Types::kOutputTrigShapeDCBGreaterThan
@ kOutputTrigShapeDCBGreaterThan
Definition: PT2026Types.h:261
MTL::Instrument::PT2026Types::sSpectrum::Samples_V
std::vector< F32 > Samples_V
Definition: PT2026Types.h:600
MTL::Instrument::PT2026Types::kCommunication
@ kCommunication
Definition: PT2026Types.h:527
MTL::Instrument::PT2026Types::sAllMeasurements::FFT
sFFTBuffer FFT
Definition: PT2026Types.h:639
MTL::Instrument::PT2026Types::sArbitraryMeasurements::RelaxationTime
bool RelaxationTime
Definition: PT2026Types.h:626
MTL::Instrument::CPT2026Instrument::ParmComUsbGet
bool ParmComUsbGet(bool &rEnabled)
Definition: PT2026.cpp:2249
MTL_SleepMs
#define MTL_SleepMs(_ms_)
Definition: Helpers.h:46
MTL::Instrument::PT2026Types::kSigRepeat
@ kSigRepeat
Definition: PT2026Types.h:202
MTL::Instrument::PT2026Types::eReferenceClock
eReferenceClock
Definition: PT2026Types.h:348
MTL::Instrument::CPT2026Instrument::ParmUnitsSet
bool ParmUnitsSet(eUnits Units)
Definition: PT2026.cpp:2135
MTL::Instrument::CPT2026Instrument::StatusGet
bool StatusGet(sStatusRegister Reg, U16 &rStatus)
Definition: PT2026.cpp:3197
MTL::Instrument::PT2026Types::eUnits
eUnits
Definition: PT2026Types.h:156
MTL::Instrument::PT2026Types::tSerialNumber
U32 tSerialNumber
Definition: PT2026Types.h:393
MTL::Instrument::PT2026Types::sProbeHall::Bz
F64 Bz
Definition: PT2026Types.h:483
MTL::Instrument::PT2026Types::kMeasMoving
@ kMeasMoving
Definition: PT2026Types.h:213
MTL::Instrument::PT2026Types::sOutputTrigger::OutputDelay_s
ParmType< F64 > OutputDelay_s
Definition: PT2026Types.h:273
MTL::Instrument::PT2026Types::sArbitraryMeasurements::Uniformity
bool Uniformity
Definition: PT2026Types.h:620
MTL::Instrument::PT2026Types::sStatusRegister::Type
eStatusRegisterType Type
Definition: PT2026Types.h:36
MTL::Instrument::PT2026Types::kMeasRepeat
@ kMeasRepeat
Definition: PT2026Types.h:214
MTL::Instrument::PT2026Types::sArbitraryMeasurements::NoFFTSamples
U32 NoFFTSamples
Definition: PT2026Types.h:629
MTL::Instrument::PT2026Types::kInputTrigSrceBus
@ kInputTrigSrceBus
Definition: PT2026Types.h:241
MTL::Instrument::PT2026Types::kSearchAuto
@ kSearchAuto
Definition: PT2026Types.h:328
MTL::Instrument::CPT2026Instrument::ParmMatchingTuningSet
bool ParmMatchingTuningSet(const sMatchingTuning< uParm > &rMatchingTuning)
Definition: PT2026.cpp:2032
MTL_ERROR_LIST_HISTORY_LEN
#define MTL_ERROR_LIST_HISTORY_LEN
Definition: PT2026.cpp:33
MTL::Instrument::CPT2026Instrument::DeleteFile
bool DeleteFile(std::string Path)
Definition: PT2026.cpp:2560
SCPIParsing.h
Utilities to aid in sending SCPI commands and parsing of SCPI reponses.
MTL::Instrument::CVISABuffer::resize
void resize(size_t size)
Definition: VISAInstrumentBuffer.h:74
MTL::Instrument::PT2026Types::sMeasure::Tracking
sTracking< ParmType > Tracking
Definition: PT2026Types.h:296
MTL::Instrument::PT2026Types::uStatusByte::sStatusByte::MAV
U8 MAV
Definition: PT2026Types.h:51
MTL::Instrument::CVISABuffer::begin
std::vector< MTL_VISA_BUFFER_TYPE >::iterator begin()
Definition: VISAInstrumentBuffer.h:99
MTL::Instrument::PT2026Types::sDigitization::DeadTime_s
ParmType< F64 > DeadTime_s
Definition: PT2026Types.h:231
MTL::Instrument::CVISABufferParser::GetNext
bool GetNext(std::vector< char >::const_iterator &rNextBegin, std::vector< char >::const_iterator &rNextEnd, const char Separator=';')
Definition: VISAInstrumentBuffer.h:232
MTL::Instrument::CVISAInstrument::SetTimeout
bool SetTimeout(ViUInt32 Timeout)
Definition: VISAInstrument.cpp:468
MTL::Instrument::CPT2026Instrument::NormalizationSet
bool NormalizationSet(const MTL::SCPI::tChannel &rChannel, const tNormalizationTable &rNormalizationTable)
Definition: PT2026.cpp:3741
PT2026.h
Interface definition for C++ API for Metrolab PT2026.
MTL::Instrument::PT2026Types::sInputTrigger::Edge
eInputTriggerEdge Edge
Definition: PT2026Types.h:253
MTL::Instrument::CPT2026Instrument::Initiate
bool Initiate(bool Continuous=false)
Starts the search operation and then immediately after NMR resonance detection proceed to NMR measure...
Definition: PT2026.cpp:2674
MTL::SCPI::FromBinaryChannelList
void FromBinaryChannelList(const char *pBinaryChanList, size_t Len, tChannelList &rChannelList)
Decode binary channel list.
Definition: SCPIParsing.h:213
MTL::Instrument::PT2026Types::kServiceRequestRegister
@ kServiceRequestRegister
Definition: PT2026Types.h:20
MTL::Instrument::PT2026Types::sAdvancedMeasurements::Basic
std::vector< sBasicMeasurement > Basic
Definition: PT2026Types.h:567
MTL::Instrument::PT2026Types::uStatusByte::StatusByte
struct MTL::Instrument::PT2026Types::uStatusByte::sStatusByte StatusByte
MTL_WRITE_AND_READ_STB_POLLING_PERIOD_MS
#define MTL_WRITE_AND_READ_STB_POLLING_PERIOD_MS
Definition: PT2026.cpp:32
MTL::Instrument::PT2026Types::kNegative
@ kNegative
Definition: PT2026Types.h:42
MTL::Instrument::CVISABufferParser::Tokenize
const tTokens Tokenize(const char Separator=';', size_t Offset=0)
Definition: VISAInstrumentBuffer.h:199
MTL::Instrument::PT2026Types::sMeasurementAveraging
Definition: PT2026Types.h:217
MTL::Instrument::PT2026Types::sMatchingTuning
Definition: PT2026Types.h:306
MTL::Instrument::CVISAInstrument::m_Lock
CRecursiveMutex m_Lock
Definition: VISAInstrument.h:63
MTL::Instrument::PT2026Types::sFile::Type
std::string Type
Definition: PT2026Types.h:521
MTL::Instrument::PT2026Types::sMeasure::Reject
bool Reject
Definition: PT2026Types.h:291
MTL::SCPI::tChannel
std::vector< unsigned char > tChannel
SCPI channel
Definition: SCPIParsing.h:25
MTL::Instrument::PT2026Types::sMatchingTuning::Mode
eMatchingTuningMode Mode
Definition: PT2026Types.h:307
MTL::Instrument::PT2026Types::kMatchTunManual
@ kMatchTunManual
Definition: PT2026Types.h:303
MTL::SCPI::IsArbitraryBlock
bool IsArbitraryBlock(const iterator_type first, const iterator_type last, size_t &rStartOffset, size_t &rLength)
Find arbitrary-block data within a buffer.
Definition: SCPIParsing.h:84
MTL::Instrument::PT2026Types::sOutputTrigger
Definition: PT2026Types.h:268
MTL::Instrument::PT2026Types::uIPAddress::Member
struct MTL::Instrument::PT2026Types::uIPAddress::@0 Member
MTL::Instrument::CPT2026Instrument::SwitchToDFUMode
bool SwitchToDFUMode()
Restart the instrument in USB DFU mode, allowing the firmware to be upgraded.
Definition: PT2026.cpp:3572
MTL::Instrument::PT2026Types::BinaryToU32
U32 BinaryToU32(const char pBinary[4])
Definition: PT2026TypeConversions.cpp:26
MTL::Instrument::PT2026Types::sSignalAveraging::Type
eSignalAveragingType Type
Definition: PT2026Types.h:206
MTL::Instrument::PT2026Types::sError::Code
I32 Code
Definition: PT2026Types.h:164
MTL::Instrument::PT2026Types::sFile
Definition: PT2026Types.h:519
MTL::Instrument::CPT2026Instrument::ParmRFPulseGet
bool ParmRFPulseGet(sPulse< uParm > &rPulse)
Definition: PT2026.cpp:1835
MTL::Instrument::PT2026Types::sFFTBuffer::FrequencyResolution_Hz
F32 FrequencyResolution_Hz
Definition: PT2026Types.h:589
MTL::Instrument::PT2026Types::sArbitraryMeasurements::RadioFrequency
bool RadioFrequency
Definition: PT2026Types.h:627
MTL::Instrument::PT2026Types::kMeasExponential
@ kMeasExponential
Definition: PT2026Types.h:212
MTL::Instrument::PT2026Types::sOutputTrigger::Level_UNITS
ParmType< F64 > Level_UNITS
Definition: PT2026Types.h:270
MTL::Instrument::PT2026Types::sError::Context
std::string Context
Definition: PT2026Types.h:166
MTL::Instrument::PT2026Types::sError::Description
std::string Description
Definition: PT2026Types.h:165
MTL::Instrument::PT2026Types::kStandardEventStatusRegister
@ kStandardEventStatusRegister
Definition: PT2026Types.h:19
MTL::Instrument::PT2026Types::sInputTrigger::Count
ParmType< U8 > Count
Definition: PT2026Types.h:254
Helpers.h
Collection of utility macros for error messages.
MTL::Instrument::PT2026Types::UnitsToString
std::string UnitsToString(eUnits Units)
Definition: PT2026TypeConversions.cpp:60
MTL::Instrument::PT2026Types::kMatchTunAuto
@ kMatchTunAuto
Definition: PT2026Types.h:302
MTL::Instrument::PT2026Types::eCommunicationFormat
eCommunicationFormat
Definition: PT2026Types.h:355
MTL::Instrument::CPT2026Instrument::ParmRefClockSet
bool ParmRefClockSet(eReferenceClock RefClock)
Definition: PT2026.cpp:2184
MTL::Instrument::CPT2026Instrument::ChannelGetRawHall
bool ChannelGetRawHall(sProbeRawHall &rRawHall)
Returns the raw 16-bit ADC measurements performed by the hall sensor located at the tip of the NMR pr...
Definition: PT2026.cpp:606
MTL::Instrument::PT2026Types::sPulse::Width_s
ParmType< F64 > Width_s
Definition: PT2026Types.h:322
MTL_Assert
#define MTL_Assert
Definition: Helpers.h:44
MTL::Instrument::PT2026Types::sEthernet::Identifier
std::string Identifier
Definition: PT2026Types.h:380
MTL::Instrument::CPT2026Instrument::ParmSearchSetHallEnable
bool ParmSearchSetHallEnable(bool Enabled)
Allow the Hall probe to take control over the search range.
Definition: PT2026.cpp:862
MTL::Instrument::PT2026Types::sArbitraryMeasurements::Flux
bool Flux
Definition: PT2026Types.h:618
MTL::Instrument::PT2026Types::sNMRSignal::Samples_V
std::vector< F32 > Samples_V
Definition: PT2026Types.h:581
MTL::Instrument::PT2026Types::kDigitizationManual
@ kDigitizationManual
Definition: PT2026Types.h:226
MTL::Instrument::CPT2026Instrument::ParmTriggerOutputGet
bool ParmTriggerOutputGet(sOutputTrigger< uParm > &rOutputTrig)
Definition: PT2026.cpp:1613
MTL::Instrument::CVISABufferParser::SetNextOffset
void SetNextOffset(std::vector< char >::const_iterator Offset)
Definition: VISAInstrumentBuffer.h:262
MTL::Instrument::PT2026Types::sInputTrigger::Period_s
ParmType< F64 > Period_s
Definition: PT2026Types.h:252
MTL::Instrument::CPT2026Instrument::ChannelsSelect
bool ChannelsSelect(const MTL::SCPI::tChannelList &rChanList)
Definition: PT2026.cpp:480
MTL_ERROR_BUFFER_LEN
#define MTL_ERROR_BUFFER_LEN
Definition: PT2026.cpp:34
MTL::Instrument::PT2026Types::sPulse
Definition: PT2026Types.h:319
MTL::Instrument::CPT2026Instrument::ParmMeasureGet
bool ParmMeasureGet(sMeasure< uParm > &rMeasure)
Definition: PT2026.cpp:925
MTL::Instrument::PT2026Types::kComFormatInteger
@ kComFormatInteger
Definition: PT2026Types.h:357
MTL::Instrument::PT2026Types::kOutputTrigShapePulseBCrossing
@ kOutputTrigShapePulseBCrossing
Definition: PT2026Types.h:265
MTL::Instrument::PT2026Types::kInputTrigSrceExternal
@ kInputTrigSrceExternal
Definition: PT2026Types.h:242
MTL::Instrument::PT2026Types::sProbeRawHall::clear
void clear()
Definition: PT2026Types.h:497
date.h
MTL::Instrument::CPT2026Instrument::ParmAveragingMeasurementGet
bool ParmAveragingMeasurementGet(sMeasurementAveraging< uParm > &rMeasAvg)
Definition: PT2026.cpp:1249
MTL::Instrument::PT2026Types::eTransition
eTransition
Definition: PT2026Types.h:40
MTL::Instrument::CPT2026Instrument::Connect
bool Connect(U32 InitialTimeout_ms)
Definition: PT2026.cpp:275
CPT2026InsException
MTL::CException< CPT2026Instrument > CPT2026InsException
Definition: PT2026.cpp:51
MTL::Instrument::CPT2026Instrument::ErrorList
const std::vector< sError > ErrorList()
Definition: PT2026.cpp:260
MTL::Instrument::CPT2026Instrument::Reset
bool Reset()
Calling this method will wipe out all user parameters that are stored in the file system and revert t...
Definition: PT2026.cpp:3545
MTL::Instrument::PT2026Types::sSignalAveraging
Definition: PT2026Types.h:205
l_ParseErrorString
void l_ParseErrorString(std::string &rErrStr, const std::string &rContext, sError &rError)
Definition: PT2026.cpp:56
MTL::Instrument::PT2026Types::tFirmwareVersion
U16 tFirmwareVersion
Definition: PT2026Types.h:468
MTL::Instrument::PT2026Types::sProbeRawHall::By
U16 By
Definition: PT2026Types.h:494
MTL::Instrument::PT2026Types::kTriggers
@ kTriggers
Definition: PT2026Types.h:529
MTL::Instrument::PT2026Types::sDigitization::Mode
eDigitizationMode Mode
Definition: PT2026Types.h:230
MTL::Instrument::CVISAInstrument::Write
bool Write(const char *Str)
Definition: VISAInstrument.cpp:393
MTL::SCPI::SplitString
void SplitString(const std::string &rStr, std::vector< std::string > &rStrings, char Sep)
Split a string into substrings separated by a given character.
Definition: SCPIParsing.h:245
MTL::Instrument
Definition: MFC3045.h:25
MTL::Instrument::CPT2026Instrument::ParmTriggerOutputSet
bool ParmTriggerOutputSet(const sOutputTrigger< uParm > &rOutputTrig)
Definition: PT2026.cpp:1540
MTL::Instrument::PT2026Types::sSpectrum::CenterFrequency_Hz
F32 CenterFrequency_Hz
Definition: PT2026Types.h:598
MTL::Instrument::PT2026Types::kPulseManual
@ kPulseManual
Definition: PT2026Types.h:316
MTL::Instrument::PT2026Types::kStatusQuestionableBit12
@ kStatusQuestionableBit12
Definition: PT2026Types.h:27
MTL::Instrument::PT2026Types::sAdvancedMeasurements::IntermediateFrequency_Hz
F64 IntermediateFrequency_Hz
Definition: PT2026Types.h:568
MTL::Instrument::PT2026Types::kDigitizationAuto
@ kDigitizationAuto
Definition: PT2026Types.h:225
MTL::Instrument::PT2026Types::kStatusOperation
@ kStatusOperation
Definition: PT2026Types.h:24
MTL::Instrument::CVISAInstrument::Close
void Close()
Definition: VISAInstrument.cpp:356
MTL::Instrument::CPT2026Instrument::LowLevelTransfer
bool LowLevelTransfer(const std::vector< U8 > &rDataToSend, std::vector< U8 > &rRcvdData, U8 &rReturnedStatus)
Definition: PT2026.cpp:3762
MTL::Instrument::PT2026Types::sOutputTrigger::InvertedPolarity
bool InvertedPolarity
Definition: PT2026Types.h:271
MTL::Instrument::PT2026Types::tFileList
std::vector< sFile > tFileList
Definition: PT2026Types.h:524
MTL::Instrument::PT2026Types::kStatusOperationBit12
@ kStatusOperationBit12
Definition: PT2026Types.h:26
MTL::Instrument::PT2026Types::kRefClockInternal
@ kRefClockInternal
Definition: PT2026Types.h:349
MTL::Instrument::CPT2026Instrument::StatusPreset
bool StatusPreset()
Definition: PT2026.cpp:3189
MTL::Instrument::PT2026Types::sAllMeasurements::clear
void clear()
Definition: PT2026Types.h:642
MTL::Instrument::PT2026Types::sArbitraryMeasurements::PolynomDegree
U32 PolynomDegree
Definition: PT2026Types.h:631
MTL::Instrument::PT2026Types::kStatusCondition
@ kStatusCondition
Definition: PT2026Types.h:31
MTL::Instrument::CPT2026Instrument::ReadFileDirectory
bool ReadFileDirectory(U32 &rUsedBytes, U32 &rAvailableBytes, tFileList &rFileList)
Definition: PT2026.cpp:2469
MTL::Instrument::PT2026Types::sArbitraryMeasurements::Deviation
bool Deviation
Definition: PT2026Types.h:619
MTL::Instrument::PT2026Types::sOutputTrigger::PulseWidth_s
ParmType< F64 > PulseWidth_s
Definition: PT2026Types.h:272
MTL::Instrument::PT2026Types::sProbeRawHall::Bz
U16 Bz
Definition: PT2026Types.h:495
MTL::Instrument::PT2026Types::sMeasurementAveraging::NoPoints
ParmType< U32 > NoPoints
Definition: PT2026Types.h:219
MTL::Instrument::CVISABuffer::end
std::vector< MTL_VISA_BUFFER_TYPE >::iterator end()
Definition: VISAInstrumentBuffer.h:111
MTL::Instrument::PT2026Types::uIPAddress::A
U8 A
Definition: PT2026Types.h:365
MTL::Instrument::CPT2026Instrument::ParmComEthernetSet
bool ParmComEthernetSet(const sEthernet &rSettings)
Definition: PT2026.cpp:2276
MTL::Instrument::PT2026Types::sEthernet::IP
uIPAddress IP
Definition: PT2026Types.h:373
MTL::Instrument::PT2026Types::sSearch::ManualValue_UNITS
ParmType< F64 > ManualValue_UNITS
Definition: PT2026Types.h:337
MTL::Instrument::PT2026Types::uStatusByte::sStatusByte::EAV
U8 EAV
Definition: PT2026Types.h:49
MTL::Instrument::PT2026Types::sMatchingTuning::Matching
ParmType< F64 > Matching
Definition: PT2026Types.h:308
MTL::Instrument::CPT2026Instrument::DeviceROMRead
bool DeviceROMRead(const MTL::SCPI::tChannel &rChannel, std::vector< U8 > &rROMContent)
Definition: PT2026.cpp:3658
MTL::Instrument::CPT2026Instrument::ParmTriggerInputGet
bool ParmTriggerInputGet(sInputTrigger< uParm > &rInputTrig)
Definition: PT2026.cpp:1428
MTL::Instrument::PT2026Types::StringToUnits
bool StringToUnits(std::string SUnits, eUnits &rUnits)
Definition: PT2026TypeConversions.cpp:47
l_ToString
std::string l_ToString(F64 number, std::streamsize precision=MTL_F64_CONVERSION_PRECISION, const char *locale=MTL_F64_CONVERSION_LOCALE)
Definition: PT2026.cpp:74
MTL::Instrument::PT2026Types::eRemoteBusyLEDmode
eRemoteBusyLEDmode
Definition: PT2026Types.h:507
MTL::Instrument::CPT2026Instrument::WriteFile
bool WriteFile(std::string Path, const std::string &rContent)
Definition: PT2026.cpp:2539
MTL::Instrument::PT2026Types::kInputTrigEdgeFalling
@ kInputTrigEdgeFalling
Definition: PT2026Types.h:246
MTL::Instrument::PT2026Types::BinaryToF32
F32 BinaryToF32(const char pBinary[4])
Definition: PT2026TypeConversions.cpp:34
MTL::Instrument::PT2026Types::sProbeRawHall::T
U16 T
Definition: PT2026Types.h:496
MTL::Instrument::PT2026Types::sArbitraryMeasurements
Definition: PT2026Types.h:617
MTL::Instrument::CPT2026Instrument::UnlockInterface
bool UnlockInterface()
Definition: PT2026.cpp:333
MTL::Instrument::PT2026Types::sMeasure::Bandwidth_Hz
ParmType< F64 > Bandwidth_Hz
Definition: PT2026Types.h:293
MTL::Instrument::CPT2026Instrument::GetSearchProgress
bool GetSearchProgress(U8 &rSPR, F64 &rHallMeasurement_UNITS)
Definition: PT2026.cpp:3125
MTL::Instrument::PT2026Types::sAllMeasurements
Definition: PT2026Types.h:633
MTL::Instrument::PT2026Types::kStatusOperationBit11
@ kStatusOperationBit11
Definition: PT2026Types.h:25
MTL::Instrument::CVISAInstrument::Open
bool Open(eOpenAccessMode AccessMode=eOpenAccessMode::NoLock, ViUInt32 Timeout_ms=0)
Definition: VISAInstrument.cpp:335
MTL::Instrument::PT2026Types::uIPAddress::D
U8 D
Definition: PT2026Types.h:368
MTL::SCPI::ToStringChannelList
void ToStringChannelList(const tChannelList &rChannelList, std::string &rStr)
Encode channel list string.
Definition: SCPIParsing.h:193
uIPAddress_to_string
std::string uIPAddress_to_string(uIPAddress Addr)
Definition: PT2026.cpp:67
MTL::Instrument::PT2026Types::kOutputTrigShapeDCBLowerThan
@ kOutputTrigShapeDCBLowerThan
Definition: PT2026Types.h:262
MTL::Instrument::CPT2026Instrument::ChannelsSetLimitedListState
bool ChannelsSetLimitedListState(bool State)
Definition: PT2026.cpp:434
MTL::Instrument::CPT2026Instrument::ParmDigitizationGet
bool ParmDigitizationGet(sDigitization< uParm > &rDigitization)
Definition: PT2026.cpp:1941
MTL::Instrument::CPT2026Instrument::ChannelsGetList
bool ChannelsGetList(MTL::SCPI::tChannelList &rChanList)
Definition: PT2026.cpp:354
MTL::Instrument::PT2026Types::sMeasurementAveraging::Type
eMeasurementAveragingType Type
Definition: PT2026Types.h:218
MTL::Instrument::PT2026Types::sSignalAveraging::NoPoints
ParmType< U32 > NoPoints
Definition: PT2026Types.h:207
MTL::Instrument::PT2026Types::sArbitraryMeasurements::IF
bool IF
Definition: PT2026Types.h:625
MTL::Instrument::PT2026Types::kStatusQestionable
@ kStatusQestionable
Definition: PT2026Types.h:23
MTL::Instrument::CPT2026Instrument::StatusSetTransitionFilter
bool StatusSetTransitionFilter(eStatusRegisterSet Set, eTransition Transition, U16 ClearMask, U16 SetMask)
Definition: PT2026.cpp:3388
MTL::Instrument::PT2026Types::sAdvancedMeasurements::RadioFrequency_Hz
F64 RadioFrequency_Hz
Definition: PT2026Types.h:570
MTL::CException
Exception to be thrown.
Definition: Exception.h:16
MTL::Instrument::CPT2026Instrument::ChannelsGetLimits
bool ChannelsGetLimits(const MTL::SCPI::tChannelList &rChanList, std::vector< F64 > &rLowLimit_UNITS, std::vector< F64 > &rHighLimit_UNITS)
Definition: PT2026.cpp:559
MTL::Instrument::PT2026Types::kOutputTrigShapePulseBRising
@ kOutputTrigShapePulseBRising
Definition: PT2026Types.h:263
MTL::CException::what
virtual const char * what() const noexcept
Return string describing what happened.
Definition: Exception.h:34
MTL::Instrument::PT2026Types::sFile::Size
size_t Size
Definition: PT2026Types.h:522
MTL::Instrument::CPT2026Instrument::ParmRefClockGet
bool ParmRefClockGet(eReferenceClock &rRefClock)
Definition: PT2026.cpp:2205
MTL::Instrument::CPT2026Instrument::ForceOutputTrigger
bool ForceOutputTrigger()
Set the output trigger according to current output trigger parametrization. This method is very speci...
Definition: PT2026.cpp:2700
MTL::Instrument::PT2026Types::sSearch::FrequencyStep_Hz
ParmType< F64 > FrequencyStep_Hz
Definition: PT2026Types.h:336
MTL::Instrument::PT2026Types::StringToExtendedChannelList
bool StringToExtendedChannelList(std::string SExtChanList, CExtendedChannelList &rExtChanList)
Definition: PT2026TypeConversions.cpp:121
MTL::Instrument::PT2026Types::sFile::Path
std::string Path
Definition: PT2026Types.h:520
MTL::Instrument::PT2026Types::tPPMReference_UNITS
F64 tPPMReference_UNITS
Definition: PT2026Types.h:344
MTL::Instrument::PT2026Types::kInputTrigSrceTimer
@ kInputTrigSrceTimer
Definition: PT2026Types.h:240
MTL::Instrument::PT2026Types::BinaryToF64
F64 BinaryToF64(const char pBinary[8])
Definition: PT2026TypeConversions.cpp:42
MTL::Instrument::CVISABufferParser::tTokens
std::vector< sToken > tTokens
Definition: VISAInstrumentBuffer.h:184
MTL::Instrument::CPT2026Instrument::ParmAveragingSignalSet
bool ParmAveragingSignalSet(const sSignalAveraging< uParm > &rSigAvg)
Definition: PT2026.cpp:1070
MTL::Instrument::tResourceName
std::string tResourceName
Definition: VISAInstrumentTypes.h:21
MTL::Instrument::CPT2026Instrument::LockInterface
bool LockInterface()
Definition: PT2026.cpp:313
MTL::SCPI::FromStringChannelList
void FromStringChannelList(iterator_type first, iterator_type last, tChannelList &rChannelList)
Decode channel list string.
Definition: SCPIParsing.h:147
MTL::Instrument::CPT2026Instrument::NormalizationGet
bool NormalizationGet(const MTL::SCPI::tChannel &rChannel, tNormalizationTable &rNormalizationTable)
Definition: PT2026.cpp:3709
MTL::Instrument::PT2026Types::sProbeHall::By
F64 By
Definition: PT2026Types.h:482
MTL::Instrument::CPT2026Instrument::ChannelGetHall
bool ChannelGetHall(sProbeHall &rHall)
Returns in the current units the calibrated Hall measurements.
Definition: PT2026.cpp:635
MTL::Instrument::CPT2026Instrument::ReadCaseTemperature
bool ReadCaseTemperature(F32 &rTemperatureDegC)
Returns the internal instrument temperature. An internal survey will shut the instrument down if this...
Definition: PT2026.cpp:3552
MTL::Instrument::PT2026Types::kMeasureManual
@ kMeasureManual
Definition: PT2026Types.h:280
MTL::Instrument::CPT2026Instrument::ParmTriggerInputSet
bool ParmTriggerInputSet(const sInputTrigger< uParm > &rInputTrig)
Definition: PT2026.cpp:1381
MTL::Instrument::CPT2026Instrument::ParmDigitizationSet
bool ParmDigitizationSet(const sDigitization< uParm > &rDigitization)
Definition: PT2026.cpp:1917
MTL_F64_CONVERSION_PRECISION
#define MTL_F64_CONVERSION_PRECISION
Definition: PT2026.cpp:42
MTL::Instrument::CVISABufferParser
Definition: VISAInstrumentBuffer.h:171
MTL::Instrument::CVISABuffer
Definition: VISAInstrumentBuffer.h:37
MTL::Instrument::PT2026Types::kUnits
@ kUnits
Definition: PT2026Types.h:531
MTL::Instrument::PT2026Types::uStatusByte
Definition: PT2026Types.h:44
MTL::Instrument::CPT2026Instrument::ParmAveragingMeasurementSet
bool ParmAveragingMeasurementSet(const sMeasurementAveraging< uParm > &rMeasAvg)
Definition: PT2026.cpp:1219
MTL::Instrument::CPT2026Instrument::MeasurementsGet
bool MeasurementsGet(U32 NoMeasurements, std::vector< tFlux > &rFlux, eUnits &rUnits)
Returns the NMR magnetic field density measurements, including the unit used. A measurement vector is...
Definition: PT2026.cpp:2712
MTL::Instrument::PT2026Types::sArbitraryMeasurements::NoSpectrumSamples
U32 NoSpectrumSamples
Definition: PT2026Types.h:630
MTL::Instrument::PT2026Types::sMeasure
Definition: PT2026Types.h:289
MTL::Instrument::PT2026Types::sNMRSignal::SamplePeriod_s
F32 SamplePeriod_s
Definition: PT2026Types.h:580
MTL::Instrument::PT2026Types::sEthernet::Domain
std::string Domain
Definition: PT2026Types.h:375
MTL::Instrument::CPT2026Instrument::ChannelsGetInfo
bool ChannelsGetInfo(const MTL::SCPI::tChannelList &rChanList, std::vector< sChannelIformation > &rChanInfo)
Definition: PT2026.cpp:501
MTL::Instrument::PT2026Types::sEthernet::Gateway
uIPAddress Gateway
Definition: PT2026Types.h:377
MTL::Instrument::PT2026Types::sAdvancedMeasurements::RelaxationTime_s
F32 RelaxationTime_s
Definition: PT2026Types.h:569
MTL::Instrument::CPT2026Instrument::ChannelSetRemoteLEDMode
bool ChannelSetRemoteLEDMode(eRemoteBusyLEDmode Mode)
Definition: PT2026.cpp:687
MTL::Instrument::PT2026Types::sAllMeasurements::AdvMeas
sAdvancedMeasurements AdvMeas
Definition: PT2026Types.h:634
MTL::Instrument::PT2026Types::kMeasure
@ kMeasure
Definition: PT2026Types.h:528
MTL::Instrument::PT2026Types::sProbeRawHall::Bx
U16 Bx
Definition: PT2026Types.h:493
MTL::Instrument::PT2026Types::tModel
U32 tModel
Definition: PT2026Types.h:392
MTL::Instrument::CPT2026Instrument::ParmMatchingTuningGet
bool ParmMatchingTuningGet(sMatchingTuning< uParm > &rMatchingTuning)
Definition: PT2026.cpp:2053
MTL::Instrument::PT2026Types::sMeasure::DetectionLevel_V
ParmType< F64 > DetectionLevel_V
Definition: PT2026Types.h:292
MTL::Instrument::CPT2026Instrument::ChannelsGetLimitedListState
bool ChannelsGetLimitedListState(bool &rState)
Definition: PT2026.cpp:454
MTL::Instrument::PT2026Types::uIPAddress::C
U8 C
Definition: PT2026Types.h:367
MTL::Instrument::PT2026Types::kInputTrigEdgeBoth
@ kInputTrigEdgeBoth
Definition: PT2026Types.h:247
MTL::Instrument::PT2026Types::MAX_BUSY_LED_MODE
const U8 MAX_BUSY_LED_MODE
Definition: PT2026Types.h:515
MTL::Instrument::CVISABuffer::data
MTL_VISA_BUFFER_TYPE * data() noexcept
Definition: VISAInstrumentBuffer.h:124
MTL::Instrument::PT2026Types::CExtendedChannelList
Definition: PT2026Types.h:446
MTL::Synchronization::CLockGuard
Lock.
Definition: Synchronization.h:62
OSDefines.h
Platform Dependent Definitions.
MTL::Instrument::PT2026Types::sFFTBuffer::Samples_V
std::vector< F32 > Samples_V
Definition: PT2026Types.h:590
MTL::Instrument::PT2026Types::tNormalizationFactor_Hz
F32 tNormalizationFactor_Hz
Definition: PT2026Types.h:666
MTL::Instrument::CPT2026Instrument::Abort
bool Abort(bool CancelContinuous=true)
Abort the current operation (Search or measure). Once the operation is aborted, the instrument will b...
Definition: PT2026.cpp:2683
MTL::Instrument::PT2026Types::sSearch::Mode
eSearchMode Mode
Definition: PT2026Types.h:334
MTL::Instrument::CPT2026Instrument::WriteCustomCommand
bool WriteCustomCommand(const std::string &rWriteStr)
Definition: PT2026.cpp:3793
MTL::Instrument::PT2026Types::sEthernet::NBNSEnabled
bool NBNSEnabled
Definition: PT2026Types.h:379
MTL::Instrument::PT2026Types::sArbitraryMeasurements::Status
bool Status
Definition: PT2026Types.h:623
MTL::Instrument::CPT2026Instrument::SaveSettings
bool SaveSettings(eSettingType Type, std::string Name)
Definition: PT2026.cpp:2607
Exception.h
Exception handling utilities.
MTL::Instrument::PT2026Types::sSearch::LowLimit_UNITS
ParmType< F64 > LowLimit_UNITS
Definition: PT2026Types.h:338
MTL::Instrument::CVISAInstrument
VISA instrument class.
Definition: VISAInstrument.h:60
MTL::Instrument::CPT2026Instrument::ParmSearchGet
bool ParmSearchGet(sSearch< uParm > &rSearch)
Definition: PT2026.cpp:729
MTL::Instrument::PT2026Types::sArbitraryMeasurements::NbValidMeas
bool NbValidMeas
Definition: PT2026Types.h:624
MTL::Instrument::CPT2026Instrument::ParmRFPulseSet
bool ParmRFPulseSet(const sPulse< uParm > &rPulse)
Definition: PT2026.cpp:1812
MTL::Instrument::PT2026Types::sPulse::Period_s
ParmType< F64 > Period_s
Definition: PT2026Types.h:321
MTL::Instrument::PT2026Types::eStandardStatusRegister
eStandardStatusRegister
Definition: PT2026Types.h:18
MTL::Instrument::CPT2026Instrument::ParmMeasureSet
bool ParmMeasureSet(const sMeasure< uParm > &rMeasure)
Definition: PT2026.cpp:896
MTL::Instrument::CPT2026Instrument::ReadInformationDates
bool ReadInformationDates(std::string &rSManufacturingDate, std::time_t &rManufacturingDate, std::string &rSCalibrationDate, std::time_t &rCalibrationDate)
Returns the manufacturing and calibration date in plain text or a number representing the amount of s...
Definition: PT2026.cpp:3599
MTL::Instrument::PT2026Types::sMeasure::NoFitPoints
ParmType< U32 > NoFitPoints
Definition: PT2026Types.h:294
MTL::Instrument::CPT2026Instrument::SendBusTrigger
bool SendBusTrigger()
Send a trigger to the instrument. If configured to react to this bus trigger, the acquisition sub sys...
Definition: PT2026.cpp:2692
MTL::Instrument::PT2026Types::uStatusByte::RawSTB
U16 RawSTB
Definition: PT2026Types.h:45
MTL::Instrument::PT2026Types::sProbeRawHall
Definition: PT2026Types.h:492
MTL::Instrument::PT2026Types::kStatusEnable
@ kStatusEnable
Definition: PT2026Types.h:32
MTL::Instrument::PT2026Types::kMeasureAuto
@ kMeasureAuto
Definition: PT2026Types.h:279
MTL::Instrument::eTriggerProtocol::Default
@ Default
MTL_Unused
#define MTL_Unused(x)
Definition: Helpers.h:47
MTL::Instrument::PT2026Types::sPulse::Mode
ePulseMode Mode
Definition: PT2026Types.h:320
MTL::Instrument::CPT2026Instrument::StatusSetEnableRegister
bool StatusSetEnableRegister(eStatusRegisterSet Set, U16 DisableMask, U16 EnableMask)
Definition: PT2026.cpp:3333
MTL::Instrument::PT2026Types::sAllMeasurements::NMR
sNMRSignal NMR
Definition: PT2026Types.h:638
MTL::Instrument::PT2026Types::sError
Definition: PT2026Types.h:163
MTL::Instrument::CVISABufferParser::end
std::vector< char >::const_iterator end()
Definition: VISAInstrumentBuffer.h:194
MTL::Instrument::CPT2026Instrument::ParmComVXI11Get
bool ParmComVXI11Get(bool &rEnabled)
Definition: PT2026.cpp:2438
MTL::Instrument::CVISAInstrument::AssertTrigger
bool AssertTrigger(eTriggerProtocol Protocol)
Definition: VISAInstrument.cpp:545
MTL::Instrument::CVISABuffer::size
size_t size() const
Definition: VISAInstrumentBuffer.h:86
MTL::Instrument::PT2026Types::sArbitraryMeasurements::Timestamp
bool Timestamp
Definition: PT2026Types.h:622
MTL::Instrument::CVISAResourceManager
VISA Resource Manager class.
Definition: VISAInstrument.h:35
MTL::Instrument::CPT2026Instrument::RecallSettings
bool RecallSettings(std::string Name)
Definition: PT2026.cpp:2651
MTL::Instrument::PT2026Types::sSpectrum::FrequencyResolution_Hz
F32 FrequencyResolution_Hz
Definition: PT2026Types.h:599
MTL::Instrument::PT2026Types::sFitPolynom::Residue
F32 Residue
Definition: PT2026Types.h:609
MTL::Instrument::PT2026Types::BinaryToU64
U64 BinaryToU64(const char pBinary[8])
Definition: PT2026TypeConversions.cpp:38
MTL::Instrument::PT2026Types::kSearchManual
@ kSearchManual
Definition: PT2026Types.h:330
MTL::Instrument::PT2026Types::kMeasNone
@ kMeasNone
Definition: PT2026Types.h:211
MTL::Instrument::PT2026Types::kAll
@ kAll
Definition: PT2026Types.h:526
MTL__LOCATION__
#define MTL__LOCATION__
Definition: Helpers.h:22
MTL::Instrument::PT2026Types::tNormalizationTable
std::vector< tNormalizationFactor_Hz > tNormalizationTable
Definition: PT2026Types.h:667
MTL::Instrument::PT2026Types::sFitPolynom::Coeffs
std::vector< F32 > Coeffs
Definition: PT2026Types.h:610
MTL::Instrument::CVISAInstrument::Clear
bool Clear()
Definition: VISAInstrument.cpp:477
MTL::Instrument::CPT2026Instrument::ParmSearchGetHallEnable
bool ParmSearchGetHallEnable(bool &rEnabled)
Definition: PT2026.cpp:871
MTL::Instrument::PT2026Types::sInputTrigger
Definition: PT2026Types.h:250
MTL::Instrument::CPT2026Instrument::ParmComVXI11Set
bool ParmComVXI11Set(bool Enabled)
Definition: PT2026.cpp:2420
MTL::Instrument::eOpenAccessMode::ExclusiveLock
@ ExclusiveLock
MTL_INSTRUMENT_PT2026_DEBUG_COUT
#define MTL_INSTRUMENT_PT2026_DEBUG_COUT(__X__)
Definition: PT2026.cpp:28
MTL::Instrument::PT2026Types::sAllMeasurements::FitPolynom
sFitPolynom FitPolynom
Definition: PT2026Types.h:641
MTL::Instrument::PT2026Types::sEthernet::Enabled
bool Enabled
Definition: PT2026Types.h:372
MTL::Instrument::PT2026Types::sAllMeasurements::Spectrum
sSpectrum Spectrum
Definition: PT2026Types.h:640