150#if (THM1176_INSTRUMENT_TYPE_IS_VISA)
152 #define THM1176_RSRC_MGR_CLS CVISAResourceManager
153 #define THM1176_INSTR_CLS CVISAInstrument
154 #define THM1176_RSRC_FILTER "USB[0-9]*::0x1BFA::0x0498::[0-9]+::INSTR"
156#elif (THM1176_INSTRUMENT_TYPE_IS_USBTMC)
158 #define THM1176_RSRC_MGR_CLS CUSBTMCResourceManager
159 #define THM1176_INSTR_CLS CUSBTMCInstrument
160 #define THM1176_RSRC_FILTER "7162:1176"
163 #error "One of THM1176_INSTRUMENT_TYPE_IS_VISA or ..._USBTMC must be defined"
166#include <QtCore/QThread>
167#include <QtCore/QTimer>
168#include <QtCore/QString>
169#include <QtCore/QDateTime>
214Q_DECLARE_METATYPE(THM1176_INSTR_CLS *)
215Q_DECLARE_METATYPE(THM1176_RSRC_MGR_CLS *)
234 static const U32 THM1176_SCAN_INTERVAL = 1000;
241 THM1176_RSRC_MGR_CLS * m_pResourceManager;
246 void timerEvent (QTimerEvent * Event)
override;
247 void HandleError (QString Description,
256 m_pResourceManager(nullptr)
268 void Start (THM1176_RSRC_MGR_CLS * pResourceManager);
300 static constexpr U32 THM1176_CONNECT_TIMEOUT = 5000;
301 static constexpr F32 MU0 = 1.256637061436E-6f;
307 THM1176_RSRC_MGR_CLS * m_pResourceManager;
335 bool m_CalibrationOverride;
340 void HandleError (QString Description,
342 void ClearInstrumentInfo (
void);
343 void GetInstrumentInfo (std::string Context);
344 void GetInstrumentParameters (std::string Context);
345 void MakeUnitsList (std::string Context);
346 void GetCurrentUnits (std::string Context);
349 void PublishInstrumentInfo (
void);
350 void PublishInstrumentParameters (
void);
351 void timerEvent (QTimerEvent * Event)
override;
359 m_pResourceManager(nullptr),
367 m_CalibrationOverride(false)
369 m_AveragingParmBounds.clear();
370 m_TriggerParmBounds.clear();
371 m_RangeParmBounds.clear();
373 m_AveragingParms.clear();
374 m_TriggerParms.clear();
375 m_OutputSelect.clear();
376 m_RangeParms.clear();
390 void Start (THM1176_RSRC_MGR_CLS * pResourceManager);
593 static const
U8 THM1176_MIN_VERSION_WITH_ABORTREAD = 4;
628 QThread m_InstrumentControlThread;
632 QThread m_InstrumentScanThread;
635 THM1176_RSRC_MGR_CLS * m_pResourceManager;
642 void HandleError (QString Description, QString Context);
661 m_pInstrumentController(
nullptr),
662 m_pInstrumentScanner(
nullptr),
666 qRegisterMetaType<eTHM1176Units>();
667 qRegisterMetaType<eTHM1176OperatingMode>();
668 qRegisterMetaType<eCommunicationFormat>();
670 qRegisterMetaType<tResourceName>();
672 qRegisterMetaType<sIdentifier>();
673 qRegisterMetaType<sArbitraryMeasurements>();
674 qRegisterMetaType<CMeasurement>();
676 qRegisterMetaType<CResourceList>();
677 qRegisterMetaType<CFluxList>();
678 qRegisterMetaType<CTHM1176UnitsList>();
679 qRegisterMetaType<CDivisorList>();
680 qRegisterMetaType<CErrorList>();
682 qRegisterMetaType<sAveraging<uParm>>();
683 qRegisterMetaType<sAveraging<sBoundedParm>>();
684 qRegisterMetaType<sInputTrigger<uParm>>();
685 qRegisterMetaType<sInputTrigger<sBoundedParm>>();
686 qRegisterMetaType<sRange<uParm>>();
687 qRegisterMetaType<sRange<sBoundedParm>>();
690 qRegisterMetaType<THM1176_RSRC_MGR_CLS *>();
796 if (m_pTHM1176 ==
nullptr)
798 HandleError(
"Instrument not connected", __func__);
803 return m_pTHM1176->ConvertTimestamp(RawTimestamp, rTimestamp);
unsigned long long U64
64-bit unsigned integer.
unsigned char U8
Unsigned byte.
float F32
32-bit floating-point number.
int I32
32-bit signed integer.
unsigned int U32
32-bit unsigned integer.
double F64
64-bit floating-point number.
unsigned short U16
16-bit unsigned integer.
Type definitions for THM1176 Instrument Manager.
USBTMC driver based on libusb: interface definition.
C++ wrapper for NI-VISA: interface definition.
Data returned for one measurement.
THM1176 Instrument Controller class: communicate with instrument.
void UpdateOutputSelect(sArbitraryMeasurements OutputSelect)
Signal a change of the output selection parameters.
void SendTrigger(void)
Send a bus trigger.
void UpdateIdentification(sIdentifier Identification)
Signal to report identifier information for newly connected instrument.
~CTHM1176InstrumentController(void) override
Destructor.
void UpdateCurrentInstrument(tResourceName CurrentInstrument)
Signal that current instrument selection has changed.
void UpdateAveragingParms(sAveraging< uParm > AveragingParms)
Signal a change of the averaging parameters.
void UpdateErrorList(CErrorList LatestErrors)
Signal that new errors have been reported.
void UpdateRangeParms(sRange< uParm > RangeParms)
Signal a change of the range parameters.
void UpdateUnitsList(CTHM1176UnitsList UnitsList)
Signal to report list of valid measurement units for newly connected instrument.
void UpdateRangeList(CFluxList RangeList)
Signal to report list of valid ranges for newly connected instrument.
void SetCommFormat(eCommunicationFormat CommFormat)
Set communication format.
void UpdateRangeParmBounds(sRange< sBoundedParm > RangeParmBounds)
Signal to report bounds of range parameters for newly connected instrument.
void UpdateInstrumentList(CResourceList InstrumentList)
Update the Instrument Controller's copy of the list of detected instruments.
void UpdateUnits(eTHM1176Units Units)
Signal a change of the measurement units.
void SetAveragingParms(sAveraging< uParm > AveragingParms)
Set the averaging parameters.
void SetUnits(eTHM1176Units Units)
Select the measurement units.
void SetOutputSelect(sArbitraryMeasurements OutputSelect)
Select what data is returned.
void UpdateTriggerParms(sInputTrigger< uParm > TriggerParms)
Signal a change of the trigger parameters.
void UpdateDivisorList(CDivisorList DivisorList)
Signal to report divisors associated with valid measurement units for newly connected instrument.
void UpdateAveragingParmBounds(sAveraging< sBoundedParm > AveragingParmBounds)
Signal to report bounds of averaging parameters for newly connected instrument.
CTHM1176InstrumentController(void)
Constructor.
void Stop(void)
Shut down the Instrument Controller.
void UpdateMeasurement(CMeasurement Measurement)
Signal that a new measurement is available.
void Start(THM1176_RSRC_MGR_CLS *pResourceManager)
Initialize the Instrument Controller.
void SetOperatingMode(eTHM1176OperatingMode OperatingMode)
Set operating mode.
void UpdateSleepParm(bool SleepParm)
Signal a change of the sleep parameter.
void UpdateOperatingMode(eTHM1176OperatingMode OperatingMode)
Signal that the operating mode has changed.
void UpdateTriggerParmBounds(sInputTrigger< sBoundedParm > TriggerParmBounds)
Signal to report bounds of trigger parameters for newly connected instrument.
void SetCurrentInstrument(tResourceName CurrentInstrument)
Select the instrument to connect to.
void UpdateCommFormat(eCommunicationFormat CommFormat)
Signal a change of the communication format.
void SetTriggerParms(sInputTrigger< uParm > TriggerParms)
Set the trigger parameters.
void UpdateInstrumentPointer(CTHM1176Instrument< THM1176_INSTR_CLS, THM1176_RSRC_MGR_CLS > *pTHM1176)
Signal to broadcast updated pointer to THM1176 Instrument object.
void SetRangeParms(sRange< uParm > RangeParms)
Set range parameters.
void SetCalibrationOverride(bool Override)
Set whether or not to override the check for instruments whose zero offset should not be calibrated.
void SetSleepParm(bool SleepParm)
Set whether or not the instrument sleeps after each measurement.
void SetAveragingParms(sAveraging< uParm > AveragingParms)
Set the averaging parameters.
CErrorList GetErrorList(void)
Get the current error list.
void RelayOperatingMode(eTHM1176OperatingMode OperatingMode)
Internal signal to relay the operating mode selection to the Instrument Controller.
sArbitraryMeasurements GetOutputSelect(void)
Get the output selection parameters.
sAveraging< sBoundedParm > AveragingParmBounds
Bounds on averaging parameter.
bool ReadInformationDates(QDateTime &rManufacturingDate, QDateTime &rCalibrationDate)
Fetch the intrument's date information.
static const I32 THM1176_INST_MGR_ERROR
Additional error code: Instrument Manager Error.
eTHM1176Units Units
Current measurement units.
void SetSleepParm(bool SleepParm)
Set the sleep parameter.
eTHM1176Units GetUnits(void)
Get the measurement units.
eTHM1176OperatingMode GetOperatingMode(void)
Get the current operating mode.
sInputTrigger< sBoundedParm > GetTriggerParmBounds(void)
Get the bounds on trigger parameters.
CTHM1176InstrumentManager(void)
Constructor.
void RelayTriggerParms(sInputTrigger< uParm > TriggerParms)
Internal signal to relay the trigger parameters to the Instrument Controller.
void SetOutputSelect(sArbitraryMeasurements OutputSelect)
Set the output selection parameters.
bool SleepParm
Sleep parameter: true if instrument should sleep after each measurement.
sRange< uParm > RangeParms
Current range parameters.
CTHM1176UnitsList GetUnitsList(void)
Get the list of valid measurement units for this instrument model.
CMeasurement GetMeasurement(void)
Get the last set of measurements.
sInputTrigger< uParm > GetTriggerParms(void)
Get the trigger parameters.
void NotifyTriggerParmBounds(sInputTrigger< sBoundedParm > TriggerParmBounds)
Notify that the bounds on trigger parameters have changed.
static const I32 THM1176_INST_CTLR_ERROR
Additional error code: Instrument Controller Error.
CFluxList RangeList
List of valid ranges for this instrument model.
bool ConvertTimestamp(const U64 RawTimestamp, CAbsoluteTimestamp &rTimestamp)
Convert a raw timestamp to UNIX Epoch time and nanoseconds.
eCommunicationFormat GetCommFormat(void)
Get the communication format parameters.
void RelayCurrentInstrument(tResourceName CurrentInstrument)
Internal signal to relay the instrument selection to the Instrument Controller.
void NotifyAveragingParmBounds(sAveraging< sBoundedParm > AveragingParmBounds)
Notify that the bounds on averaging parameters have changed.
CDivisorList DivisorList
List of divisors for each measurement unit for this instrument model, to convert "base" units to the ...
void NotifyAveragingParms(sAveraging< uParm > AveragingParms)
Notify that the averaging parameters have changed.
sInputTrigger< sBoundedParm > TriggerParmBounds
Bounds on trigger parameters.
bool GetIsTHMNullptr(void)
Get the test result of m_pTHM1176 pointer is Nullptr.
void NotifyUnits(eTHM1176Units Units)
Notify that the measurement units have changed.
sAveraging< uParm > GetAveragingParms(void)
Get the averaging parameters.
void NotifyCurrentInstrument(tResourceName CurrentInstrument)
Notify that the currently connected instrument has changed.
void NotifySleepParm(bool SleepParm)
Notify that the sleep parameter has changed.
void NotifyUnitsList(CTHM1176UnitsList UnitsList)
Notify that the list of valid measurement units has changed.
void NotifyRangeParms(sRange< uParm > RangeParms)
Notify that the range parameters have changed.
bool GetImmediateMeasurementPeriod(const sAveraging< uParm > &rAvg, F64 &rPeriod)
Get measurement interval for Immediate Trigger, for a given averaging parameter.
void SetCalibrationOverride(bool Override)
Set whether or not to override the check for instruments whose zero offset should not be calibrated.
sIdentifier GetIdentification(void)
Get the current instrument's identification information.
void NotifyDivisorList(CDivisorList DivisorList)
Notify that the list of divisors associated with each measurement unit for this instrument model has ...
void SendTrigger(void)
Send a bus trigger to the instrument (both slot and signal).
void RelayAveragingParms(sAveraging< uParm > AveragingParms)
Internal signal to relay the averaging parameters to the Instrument Controller.
void RelayUnits(eTHM1176Units Units)
Internal signal to relay the measurement units to the Instrument Controller.
void RelayOutputSelect(sArbitraryMeasurements OutputSelect)
Internal signal to relay the output selection parameters to the Instrument Controller.
void NotifyCommFormat(eCommunicationFormat CommFormat)
Notify that the communication format parameters have changed.
sArbitraryMeasurements OutputSelect
Output selection parameters: select what data elements are returned.
CMeasurement Measurement
Last measurement set returned.
sRange< sBoundedParm > RangeParmBounds
Bounds on range parameters.
static const I32 THM1176_INST_SCANNER_ERROR
Additional error code: Instrument Scanner Error.
void SetRangeParms(sRange< uParm > RangeParms)
Set the range parameters.
void NotifyMeasurement(CMeasurement Measurement)
Notify that a new set of measurements is available.
bool GetSleepParm(void)
Get the sleep parameter.
void SetOperatingMode(eTHM1176OperatingMode OperatingMode)
Set a new operating mode, for example to start measuring.
void NotifyTriggerParms(sInputTrigger< uParm > TriggerParms)
Notify that the trigger parameters have changed.
void StopInstrumentController(void)
Internal signal to stop the Instrument Controller.
void StopInstrumentScanner(void)
Internal signal to stop the Instrument Scanner.
void NotifyInstrumentList(CResourceList InstrumentList)
Notify that the list of detected instruments has changed.
CResourceList GetInstrumentList(void)
Get the list of connected instruments.
void RelayCommFormat(eCommunicationFormat CommFormat)
Internal signal to relay the communications format to the Instrument Controller.
void SetTriggerParms(sInputTrigger< uParm > TriggerParms)
Set the trigger parameters.
tResourceName CurrentInstrument
Currently connected instrument.
~CTHM1176InstrumentManager(void)
Destructor.
sIdentifier Identification
Identification information of currently connected instrument.
CResourceList InstrumentList
List of detected instruments.
CErrorList ErrorList
Current error list.
void StartInstrumentScanner(THM1176_RSRC_MGR_CLS *pResourceManager)
Internal signal to start the Instrument Scanner.
void SetCommFormat(eCommunicationFormat CommFormat)
Set the communication format parameters.
void StartInstrumentController(THM1176_RSRC_MGR_CLS *pResourceManager)
Internal signal to start to Instrument Controller.
void NotifyRangeParmBounds(sRange< sBoundedParm > RangeParmBounds)
Notify that the bounds on range parameters have changed.
tResourceName GetCurrentInstrument(void)
Get VISA resource name of currently connected instrument.
void NotifyOperatingMode(eTHM1176OperatingMode OperatingMode)
Notify that the operating mode has changed.
void NotifyErrorList(CErrorList ErrorList)
Notify that new errors are present.
void Start(void)
Initialize the THM1176 Instrument Manager.
void RelaySleepParm(bool SleepParm)
Internal signal to relay the sleep parameter to the Instrument Controller.
void NotifyRangeList(CFluxList RangeList)
Notify that the list of valid ranges has changed.
void Stop(void)
Shut down the THM1176 Instrument Manager.
eCommunicationFormat CommFormat
Current communication format parameter.
void RelayRangeParms(sRange< uParm > RangeParms)
Internal signal to relay the range parameters to the Instrument Controller.
sRange< uParm > GetRangeParms(void)
Get the range parameters.
sAveraging< uParm > AveragingParms
Current averaging parameters.
sRange< sBoundedParm > GetRangeParmBounds(void)
Get the bounds on range parameters.
void SetCurrentInstrument(tResourceName CurrentInstrument)
Connect a new instrument.
sAveraging< sBoundedParm > GetAveragingParmBounds(void)
Get the bounds on averaging parameters.
CDivisorList GetDivisorList(void)
Get the list of divisors associated with each measurement unit for this instrument model.
CFluxList GetRangeList(void)
Get list of valid ranges for this instrument model.
void NotifyIdentification(sIdentifier Identification)
Notify that the instrument identification information has changed.
void NotifyOutputSelect(sArbitraryMeasurements OutputSelect)
Notify that the output selection parameters have changed.
sInputTrigger< uParm > TriggerParms
Current trigger parameters.
eTHM1176OperatingMode OperatingMode
Current operating mode.
CTHM1176UnitsList UnitsList
List of valid measurement units for this instrument model.
void SetUnits(eTHM1176Units Units)
Set the measurement units.
THM1176 Instrument Scanner class: scan for connected instruments.
void UpdateErrorList(CErrorList ErrorList)
An update to the error list is available.
~CTHM1176InstrumentScanner(void) override
Destructor.
void Stop(void)
Shut down THM1176 Instrument Scanner.
CTHM1176InstrumentScanner(void)
Constructor.
void Start(THM1176_RSRC_MGR_CLS *pResourceManager)
Initialize THM1176 Instrument Scanner.
void UpdateInstrumentList(CResourceList InstrumentList)
An update to the instrument list is available.
List of measurement units.
List of VISA resource names.
THM1176 instrument class.
Timestamp for a measurement.
List of divisors, one per measurement unit.
List of errors returned by the instrument.
List of flux density values.
DataType uParm
Parameter template, with only current value.
eCommunicationFormat
Enumeration of possible formats for returned data.
@ kComFormatAscii
Human-legible text.
eUnits
Enumeration of possible measurement units.
std::string tResourceName
IEEE488 resource name.
eTHM1176OperatingMode
Operating modes used to initiate actions or provide status.
@ kTHM1176NotConnected
Disconnect instrument.
eTHM1176Units
Enumeration of possible measurement units, including "ADC".
Specify the measurement data to be returned.
Parameter template, with current/min/max/default values.
Instrument's identification string - parsed version.
Measurement range parameter.