| THM1176InstrumentManager 1.2 Qt Object abstraction for Metrolab THM1176

Loading...
Searching...
No Matches
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 //----------------------------------------------------------------------//
22 class CIEEE488ResourceManager
23 {
24 protected:
25 mutable CMutex m_Lock;
26 I32 m_Status;
27
28 public:
29 // Constructors / destructors
30 CIEEE488ResourceManager()
31 { }
32 virtual ~CIEEE488ResourceManager()
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 //----------------------------------------------------------------------//
62 class CIEEE488Instrument
63 {
64 protected:
65 static const I32 IEEE488_DEFAULT_TIMEOUT = 100;
66
67 protected:
68 mutable CRecursiveMutex m_Lock;
69 CIEEE488ResourceManager & m_rRrsrcMan;
70 tResourceName m_Rsrc;
71 I32 m_Status;
72 U32 m_Timeout;
73
74 public:
75 // Constructors / destructors
79 CIEEE488Instrument(CIEEE488ResourceManager & rRM, tResourceName Rsrc)
80 : m_rRrsrcMan(rRM), m_Rsrc(Rsrc), m_Status(0), m_Timeout(IEEE488_DEFAULT_TIMEOUT)
81 { }
82 virtual ~CIEEE488Instrument()
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
141 U32 GetTimeout(void)
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 virtual bool EnableEvent (void) = 0;
168
169 virtual bool DisableEvent (void) = 0;
170
171 virtual bool WaitOnEvent (U32 Timeout) = 0;
172
173 virtual bool DiscardEvents (void) = 0;
174
175 }; // class CIEEE488Instrument
176
177 } // namespace MTL::Instrument
178} // namespace MTL
IEEE488InstrumentTypes.h
Abstract IEEE488 instrument class: type definitions.
OSDefines.h
Platform Dependent Definitions.
I32
int I32
32-bit signed integer.
Definition OSDefines.h:27
U32
unsigned int U32
32-bit unsigned integer.
Definition OSDefines.h:31
U16
unsigned short U16
16-bit unsigned integer.
Definition OSDefines.h:30
SCPIInstrumentBuffer.h
IEEE488.2 / SCPI instrument I/O: Instrument buffer management.
Synchronization.h
Synchronization primitives.
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 CSCPIBuffer &rBuf)=0
Write to a IEEE488 instrument: SCPI buffer class variant.
MTL::Instrument::CIEEE488Instrument::Clear
virtual bool Clear()=0
Clear the instrument.
MTL::Instrument::CIEEE488Instrument::LockExclusive
virtual bool LockExclusive(U32 Timeout)=0
Obtain an exclusive lock for this session.
MTL::Instrument::CIEEE488Instrument::Write
virtual bool Write(const std::string &rStr)=0
Write to a IEEE488 instrument: C++ string variant.
MTL::Instrument::CIEEE488Instrument::m_Rsrc
tResourceName m_Rsrc
Resource name of the instrument.
Definition IEEE488Instrument.h:70
MTL::Instrument::CIEEE488Instrument::GetTimeout
U32 GetTimeout(void)
Return the timeout for this instrument.
Definition IEEE488Instrument.h:141
MTL::Instrument::CIEEE488Instrument::~CIEEE488Instrument
virtual ~CIEEE488Instrument()
Definition IEEE488Instrument.h:82
MTL::Instrument::CIEEE488Instrument::DiscardEvents
virtual bool DiscardEvents(void)=0
Discard service requests.
MTL::Instrument::CIEEE488Instrument::DisableEvent
virtual bool DisableEvent(void)=0
Disable service requests.
MTL::Instrument::CIEEE488Instrument::Timeout
virtual bool Timeout(void)=0
Last operation timed out.
MTL::Instrument::CIEEE488Instrument::AssertTrigger
virtual bool AssertTrigger(void)=0
Assert a trigger.
MTL::Instrument::CIEEE488Instrument::LockedExclusive
virtual bool LockedExclusive()=0
Check whether session is locked exclusively.
MTL::Instrument::CIEEE488Instrument::m_Timeout
U32 m_Timeout
Timeout for operations.
Definition IEEE488Instrument.h:72
MTL::Instrument::CIEEE488Instrument::Close
virtual void Close()=0
Close session to this instrument.
MTL::Instrument::CIEEE488Instrument::EnableEvent
virtual bool EnableEvent(void)=0
Enable service requests.
MTL::Instrument::CIEEE488Instrument::StatusDescription
virtual std::string StatusDescription(I32 Status)=0
Return description of status word.
MTL::Instrument::CIEEE488Instrument::Status
I32 Status(void)
Definition IEEE488Instrument.h:93
MTL::Instrument::CIEEE488Instrument::m_rRrsrcMan
CIEEE488ResourceManager & m_rRrsrcMan
Reference to the associated resource manager.
Definition IEEE488Instrument.h:69
MTL::Instrument::CIEEE488Instrument::SetTimeout
bool SetTimeout(U32 Timeout)
Set the timeout for this instrument.
Definition IEEE488Instrument.h:132
MTL::Instrument::CIEEE488Instrument::CIEEE488Instrument
CIEEE488Instrument(CIEEE488ResourceManager &rRM, tResourceName Rsrc)
Constructor.
Definition IEEE488Instrument.h:79
MTL::Instrument::CIEEE488Instrument::IsOpen
virtual bool IsOpen()=0
Check whether a session to this instrument is open.
MTL::Instrument::CIEEE488Instrument::Unlock
virtual bool Unlock()=0
Unlock the session.
MTL::Instrument::CIEEE488Instrument::Read
virtual bool Read(CSCPIBuffer &rBuf, bool Append=false)=0
Read from a IEEE488 instrument: SCPI buffer class variant.
MTL::Instrument::CIEEE488Instrument::IEEE488_DEFAULT_TIMEOUT
static const I32 IEEE488_DEFAULT_TIMEOUT
Default timeout (ms).
Definition IEEE488Instrument.h:65
MTL::Instrument::CIEEE488Instrument::Open
virtual bool Open(void)=0
Open a session to this IEEE488 instrument.
MTL::Instrument::CIEEE488Instrument::m_Status
I32 m_Status
Status of last operation.
Definition IEEE488Instrument.h:71
MTL::Instrument::CIEEE488Instrument::WaitOnEvent
virtual bool WaitOnEvent(U32 Timeout)=0
Wait for a service request.
MTL::Instrument::CIEEE488Instrument::ReadSTB
virtual bool ReadSTB(U16 &rSTB)=0
Read status byte.
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::CIEEE488ResourceManager::Initialize
virtual bool Initialize()=0
Initialize the Resource Manager.
MTL::Instrument::CIEEE488ResourceManager::FindResources
virtual bool FindResources(CResourceList &rList, std::string Filter="?*")=0
Find IEEE488 resources.
MTL::Instrument::CIEEE488ResourceManager::Timeout
virtual bool Timeout(void)=0
Last operation timed out.
MTL::Instrument::CIEEE488ResourceManager::m_Lock
CMutex m_Lock
Lock onto the resource manager.
Definition IEEE488Instrument.h:25
MTL::Instrument::CIEEE488ResourceManager::StatusDescription
virtual std::string StatusDescription(I32 Status)=0
Return description of status word.
MTL::Instrument::CIEEE488ResourceManager::Status
I32 Status(void)
Definition IEEE488Instrument.h:46
MTL::Instrument::CIEEE488ResourceManager::CIEEE488ResourceManager
CIEEE488ResourceManager()
Definition IEEE488Instrument.h:30
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::Instrument::CResourceList
List of VISA resource names.
Definition IEEE488InstrumentTypes.h:26
MTL::Instrument::CSCPIBuffer
Instrument Buffer.
Definition SCPIInstrumentBuffer.h:44
MTL::Synchronization::CLockGuard
Lock.
Definition Synchronization.h:74
MTL::Instrument
Definition THM1176.h:74
MTL::Instrument::tResourceName
std::string tResourceName
IEEE488 resource name.
Definition IEEE488InstrumentTypes.h:22
MTL::Synchronization
Definition Synchronization.h:12
MTL::Synchronization::CMutex
std::mutex CMutex
Mutex.
Definition Synchronization.h:16
MTL::Synchronization::CRecursiveMutex
std::recursive_mutex CRecursiveMutex
Recursive Mutex.
Definition Synchronization.h:20
MTL
Definition CTHM1176InstrumentManager.h:179