ngscopeclient 0.1-dev+51fbda87c
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
SCPITransport Class Referenceabstract

Abstraction of a transport layer for moving SCPI data between endpoints. More...

#include <SCPITransport.h>

Inheritance diagram for SCPITransport:
Inheritance graph
[legend]

Public Types

typedef SCPITransport *(* CreateProcType) (const std::string &args)
 

Public Member Functions

virtual std::string GetConnectionString ()=0
 
virtual std::string GetName ()=0
 
void SendCommandQueued (const std::string &cmd)
 Pushes a command into the transmit FIFO then returns immediately. More...
 
std::string SendCommandQueuedWithReply (std::string cmd, bool endOnSemicolon=true)
 Sends a command (flushing any pending/queued commands first), then returns the response. More...
 
void SendCommandImmediate (std::string cmd)
 Sends a command (jumping ahead of the queue) which does not require a response.
 
std::string SendCommandImmediateWithReply (std::string cmd, bool endOnSemicolon=true)
 Sends a command (jumping ahead of the queue), then returns the response. More...
 
void * SendCommandImmediateWithRawBlockReply (std::string cmd, size_t &len)
 Sends a command (jumping ahead of the queue) which reads a binary block response.
 
bool FlushCommandQueue ()
 Pushes all pending commands from SendCommandQueued() calls and blocks until they are all sent.
 
std::recursive_mutex & GetMutex ()
 
virtual void FlushRXBuffer (void)
 
virtual bool SendCommand (const std::string &cmd)=0
 
virtual std::string ReadReply (bool endOnSemicolon=true, std::function< void(float)> progress=nullptr)=0
 
virtual size_t ReadRawData (size_t len, unsigned char *buf, std::function< void(float)> progress=nullptr)=0
 
virtual void SendRawData (size_t len, const unsigned char *buf)=0
 
virtual bool IsCommandBatchingSupported ()=0
 
virtual bool IsConnected ()=0
 
void EnableRateLimiting (std::chrono::milliseconds interval)
 Enables rate limiting. Rate limiting is only applied to the queued command API. More...
 
void DeduplicateCommand (const std::string &cmd)
 Adds a command to the set of commands which may be deduplicated in the queue. More...
 

Static Public Member Functions

static void DoAddTransportClass (std::string name, CreateProcType proc)
 
static void EnumTransports (std::vector< std::string > &names)
 
static SCPITransportCreateTransport (const std::string &transport, const std::string &args)
 

Protected Types

typedef std::map< std::string, CreateProcType > CreateMapType
 

Protected Member Functions

void RateLimitingWait ()
 Block until it's time to send the next command when rate limiting.
 

Protected Attributes

std::mutex m_queueMutex
 
std::recursive_mutex m_netMutex
 
std::list< std::string > m_txQueue
 
std::set< std::string > m_dedupCommands
 
bool m_rateLimitingEnabled
 
std::chrono::system_clock::time_point m_nextCommandReady
 
std::chrono::milliseconds m_rateLimitingInterval
 

Static Protected Attributes

static CreateMapType m_createprocs
 

Detailed Description

Abstraction of a transport layer for moving SCPI data between endpoints.

Member Function Documentation

◆ DeduplicateCommand()

void SCPITransport::DeduplicateCommand ( const std::string &  cmd)
inline

Adds a command to the set of commands which may be deduplicated in the queue.

If SendCommandQueued() is called with a command in this list, and a second instance of the same command is already present in the queue, then the redundant instance will be removed.

The command subject, if present, must match. For example, if "OFFS" is in the deduplication set, then

C2:OFFS 1.1 C2:OFFS 1.2

will be deduplicated, while

C1:OFFS 1.1 C2:OFFS 1.2

will not be.

◆ EnableRateLimiting()

void SCPITransport::EnableRateLimiting ( std::chrono::milliseconds  interval)
inline

Enables rate limiting. Rate limiting is only applied to the queued command API.

The rate limiting feature ensures a minimum delay between SCPI commands. This severely degrades performance and is intended to be used as a crutch to work around instrument firmware bugs. Other synchronization mechanisms should be used if at all possible.

Once rate limiting is enabled on a transport, it cannot be disabled.

◆ SendCommandImmediateWithReply()

string SCPITransport::SendCommandImmediateWithReply ( std::string  cmd,
bool  endOnSemicolon = true 
)

Sends a command (jumping ahead of the queue), then returns the response.

This is an atomic operation requiring no mutexing at the caller side.

◆ SendCommandQueued()

void SCPITransport::SendCommandQueued ( const std::string &  cmd)

Pushes a command into the transmit FIFO then returns immediately.

This command will actually be sent the next time FlushCommandQueue() is called.

◆ SendCommandQueuedWithReply()

string SCPITransport::SendCommandQueuedWithReply ( std::string  cmd,
bool  endOnSemicolon = true 
)

Sends a command (flushing any pending/queued commands first), then returns the response.

This is an atomic operation requiring no mutexing at the caller side.


The documentation for this class was generated from the following files: