THM1176InstrumentManager  1.0
Qt Object abstraction for Metrolab THM1176
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 
18 namespace 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 
36 
38  enum class eResourceClass {
39  INSTR = 0,
40  MEMACC,
41  INTFC,
42  BACKPLANE,
43  SERVANT,
44  SOCKET,
45  RAW
46  };
47 
49  enum class eOpenAccessMode {
50  NoLock = VI_NO_LOCK,
51  ExclusiveLock = VI_EXCLUSIVE_LOCK,
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,
68  IOCompletion = VI_EVENT_IO_COMPLETION,
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,
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,
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  };
133  enum class eSerialDataBits {
134  k7 = 7,
135  k8 = 8
136  };
137  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,
144 
145  };
147  enum class eSerialStopBits {
148  k1 = VI_ASRL_STOP_ONE,
149  k1_5 = VI_ASRL_STOP_ONE5,
151  };
153  enum class eSerialHandshake {
154  kNone = VI_ASRL_FLOW_NONE,
155  kXonXoff = VI_ASRL_FLOW_XON_XOFF,
156  kHardware = VI_ASRL_FLOW_RTS_CTS,
158  };
160  enum class eSerialTermMode {
161  kEndNone = VI_ASRL_END_NONE,
162  kEndLast = VI_ASRL_END_LAST_BIT,
163  kEndTermChar = VI_ASRL_END_TERMCHAR,
165  };
168  std::string COMPort;
177  : COMPort(""),
178  Baudrate(eSerialBaudrate::k9600),
180  Parity(eSerialParity::kNone),
182  Handshake(eSerialHandshake::kNone),
183  ReadTermMode(eSerialTermMode::kEndTermChar),
184  ReadTermChar('\n')
185  {}
186  };
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:
204  VISAResourceInfo(eInterfaceType Type = eInterfaceType::GPIB, tInterfaceNumber Number = 0, tClass Class = "", tExpandedName Expname = "", tAlias Alias = "")
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
VI_TRIG_PROT_SYNC
#define VI_TRIG_PROT_SYNC
Definition: visa.h:763
VI_ALL_MECH
#define VI_ALL_MECH
Definition: visa.h:721
MTL::Instrument::VISAResourceInfo::Number
const tInterfaceNumber & Number() const
Return interface number.
Definition: VISAInstrumentTypes.h:211
MTL::Instrument::VISAResourceInfo::Type
const eInterfaceType & Type() const
Return interface type.
Definition: VISAInstrumentTypes.h:207
VI_ASRL_PAR_NONE
#define VI_ASRL_PAR_NONE
Definition: visa.h:795
VI_TRIG_PROT_RESERVE
#define VI_TRIG_PROT_RESERVE
Definition: visa.h:764
VI_TRIG_PROT_DEFAULT
#define VI_TRIG_PROT_DEFAULT
Definition: visa.h:760
MTL::Instrument::eEventType::Clear
@ Clear
Device clear message was sent to the local controller.
MTL::Instrument::eEventType::ServiceRequest
@ ServiceRequest
Service request was received from device or interface.
MTL::Instrument::eResourceClass
eResourceClass
Classes of VISA resource.
Definition: VISAInstrumentTypes.h:38
MTL::Instrument::eSerialDataBits
eSerialDataBits
Number of data bits for the serial communication.
Definition: VISAInstrumentTypes.h:133
MTL::Instrument::sSerialPortSettings::Handshake
eSerialHandshake Handshake
[-] Handshake configuration of the serial communication
Definition: VISAInstrumentTypes.h:173
VI_EVENT_IO_COMPLETION
#define VI_EVENT_IO_COMPLETION
Definition: visa.h:550
MTL::Instrument::sSerialPortSettings::ReadTermMode
eSerialTermMode ReadTermMode
[-] Termination Read mode of the serial communication
Definition: VISAInstrumentTypes.h:174
VI_ASRL_STOP_ONE
#define VI_ASRL_STOP_ONE
Definition: visa.h:801
VI_TRIG_PROT_UNRESERVE
#define VI_TRIG_PROT_UNRESERVE
Definition: visa.h:765
VI_EVENT_TCPIP_CONNECT
#define VI_EVENT_TCPIP_CONNECT
Definition: visa.h:563
VI_EVENT_VXI_VME_INTR
#define VI_EVENT_VXI_VME_INTR
Definition: visa.h:561
MTL::Instrument::sSerialPortSettings::Baudrate
eSerialBaudrate Baudrate
[bd] Speed of the serial communication
Definition: VISAInstrumentTypes.h:169
VI_EVENT_USB_INTR
#define VI_EVENT_USB_INTR
Definition: visa.h:564
VI_ASRL_FLOW_XON_XOFF
#define VI_ASRL_FLOW_XON_XOFF
Definition: visa.h:806
MTL::Instrument::eResourceClass::INSTR
@ INSTR
Instrument.
MTL::Instrument::eEventMechanism
eEventMechanism
Event mechanisms.
Definition: VISAInstrumentTypes.h:56
VI_ASRL_PAR_MARK
#define VI_ASRL_PAR_MARK
Definition: visa.h:798
MTL::Instrument::VISAResourceInfo
Information about a VISA resource.
Definition: VISAInstrumentTypes.h:191
VI_ASRL_END_NONE
#define VI_ASRL_END_NONE
Definition: visa.h:810
MTL::Instrument::sSerialPortSettings
Serial port settings.
Definition: VISAInstrumentTypes.h:167
MTL::Instrument::eSerialTermMode::kEndNone
@ kEndNone
Set termination character to None.
VI_EVENT_SERVICE_REQ
#define VI_EVENT_SERVICE_REQ
Definition: visa.h:552
VI_INTF_PXI
#define VI_INTF_PXI
Definition: visa.h:685
VI_NO_LOCK
#define VI_NO_LOCK
Definition: visa.h:788
MTL::Instrument::sParsedResource::Info
VISAResourceInfo Info
Parsed VISA resource information.
Definition: VISAInstrumentTypes.h:233
VI_ASRL_FLOW_NONE
#define VI_ASRL_FLOW_NONE
Definition: visa.h:805
VI_EVENT_VXI_VME_SYSRESET
#define VI_EVENT_VXI_VME_SYSRESET
Definition: visa.h:559
MTL::Instrument::eEventType
eEventType
Event types.
Definition: VISAInstrumentTypes.h:64
VI_ASRL_END_TERMCHAR
#define VI_ASRL_END_TERMCHAR
Definition: visa.h:812
VI_INTF_USB
#define VI_INTF_USB
Definition: visa.h:687
MTL::Instrument::VISAResourceInfo::Class
const tClass & Class() const
Return interface class.
Definition: VISAInstrumentTypes.h:215
MTL::Instrument::CParsedResourceList::operator==
bool operator==(CParsedResourceList const &other)
Equality operator.
Definition: VISAInstrumentTypes.h:254
VI_EVENT_CLEAR
#define VI_EVENT_CLEAR
Definition: visa.h:553
MTL::Instrument::eInterfaceType
eInterfaceType
VISA interface types.
Definition: VISAInstrumentTypes.h:25
MTL::Instrument::sSerialPortSettings::COMPort
std::string COMPort
[-] String identifying the serial port to connect to
Definition: VISAInstrumentTypes.h:168
MTL::Instrument::eOpenAccessMode::NoLock
@ NoLock
Open session without using an exclusive lock or loading configuration information.
VI_TRIG_PROT_ON
#define VI_TRIG_PROT_ON
Definition: visa.h:761
VI_EVENT_GPIB_TALK
#define VI_EVENT_GPIB_TALK
Definition: visa.h:556
VI_TRIG_PROT_OFF
#define VI_TRIG_PROT_OFF
Definition: visa.h:762
MTL::Instrument::eEventMechanism::Queue
@ Queue
Enable the session to queue events.
MTL::Instrument::eInterfaceType::GPIB
@ GPIB
GPIB (a.k.a. HPIB or IEEE 488.1).
VI_EVENT_TRIG
#define VI_EVENT_TRIG
Definition: visa.h:551
MTL
Definition: CTHM1176InstrumentManager.h:179
VI_ASRL_PAR_SPACE
#define VI_ASRL_PAR_SPACE
Definition: visa.h:799
VI_INTF_TCPIP
#define VI_INTF_TCPIP
Definition: visa.h:686
MTL::Instrument::eSerialDataBits::k7
@ k7
7 data bits
MTL::Instrument::sParsedResource
Parsed information about a VISA resource.
Definition: VISAInstrumentTypes.h:231
MTL::Instrument::eSerialParity::kNone
@ kNone
Set Parity to None.
VI_QUEUE
#define VI_QUEUE
Definition: visa.h:718
VI_HNDLR
#define VI_HNDLR
Definition: visa.h:719
VI_EVENT_VXI_SIGP
#define VI_EVENT_VXI_SIGP
Definition: visa.h:560
MTL::Instrument::sSerialPortSettings::DataBits
eSerialDataBits DataBits
[-] Number of transmitted bits per packet
Definition: VISAInstrumentTypes.h:170
MTL::Instrument::eSerialTermMode
eSerialTermMode
Serial termination mode.
Definition: VISAInstrumentTypes.h:160
MTL::Instrument::CParsedResourceList::operator!=
bool operator!=(CParsedResourceList const &other)
Inequality operator.
Definition: VISAInstrumentTypes.h:265
VI_SUSPEND_HNDLR
#define VI_SUSPEND_HNDLR
Definition: visa.h:720
MTL::Instrument::eTriggerProtocol
eTriggerProtocol
Trigger protocols.
Definition: VISAInstrumentTypes.h:103
VI_ASRL_END_BREAK
#define VI_ASRL_END_BREAK
Definition: visa.h:813
MTL::Instrument::sSerialPortSettings::Parity
eSerialParity Parity
[-] Parity configuration of the serial communication
Definition: VISAInstrumentTypes.h:171
MTL::Instrument::eSerialParity
eSerialParity
Parity configuration for the serial communication.
Definition: VISAInstrumentTypes.h:138
MTL::Instrument::tInterfaceNumber
ViUInt16 tInterfaceNumber
Interface number.
Definition: VISAInstrumentTypes.h:35
VI_LOAD_CONFIG
#define VI_LOAD_CONFIG
Definition: visa.h:791
VI_EVENT_VXI_VME_SYSFAIL
#define VI_EVENT_VXI_VME_SYSFAIL
Definition: visa.h:558
MTL::Instrument::eEventType::Exception
@ Exception
Error condition has occured during an operation.
VI_ASRL_PAR_EVEN
#define VI_ASRL_PAR_EVEN
Definition: visa.h:797
VI_EVENT_GPIB_CIC
#define VI_EVENT_GPIB_CIC
Definition: visa.h:555
VI_INTF_GPIB_VXI
#define VI_INTF_GPIB_VXI
Definition: visa.h:683
VI_INTF_ASRL
#define VI_INTF_ASRL
Definition: visa.h:684
VI_ASRL_FLOW_RTS_CTS
#define VI_ASRL_FLOW_RTS_CTS
Definition: visa.h:807
VI_EXCLUSIVE_LOCK
#define VI_EXCLUSIVE_LOCK
Definition: visa.h:789
VI_EVENT_GPIB_LISTEN
#define VI_EVENT_GPIB_LISTEN
Definition: visa.h:557
MTL::Instrument::eSerialHandshake::kNone
@ kNone
Set None.
MTL::Instrument::tResourceName
std::string tResourceName
IEEE488 resource name.
Definition: IEEE488InstrumentTypes.h:22
MTL::Instrument::eSerialStopBits
eSerialStopBits
Stop bit configuration for the serial communication.
Definition: VISAInstrumentTypes.h:147
VI_ASRL_PAR_ODD
#define VI_ASRL_PAR_ODD
Definition: visa.h:796
MTL::Instrument::VISAResourceInfo::tAlias
std::string tAlias
Alias, if any.
Definition: VISAInstrumentTypes.h:195
VI_ASRL_STOP_ONE5
#define VI_ASRL_STOP_ONE5
Definition: visa.h:802
MTL::Instrument::sParsedResource::sParsedResource
sParsedResource(tResourceName &rName, VISAResourceInfo &rInfo)
Constructor.
Definition: VISAInstrumentTypes.h:235
MTL::Instrument::sSerialPortSettings::ReadTermChar
char ReadTermChar
[-] Specific termination character when readTermMode = kEndTermChar
Definition: VISAInstrumentTypes.h:175
VI_EVENT_PXI_INTR
#define VI_EVENT_PXI_INTR
Definition: visa.h:562
MTL::Instrument::VISAResourceInfo::VISAResourceInfo
VISAResourceInfo(eInterfaceType Type=eInterfaceType::GPIB, tInterfaceNumber Number=0, tClass Class="", tExpandedName Expname="", tAlias Alias="")
Constructor.
Definition: VISAInstrumentTypes.h:204
MTL::Instrument::VISAResourceInfo::ExpName
const tExpandedName & ExpName() const
Return full resource name.
Definition: VISAInstrumentTypes.h:219
MTL::Instrument::eOpenAccessMode
eOpenAccessMode
Access modes for VISA resources.
Definition: VISAInstrumentTypes.h:49
VI_INTF_VXI
#define VI_INTF_VXI
Definition: visa.h:682
MTL::Instrument::sParsedResource::operator==
bool operator==(sParsedResource const &other) const
Equality operator.
Definition: VISAInstrumentTypes.h:239
VI_ASRL_STOP_TWO
#define VI_ASRL_STOP_TWO
Definition: visa.h:803
MTL::Instrument::eSerialStopBits::k1
@ k1
Set Stop bit to 1.
MTL::Instrument::sSerialPortSettings::sSerialPortSettings
sSerialPortSettings()
Constructor.
Definition: VISAInstrumentTypes.h:176
MTL::Instrument::sSerialPortSettings::StopBits
eSerialStopBits StopBits
[-] Stop bit configuration of the serial communication
Definition: VISAInstrumentTypes.h:172
VI_EVENT_EXCEPTION
#define VI_EVENT_EXCEPTION
Definition: visa.h:554
VI_ALL_ENABLED_EVENTS
#define VI_ALL_ENABLED_EVENTS
Definition: visa.h:566
MTL::Instrument::sParsedResource::operator!=
bool operator!=(sParsedResource const &other) const
Inequality operator.
Definition: VISAInstrumentTypes.h:243
MTL::Instrument::eTriggerProtocol::Default
@ Default
Default protocol.
ViUInt16
unsigned short ViUInt16
Definition: visatype.h:114
MTL::Instrument::VISAResourceInfo::tExpandedName
std::string tExpandedName
Full resource name.
Definition: VISAInstrumentTypes.h:194
MTL::Instrument::sParsedResource::Name
tResourceName Name
VISA resource name.
Definition: VISAInstrumentTypes.h:232
MTL::Instrument::VISAResourceInfo::tClass
std::string tClass
Class: INSTR / RAW / ...
Definition: VISAInstrumentTypes.h:193
MTL::Instrument::CParsedResourceList
Parsed resource information for a list of instruments.
Definition: VISAInstrumentTypes.h:252
MTL::Instrument::eSerialBaudrate::k110
@ k110
110 baud
MTL::Instrument::VISAResourceInfo::Alias
const tAlias & Alias() const
Return alias.
Definition: VISAInstrumentTypes.h:223
MTL::Instrument::eSerialBaudrate
eSerialBaudrate
Serial baudrate.
Definition: VISAInstrumentTypes.h:114
MTL::Instrument::eSerialHandshake
eSerialHandshake
Handshake configuration for the serial communication.
Definition: VISAInstrumentTypes.h:153
VI_ASRL_END_LAST_BIT
#define VI_ASRL_END_LAST_BIT
Definition: visa.h:811
VI_INTF_GPIB
#define VI_INTF_GPIB
Definition: visa.h:681