THM1176InstrumentManager  1.0
Qt Object abstraction for Metrolab THM1176
IEEE488Instrument.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 
8 
9 #pragma once
10 
11 #include "OSDefines.h"
12 #include "IEEE488InstrumentTypes.h"
13 #include "SCPIInstrumentBuffer.h"
14 #include "Synchronization.h"
15 
16 using namespace MTL::Synchronization;
17 
18 namespace MTL {
19  namespace Instrument {
20  //----------------------------------------------------------------------//
23  {
24  protected:
25  mutable CMutex m_Lock;
27 
28  public:
29  // Constructors / destructors
31  { }
33  { }
34 
35  // Initialization
36  virtual bool Initialize() = 0;
37 
38  // Resource utilities
43  virtual bool FindResources(CResourceList & rList, std::string Filter = "?*") = 0;
44 
45  // Info
46  I32 Status(void)
47  {
48  CLockGuard<CMutex> l_LockGuard(m_Lock);
49  return m_Status;
50  }
51 
55  virtual std::string StatusDescription (I32 Status) = 0;
56 
57  virtual bool Timeout(void) = 0;
58  };
59 
60  //----------------------------------------------------------------------//
63  {
64  private:
65  static const I32 IEEE488_DEFAULT_TIMEOUT = 1000;
66 
67  protected:
73 
74  public:
75  // Constructors / destructors
80  : m_rRrsrcMan(rRM), m_Rsrc(Rsrc), m_Status(0), m_Timeout(IEEE488_DEFAULT_TIMEOUT)
81  { }
83  { }
84 
85  // Connection
88  virtual bool Open(void) = 0;
89  virtual void Close() = 0;
90  virtual bool IsOpen() = 0;
91 
92  // Info
93  I32 Status(void)
94  {
95  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
96  return m_Status;
97  }
98 
102  virtual std::string StatusDescription (I32 Status) = 0;
103 
104  virtual bool Timeout(void) = 0;
105 
106  // Write / Read
110  virtual bool Write(const char * Str) = 0;
111 
115  virtual bool Write(const std::string & rStr) = 0;
116 
120  virtual bool Write(const CSCPIBuffer & rBuf) = 0;
121 
126  virtual bool Read(CSCPIBuffer & rBuf, bool Append = false) = 0;
127 
128  // Other operations
132  bool SetTimeout(U32 Timeout)
133  {
134  CLockGuard<CRecursiveMutex> l_LockGuard(m_Lock);
135  m_Timeout = Timeout;
136  return true;
137  }
138 
142  {
143  return m_Timeout;
144  }
145 
146  virtual bool Clear() = 0;
147 
151  virtual bool ReadSTB(U16 & rSTB) = 0;
152 
155  virtual bool AssertTrigger(void) = 0;
156 
157  // Lock / Unlock
161  virtual bool LockExclusive(U32 Timeout) = 0;
162 
163  virtual bool Unlock() = 0;
164 
165  virtual bool LockedExclusive() = 0;
166 
167  };
168 
169  }
170 } // namespace MTL::Instrument
Synchronization.h
Synchronization primitives.
MTL::Instrument::CResourceList
List of VISA resource names.
Definition: IEEE488InstrumentTypes.h:26
MTL::Instrument::CIEEE488Instrument::CIEEE488Instrument
CIEEE488Instrument(CIEEE488ResourceManager &rRM, tResourceName Rsrc)
Constructor.
Definition: IEEE488Instrument.h:79
MTL::Instrument::CIEEE488Instrument::AssertTrigger
virtual bool AssertTrigger(void)=0
Assert a trigger.
MTL::Instrument::CIEEE488Instrument::LockExclusive
virtual bool LockExclusive(U32 Timeout)=0
Obtain an exclusive lock for this session.
MTL::Instrument::CIEEE488Instrument::m_Timeout
U32 m_Timeout
Timeout for operations.
Definition: IEEE488Instrument.h:72
IEEE488InstrumentTypes.h
Abstract IEEE488 instrument class: type definitions.
MTL::Instrument::CIEEE488Instrument::Write
virtual bool Write(const std::string &rStr)=0
Write to a IEEE488 instrument: C++ string variant.
MTL::Instrument::CIEEE488Instrument::Read
virtual bool Read(CSCPIBuffer &rBuf, bool Append=false)=0
Read from a IEEE488 instrument: SCPI buffer class variant.
MTL::Instrument::CIEEE488ResourceManager::m_Lock
CMutex m_Lock
Lock onto the resource manager.
Definition: IEEE488Instrument.h:25
MTL::Instrument::CIEEE488Instrument::SetTimeout
bool SetTimeout(U32 Timeout)
Set the timeout for this instrument.
Definition: IEEE488Instrument.h:132
MTL::Synchronization
Definition: Synchronization.h:12
MTL::Instrument::CIEEE488ResourceManager::Timeout
virtual bool Timeout(void)=0
Last operation timed out.
MTL::Instrument::CIEEE488ResourceManager::Initialize
virtual bool Initialize()=0
Initialize the Resource Manager.
MTL::Instrument::CIEEE488ResourceManager::m_Status
I32 m_Status
Status of last operation.
Definition: IEEE488Instrument.h:26
MTL::Instrument::CIEEE488ResourceManager::~CIEEE488ResourceManager
virtual ~CIEEE488ResourceManager()
Definition: IEEE488Instrument.h:32
MTL::Synchronization::CMutex
std::mutex CMutex
Mutex.
Definition: Synchronization.h:16
MTL::Instrument::CIEEE488Instrument::~CIEEE488Instrument
virtual ~CIEEE488Instrument()
Definition: IEEE488Instrument.h:82
MTL::Instrument::CIEEE488Instrument::m_Rsrc
tResourceName m_Rsrc
Resource name of the instrument.
Definition: IEEE488Instrument.h:70
MTL::Instrument::CIEEE488Instrument::Write
virtual bool Write(const CSCPIBuffer &rBuf)=0
Write to a IEEE488 instrument: SCPI buffer class variant.
MTL
Definition: CTHM1176InstrumentManager.h:179
MTL::Instrument::CIEEE488ResourceManager::FindResources
virtual bool FindResources(CResourceList &rList, std::string Filter="?*")=0
Find IEEE488 resources.
MTL::Instrument::CIEEE488ResourceManager::StatusDescription
virtual std::string StatusDescription(I32 Status)=0
Return description of status word.
I32
int I32
32-bit signed integer.
Definition: OSDefines.h:28
MTL::Instrument::CIEEE488Instrument::ReadSTB
virtual bool ReadSTB(U16 &rSTB)=0
Read status byte.
MTL::Instrument::CIEEE488Instrument::Open
virtual bool Open(void)=0
Open a session to this IEEE488 instrument.
MTL::Instrument::CIEEE488Instrument
IEEE488 instrument class.
Definition: IEEE488Instrument.h:63
MTL::Instrument::CIEEE488Instrument::m_Lock
CRecursiveMutex m_Lock
Lock onto the class interface.
Definition: IEEE488Instrument.h:68
MTL::Instrument::CIEEE488Instrument::Write
virtual bool Write(const char *Str)=0
Write to a IEEE488 instrument: C string variant.
MTL::Instrument::CIEEE488ResourceManager
IEEE488 Instrument Resource Manager class.
Definition: IEEE488Instrument.h:23
MTL::Instrument::CIEEE488Instrument::StatusDescription
virtual std::string StatusDescription(I32 Status)=0
Return description of status word.
MTL::Instrument::tResourceName
std::string tResourceName
IEEE488 resource name.
Definition: IEEE488InstrumentTypes.h:22
MTL::Instrument::CIEEE488ResourceManager::Status
I32 Status(void)
Definition: IEEE488Instrument.h:46
MTL::Instrument::CIEEE488Instrument::m_rRrsrcMan
CIEEE488ResourceManager & m_rRrsrcMan
Reference to the associated resource manager.
Definition: IEEE488Instrument.h:69
MTL::Instrument::CIEEE488Instrument::m_Status
I32 m_Status
Status of last operation.
Definition: IEEE488Instrument.h:71
MTL::Instrument::CIEEE488Instrument::Close
virtual void Close()=0
Close session to this instrument.
MTL::Synchronization::CLockGuard
Lock.
Definition: Synchronization.h:63
U16
unsigned short U16
16-bit unsigned integer.
Definition: OSDefines.h:31
OSDefines.h
Platform Dependent Definitions.
MTL::Instrument::CIEEE488Instrument::Clear
virtual bool Clear()=0
Clear the instrument.
SCPIInstrumentBuffer.h
IEEE488.2 / SCPI instrument I/O: Instrument buffer management.
MTL::Instrument::CIEEE488Instrument::Unlock
virtual bool Unlock()=0
Unlock the session.
MTL::Instrument::CIEEE488Instrument::GetTimeout
U32 GetTimeout(void)
Return the timeout for this instrument.
Definition: IEEE488Instrument.h:141
MTL::Instrument::CSCPIBuffer
Instrument Buffer.
Definition: SCPIInstrumentBuffer.h:44
MTL::Synchronization::CRecursiveMutex
std::recursive_mutex CRecursiveMutex
Recursive Mutex.
Definition: Synchronization.h:20
MTL::Instrument::CIEEE488Instrument::Timeout
virtual bool Timeout(void)=0
Last operation timed out.
MTL::Instrument::CIEEE488Instrument::LockedExclusive
virtual bool LockedExclusive()=0
Check whether session is locked exclusively.
U32
unsigned int U32
32-bit unsigned integer.
Definition: OSDefines.h:32
MTL::Instrument::CIEEE488ResourceManager::CIEEE488ResourceManager
CIEEE488ResourceManager()
Definition: IEEE488Instrument.h:30
MTL::Instrument::CIEEE488Instrument::Status
I32 Status(void)
Definition: IEEE488Instrument.h:93
MTL::Instrument::CIEEE488Instrument::IsOpen
virtual bool IsOpen()=0
Check whether a session to this instrument is open.