C++Instrument Catalog MFC 1.2
Metrolab C++InstrumentCatalog for MFC
Loading...
Searching...
No Matches
PT2026.h
Go to the documentation of this file.
1
7
8
9#pragma once
10
11// Standard includes
12#include <ctime>
13#include <queue>
14
15// Personal includes
16#include "VISAInstrument.h"
17#include "PT2026Types.h"
18
19// Version
20#define PT2026_CPP_DRIVER_BCD_VERSION 0x0106
21
22using namespace MTL::Instrument::PT2026Types;
23
24namespace MTL {
25 namespace Instrument {
26
29 {
30 //----------------------------------------------------------------------//
31 // Private Attributes //
32 //----------------------------------------------------------------------//
33 private:
34 // General
35 ViUInt32 m_Timeout_ms;
36 std::queue<sError> m_ErrorList;
37 CVISABuffer m_ReadBuffer;
38 struct sFwVersion {
39 U32 Major;
40 U32 Minor;
41 bool IsLegacy0122; // Whether firmware is <= 1.22
42 bool IsLegacy0121; // Whether firmware is <= 1.21 (Busy led state not supported)
43 bool IsLegacyPT2026; // Whether the PT2026 is first edition and not the PT2026B/+
44 sFwVersion()
45 : Major(0), Minor(0), IsLegacy0122(false), IsLegacy0121(false), IsLegacyPT2026(false)
46 {}
47 } m_FwVersion;
48 struct sInstrInformation {
49 std::string Idn; // [-] Full identification of connected instrument
50 std::string Manufacturer; // [-] Manufacturer of the instrument
51 std::string Model; // [-] Model of the instrument
52 std::string SerialNumber; // [-] Serial Number of the instrument
53 std::string FirmwareInfo; // [-] Overall Firmware information of the instrument
54 sInstrInformation()
55 : Idn(""), Manufacturer(""), Model(""), SerialNumber(""), FirmwareInfo("")
56 {}
57 } m_InstrInformation;
58 //----------------------------------------------------------------------//
59 // Utilities //
60 //----------------------------------------------------------------------//
61 private:
62 bool l_GetErrorList(const std::string & rContext);
63 bool l_WriteAndRead(const std::string & rWriteStr, CVISABuffer & rReadBuffer, bool WaitForMAV = false);
64
65 //----------------------------------------------------------------------//
66 // PT2026 Interface //
67 //----------------------------------------------------------------------//
68 public:
72
73 //----------------------------------------------------------------------//
74 // Constructors / destructors
76 virtual ~CPT2026Instrument();
77
83
84 //----------------------------------------------------------------------//
85 // General Information
86 const std::vector<sError> ErrorList();
87 const sFwVersion& FwVerInfo(); // Available once connected to device
88 const sInstrInformation& InstrumentInfo(); // Available once connected to device
89
91
97
98 //----------------------------------------------------------------------//
99 // Open / Close
100 bool Connect(U32 InitialTimeout_ms);
101 void Disconnect();
102
104
113
114 //----------------------------------------------------------------------//
115 // Interface lock
116 bool LockInterface();
117 bool UnlockInterface();
118
120
126
127 //----------------------------------------------------------------------//
128 // Channels
130 bool ChannelsGetList(CExtendedChannelList & rChanList);
131 bool ChannelsGetState(MTL::SCPI::tChannelList & rSelChanList, MTL::SCPI::tChannelList & rActiveChan);
132 bool ChannelsSetLimitedListState(bool State);
133 bool ChannelsGetLimitedListState(bool & rState);
134 bool ChannelsSelect(const MTL::SCPI::tChannelList & rChanList);
135 bool ChannelsGetInfo(const MTL::SCPI::tChannelList & rChanList, std::vector<sChannelIformation> & rChanInfo);
136 bool ChannelsGetLimits(const MTL::SCPI::tChannelList & rChanList, std::vector<F64> & rLowLimit_UNITS, std::vector<F64> & rHighLimit_UNITS);
137
138 bool ChannelGetRawHall(sProbeRawHall & rRawHall);
139 bool ChannelGetHall(sProbeHall & rHall);
140
143
145
146 //----------------------------------------------------------------------//
147 // Parameters
148
161
162 // Search
163 bool ParmSearchSet(const sSearch<uParm> & rSearch, F64 Lgc0122_DetectionLevel_V = 0.15);
164 bool ParmSearchGet(sSearch<uParm> & rSearch);
165 bool ParmSearchGet(sSearch<sBoundedParm> & rSearch);
166
167 bool ParmSearchSetManualValue(F64 ManualValue_UNITS);
168 bool ParmSearchSetLimits(F64 LowLimit_UNITS, F64 HighLimit_UNITS);
169 bool ParmSearchSetHallEnable(bool Enabled);
170 bool ParmSearchGetHallEnable(bool & rEnabled);
171
177
178 // Measure
179 bool ParmMeasureSet(const sMeasure<uParm> & rMeasure);
180 bool ParmMeasureGet(sMeasure<uParm> & rMeasure);
181 bool ParmMeasureGet(sMeasure<sBoundedParm> & rMeasure);
182
195
196 // Averaging
203
211
212 // Input Trigger
213 bool ParmTriggerInputSet(const sInputTrigger<uParm> & rInputTrig);
214 bool ParmTriggerInputGet(sInputTrigger<uParm> & rInputTrig);
216
225
226 // Output Trigger
227 bool ParmTriggerOutputSet(const sOutputTrigger<uParm> & rOutputTrig);
230
240
241 // RF Pulse
242 bool ParmRFPulseSet(const sPulse<uParm> & rPulse);
243 bool ParmRFPulseGet(sPulse<uParm> & rPulse);
245
254
255 // Digitization
256 bool ParmDigitizationSet(const sDigitization<uParm> & rDigitization);
257 bool ParmDigitizationGet(sDigitization<uParm> & rDigitization);
259
267
268 // Matching / Tuning
269 bool ParmMatchingTuningSet(const sMatchingTuning<uParm> & rMatchingTuning);
270 bool ParmMatchingTuningGet(sMatchingTuning<uParm> & rMatchingTuning);
272
282
283 // Units
284 bool ParmUnitsSet(eUnits Units);
286 bool ParmUnitsGet(eUnits & rUnits, tPPMReference_UNITS & rRef);
287
294
295 // Ref Clock
296 bool ParmRefClockSet(eReferenceClock RefClock);
297 bool ParmRefClockGet(eReferenceClock & rRefClock);
298
300
306
307 // Communication : USB
308 bool ParmComUsbSet(bool Enabled);
309 bool ParmComUsbGet(bool & rEnabled);
310
317
318 // Communication : Ethernet
319 bool ParmComEthernetSet(const sEthernet & rSettings);
320 bool ParmComEthernetGet(sEthernet & rSettings);
321
328
329 // Communication : VXI11
330 bool ParmComVXI11Set(bool Enabled);
331 bool ParmComVXI11Get(bool & rEnabled);
332
334
335 // Settings / Files
339
340 //----------------------------------------------------------------------//
341 // Settings / Files
342 bool ReadFileDirectory(U32 & rUsedBytes, U32 & rAvailableBytes, tFileList & rFileList);
343 bool ReadFile(std::string Path, std::string & rContent);
344 bool WriteFile(std::string Path, const std::string & rContent);
345 bool DeleteFile(std::string Path);
346 bool GetSettingFileList(std::vector<std::string> & rSettingFileList);
347 bool SaveSettings(eSettingType Type, std::string Name);
348 bool RecallSettings(std::string Name);
349
351
356
357 //----------------------------------------------------------------------//
358 // Initiate / Abort / Trigger
359 bool Initiate(bool Continuous = false);
360 bool Abort(bool CancelContinuous = true);
361 bool SendBusTrigger();
362 bool ForceOutputTrigger();
363
365
369
370 //----------------------------------------------------------------------//
371 // Measurements / Data
372 bool MeasurementsGet(U32 NoMeasurements, std::vector<tFlux> & rFlux, eUnits & rUnits);
373 bool MeasurementsGet(U32 NoMeasurements, sArbitraryMeasurements ArbSelect, sAllMeasurements & rMeas, eUnits & rUnits);
374 bool GetSearchProgress(U8 & rSPR, F32 & rHallMeasurement_UNITS);
375 bool SetFormat(eCommunicationFormat Format);
376
378
379 //----------------------------------------------------------------------//
380 // High Level Measurement
381 //bool Measure(tFlux & rFlux, MTL::SCPI::tChannelList ChanList, F64 ExpectedField = 0, unsigned int NoDigits = 0);
382 //bool Measure(std::vector<tFlux> & rFluxArray, unsigned int NoMeasurements, MTL::SCPI::tChannelList ChanList, F64 ExpectedField = 0, unsigned int NoDigits = 0);
383
388
389 //----------------------------------------------------------------------//
390 // Status Handling
391 bool StatusPreset();
392 bool StatusGet(sStatusRegister Reg, U16 & rStatus);
393 bool StatusGet(std::vector<sStatusRegister> Regs, std::vector<U16> & rStatus);
394 bool StatusSetEnableRegister(eStatusRegisterSet Set, U16 DisableMask, U16 EnableMask);
395 bool StatusSetTransitionFilter(eStatusRegisterSet Set, eTransition Transition, U16 ClearMask, U16 SetMask);
396 bool StandardStatusSetEnableRegister(eStandardStatusRegister Set, U16 DisableMask, U16 EnableMask);
397
399
402
403 //----------------------------------------------------------------------//
404 // Utilities
405 bool GetIdentification(std::string & rIdentification);
406 bool GetSystemVersionAll(std::string & rSystVersion);
407 bool PowerOff(bool Reboot = false);
408 bool Reset();
409 bool ReadCaseTemperature(F32 & rTemperatureDegC);
410 bool SwitchToDFUMode();
411 bool ReadDebugLog(std::string & rDebugLog);
412 bool ReadManufacturingDate(std::string & rSManufacturingDate, std::time_t & rManufacturingDate);
413 bool ReadCalibrationDate(std::string & rSCalibrationDate, std::time_t & rCalibrationDate);
414 bool SetCalibrationDate(std::string & rNewCalibrationDate);
415
417
418 // Low Level Utilities
421
422 //----------------------------------------------------------------------//
423 // Low Level Utilities
424 bool DeviceROMRead(const MTL::SCPI::tChannel & rChannel, std::vector<U8> & rROMContent);
425 bool DeviceROMWrite(const MTL::SCPI::tChannel & rChannel, const std::vector<U8> & rROMContent);
426 bool NormalizationGet(const MTL::SCPI::tChannel & rChannel, tNormalizationTable & rNormalizationTable);
427 bool NormalizationSet(const MTL::SCPI::tChannel & rChannel, const tNormalizationTable & rNormalizationTable);
428 bool AuthenticationStatus(bool & rIsAuthenticated, std::string & rCipherMsgGet);
429 bool AuthenticationRequest(const std::string & rCipherMsgSet, bool & rIsAuthenticated);
430 bool LowLevelTransfer(const std::vector<U8> & rDataToSend, std::vector<U8> & rRcvdData, U8 & rReturnedStatus);
431 bool WriteCustomCommand(const std::string & rWriteStr);
432
434
435 private:
436 // Legacy commands for PT2026 firmwares prior and equal to 1.22
439
440 //----------------------------------------------------------------------//
441 // Legacy commands (FW <= 1.22)
442 bool l_Lgc0122_ParmSearchSet(const sLgc0122_Search<uParm>& rSearch);
443 bool l_Lgc0122_ParmSearchGet(sLgc0122_Search<uParm>& rSearch);
444 bool l_Lgc0122_ParmSearchGet(sLgc0122_Search<sBoundedParm>& rSearch);
445
447 };
448
449 } // namespace Instrument
450} // namespace MTL
C++ wrapper for NI-VISA: interface definition.
unsigned long ViUInt32
Definition visatype.h:102
std::string tResourceName
std::vector< tNormalizationFactor_Hz > tNormalizationTable
std::vector< sFile > tFileList
std::vector< tChannel > tChannelList
SCPI channel list
Definition SCPIParsing.h:26
std::vector< unsigned char > tChannel
SCPI channel
Definition SCPIParsing.h:25
bool ParmSearchSet(const sSearch< uParm > &rSearch, F64 Lgc0122_DetectionLevel_V=0.15)
Configure the search operation, including frequency steps and the search bounds specified in the sele...
Definition PT2026.cpp:755
bool ParmRefClockSet(eReferenceClock RefClock)
Definition PT2026.cpp:2284
bool NormalizationSet(const MTL::SCPI::tChannel &rChannel, const tNormalizationTable &rNormalizationTable)
Definition PT2026.cpp:3898
bool LowLevelTransfer(const std::vector< U8 > &rDataToSend, std::vector< U8 > &rRcvdData, U8 &rReturnedStatus)
Definition PT2026.cpp:3983
bool ParmMeasureGet(sMeasure< uParm > &rMeasure)
Definition PT2026.cpp:1025
const std::vector< sError > ErrorList()
Definition PT2026.cpp:259
bool ReadDebugLog(std::string &rDebugLog)
Returns a long string containing all the operations that were processed before the last proper instru...
Definition PT2026.cpp:3705
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:2812
bool ParmComVXI11Get(bool &rEnabled)
Definition PT2026.cpp:2538
bool ParmSearchGet(sSearch< uParm > &rSearch)
Definition PT2026.cpp:796
bool ParmSearchSetHallEnable(bool Enabled)
Allow the Hall probe to take control over the search range.
Definition PT2026.cpp:962
bool GetSearchProgress(U8 &rSPR, F32 &rHallMeasurement_UNITS)
Definition PT2026.cpp:3225
bool ChannelGetHall(sProbeHall &rHall)
Returns in the current units the calibrated Hall measurements.
Definition PT2026.cpp:691
bool Abort(bool CancelContinuous=true)
Abort the current operation (Search or measure). Once the operation is aborted, the instrument will b...
Definition PT2026.cpp:2783
bool ChannelGetRemoteLEDMode(eRemoteBusyLEDmode &rMode)
Definition PT2026.cpp:720
bool ReadFile(std::string Path, std::string &rContent)
Definition PT2026.cpp:2618
bool GetSettingFileList(std::vector< std::string > &rSettingFileList)
Definition PT2026.cpp:2679
bool ChannelsGetInfo(const MTL::SCPI::tChannelList &rChanList, std::vector< sChannelIformation > &rChanInfo)
Definition PT2026.cpp:545
bool ParmMatchingTuningSet(const sMatchingTuning< uParm > &rMatchingTuning)
Definition PT2026.cpp:2132
bool NormalizationGet(const MTL::SCPI::tChannel &rChannel, tNormalizationTable &rNormalizationTable)
Definition PT2026.cpp:3866
bool ChannelsGetState(MTL::SCPI::tChannelList &rSelChanList, MTL::SCPI::tChannelList &rActiveChan)
Definition PT2026.cpp:443
bool ParmUnitsSetPPMRef(tPPMReference_UNITS Ref)
Definition PT2026.cpp:2244
bool ParmSearchSetLimits(F64 LowLimit_UNITS, F64 HighLimit_UNITS)
Set the search bounds in the selected unit.
Definition PT2026.cpp:951
bool RecallSettings(std::string Name)
Definition PT2026.cpp:2751
const sInstrInformation & InstrumentInfo()
Definition PT2026.cpp:275
CPT2026Instrument(CVISAResourceManager &rRM, tResourceName Rsrc)
Constructors / destructors.
Definition PT2026.cpp:244
bool WriteFile(std::string Path, const std::string &rContent)
Definition PT2026.cpp:2639
bool ParmTriggerInputGet(sInputTrigger< uParm > &rInputTrig)
Definition PT2026.cpp:1528
bool SendBusTrigger()
Send a trigger to the instrument. If configured to react to this bus trigger, the acquisition sub sys...
Definition PT2026.cpp:2792
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:662
bool ChannelsSelect(const MTL::SCPI::tChannelList &rChanList)
Definition PT2026.cpp:524
bool ParmComVXI11Set(bool Enabled)
Definition PT2026.cpp:2520
bool ParmUnitsSet(eUnits Units)
Definition PT2026.cpp:2235
bool ChannelsSetLimitedListState(bool State)
Definition PT2026.cpp:478
bool ParmRFPulseSet(const sPulse< uParm > &rPulse)
Definition PT2026.cpp:1912
bool ChannelsGetLimits(const MTL::SCPI::tChannelList &rChanList, std::vector< F64 > &rLowLimit_UNITS, std::vector< F64 > &rHighLimit_UNITS)
Definition PT2026.cpp:615
bool ParmRFPulseGet(sPulse< uParm > &rPulse)
Definition PT2026.cpp:1935
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:3269
bool ParmComUsbSet(bool Enabled)
Definition PT2026.cpp:2331
bool ParmTriggerInputSet(const sInputTrigger< uParm > &rInputTrig)
Definition PT2026.cpp:1481
bool ParmUnitsGet(eUnits &rUnits, tPPMReference_UNITS &rRef)
Definition PT2026.cpp:2253
bool ParmRefClockGet(eReferenceClock &rRefClock)
Definition PT2026.cpp:2305
bool ChannelSetRemoteLEDMode(eRemoteBusyLEDmode Mode)
Definition PT2026.cpp:743
bool StandardStatusSetEnableRegister(eStandardStatusRegister Set, U16 DisableMask, U16 EnableMask)
Definition PT2026.cpp:3571
bool ParmSearchGetHallEnable(bool &rEnabled)
Definition PT2026.cpp:971
bool GetIdentification(std::string &rIdentification)
Returns the instrument identification string including its serial number and make....
Definition PT2026.cpp:3619
bool ParmDigitizationSet(const sDigitization< uParm > &rDigitization)
Definition PT2026.cpp:2017
bool ReadFileDirectory(U32 &rUsedBytes, U32 &rAvailableBytes, tFileList &rFileList)
Definition PT2026.cpp:2569
bool DeviceROMRead(const MTL::SCPI::tChannel &rChannel, std::vector< U8 > &rROMContent)
Definition PT2026.cpp:3815
bool SaveSettings(eSettingType Type, std::string Name)
Definition PT2026.cpp:2707
bool ParmComEthernetSet(const sEthernet &rSettings)
Definition PT2026.cpp:2376
bool ReadManufacturingDate(std::string &rSManufacturingDate, std::time_t &rManufacturingDate)
Returns the manufacturing date in plain text or a number representing the amount of seconds since 00:...
Definition PT2026.cpp:3725
bool ParmAveragingMeasurementSet(const sMeasurementAveraging< uParm > &rMeasAvg)
Definition PT2026.cpp:1319
bool AuthenticationRequest(const std::string &rCipherMsgSet, bool &rIsAuthenticated)
Definition PT2026.cpp:3955
bool ParmAveragingMeasurementGet(sMeasurementAveraging< uParm > &rMeasAvg)
Definition PT2026.cpp:1349
bool DeviceROMWrite(const MTL::SCPI::tChannel &rChannel, const std::vector< U8 > &rROMContent)
Definition PT2026.cpp:3846
bool AuthenticationStatus(bool &rIsAuthenticated, std::string &rCipherMsgGet)
Definition PT2026.cpp:3919
bool StatusGet(sStatusRegister Reg, U16 &rStatus)
Definition PT2026.cpp:3302
bool ForceOutputTrigger()
Set the output trigger according to current output trigger parametrization. This method is very speci...
Definition PT2026.cpp:2800
bool ParmMatchingTuningGet(sMatchingTuning< uParm > &rMatchingTuning)
Definition PT2026.cpp:2153
bool ParmMeasureSet(const sMeasure< uParm > &rMeasure)
Definition PT2026.cpp:996
bool ParmComEthernetGet(sEthernet &rSettings)
Definition PT2026.cpp:2404
bool ReadCalibrationDate(std::string &rSCalibrationDate, std::time_t &rCalibrationDate)
Returns the calibration date in plain text or a number representing the amount of seconds since 00:00...
Definition PT2026.cpp:3757
bool ParmDigitizationGet(sDigitization< uParm > &rDigitization)
Definition PT2026.cpp:2041
bool Connect(U32 InitialTimeout_ms)
Definition PT2026.cpp:283
bool SwitchToDFUMode()
Restart the instrument in USB DFU mode, allowing the firmware to be upgraded.
Definition PT2026.cpp:3698
bool SetCalibrationDate(std::string &rNewCalibrationDate)
Sets the new calibration date, given in YYMMDD format.
Definition PT2026.cpp:3789
bool WriteCustomCommand(const std::string &rWriteStr)
Definition PT2026.cpp:4014
bool ChannelsGetList(MTL::SCPI::tChannelList &rChanList)
Definition PT2026.cpp:398
bool StatusSetEnableRegister(eStatusRegisterSet Set, U16 DisableMask, U16 EnableMask)
Definition PT2026.cpp:3438
bool DeleteFile(std::string Path)
Definition PT2026.cpp:2660
bool ParmAveragingSignalGet(sSignalAveraging< uParm > &rSigAvg)
Definition PT2026.cpp:1196
bool Reset()
Calling this method will wipe out all user parameters that are stored in the file system and revert t...
Definition PT2026.cpp:3671
bool StatusSetTransitionFilter(eStatusRegisterSet Set, eTransition Transition, U16 ClearMask, U16 SetMask)
Definition PT2026.cpp:3493
bool PowerOff(bool Reboot=false)
Sending this command will shut the instrument down. Setting the reboot parameter to true will initiat...
Definition PT2026.cpp:3661
bool ReadCaseTemperature(F32 &rTemperatureDegC)
Returns the internal instrument temperature. An internal survey will shut the instrument down if this...
Definition PT2026.cpp:3678
bool ChannelsGetLimitedListState(bool &rState)
Definition PT2026.cpp:498
bool GetSystemVersionAll(std::string &rSystVersion)
Returns all versions information (Hardware & Firmware) for the entire instrument. Available command w...
Definition PT2026.cpp:3641
bool Initiate(bool Continuous=false)
Starts the search operation and then immediately after NMR resonance detection proceed to NMR measure...
Definition PT2026.cpp:2774
bool ParmComUsbGet(bool &rEnabled)
Definition PT2026.cpp:2349
bool ParmAveragingSignalSet(const sSignalAveraging< uParm > &rSigAvg)
Definition PT2026.cpp:1170
bool ParmSearchSetManualValue(F64 ManualValue_UNITS)
Ask the instrument to perform a measurement at fixed frequency. Automatic search mode is left.
Definition PT2026.cpp:942
bool ParmTriggerOutputGet(sOutputTrigger< uParm > &rOutputTrig)
Definition PT2026.cpp:1713
bool ParmTriggerOutputSet(const sOutputTrigger< uParm > &rOutputTrig)
Definition PT2026.cpp:1640
const sFwVersion & FwVerInfo()
Definition PT2026.cpp:270
VISA Resource Manager class.
CVISAInstrument(CVISAResourceManager &rRM, tResourceName Rsrc)