Instrument

public protocol Instrument : AnyObject

A type that can communicated with via VISA.

  • The session associated with the instrument.

    Declaration

    Swift

    var session: Session { get }
  • A unique identifier for the instrument.

    Declaration

    Swift

    var identifier: String { get }
  • The time in seconds to wait before timing out when performing operations with the instrument.

    Declaration

    Swift

    var timeout: TimeInterval { get set }
  • The delegate for the instrument – used for managing events.

    Declaration

    Swift

    var delegate: InstrumentDelegate? { get }
  • The instrument’s dispatch queue that allows for running instrument code on another thread. Each instrument has a unique dispatch queue.

    It is reccomended to run all code that interfaces with the instrument on this dispatch queue to prevent blocking the main thread when reading/writing data to/from the instrument. Doing so will prevent GUI hangs and also allows for communicating with multiple instruments at the same time. If one or more instruments need to wait on another instrument before doing work, you can run the code for the instruments on a single instrument’s dispatch queue.

    Declaration

    Swift

    var dispatchQueue: DispatchQueue { get }
  • clear() Extension method

    Performs an IEEE-488.1-style clear of the device.

    Throws

    One of the following VISAError errors:
    • .invalidSession
    • .unsupportedOperation
    • .resourceLocked
    • .timeout
    • .rawWriteProtocolViolation
    • .rawReadProtocolViolation
    • .busError
    • .notControllerInCharge
    • .noListeners
    • .invalidSetup
    • .connectionLost

    Declaration

    Swift

    func clear() throws
  • close() Extension method

    Closes the specified insturment. After the instrument has been closed, no more operations can be performed with the instrument.

    Throws

    One of the following VISAError errors:
    • .invalidSession
    • .failedToClose

    Declaration

    Swift

    func close() throws
  • lockState Extension method

    The current lock state of the instrument.

    Declaration

    Swift

    var lockState: LockState { get }
  • lock(_:timeout:) Extension method

    Locks the instrument with the specified lock type and timeout.

    Throws

    One of the following VISAError errors:
    • .invalidSession
    • .resourceLocked
    • .invalidLockType
    • .invalidAccessKey
    • .timeout

    Note

    Locks can be nested.

    Declaration

    Swift

    func lock(_ type: LockState.LockType, timeout: TimeInterval) throws

    Parameters

    type

    The lock type to use.

    timeout

    The time in seconds to wait before timing out.

  • unlock() Extension method

    Unlocks the instrument if it is locked.

    Throws

    One of the following VISAError errors:
    • .invalidSession
    • .sessionNotLocked

    Note

    Locks can be nested.

    Declaration

    Swift

    func unlock() throws