ivi

package module
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 5 Imported by: 0

README

ivi

Go-based implementation of the Interchangeable Virtual Instrument (IVI) standard.

GoDoc Go Report Card License Badge

Overview

The IVI Specifications developed by the IVI Foundation provide standardized APIs for programming test instruments. This package is a partial, Go-based implementation of the IVI Specifications.

The main advantage of the ivi package is not having to learn the SCPI commands for each individual piece of test equipment. For instance, by using the ivi package both the Agilent 33220A and the Stanford Research Systems DS345 function generators can be programmed using one standard API. The only requirement for this is having an IVI driver for the desired test equipment.

If an ivi driver doesn't exist for a peice of test equipment that you want to use, please open an issue and/or submit a pull request. The IVI Specifications don't provide APIs for every type of test equipment (e.g., they don't specify an API for electronic loads) in which case a set of APIs will be developed as needed for new types of test equipment.

Development focus is currently on solidifying the APIs and creating a few IVI drivers for each instrument type.

IVI Driver Goal

Per Section 2.6 Capability Groups in IVI-3.1 Driver Architecture Specification:

The fundamental goal of IVI drivers is to allow test developers to change the instrumentation hardware on their test systems without changing test program source code, recompiling, or re-linking. To achieve this goal, instrument drivers must have a standard programming interface...Because instruments do not have identical functionality or capability, it is impossible to create a single programming interface that covers all features of all instruments in a class. For this reason, the IVI Foundation recognizes different types of capabilities – Inherent Capabilities, Base Class Capabilities, Class Extension Capabilities and Instrument Specific Capabilities.

IVI Specification Deviation

TL;DR: When developing Go-based IVI drivers follow the .NET methods and prototypes as much as possible but deviate as required.

As stated in Section 1.5 Conformance Requirements of the IVI-3.1: Driver Architecture Specification, Revision 3.8, "IVI drivers can be developed with a COM, ANSI-C, or .NET API." In general, the Go method signatures try to be as close to the .NET signatures as possible. However, given the desire to write idiomatic Go, where necessary and where it makes sense, the Go-based IVI drivers deviate from the detailed IVI Specifications at times.

For instance, since Go does not provide method overloading, the .NET method prototypes cannot be followed in all cases. For example, in the IVI-4.2 IviDmm Class Specification, the .NET method prototypes show two Configure methods with different function signatures based on whether auto-range is specified or a manual range value is provided.

void Configure(MeasurementFunction measurementFunction,
               Auto autoRange,
               Double resolution);

void Configure(MeasurementFunction measurementFunction,
               Double range,

               Double resolution);

However, Go isn't C, so the Go-based IVI drivers don't have to rely on defined values, such as specific negative numbers representing auto-range (e.g., -1.0 = auto range on) and positive numbers representing the user specified manual range. Using the same example, below is the C prototype for Configure, where Range is a ViReal64 and negative values provided defined values.

ViStatus IviDmm_ConfigureMeasurement (ViSession Vi,
                                      ViInt32 Function,
                                      ViReal64 Range,
                                      ViReal64 Resolution);

Because of these differences, the Go function signatures may deviate from the IVI Specifications, when required and where it makes sense to enable writing idiomatic Go. Using the same example, below is the function signature for ConfigureMeasurement in Go.

ConfigureMeasurement(
    msrFunc MeasurementFunction,
    autoRange AutoRange,
    rangeValue float64,
    resolution float64,
) error

MeasurementFunction and AutoRange are user-defined types with enumerated constant values. Note: the function parameter rangeValue is used instead of range, since range is a reserved keyword and cannot be used as an identifier in Go.

type MeaurementFunction int

const (
	DCVolts MeasurementFunction = iota
	ACVolts
    ...
	Period
	Temperature
)

type AutoRange int

const (
	AutoOn AutoRange = iota
	AutoOff
	AutoOnce
)

Installation

$ go get github.com/gotmc/ivi

Usage

The ivi package requires receiving an Instrument interface. The following gotmc packages meet the Instrument interface:

  • visa — Calls lxi or usbtmc as needed, so that you can identify instruments using a VISA resource address string.
  • lxi — Used to control LXI enabled instruments via Ethernet.
  • usbtmc — Used to control USBTMC compliant instruments via USB.
  • prologix — Used to communicate with instruments using a Prologix GPIB controller.
  • asrl — Used to control intstruments via serial.

Examples

Examples can be found at https://github.com/gotmc/ivi-examples.

Documentation

Documentation can be found at either:

Contributing

Contributions are welcome! To contribute please:

  1. Fork the repository
  2. Create a feature branch
  3. Code
  4. Submit a pull request
Testing

Prior to submitting a pull request, please run:

$ make check
$ make lint

To update and view the test coverage report:

$ make cover

License

ivi is released under the MIT license. Please see the LICENSE.txt file for more information.

Documentation

Overview

Package ivi provides a Go-based implementation of the Interchangeable Virtual Instrument (IVI) standard. The IVI Specifications developed by the IVI Foundation provide standardized APIs for programming test instruments, such as oscilloscopes, power supplies, and function generators.

The main advantage of the ivi package is not having to learn the Standard Commands for Programmable Instruments (SCPI) commands for each individual piece of test equipment. Contrary to the name, SCPI commands differ from one piece of test equipment to another. For instance, with ivi both the Agilent 33220A and the Stanford Research Systems DS345 function generators can be programmed using one API.

Currently, ivi doesn't cache state. Every time an attribute is read directly from the instrument. Development focus is currently on fleshing out the APIs and creating a few IVI drivers for each instrument type.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFunctionNotSupported = errors.New("function not supported")
	ErrValueNotSupported    = errors.New("value not supported")
)

Functions

func QueryID

func QueryID(q Querier) (string, error)

QueryID queries the identity of the instrument.

func Set

func Set(sw StringWriter, format string, a ...interface{}) error

Set formats according to a format specifier and then writes the resulting string to the given StringWriter interface.

Types

type Commander added in v0.9.0

type Commander interface {
	Command(format string, a ...any) error
}

type Inherent

type Inherent struct {
	InherentBase
	// contains filtered or unexported fields
}

Inherent provides the inherent capabilities for all IVI instruments.

func NewInherent

func NewInherent(inst Instrument, base InherentBase) Inherent

NewInherent creates a new Inherent struct using the given Instrument interface and the InherentBase struct.

func (*Inherent) Clear

func (inherent *Inherent) Clear() error

Clear clears the instrument.

func (*Inherent) Disable

func (inherent *Inherent) Disable() error

Disable places the instrument in a quiescent state as quickly as possible. Disable provides the method described in Section 6.4 of IVI-3.2: Inherent Capabilities Specification.

func (*Inherent) FirmwareRevision

func (inherent *Inherent) FirmwareRevision() (string, error)

FirmwareRevision queries the instrument and returns the firmware revision of the instrument. FirmwareRevision is the getter for the read-only inherent attribute Instrument Firmware Revision described in Section 5.18 of IVI-3.2: Inherent Capabilities Specification.

func (*Inherent) InstrumentManufacturer

func (inherent *Inherent) InstrumentManufacturer() (string, error)

InstrumentManufacturer queries the instrument and returns the manufacturer of the instrument. InstrumentManufacturer is the getter for the read-only inherent attribute Instrument Manufacturer described in Section 5.19 of IVI-3.2: Inherent Capabilities Specification.

func (*Inherent) InstrumentModel

func (inherent *Inherent) InstrumentModel() (string, error)

InstrumentModel queries the instrument and returns the model of the instrument. InstrumentModel is the getter for the read-only inherent attribute Instrument Model described in Section 5.20 of IVI-3.2: Inherent Capabilities Specification.

func (*Inherent) InstrumentSerialNumber

func (inherent *Inherent) InstrumentSerialNumber() (string, error)

InstrumentSerialNumber queries the instrument and returns the S/N of the instrument.

func (*Inherent) Reset

func (inherent *Inherent) Reset() error

Reset resets the instrument.

type InherentBase

type InherentBase struct {
	ClassSpecMajorVersion     int
	ClassSpecMinorVersion     int
	ClassSpecRevision         string
	IDNString                 string
	ResetDelay                time.Duration
	ClearDelay                time.Duration
	GroupCapabilities         []string
	SupportedInstrumentModels []string
	SupportedBusInterfaces    []string
}

InherentBase provides the exported properties for the inherent capabilities of all IVI instruments.

type Instrument

type Instrument interface {
	Read(p []byte) (n int, err error)
	Write(p []byte) (n int, err error)
	WriteString(s string) (n int, err error)
	Command(format string, a ...any) error
	Query(s string) (value string, err error)
}

Instrument provides the interface required for all IVI Instruments.

type Querier

type Querier interface {
	Query(s string) (value string, err error)
}

Querier provides the interface to query using a given string and provide the resultant string.

type StringWriter

type StringWriter interface {
	WriteString(s string) (n int, err error)
}

StringWriter provides the interface to write a string.

Directories

Path Synopsis
Package com provides information about communication ports (Ethernet, serial, etc.) for various IVI devices.
Package com provides information about communication ports (Ethernet, serial, etc.) for various IVI devices.
Package dcpwr provides the Defined Values and other structs, methods, etc.
Package dcpwr provides the Defined Values and other structs, methods, etc.
keysight/e36xx
Package e36xx implements the IVI driver for the Agilent/Keysight E3600 series of power supplies.
Package e36xx implements the IVI driver for the Agilent/Keysight E3600 series of power supplies.
kikusui/pmx
Package pmx implements the IVI driver for the KIKUSUI PMX series of regulated DC power supplies.
Package pmx implements the IVI driver for the KIKUSUI PMX series of regulated DC power supplies.
rigol/dp800
Package dp800 implements the IVI driver for the Rigol DP800 series of programmable linear DC power supplies.
Package dp800 implements the IVI driver for the Rigol DP800 series of programmable linear DC power supplies.
template
Package template provides a template to create additional IVI drivers for DC power supplies.
Package template provides a template to create additional IVI drivers for DC power supplies.
dmm
Package dmm provides the defined values, interfaces, structs, methods, and enums that are common among all instruments meeting the IVI-4.2: IviFDmm Class Specification.
Package dmm provides the defined values, interfaces, structs, methods, and enums that are common among all instruments meeting the IVI-4.2: IviFDmm Class Specification.
fluke/fluke45
Package fluke45 implements the IVI driver for the Fluke 45 DMM.
Package fluke45 implements the IVI driver for the Fluke 45 DMM.
keysight/key3446x
Package key3446x implements the IVI Instrument driver for the Keysight 3446x family of DMM.
Package key3446x implements the IVI Instrument driver for the Keysight 3446x family of DMM.
dsa
Package dsa provides the Defined Values and other structs, methods, etc.
Package dsa provides the Defined Values and other structs, methods, etc.
Package fgen provides the defined values, interfaces, structs, methods, and enums that are common among all instruments meeting the IVI-4.3: IviFgen Class Specification.
Package fgen provides the defined values, interfaces, structs, methods, and enums that are common among all instruments meeting the IVI-4.3: IviFgen Class Specification.
keysight/key33220
Package key33220 implements the IVI driver for the Keysight/Agilent 33220A and 33210A function/arbitrary waveform generators.
Package key33220 implements the IVI driver for the Keysight/Agilent 33220A and 33210A function/arbitrary waveform generators.
srs/ds345
Package ds345 implements the IVI driver for the Stanford Research System DS345 function generator.
Package ds345 implements the IVI driver for the Stanford Research System DS345 function generator.
Package load provides the Defined Values and other structs, methods, etc.
Package load provides the Defined Values and other structs, methods, etc.
siglent/sdl10xx
Package sdl10xx implements the IVI driver for the Signlent SDL1000X and SDL1030X DC electronic loads.
Package sdl10xx implements the IVI driver for the Signlent SDL1000X and SDL1030X DC electronic loads.
keysight/esa
Package esa implements the IVI driver for the Agilent ESA series spectrum analyzers.
Package esa implements the IVI driver for the Agilent ESA series spectrum analyzers.
Package swtch provides the Defined Values and other structs, interfaces, methods, etc.
Package swtch provides the Defined Values and other structs, interfaces, methods, etc.
keysight/u2751a
Package u2751a implements the IVI driver for the Keysight U2751A 4x8 2-wire switch matrix.
Package u2751a implements the IVI driver for the Keysight U2751A 4x8 2-wire switch matrix.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL