C++Instrument Catalog MFC 1.2
Metrolab C++InstrumentCatalog for MFC
Loading...
Searching...
No Matches
VISAInstrumentTypes.h
Go to the documentation of this file.
1
4
5#pragma once
6
7// External tools
8#include "visa.h"
9
10// Standard libraries
11#include <string>
12#include <vector>
13#include <iostream>
14
15namespace MTL {
16 namespace Instrument
17 {
18 //----------------------------------------------------------------------//
19 // Types //
20 //----------------------------------------------------------------------//
21 typedef std::string tResourceName;
22
23 class CResourceList : public std::vector<tResourceName>
24 {
25 public:
26 std::string Dump() const
27 {
28 std::string l_RsrcList;
29 for (CResourceList::const_iterator it = this->begin(); it != this->end(); it++)
30 l_RsrcList += *it + '\n';
31 return l_RsrcList;
32 }
33 bool operator==(CResourceList const & other)
34 {
35 if (other.size() != size())
36 return false;
37 for (CResourceList::const_iterator thisit = begin(), otherit = other.begin(); thisit != end(); thisit++, otherit++)
38 {
39 if (*thisit != *otherit)
40 return false;
41 }
42 return true;
43 }
44 bool operator!=(CResourceList const & other)
45 {
46 if (other.size() != size())
47 return true;
48 for (CResourceList::const_iterator thisit = begin(), otherit = other.begin(); thisit != end(); thisit++, otherit++)
49 {
50 if (*thisit != *otherit)
51 return true;
52 }
53 return false;
54 }
55 };
56
66
68
78
79 enum class eOpenAccessMode {
80 NoLock = VI_NO_LOCK, // Open session without using an exclusive lock or loading configuration information
81 ExclusiveLock = VI_EXCLUSIVE_LOCK, // Acquire an exclusive lock immediately upon opening a session. If a lock cannot be acquired, the session is closed and an error is returned
82 LoadConfig = VI_LOAD_CONFIG // Configure attributes to values specified by an external configuration utility, such as the following utilities:
83 // - (Windows) Measurement & Automation Explorer
84 // - (Mac OS X) NI - VISA Configuration
85 // - (Linux) visaconf
86 };
87
88 enum class eEventMechanism {
89 Queue = VI_QUEUE, // Enable the session to queue events
90 Handle = VI_HNDLR, // Enable the session to invoke a callback function
91 Suspendedhandler = VI_SUSPEND_HNDLR, // Enable the session to execute the handler
92 All = VI_ALL_MECH // Enable the session to all events
93 };
94
95 enum class eEventType : unsigned long {
96 ServiceRequest = VI_EVENT_SERVICE_REQ, // Notifies the application that a service request was received from the device or interface associated with the given session.
97 Trig = VI_EVENT_TRIG, // Notifies the application that a trigger interrupt was received from the device. This may be either a hardware or software trigger, depending on the interface and the current session settings.
98 Clear = VI_EVENT_CLEAR, // Notifies the application that a device clear message was sent to the local controller.
99 IOCompletion = VI_EVENT_IO_COMPLETION, // Notifies the application that an asynchronous operation has completed.
100 Exception = VI_EVENT_EXCEPTION, // Notifies the application that an error condition has occured during an operation invocation.
101 GPIB_CIC = VI_EVENT_GPIB_CIC, // Notifies the application that the GPIB controller has gained or lost CIC (controller-in-charge) status.
102 GPIB_TALK = VI_EVENT_GPIB_TALK, // Notifies the application that the GPIB controller was addressed to talk.
103 GPIB_LISTEN = VI_EVENT_GPIB_LISTEN, // Notifies the application that the GPIB controller has been addressed to listen.
104 VXI_VME_SYSFAIL = VI_EVENT_VXI_VME_SYSFAIL, // Notifies the application that the VXI/VME SYSFAIL* line was asserted.
105 VXI_VME_SYSRESET = VI_EVENT_VXI_VME_SYSRESET, // Notifies the application that the VXI/VME SYSRESET* line was asserted.
106 VXI_SIGP = VI_EVENT_VXI_SIGP, // Notifies the application that a VXIbus signal or VXIbus interrupt was received from the device associated with the given session.
107 VXI_VME_INTR = VI_EVENT_VXI_VME_INTR, // Notifies the application that a VXIbus interrupt was received from the device associated with the given session.
108 PXI_INTR = VI_EVENT_PXI_INTR, // Notifies the application that a PXI interrupt occurred.
109 TCPIP_CONNECT = VI_EVENT_TCPIP_CONNECT, // Notifies the application that ...? No documentation...
110 USB_INTR = VI_EVENT_USB_INTR, // Notifies the application that a USB interrupt has occurred.
112 };
113
123
124 enum class eSerialBaudrate { // Serial baudrate
125 k110 = 110,
126 k300 = 300,
127 k600 = 600,
128 k1200 = 1200,
129 k2400 = 2400,
130 k4800 = 4800,
131 k9600 = 9600,
132 k14400 = 14400,
133 k19200 = 19200,
134 k28800 = 28800,
135 k38400 = 38400,
136 k57600 = 57600,
137 k115200 = 115200,
138 k230400 = 230400,
139 k460800 = 460800,
140 k921600 = 921600
141 };
142 enum class eSerialDataBits { // Number of data bits for the serial communication
143 k7 = 7,
144 k8 = 8
145 };
146 enum class eSerialParity { // Parity configuration for the serial communication
147 kNone = VI_ASRL_PAR_NONE, //set Parity to None
148 kOdd = VI_ASRL_PAR_ODD, //set Parity to Odd
149 kEven = VI_ASRL_PAR_EVEN, //set Parity to Even
150 kMark = VI_ASRL_PAR_MARK, //set Parity to Mark
151 kSpace = VI_ASRL_PAR_SPACE //set Parity to Space
152
153 };
154 enum class eSerialStopBits { // Stop bit configuration for the serial communication
155 k1 = VI_ASRL_STOP_ONE, //set Stop bit to 1
156 k1_5 = VI_ASRL_STOP_ONE5, //set Stop bit to 1.5
157 k2 = VI_ASRL_STOP_TWO //set Stop bit to 2
158 };
159 enum class eSerialHandshake { // Handshake configuration for the serial communication
161 kXonXoff = VI_ASRL_FLOW_XON_XOFF, //set Software Handshake Xon/Xoff
162 kHardware = VI_ASRL_FLOW_RTS_CTS, //set Hardware Handshake RTS/CTS
163 kHardAndSoft = (VI_ASRL_FLOW_XON_XOFF | VI_ASRL_FLOW_RTS_CTS) //set Hardware & Software Handshake (Xon/Xoff & RTS/CTS)
164 };
165
166 enum class eSerialTermMode { //Serial termination mode
167 kEndNone = VI_ASRL_END_NONE, //set termination character to None
168 kEndLast = VI_ASRL_END_LAST_BIT, //set termination character to Last bit
169 kEndTermChar = VI_ASRL_END_TERMCHAR, //set termination character to the one specified by VI_ATTR_TERMCHAR()
170 kEndBreak = VI_ASRL_END_BREAK //set termination character to Break (Only available in Write termination)
171 };
172
173 struct sSerialPortSettings { // Sets serial port settings
174 eSerialBaudrate Baudrate; // [bd] Speed of the serial communication
175 eSerialDataBits DataBits; // [-] Number of transmitted bits per packet
176 eSerialParity Parity; // [-] Parity configuration of the serial communication
177 eSerialStopBits StopBits; // [-] Stop bit configuration of the serial communication
178 eSerialHandshake Handshake; // [-] Handshake configuration of the serial communication
179 eSerialTermMode ReadTermMode; // [-] Termination Read mode of the serial communication
180 char ReadTermChar; // [-] Specific termination character when readTermMode = kEndTermChar
190 };
191
192 // For future use
194 {
195 public:
196 typedef std::string tClass; // INSTR / RAW / ...
197 typedef std::string tExpandedName;
198 typedef std::string tAlias; // If any
199
200 private:
201 eInterfaceType m_Type;
202 tInterfaceNumber m_Number;
203 tClass m_Class;
204 tExpandedName m_ExpName;
205 tAlias m_Alias;
206 public:
210 : m_Type(Type), m_Number(Number), m_Class(Class), m_ExpName(Expname), m_Alias(Alias)
211 {}
212 const eInterfaceType & Type() const
213 {
214 return m_Type;
215 }
216 const tInterfaceNumber & Number() const
217 {
218 return m_Number;
219 }
220 const tClass & Class() const
221 {
222 return m_Class;
223 }
224 const tExpandedName & ExpName() const
225 {
226 return m_ExpName;
227 }
228 const tAlias & Alias() const
229 {
230 return m_Alias;
231 }
232 };
233
235 {
238
240 : Name(rName), Info(rInfo)
241 {}
242
243 bool operator==(sParsedResource const & other) const
244 {
245 return (Name == other.Name);
246 }
247 bool operator!=(sParsedResource const & other) const
248
249 {
250 return !(*this == other);
251 }
252 };
253 class CParsedResourceList : public std::vector<sParsedResource>
254 {
255 public:
256 bool operator==(CParsedResourceList const & other)
257 {
258 if (other.size() != size())
259 return false;
260 for (CParsedResourceList::const_iterator thisit = begin(), otherit = other.begin(); thisit != end(); thisit++, otherit++)
261 {
262 if (*thisit != *otherit)
263 return false;
264 }
265 return true;
266 }
267 bool operator!=(CParsedResourceList const & other)
268 {
269 if (other.size() != size())
270 return true;
271 for (CParsedResourceList::const_iterator thisit = begin(), otherit = other.begin(); thisit != end(); thisit++, otherit++)
272 {
273 if (*thisit != *otherit)
274 return true;
275 }
276 return false;
277 }
278 };
279
280}} // namespace MTL::Instrument
#define VI_TRIG_PROT_RESERVE
Definition visa.h:761
#define VI_TRIG_PROT_ON
Definition visa.h:758
#define VI_EVENT_VXI_VME_SYSFAIL
Definition visa.h:555
#define VI_INTF_USB
Definition visa.h:684
#define VI_INTF_ASRL
Definition visa.h:681
#define VI_INTF_TCPIP
Definition visa.h:683
#define VI_EVENT_GPIB_TALK
Definition visa.h:553
#define VI_EVENT_VXI_VME_SYSRESET
Definition visa.h:556
#define VI_NO_LOCK
Definition visa.h:785
#define VI_EVENT_CLEAR
Definition visa.h:550
#define VI_EXCLUSIVE_LOCK
Definition visa.h:786
#define VI_ASRL_END_LAST_BIT
Definition visa.h:808
#define VI_ASRL_STOP_TWO
Definition visa.h:800
#define VI_ASRL_END_TERMCHAR
Definition visa.h:809
#define VI_EVENT_EXCEPTION
Definition visa.h:551
#define VI_TRIG_PROT_UNRESERVE
Definition visa.h:762
#define VI_INTF_GPIB
Definition visa.h:678
#define VI_ASRL_PAR_NONE
Definition visa.h:792
#define VI_EVENT_GPIB_CIC
Definition visa.h:552
#define VI_INTF_GPIB_VXI
Definition visa.h:680
#define VI_EVENT_VXI_SIGP
Definition visa.h:557
#define VI_ASRL_FLOW_XON_XOFF
Definition visa.h:803
#define VI_QUEUE
Definition visa.h:715
#define VI_ASRL_FLOW_NONE
Definition visa.h:802
#define VI_EVENT_TCPIP_CONNECT
Definition visa.h:560
#define VI_TRIG_PROT_DEFAULT
Definition visa.h:757
#define VI_SUSPEND_HNDLR
Definition visa.h:717
#define VI_ASRL_STOP_ONE5
Definition visa.h:799
#define VI_ALL_ENABLED_EVENTS
Definition visa.h:563
#define VI_TRIG_PROT_OFF
Definition visa.h:759
#define VI_EVENT_GPIB_LISTEN
Definition visa.h:554
#define VI_LOAD_CONFIG
Definition visa.h:788
#define VI_EVENT_USB_INTR
Definition visa.h:561
#define VI_TRIG_PROT_SYNC
Definition visa.h:760
#define VI_EVENT_TRIG
Definition visa.h:548
#define VI_ASRL_PAR_EVEN
Definition visa.h:794
#define VI_ASRL_END_NONE
Definition visa.h:807
#define VI_ASRL_FLOW_RTS_CTS
Definition visa.h:804
#define VI_EVENT_IO_COMPLETION
Definition visa.h:547
#define VI_ALL_MECH
Definition visa.h:718
#define VI_EVENT_VXI_VME_INTR
Definition visa.h:558
#define VI_INTF_VXI
Definition visa.h:679
#define VI_EVENT_PXI_INTR
Definition visa.h:559
#define VI_EVENT_SERVICE_REQ
Definition visa.h:549
#define VI_ASRL_STOP_ONE
Definition visa.h:798
#define VI_ASRL_END_BREAK
Definition visa.h:810
#define VI_ASRL_PAR_MARK
Definition visa.h:795
#define VI_ASRL_PAR_SPACE
Definition visa.h:796
#define VI_ASRL_PAR_ODD
Definition visa.h:793
#define VI_INTF_PXI
Definition visa.h:682
#define VI_HNDLR
Definition visa.h:716
unsigned short ViUInt16
Definition visatype.h:111
std::string tResourceName
bool operator!=(CResourceList const &other)
bool operator==(CResourceList const &other)
const tInterfaceNumber & Number() const
VISAResourceInfo(eInterfaceType Type, tInterfaceNumber Number, tClass Class, tExpandedName Expname, tAlias Alias)
const eInterfaceType & Type() const
const tExpandedName & ExpName() const
bool operator==(sParsedResource const &other) const
sParsedResource(tResourceName &rName, VISAResourceInfo &rInfo)
bool operator!=(sParsedResource const &other) const
bool operator==(CParsedResourceList const &other)
bool operator!=(CParsedResourceList const &other)