 |
THM1176InstrumentManager
1.0
Qt Object abstraction for Metrolab THM1176
|
Go to the documentation of this file.
18 #define VI_STATUS_DESC_MAX_LEN 256
20 #define READ_STB_WORKAROUND_POLL_PERIOD_MS 10
23 #define DEBUG_MTL_VISA_INSTRUMENT 0
24 #define DEBUG_MTL_VISA_INSTRUMENT_ERRORS_ONLY 0
25 #if (defined(_DEBUG) && defined(DEBUG_MTL_VISA_INSTRUMENT) && DEBUG_MTL_VISA_INSTRUMENT)
26 #if (defined(DEBUG_MTL_VISA_INSTRUMENT_ERRORS_ONLY) && DEBUG_MTL_VISA_INSTRUMENT_ERRORS_ONLY)
27 #define MTL_VISA_INSTRUMENT_DEBUG_COUT(__X__)
29 #define MTL_VISA_INSTRUMENT_DEBUG_COUT(__X__) COUT(__X__)
31 #define MTL_VISA_INSTRUMENT_DEBUG_CERR(__X__) CERR(__X__)
33 #define MTL_VISA_INSTRUMENT_DEBUG_COUT(__X__)
34 #define MTL_VISA_INSTRUMENT_DEBUG_CERR(__X__)
51 return std::string(Desc);
53 #if (defined(DEBUG_MTL_VISA_INSTRUMENT) && DEBUG_MTL_VISA_INSTRUMENT)
62 #define l_DebugCheckStatus(__X__, __Y__)
96 m_DefaultRM =
static_cast<ViSession>(NULL);
126 return std::string(Desc);
172 if (rList.size() > 0)
220 ViChar l_Class[100], l_ExpName[100], l_Alias[100];
308 ViChar l_Class[100], l_ExpName[100], l_Alias[100];
364 return Open(eOpenAccessMode::NoLock, 0);
403 return (0 != m_InstrSession);
419 return std::string(Desc);
426 return m_InstrSession;
441 return Write(
reinterpret_cast<ViBuf>(
const_cast<char *
>(Str)),
static_cast<ViUInt32>(std::strlen(Str)));
447 return Write(
reinterpret_cast<ViBuf>(
const_cast<char *
>(rStr.c_str())),
static_cast<ViUInt32>(rStr.length()));
489 size_t l_Size = rBuf.
size();
490 size_t l_Capacity = rBuf.
capacity();
491 if (l_Size >= l_Capacity)
496 l_Ret =
Read(
reinterpret_cast<ViPBuf>(rBuf.
data() + l_Size),
static_cast<ViUInt32>(l_Capacity - l_Size), l_RetLen);
497 rBuf.
resize(l_Size + l_RetLen);
547 #if (defined(ACTIVATE_READ_STB_WORKAROUND) && ACTIVATE_READ_STB_WORKAROUND)
563 for (
unsigned char NoRetries = 5; NoRetries > 0; NoRetries--)
621 m_ExclusiveLock =
true;
656 m_ExclusiveLock =
false;
665 return m_ExclusiveLock;
778 m_Status =
viUsbControlIn(m_InstrSession, bmRequestType, bRequest, wValue, wIndex, wLength, buf, &rretCnt);
853 if (rPortSettings.
ReadTermMode == eSerialTermMode::kEndTermChar)
CVISAResourceManager()
Constructor.
ViStatus _VI_FUNC viOpenDefaultRM(ViPSession vi)
ViStatus _VI_FUNC viFindNext(ViFindList vi, ViChar _VI_FAR desc[])
ViStatus _VI_FUNC viEnableEvent(ViSession vi, ViEventType eventType, ViUInt16 mechanism, ViEventFilter context)
#define VI_SUCCESS_NESTED_SHARED
#define VI_STATUS_DESC_MAX_LEN
bool ConfigSerialPort(const sSerialPortSettings &rPortSettings)
Set all the instrument attributes to configure the serial communication.
List of VISA resource names.
virtual bool Read(CSCPIBuffer &rBuf, bool Append=false)
Read from a VISA instrument: SCPI buffer class variant.
virtual bool ReadSTB(ViUInt16 &rSTB)
Read status byte.
bool ResourceInfo(tResourceName &rRsrc, eInterfaceType &rIntfType, tInterfaceNumber &rIntfNumber)
Get the interface type and number for the given VISA resource name.
#define MTL_VISA_INSTRUMENT_DEBUG_COUT(__X__)
#define l_DebugCheckStatus(__X__, __Y__)
eSerialHandshake Handshake
[-] Handshake configuration of the serial communication
bool UsbControlOut(ViInt16 bmRequestType, ViInt16 bRequest, ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength, ViBuf buf)
Performs a USB control pipe transfer to the instrument.
bool UsbControlIn(ViInt16 bmRequestType, ViInt16 bRequest, ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength, ViPBuf buf, ViUInt16 &rretCnt)
Performs a USB control pipe transfer from the instrument.
ViStatus _VI_FUNC viSetAttribute(ViObject vi, ViAttr attrName, ViAttrState attrValue)
virtual bool FindResources(CResourceList &rList, std::string Filter="?*")
Find VISA resources.
#define VI_ERROR_NSUP_ATTR
void reserve(size_t capacity)
Allocate at least a given amount of space.
bool DisableEvent(eEventType Type, eEventMechanism Mechanism)
Disable notification of a specified event.
bool GetAttribute(ViAttr Attribute, void *Value)
Retrieves the state of an attribute.
eSerialTermMode ReadTermMode
[-] Termination Read mode of the serial communication
const ViSession & Session()
Return instrument session identifier.
bool EnableEvent(eEventType Type, eEventMechanism Mechanism)
Enable notification of a specified event.
eSerialBaudrate Baudrate
[bd] Speed of the serial communication
bool WaitOnAllEvents(ViUInt32 Timeout)
Wait for all events.
ViStatus _VI_FUNC viWaitOnEvent(ViSession vi, ViEventType inEventType, ViUInt32 timeout, ViPEventType outEventType, ViPEvent outContext)
eEventMechanism
Event mechanisms.
CMutex m_Lock
Lock onto the resource manager.
#define VI_SUCCESS_EVENT_DIS
ViStatus _VI_FUNC viParseRsrc(ViSession rmSesn, ViRsrc rsrcName, ViPUInt16 intfType, ViPUInt16 intfNum)
#define VI_ERROR_INV_OBJECT
size_t size() const
Return the buffer size.
Information about a VISA resource.
bool SetTimeout(U32 Timeout)
Set the timeout for this instrument.
virtual bool Timeout()
Last operation timed out.
#define VI_SUCCESS_TERM_CHAR
ViStatus _VI_FUNC viDiscardEvents(ViSession vi, ViEventType eventType, ViUInt16 mechanism)
virtual bool Timeout()
Last operation timed out.
#define VI_ATTR_ASRL_END_IN
#define VI_ERROR_INTF_NUM_NCONFIG
#define VI_ERROR_INV_MASK
ViStatus Status()
Return Resource Manager status.
ViStatus _VI_FUNC viParseRsrcEx(ViSession rmSesn, ViRsrc rsrcName, ViPUInt16 intfType, ViPUInt16 intfNum, ViChar _VI_FAR rsrcClass[], ViChar _VI_FAR expandedUnaliasedName[], ViChar _VI_FAR aliasIfExists[])
#define VI_SUCCESS_EVENT_EN
virtual bool SetTimeout(ViUInt32 Timeout)
Set the timeout for this instrument session.
#define VI_ATTR_ASRL_DATA_BITS
#define VI_ATTR_ASRL_BAUD
#define VI_WARN_EXT_FUNC_NIMPL
I32 m_Status
Status of last operation.
#define VI_ATTR_ASRL_PARITY
virtual std::string StatusDescription(I32 Status)
Return description of status word.
eInterfaceType
VISA interface types.
Collection of utility macros for error messages.
void resize(size_t size)
Resize the buffer.
size_t capacity() const
Return the buffer capacity (allocated size).
ViStatus _VI_FUNC viOpen(ViSession sesn, ViRsrc name, ViAccessMode mode, ViUInt32 timeout, ViPSession vi)
tResourceName m_Rsrc
Resource name of the instrument.
std::string StatusDescription(ViSession Session, ViStatus Status)
Return user-readable description of the given status code.
virtual bool Write(const char *Str)
Write to a VISA instrument: C string variant.
Parsed information about a VISA resource.
virtual void Close()
Close session to this VISA instrument.
#define VI_ERROR_RSRC_NFOUND
virtual ~CVISAInstrument()
Destructor.
const ViSession & Session()
Return Resource Manager session identifier.
#define VI_ATTR_ASRL_FLOW_CNTRL
virtual ~CVISAResourceManager()
Destructor.
ViStatus _VI_FUNC viUsbControlOut(ViSession vi, ViInt16 bmRequestType, ViInt16 bRequest, ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength, ViBuf buf)
bool DiscardEvents(eEventType Type, eEventMechanism Mechanism)
Discard event occurrences for specified event types and mechanisms.
virtual bool IsOpen()
Check whether a session to this instrument is open.
ViStatus _VI_FUNC viStatusDesc(ViObject vi, ViStatus status, ViChar _VI_FAR desc[])
bool WaitOnEvent(eEventType Type, ViUInt32 Timeout)
Wait for a specified event.
eSerialDataBits DataBits
[-] Number of transmitted bits per packet
int I32
32-bit signed integer.
virtual bool AssertTrigger(void)
Assert a trigger.
ViStatus _VI_FUNC viFindRsrc(ViSession sesn, ViString expr, ViPFindList vi, ViPUInt32 retCnt, ViChar _VI_FAR desc[])
eTriggerProtocol
Trigger protocols.
eSerialParity Parity
[-] Parity configuration of the serial communication
ViUInt16 tInterfaceNumber
Interface number.
#define VI_ERROR_CLOSING_FAILED
ViStatus _VI_FUNC viDisableEvent(ViSession vi, ViEventType eventType, ViUInt16 mechanism)
ViStatus _VI_FUNC viLock(ViSession vi, ViAccessMode lockType, ViUInt32 timeout, ViKeyId requestedKey, ViChar _VI_FAR accessKey[])
IEEE488 instrument class.
virtual bool LockedExclusive()
Check whether session is locked exclusively.
CRecursiveMutex m_Lock
Lock onto the class interface.
ViStatus _VI_FUNC viWrite(ViSession vi, ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt)
#define VI_ERROR_INV_PROT
ViStatus _VI_FUNC viAssertTrigger(ViSession vi, ViUInt16 protocol)
#define VI_EXCLUSIVE_LOCK
#define VI_SUCCESS_MAX_CNT
std::string tResourceName
IEEE488 resource name.
#define VI_ATTR_ASRL_STOP_BITS
ViStatus _VI_FUNC viClose(ViObject vi)
#define VI_SUCCESS_QUEUE_EMPTY
#define VI_ERROR_LIBRARY_NFOUND
#define VI_ERROR_RSRC_LOCKED
virtual bool LockExclusive(U32 Timeout)
Obtain an exclusive lock for this session.
#define VI_ATTR_TERMCHAR_EN
std::string tAlias
Alias, if any.
CIEEE488ResourceManager & m_rRrsrcMan
Reference to the associated resource manager.
CVISAInstrument(CVISAResourceManager &rRM, tResourceName Rsrc)
Constructor.
#define VI_ERROR_INV_EXPR
char ReadTermChar
[-] Specific termination character when readTermMode = kEndTermChar
ViStatus _VI_FUNC viRead(ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt)
#define VI_ERROR_INV_RSRC_NAME
MTL_INSTRUMENT_BUFFER_TYPE * data() noexcept
Return a pointer to the data.
ViStatus _VI_FUNC viUsbControlIn(ViSession vi, ViInt16 bmRequestType, ViInt16 bRequest, ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength, ViPBuf buf, ViPUInt16 retCnt)
eOpenAccessMode
Access modes for VISA resources.
I32 m_Status
Status of last operation.
C++ wrapper for NI-VISA: interface definition.
ViStatus _VI_FUNC viUnlock(ViSession vi)
Platform Dependent Definitions.
#define VI_SUCCESS_NESTED_EXCLUSIVE
ViStatus _VI_FUNC viReadSTB(ViSession vi, ViPUInt16 status)
virtual std::string StatusDescription(I32 Status)
Return description of status word.
eSerialStopBits StopBits
[-] Stop bit configuration of the serial communication
bool LockShared(ViUInt32 Timeout, ViKeyId RequestedKey, ViChar AccessKey[])
Obtain a shared lock for this session.
#define VI_ATTR_TMO_VALUE
#define VI_SUCCESS_QUEUE_NEMPTY
#define VI_ALL_ENABLED_EVENTS
#define READ_STB_WORKAROUND_POLL_PERIOD_MS
#define VI_ERROR_INV_PARAMETER
unsigned int U32
32-bit unsigned integer.
#define VI_ERROR_CONN_LOST
std::string tExpandedName
Full resource name.
VISA Resource Manager class.
ViStatus _VI_FUNC viClear(ViSession vi)
#define VI_ERROR_INV_SETUP
std::string tClass
Class: INSTR / RAW / ...
Parsed resource information for a list of instruments.
virtual bool Clear()
Clear the instrument.
#define VI_ERROR_NSUP_OPER
virtual bool Open(void)
Open a session to this VISA instrument.
ViStatus _VI_FUNC viGetAttribute(ViObject vi, ViAttr attrName, void _VI_PTR attrValue)
#define MTL_VISA_INSTRUMENT_DEBUG_CERR(__X__)
virtual bool Initialize()
Initialize the Resource Manager.
virtual bool Unlock()
Unlock the session.