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