THM1176InstrumentManager 1.1
Qt Object abstraction for Metrolab THM1176
Loading...
Searching...
No Matches
VISAInstrumentTypes.h
Go to the documentation of this file.
1// Copyright (c) 2020 Metrolab Technology S.A., Geneva, Switzerland (www.metrolab.com)
2// See the included file LICENSE.txt for the licensing conditions.
3
7
8#pragma once
9
10// External tools
11#include "../resources/visa.h"
12
13// Standard libraries
14#include <string>
15#include <vector>
16#include <iostream>
17
18namespace MTL {
19 namespace Instrument
20 {
21 //----------------------------------------------------------------------//
22 // Types //
23 //----------------------------------------------------------------------//
25 enum class eInterfaceType {
26 GPIB = VI_INTF_GPIB,
27 VXI = VI_INTF_VXI,
28 GPIB_VXI = VI_INTF_GPIB_VXI,
29 ASRL = VI_INTF_ASRL,
30 PXI = VI_INTF_PXI,
31 TCPIP = VI_INTF_TCPIP,
32 USB = VI_INTF_USB
33 };
34
35 typedef ViUInt16 tInterfaceNumber;
36
47
49 enum class eOpenAccessMode {
50 NoLock = VI_NO_LOCK,
51 ExclusiveLock = VI_EXCLUSIVE_LOCK,
52 LoadConfig = VI_LOAD_CONFIG
53 };
54
56 enum class eEventMechanism {
57 Queue = VI_QUEUE,
58 Handle = VI_HNDLR,
59 Suspendedhandler = VI_SUSPEND_HNDLR,
60 All = VI_ALL_MECH
61 };
62
64 enum class eEventType : unsigned long {
65 ServiceRequest = VI_EVENT_SERVICE_REQ,
66 Trig = VI_EVENT_TRIG,
67 Clear = VI_EVENT_CLEAR,
68 IOCompletion = VI_EVENT_IO_COMPLETION,
69 Exception = VI_EVENT_EXCEPTION,
70 GPIB_CIC = VI_EVENT_GPIB_CIC,
71 GPIB_TALK = VI_EVENT_GPIB_TALK,
72 GPIB_LISTEN = VI_EVENT_GPIB_LISTEN,
73 VXI_VME_SYSFAIL = VI_EVENT_VXI_VME_SYSFAIL,
74 VXI_VME_SYSRESET = VI_EVENT_VXI_VME_SYSRESET,
75 VXI_SIGP = VI_EVENT_VXI_SIGP,
76 VXI_VME_INTR = VI_EVENT_VXI_VME_INTR,
77 PXI_INTR = VI_EVENT_PXI_INTR,
78 TCPIP_CONNECT = VI_EVENT_TCPIP_CONNECT,
79 USB_INTR = VI_EVENT_USB_INTR,
80 ALL = VI_ALL_ENABLED_EVENTS
81 };
82
103 enum class eTriggerProtocol {
104 Default = VI_TRIG_PROT_DEFAULT,
105 VXI_Default = VI_TRIG_PROT_DEFAULT,
106 VXI_On = VI_TRIG_PROT_ON,
107 VXI_Off = VI_TRIG_PROT_OFF,
108 VXI_Sync = VI_TRIG_PROT_SYNC,
109 PXI_Reserve = VI_TRIG_PROT_RESERVE,
110 PXI_Unreserve = VI_TRIG_PROT_UNRESERVE
111 };
112
114 enum class eSerialBaudrate {
115 k110 = 110,
116 k300 = 300,
117 k600 = 600,
118 k1200 = 1200,
119 k2400 = 2400,
120 k4800 = 4800,
121 k9600 = 9600,
122 k14400 = 14400,
123 k19200 = 19200,
124 k28800 = 28800,
125 k38400 = 38400,
126 k57600 = 57600,
127 k115200 = 115200,
128 k230400 = 230400,
129 k460800 = 460800,
130 k921600 = 921600
131 };
132
133 enum class eSerialDataBits {
134 k7 = 7,
135 k8 = 8
136 };
137
138 enum class eSerialParity {
139 kNone = VI_ASRL_PAR_NONE,
140 kOdd = VI_ASRL_PAR_ODD,
141 kEven = VI_ASRL_PAR_EVEN,
142 kMark = VI_ASRL_PAR_MARK,
143 kSpace = VI_ASRL_PAR_SPACE
144
145 };
146
147 enum class eSerialStopBits {
148 k1 = VI_ASRL_STOP_ONE,
149 k1_5 = VI_ASRL_STOP_ONE5,
150 k2 = VI_ASRL_STOP_TWO
151 };
152
153 enum class eSerialHandshake {
154 kNone = VI_ASRL_FLOW_NONE,
155 kXonXoff = VI_ASRL_FLOW_XON_XOFF,
156 kHardware = VI_ASRL_FLOW_RTS_CTS,
157 kHardAndSoft = (VI_ASRL_FLOW_XON_XOFF | VI_ASRL_FLOW_RTS_CTS)
158 };
159
160 enum class eSerialTermMode {
161 kEndNone = VI_ASRL_END_NONE,
162 kEndLast = VI_ASRL_END_LAST_BIT,
163 kEndTermChar = VI_ASRL_END_TERMCHAR,
164 kEndBreak = VI_ASRL_END_BREAK
165 };
166
187
188 // For future use
191 {
192 public:
193 typedef std::string tClass;
194 typedef std::string tExpandedName;
195 typedef std::string tAlias;
196
197 private:
198 eInterfaceType m_Type;
199 tInterfaceNumber m_Number;
200 tClass m_Class;
201 tExpandedName m_ExpName;
202 tAlias m_Alias;
203 public:
205 : m_Type(Type), m_Number(Number), m_Class(Class), m_ExpName(Expname), m_Alias(Alias)
206 {}
207 const eInterfaceType & Type() const
208 {
209 return m_Type;
210 }
211 const tInterfaceNumber & Number() const
212 {
213 return m_Number;
214 }
215 const tClass & Class() const
216 {
217 return m_Class;
218 }
219 const tExpandedName & ExpName() const
220 {
221 return m_ExpName;
222 }
223 const tAlias & Alias() const
224 {
225 return m_Alias;
226 }
227 };
228
231 {
234
236 : Name(rName), Info(rInfo)
237 {}
238
239 bool operator==(sParsedResource const & other) const
240 {
241 return (Name == other.Name);
242 }
243 bool operator!=(sParsedResource const & other) const
244
245 {
246 return !(*this == other);
247 }
248 };
249
251 class CParsedResourceList : public std::vector<sParsedResource>
252 {
253 public:
254 bool operator==(CParsedResourceList const & other)
255 {
256 if (other.size() != size())
257 return false;
258 for (CParsedResourceList::const_iterator thisit = begin(), otherit = other.begin(); thisit != end(); thisit++, otherit++)
259 {
260 if (*thisit != *otherit)
261 return false;
262 }
263 return true;
264 }
265 bool operator!=(CParsedResourceList const & other)
266 {
267 if (other.size() != size())
268 return true;
269 for (CParsedResourceList::const_iterator thisit = begin(), otherit = other.begin(); thisit != end(); thisit++, otherit++)
270 {
271 if (*thisit != *otherit)
272 return true;
273 }
274 return false;
275 }
276 };
277
278}} // namespace MTL::Instrument
Parsed resource information for a list of instruments.
bool operator==(CParsedResourceList const &other)
Equality operator.
bool operator!=(CParsedResourceList const &other)
Inequality operator.
Information about a VISA resource.
const tAlias & Alias() const
Return alias.
std::string tClass
Class: INSTR / RAW / ...
const tClass & Class() const
Return interface class.
VISAResourceInfo(eInterfaceType Type=eInterfaceType::GPIB, tInterfaceNumber Number=0, tClass Class="", tExpandedName Expname="", tAlias Alias="")
Constructor.
const tInterfaceNumber & Number() const
Return interface number.
std::string tExpandedName
Full resource name.
const eInterfaceType & Type() const
Return interface type.
const tExpandedName & ExpName() const
Return full resource name.
eSerialParity
Parity configuration for the serial communication.
eSerialDataBits
Number of data bits for the serial communication.
eSerialStopBits
Stop bit configuration for the serial communication.
std::string tResourceName
IEEE488 resource name.
eEventMechanism
Event mechanisms.
@ Queue
Enable the session to queue events.
@ All
Enable the session to all events.
@ Suspendedhandler
Enable the session to execute the handler.
@ Handle
Enable the session to invoke a callback function.
eSerialHandshake
Handshake configuration for the serial communication.
@ kHardAndSoft
Set Hardware & Software Handshake (Xon/Xoff & RTS/CTS)
@ kXonXoff
Set Software Handshake Xon/Xoff.
@ kHardware
Set Hardware Handshake RTS/CTS.
ViUInt16 tInterfaceNumber
Interface number.
eOpenAccessMode
Access modes for VISA resources.
@ LoadConfig
Configure attributes to values specified by an external configuration utility.
@ ExclusiveLock
Acquire an exclusive lock immediately upon opening a session. If a lock cannot be acquired,...
@ NoLock
Open session without using an exclusive lock or loading configuration information.
eInterfaceType
VISA interface types.
@ VXI
VXI (IEEE 488.2 over Ethernet).
@ GPIB_VXI
Ethernet GPIB adapter. (?)
@ GPIB
GPIB (a.k.a. HPIB or IEEE 488.1).
@ PXI
PXI (PCI eXtensions for Instrumentation).
eTriggerProtocol
Trigger protocols.
@ PXI_Unreserve
Release a trigger line.
@ VXI_Default
Default protocol for VXI.
@ VXI_Sync
Pulses the trigger (assert followed by deassert).
eSerialTermMode
Serial termination mode.
@ kEndTermChar
Set termination character to the one specified by VI_ATTR_TERMCHAR()
@ kEndNone
Set termination character to None.
@ kEndLast
Set termination character to Last bit.
@ kEndBreak
Set termination character to Break (Only available in Write termination)
@ ServiceRequest
Service request was received from device or interface.
@ VXI_VME_SYSFAIL
VXI/VME SYSFAIL* line was asserted.
@ VXI_VME_INTR
VXIbus interrupt was received from the device.
@ GPIB_CIC
GPIB controller has gained or lost CIC (controller-in-charge) status.
@ GPIB_LISTEN
GPIB controller has been addressed to listen.
@ VXI_SIGP
VXIbus signal or VXIbus interrupt was received from the device.
@ Trig
Trigger interrupt was received from the device.
@ Exception
Error condition has occured during an operation.
@ VXI_VME_SYSRESET
VXI/VME SYSRESET* line was asserted.
@ TCPIP_CONNECT
TCP/IP connection has been made.
@ GPIB_TALK
GPIB controller was addressed to talk.
@ IOCompletion
Asynchronous operation has completed.
@ Clear
Device clear message was sent to the local controller.
@ PXI_INTR
PXI interrupt occurred.
@ USB_INTR
USB interrupt has occurred.
eSerialBaudrate
Serial baudrate.
eResourceClass
Classes of VISA resource.
@ BACKPLANE
VXIbus Mainframe Backplane.
@ SERVANT
Device-side functionality.
VISAResourceInfo Info
Parsed VISA resource information.
bool operator==(sParsedResource const &other) const
Equality operator.
tResourceName Name
VISA resource name.
sParsedResource(tResourceName &rName, VISAResourceInfo &rInfo)
Constructor.
bool operator!=(sParsedResource const &other) const
Inequality operator.
std::string COMPort
[-] String identifying the serial port to connect to
eSerialDataBits DataBits
[-] Number of transmitted bits per packet
eSerialHandshake Handshake
[-] Handshake configuration of the serial communication
eSerialBaudrate Baudrate
[bd] Speed of the serial communication
eSerialStopBits StopBits
[-] Stop bit configuration of the serial communication
eSerialParity Parity
[-] Parity configuration of the serial communication
eSerialTermMode ReadTermMode
[-] Termination Read mode of the serial communication
char ReadTermChar
[-] Specific termination character when readTermMode = kEndTermChar