daq

package
v0.0.0-...-efe4ef5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package daq provides a generic HTTP interface to ADC and DAC devices

This is not the last word in speed, due to HTTP having reasonable latency in most client languages, but it is the last word in ease of use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOperatingMode

func GetOperatingMode(d WaveformDAC) http.HandlerFunc

GetOperatingMode retrieves whether the dac is in "single" or "waveform" mode

func GetOutputSimultaneous

func GetOutputSimultaneous(d ExtendedDAC) http.HandlerFunc

GetOutputSimultaneous retrieves if the output of a channel of a DAC is simultaneous

func GetRange

func GetRange(d ExtendedDAC) http.HandlerFunc

GetRange configures the output range of one channel of a DAC

func GetTimerPeriod

func GetTimerPeriod(t Timer) http.HandlerFunc

GetTimerPeriod invokes the function of the same name on a timer

func GetTriggerDirection

func GetTriggerDirection(t TriggerExport) http.HandlerFunc

GetTriggerDirection invokes the function of the same name on a Trigger

func GetTriggerMode

func GetTriggerMode(d WaveformDAC) http.HandlerFunc

GetTriggerMode retrieves whether the dac is in "single" or "waveform" mode

func HTTPBasicDAC

func HTTPBasicDAC(iface DAC, table generichttp.RouteTable)

HTTPBasicDAC adds routes for basic DAC operation to a table

func HTTPExtended

func HTTPExtended(iface ExtendedDAC, table generichttp.RouteTable)

HTTPExtended adds routes for multi channel output to the table

func HTTPMultiChannel

func HTTPMultiChannel(iface MultiChannelDAC, table generichttp.RouteTable)

HTTPMultiChannel adds routes for multi channel output to the table

func HTTPTimer

func HTTPTimer(iface Timer, table generichttp.RouteTable)

HTTPTimer adds routes for basic Timer operation to a table

func HTTPWaveform

func HTTPWaveform(iface WaveformDAC, table generichttp.RouteTable)

HTTPWaveform adds routes for multi channel output to the table

func LoadCSVFloats

func LoadCSVFloats(d TimerDAC, r io.Reader, periodNano uint32) error

LoadCSVFloats populates the waveform table of a DAC and sets the sampling period in nanoseconds. r is not closed and must be managed by the caller. Playback is not started.

func Output

func Output(d DAC) http.HandlerFunc

Output returns an HTTP handlerfunc that will write a voltage to a channel

func OutputDN16

func OutputDN16(d DAC) http.HandlerFunc

OutputDN16 returns an HTTP handlerfunc that will write a data number to a channel

func OutputMulti

func OutputMulti(d MultiChannelDAC) http.HandlerFunc

OutputMulti returns an HTTP handlerfunc that will write a voltage to a channel

func OutputMultiDN16

func OutputMultiDN16(d MultiChannelDAC) http.HandlerFunc

OutputMultiDN16 returns an HTTP handlerfunc that will write a data number to a channel

func SetOperatingMode

func SetOperatingMode(d WaveformDAC) http.HandlerFunc

SetOperatingMode configures the operating mode of a DAC between "single" and "waveform" modes

func SetOutputSimultaneous

func SetOutputSimultaneous(d ExtendedDAC) http.HandlerFunc

SetOutputSimultaneous configures the output channel of a DAC to be simultaneous

func SetRange

func SetRange(d ExtendedDAC) http.HandlerFunc

SetRange configures the output range of one channel of a DAC

func SetTimerPeriod

func SetTimerPeriod(t Timer) http.HandlerFunc

SetTimerPeriod invokes the function of the same name on a timer

func SetTriggerDirection

func SetTriggerDirection(t TriggerExport) http.HandlerFunc

SetTriggerDirection causes the device to export a trigger if True, else import

func SetTriggerMode

func SetTriggerMode(d WaveformDAC) http.HandlerFunc

SetTriggerMode configures the operating mode of a DAC between "single" and "waveform" modes

func StartWaveform

func StartWaveform(d WaveformDAC) http.HandlerFunc

StartWaveform commences waveform playback

func StopWaveform

func StopWaveform(d WaveformDAC) http.HandlerFunc

StopWaveform ceases waveform playback

func UploadWaveformFloatCSV

func UploadWaveformFloatCSV(d WaveformDAC) http.HandlerFunc

UploadWaveformFloatCSV is an HTTP interface to multiple PopulateWaveform calls from one CSV file

Types

type ChannelWaveformDN

type ChannelWaveformDN struct {
	// contains filtered or unexported fields
}

ChannelWaveformDN is a combination of a channel index and waveform data

func CSVToWaveformDN

func CSVToWaveformDN(r io.Reader) ([]ChannelWaveformDN, error)

CSVToWaveformDN reads a csv file in r to a list of channel-waveform combinations the columns of r are to be 16 bit DNs, 0 to 2^16. The header row is to specify channel numbers. A sample file has head: 0,1,2 0,32768,65535

where 0,1,2 are channel #s on the DAC

type ChannelWaveformVolt

type ChannelWaveformVolt struct {
	// contains filtered or unexported fields
}

ChannelWaveformVolt is a combination of a channel index and waveform data

func CSVToWaveformFloat

func CSVToWaveformFloat(r io.Reader) ([]ChannelWaveformVolt, error)

CSVToWaveformFloat reads a csv file in r to a list of channel-waveform combinations the columns of r are to be floating point voltages. The header row is to specify channel numbers. A sample file has head: 0,1,2 -10,0,10

where 0,1,2 are channel #s on the DAC

type DAC

type DAC interface {
	// Output sends a voltage on a given channel
	Output(int, float64) error

	// OutputDN sends a data number on a given channel
	OutputDN16(int, uint16) error
}

DAC is a model for simple digital to analog converter

type ExtendedDAC

type ExtendedDAC interface {
	MultiChannelDAC

	// SetRange sets the output range of a DAC channel
	SetRange(int, string) error

	// GetRange returns the output range of a DAC channel
	GetRange(int) (string, error)

	// SetOutputSimultaneous configures a channel for simultaneous output
	SetOutputSimultaneous(int, bool) error

	// GetOutputSimultaneous returns true if a channel is configured for simultaneous output
	GetOutputSimultaneous(int) (bool, error)
}

ExtendedDAC is a larger part of the interface to the AP236 from Acromag

type HTTPDAC

type HTTPDAC struct {
	RouteTable generichttp.RouteTable
	// contains filtered or unexported fields
}

HTTPDAC is a type that allows setting up a DAC satisfying any combination of the interfaces in this package to an HTTP interface

func NewHTTPDAC

func NewHTTPDAC(d DAC) HTTPDAC

NewHTTPDAC sets up an HTTP interface to a DAC

func (HTTPDAC) RT

RT satisfies generichttp.HTTPer

type MultiChannelDAC

type MultiChannelDAC interface {
	DAC

	// OutputMulti writes a sequence of voltages to a sequence of channels
	OutputMulti([]int, []float64) error

	// OutputMultiDN16 outputs a sequence of data numbers to a sequence of channels
	OutputMultiDN16([]int, []uint16) error
}

MultiChannelDAC allows multiple channels to be written at once

type Timer

type Timer interface {
	SetTimerPeriod(uint32) error

	GetTimerPeriod() (uint32, error)
}

Timer describes a clock

type TimerDAC

type TimerDAC interface {
	WaveformDAC
	Timer
}

TimerDAC is the union of WaveformDAC and Timer

type TriggerExport

type TriggerExport interface {
	SetTriggerDirection(bool) error

	GetTriggerDirection() (bool, error)
}

TriggerExport describes a piece of hardware which imports or exports a trigger

type WaveformDAC

type WaveformDAC interface {
	ExtendedDAC

	SetOperatingMode(int, string) error

	GetOperatingMode(int) (string, error)

	SetTriggerMode(int, string) error

	GetTriggerMode(int) (string, error)

	PopulateWaveform(int, []float64) error

	StartWaveform() error

	StopWaveform() error
}

WaveformDAC is a DAC which allows waveform playback

Jump to

Keyboard shortcuts

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