sdk3

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: 13 Imported by: 0

Documentation

Overview

Package sdk3 exposes control of Andor cameras in Go via their SDK, v3.

Index

Constants

View Source
const (

	// LengthOfUndefinedBuffers is how large a buffer to allocate for a Wchar
	// string when we have no way of knowing ahead of time how big it is
	// it is measured in Wchars
	LengthOfUndefinedBuffers = 255

	// WRAPVER is the andor wrapper code version.
	// Increment this when pkg sdk3 is updated.
	WRAPVER = 11

	// NeoBufferSize is the size of the buffer on the Andor Neo camera itself (4GB)
	NeoBufferSize = 4e9

	// CLBaseSpeed is the transfer rate in B/s of base speed camera link,
	// used by the Andor Neo camera.
	CLBaseSpeed = 255e6
)

Variables

View Source
var (
	// ErrBufferNotOnQueue is generated before a catastrophic side effect is triggered
	ErrBufferNotOnQueue = errors.New("no buffer placed on queue, this error saves you from memory corruption")

	// ErrCodes is a map of error codes (ints) to error strings
	ErrCodes = map[int]string{
		0:  "AT_SUCCESS",
		1:  "AT_ERR_NOT_INITIALISED",
		2:  "AT_ERR_NOT_IMPLEMENTED",
		3:  "AT_ERR_READONLY",
		4:  "AT_ERR_NOT_READABLE",
		5:  "AT_ERR_NOT_WRITABLE",
		6:  "AT_ERR_OUT_OF_RANGE",
		7:  "AT_ERR_INDEX_NOT_AVAILABLE",
		8:  "AT_ERR_INDEX_NOT_IMPLEMENTED",
		9:  "AT_ERR_EXCEEDED_MAX_STRING_LENGTH",
		10: "AT_ERR_CONNECTION",
		11: "AT_ERR_NO_DATA",
		12: "AT_ERR_INVALID_HANDLE",
		13: "AT_ERR_TIMED_OUT",
		14: "AT_ERR_BUFFER_FULL",
		15: "AT_ERR_INVALID_SIZE",
		16: "AT_ERR_INVALID_ALIGNMENT",
		17: "AT_ERR_COMM",
		18: "AT_ERR_STRING_NOT_AVAILABLE",
		19: "AT_ERR_STRING_NOT_IMPLEMENTED",
		20: "AT_ERR_NULL_FEATURE",
		21: "AT_ERR_NULL_HANDLE",
		22: "AT_ERR_NULL_IMPLEMENTED_VAR",
		23: "AT_ERR_NULL_READABLE_VAR",
		24: "AT_ERR_NULL_READONLY_VAR",
		25: "AT_ERR_NULL_WRITABLE_VAR",
		26: "AT_ERR_NULL_MIN_VALUE",
		27: "AT_ERR_NULL_MAX_VALUE",
		28: "AT_ERR_NULL_VALUE",
		29: "AT_ERR_NULL_STRING",
		30: "AT_ERR_NULL_COUNT_VAR",
		31: "AT_ERR_NULL_IS_AVAILABLE_VAR",
		32: "AT_ERR_NULL_MAX_STRING_LENGTH",
		33: "ATT_ERR_NULL_EV_CALLBACK",
		34: "AT_ERR_NULL_QUEUE_PTR",
		35: "AT_ERR_NULL_WAIT_PTR",
		36: "AT_ERR_NULL_PTR_SIZE",
		37: "AT_ERR_NO_MEMORY",
		38: "AT_ERR_DEVICE_IN_USE",
		39: "AT_ERR_DEVICE_NOT_FOUND",

		100: "AT_ERR_HARDWARE_OVERFLOW",
	}
)
View Source
var (
	// Features maps features to "types" without using the types pkg, due to C enums
	Features = map[string]string{

		"AccumulatedCount":        "int",
		"AOIHBin":                 "int",
		"AOIVBin":                 "int",
		"AOILeft":                 "int",
		"AOITop":                  "int",
		"AOIStride":               "int",
		"AOIHeight":               "int",
		"AOIWidth":                "int",
		"BaselineLevel":           "int",
		"BufferOverflowEvent":     "int",
		"DeviceCount":             "int",
		"DeviceVideoIndex":        "int",
		"EventsMissedEvent":       "int",
		"ExposureStartEvent":      "int",
		"ExposureEndEvent":        "int",
		"FrameCount":              "int",
		"ImageSizeBytes":          "int",
		"LUTIndex":                "int",
		"LUTValue":                "int",
		"RowNExposureEndEvent":    "int",
		"RowNExposureStartEvent":  "int",
		"SensorHeight":            "int",
		"SensorWidth":             "int",
		"TimestampClock":          "int",
		"TimestampClockFrequency": "int",

		"AlternatingReadoutDirection": "bool",
		"CameraAcquiring":             "bool",
		"EventEnable":                 "bool",
		"FastAOIFrameRateEnable":      "bool",
		"FullAOIControl":              "bool",
		"IOInvert":                    "bool",
		"MetadataEnable":              "bool",
		"MetadataFrame":               "bool",
		"MetadataTimestamp":           "bool",
		"Overlap":                     "bool",
		"RollingShutterGlobalClear":   "bool",
		"ScanSpeedControlEnable":      "bool",
		"SensorCooling":               "bool",
		"SpuriousNoiseFilter":         "bool",
		"StaticBlemishCorrection":     "bool",
		"SynchronousTriggering":       "bool",
		"VerticallyCentreAOI":         "bool",

		"AcquisitionStart":    "command",
		"AcquisitionStop":     "command",
		"CameraDump":          "command",
		"SoftwareTrigger":     "command",
		"TimestampClockReset": "command",

		"BytesPerPixel":            "float",
		"ExposureTime":             "float",
		"FrameRate":                "float",
		"LineScanSpeed":            "float",
		"MaxInterfaceTransferRate": "float",
		"PixelHeight":              "float",
		"PixelWidth":               "float",
		"ReadoutTime":              "float",
		"SensorTemperature":        "float",

		"AOIBinning":               "enum",
		"AOILayout":                "enum",
		"BitDepth":                 "enum",
		"CycleMode":                "enum",
		"ElectronicShutteringMode": "enum",
		"FanSpeed":                 "enum",
		"PixelEncoding":            "enum",
		"PixelReadoutRate":         "enum",
		"TemperatureControl":       "enum",
		"TemperatureStatus":        "enum",
		"TriggerMode":              "enum",
		"SensorReadoutMode":        "enum",
		"SimplePreAmpGainControl":  "enum",

		"CameraModel":     "string",
		"CameraName":      "string",
		"ControllerID":    "string",
		"DriverVersion":   "string",
		"FirmwareVersion": "string",
		"InterfaceType":   "string",
		"SerialNumber":    "string",
	}
)

Functions

func DeviceCount

func DeviceCount() (int, error)

DeviceCount returns the number of devices (cameras) found by the SDK InitializeLibrary must be called first

func Error

func Error(code int) error

Error returns nil on beneign error codes or returns an error object on non-beneign ones

func FinalizeLibrary

func FinalizeLibrary()

FinalizeLibrary calls the function of the same name in the Andor SDK

func GetBool

func GetBool(handle int, feature string) (bool, error)

GetBool gets the value of a boolean feature

func GetEnumCount

func GetEnumCount(handle int, feature string) (int, error)

GetEnumCount gets the number of items in the enum behind a feature

func GetEnumIndex

func GetEnumIndex(handle int, feature string) (int, error)

GetEnumIndex gets the currently selected index into the enum behind feature

func GetEnumString

func GetEnumString(handle int, feature string) (string, error)

GetEnumString gets the string value of an enum. this function is just a convenience wrapper around GetEnumIndex and GetEnumStringByIndex

func GetEnumStringByIndex

func GetEnumStringByIndex(handle int, feature string, idx int) (string, error)

GetEnumStringByIndex gets the string value of an enum at a given index

func GetEnumStrings

func GetEnumStrings(handle int, feature string) ([]string, error)

GetEnumStrings gets the string values that are valid for an enum

func GetFloat

func GetFloat(handle int, feature string) (float64, error)

GetFloat gets a floating point value

func GetFloatMax

func GetFloatMax(handle int, feature string) (float64, error)

GetFloatMax gets the maximum of a floating point value

func GetFloatMin

func GetFloatMin(handle int, feature string) (float64, error)

GetFloatMin gets the minimum of a floating point value

func GetInt

func GetInt(handle int, feature string) (int, error)

GetInt gets an integer

func GetIntMax

func GetIntMax(handle int, feature string) (int, error)

GetIntMax gets the max value an integer can be set to

func GetIntMin

func GetIntMin(handle int, feature string) (int, error)

GetIntMin gets the min value an integer can be set to

func GetString

func GetString(handle int, feature string) (string, error)

GetString returns the string value of a feature we deviate from SDK3 API by using GetStringMaxLength internally and avoid users having to deal with allocating C.wchar_t buffers

func GetStringMaxLength

func GetStringMaxLength(handle int, feature string) (int, error)

GetStringMaxLength returns the length of a string, use this to determine how big of a cgo.widechar string to allocate

func InitializeLibrary

func InitializeLibrary() error

InitializeLibrary calls the function of the same name in the Andor SDK

func IssueCommand

func IssueCommand(handle int, feature string) error

IssueCommand sends a command to the SDK

func SetBool

func SetBool(handle int, feature string, tru bool) error

SetBool sets a boolean feature

func SetEnumIndex

func SetEnumIndex(handle int, feature string, idx int) error

SetEnumIndex sets the value of a feature to an index in the backing enum

func SetEnumString

func SetEnumString(handle int, feature, value string) error

SetEnumString sets the value of a feature to a string that is a valid member of the backing enum

func SetFloat

func SetFloat(handle int, feature string, value float64) error

SetFloat sets a floating point value

func SetInt

func SetInt(handle int, feature string, val int64) error

SetInt sets an integer

func SetString

func SetString(handle int, feature, value string) error

SetString sets the value of a string

func SoftwareVersion

func SoftwareVersion() (string, error)

SoftwareVersion returns the software (SDK) version InitializeLibrary must be called first

func UnpadBuffer

func UnpadBuffer(buf []byte, aoistride, aoiwidth, aoiheight int) []byte

UnpadBuffer strips padding bytes from a buffer

Types

type Camera

type Camera struct {
	sync.Mutex

	// Handle holds the int that points to a specific camera
	Handle int

	// UseSpinner indicates whether to run a spinner in the command line when
	// taking video
	UseSpinner bool
	// contains filtered or unexported fields
}

Camera represents a camera from SDK3

func Open

func Open(camIdx int) (*Camera, error)

Open opens a connection to the camera. Typically, a real camera is index 0, and there are two simulator cameras at indices 1 and 2

func (*Camera) Allocate

func (c *Camera) Allocate() error

Allocate creates the buffer that will be populated by the SDK it should be called at init, and whenever the AOI or encoding changes AT_Flush is called to ensure stale buffers are not held by the SDK

func (*Camera) Buffer

func (c *Camera) Buffer() []byte

Buffer the current buffer at this moment in time. This is technically a copy but go slices are allocated on the heap, so it only copies the header with minimal performance impact.

may have undefined behavior if camera is writing while you read

func (*Camera) Burst

func (c *Camera) Burst(frames int, fps float64, ch chan<- image.Image) error

Burst performs a burst by taking N images at M fps. The images are streamed to ch, and are image.Gray16. the channel is always closed after

func (*Camera) Close

func (c *Camera) Close() error

Close closes a connection to the camera

func (*Camera) CollectHeaderMetadata

func (c *Camera) CollectHeaderMetadata() []fitsio.Card

CollectHeaderMetadata satisfies generichttp/camera and makes a stack of FITS cards

func (*Camera) Command

func (c *Camera) Command(cmd string) error

Command issues a command to this camera's handle

func (*Camera) Configure

func (c *Camera) Configure(settings map[string]interface{}) error

Configure takes a map of interfaces and calls Set_xxx for each, where xxx is Bool, Int, etc.

func (*Camera) Features

func (c *Camera) Features() (map[string]string, error)

Features returns a map of feature names to their types, as strings the types map as:

int => int float => float64 string => string bool => bool enum => string

Caller editing of the map is considered a usage error and results in undefined behavior

the error is always nil

func (*Camera) Flush

func (c *Camera) Flush() error

Flush removes any pending buffers from the andor SDK's internal queue

func (*Camera) GetAOI

func (c *Camera) GetAOI() (camera.AOI, error)

GetAOI gets the AOI

func (*Camera) GetAOIHeight

func (c *Camera) GetAOIHeight() (int, error)

GetAOIHeight is the height of one column in the image buffer in pixels. This function allows us to cache the value without going to the SDK for it. Use GetInt directly if you want to guarantee there are no desync bugs.

func (*Camera) GetAOILeft

func (c *Camera) GetAOILeft() (int, error)

GetAOILeft gets the left pixel of the AOI. Starts at 1.

func (*Camera) GetAOIStride

func (c *Camera) GetAOIStride() (int, error)

GetAOIStride is the stride of one row in the image buffer in bytes. This function allows us to cache the value without going to the SDK for it. Use GetInt directly if you want to guarantee there are no desync bugs.

func (*Camera) GetAOITop

func (c *Camera) GetAOITop() (int, error)

GetAOITop gets the top pixel index of the AOI. Starts at 1.

func (*Camera) GetAOIWidth

func (c *Camera) GetAOIWidth() (int, error)

GetAOIWidth is the width of one row in the image buffer in pixels. This function allows us to cache the value without going to the SDK for it. Use GetInt directly if you want to guarantee there are no desync bugs.

func (*Camera) GetBinning

func (c *Camera) GetBinning() (camera.Binning, error)

GetBinning gets the binning

func (*Camera) GetCooling

func (c *Camera) GetCooling() (bool, error)

GetCooling gets if temperature control is currently active or not

func (*Camera) GetDriverVersion

func (c *Camera) GetDriverVersion() (string, error)

GetDriverVersion gets the software version of the SDK

func (*Camera) GetExposureTime

func (c *Camera) GetExposureTime() (time.Duration, error)

GetExposureTime gets the current exposure time as a duration

func (*Camera) GetFan

func (c *Camera) GetFan() (bool, error)

GetFan gets if the fan is currently on

func (*Camera) GetFeature

func (c *Camera) GetFeature(feature string) (interface{}, error)

GetFeature implements generichttp/camera.FeatureManipulator the return value's type is known through the camera.Features() function the types map as:

int => int float => float64 string => string bool => bool enum => string (current value)

func (*Camera) GetFeatureInfo

func (c *Camera) GetFeatureInfo(feature string) (map[string]interface{}, error)

GetFeatureInfo retrieves information about a feature which varies based on its type

func (*Camera) GetFirmwareVersion

func (c *Camera) GetFirmwareVersion() (string, error)

GetFirmwareVersion gets the firmware version of the camera

func (*Camera) GetFrame

func (c *Camera) GetFrame() (image.Image, error)

GetFrame triggers an exposure and returns the frame as an image.Gray16 masquerading as an image.Image

func (*Camera) GetFrameSize

func (c *Camera) GetFrameSize() (int, int, error)

GetFrameSize returns the AOI W, H

func (*Camera) GetModel

func (c *Camera) GetModel() (string, error)

GetModel returns the model string

func (*Camera) GetSDKVersion

func (c *Camera) GetSDKVersion() (string, error)

GetSDKVersion gets the software version of the SDK

func (*Camera) GetSensorHeight

func (c *Camera) GetSensorHeight() (int, error)

GetSensorHeight gets the height of the sensor in pixels

func (*Camera) GetSensorWidth

func (c *Camera) GetSensorWidth() (int, error)

GetSensorWidth gets the width of the sensor in pixels

func (*Camera) GetSerialNumber

func (c *Camera) GetSerialNumber() (string, error)

GetSerialNumber return the serial number

func (*Camera) GetTemperature

func (c *Camera) GetTemperature() (float64, error)

GetTemperature gets the current temperature of the sensor in Celsius

func (*Camera) GetTemperatureSetpoint

func (c *Camera) GetTemperatureSetpoint() (string, error)

GetTemperatureSetpoint gets the temp control setpoint as a string

func (*Camera) GetTemperatureSetpoints

func (c *Camera) GetTemperatureSetpoints() ([]string, error)

GetTemperatureSetpoints gets a list of strings representing the temperatures the detector can currently be cooled to

func (*Camera) GetTemperatureStatus

func (c *Camera) GetTemperatureStatus() (string, error)

GetTemperatureStatus gets the current status of sensor cooling. One of: - Cooler Off - Stabilised - Cooling - Drift - Not Stabilised - Fault

func (*Camera) ImageSizeBytes

func (c *Camera) ImageSizeBytes() (int, error)

ImageSizeBytes is the size of the image buffer in bytes. This function allows us to cache the value without going to the SDK for it. Use GetInt directly if you want to guarantee there are no desync bugs.

func (*Camera) QueueBuffer

func (c *Camera) QueueBuffer() error

QueueBuffer puts the Camera's internal buffer into the write queue for the SDK only one buffer is supported in this wrapper, though the SDK supports multiple buffers

func (*Camera) SetAOI

func (c *Camera) SetAOI(aoi camera.AOI) error

SetAOI updates the AOI and re-allocates the buffer. Width and height are calculated from the difference of the sensor dimensions and top-left if they are zero

func (*Camera) SetBinning

func (c *Camera) SetBinning(b camera.Binning) error

SetBinning sets the AOIBinning feature

func (*Camera) SetCooling

func (c *Camera) SetCooling(b bool) error

SetCooling sets if temperature control is currently active or not

func (*Camera) SetExposureTime

func (c *Camera) SetExposureTime(d time.Duration) error

SetExposureTime sets the exposure time as a duration

func (*Camera) SetFan

func (c *Camera) SetFan(b bool) error

SetFan sets the fan on or off

func (*Camera) SetFeature

func (c *Camera) SetFeature(feature string, v interface{}) error

SetFeature implements generichttp/camera.FeatureManipulator the feature's type is known through the camera.Features() function the types map as:

int => int float => float64 string => string bool => bool enum => string

This function will return an error if the feature is not known or the type is mismatched, with the exception of integral float64s for integer features or integers for float64s

func (*Camera) SetTemperatureSetpoint

func (c *Camera) SetTemperatureSetpoint(s string) error

SetTemperatureSetpoint sets the temp control point to a value that is returned by GetTemperatureSetpoints

func (*Camera) WaitBuffer

func (c *Camera) WaitBuffer(timeout time.Duration) error

WaitBuffer waits for the camera to push a frame into the buffer errors if Queue has not been called, on timeout, or on an SDK error

type DRVError

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

DRVError represents a driver error

func (DRVError) Error

func (e DRVError) Error() string

Error satisfies the error interface

type ErrFeatureNotFound

type ErrFeatureNotFound struct {
	// Feature is the specific feature not found
	Feature string
}

ErrFeatureNotFound is generated when a feature is looked up in the Features map but does not exist there

func (ErrFeatureNotFound) Error

func (e ErrFeatureNotFound) Error() string

Error satisfies the error interface

Jump to

Keyboard shortcuts

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