camera

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

Documentation

Overview

Package camera provides a generic HTTP interface to a scientific camera

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Features

func Features(f FeatureManager) http.HandlerFunc

Features retrieves the feature mapping from the manager

func GetAOI

GetAOI returns an HTTP handler func that gets the AOI of the camera

func GetBinning

func GetBinning(a AOIManipulator) http.HandlerFunc

GetBinning gets the binning over HTTP as JSON

func GetCooling

func GetCooling(t ThermalManager) http.HandlerFunc

GetCooling returns an HTTP handler func that returns the cooling status of the camera

func GetEMGain

func GetEMGain(e EMGainManager) http.HandlerFunc

GetEMGain gets the EM gain over HTTP as JSON

func GetEMGainMode

func GetEMGainMode(e EMGainManager) http.HandlerFunc

GetEMGainMode returns the EM gain mode over HTTP as JSON

func GetEMGainRange

func GetEMGainRange(e EMGainManager) http.HandlerFunc

GetEMGainRange returns the min/max EM gain over HTTP as JSON

func GetExposureTime

func GetExposureTime(p PictureTaker) http.HandlerFunc

GetExposureTime gets the exposure time on a GET request

func GetFan

GetFan returns an HTTP handler func that returns the fan status over HTTP

func GetFeature

func GetFeature(f FeatureManager) http.HandlerFunc

GetFeature returns a feature that is URL encoded from the manager

func GetFeatureInfo

func GetFeatureInfo(f FeatureManager) http.HandlerFunc

GetFeatureInfo retrieves information about a feature from f

func GetFrame

func GetFrame(p Camera, rec *imgrec.Recorder) http.HandlerFunc

GetFrame takes a picture and returns it on a GET request.

the image format may be specified in a query parameter; default to jpg

the exposure time may be specified as a query parameter in any time-looking format, such as "25ms" or "10us". Strictly speaking, it must be a valid input to golang time.ParseDuration.

if no unit is appended, an s (seconds) is added.

if no exposure time is provided, it is not updated and the existing value is used.

func GetShutter

func GetShutter(s ShutterController) http.HandlerFunc

GetShutter returns if the shutter is currently open over HTTP as JSON

func GetShutterAuto

func GetShutterAuto(s ShutterController) http.HandlerFunc

GetShutterAuto returns if the shutter is currently open over HTTP as JSON

func GetShutterSpeed

func GetShutterSpeed(e ExtendedShutterController) http.HandlerFunc

GetShutterSpeed retrieves the current shutter speed in seconds and returns it as seconds, encoded in {'f64': texpS}

func GetTemperature

func GetTemperature(t ThermalManager) http.HandlerFunc

GetTemperature returns an HTTP handler func that returns the temperature over HTTP

func GetTemperatureSetpoint

func GetTemperatureSetpoint(t ThermalManager) http.HandlerFunc

GetTemperatureSetpoint returns an HTTP handler func that returns the temperature setpoint over HTTP

func GetTemperatureSetpoints

func GetTemperatureSetpoints(t ThermalManager) http.HandlerFunc

GetTemperatureSetpoints returns an HTTP handler func that returns the temperature setpoint over HTTP

func GetTemperatureStatus

func GetTemperatureStatus(t ThermalManager) http.HandlerFunc

GetTemperatureStatus returns an HTTP handler func that returns the cooling status over HTTP

func HTTPAOIManipulator

func HTTPAOIManipulator(a AOIManipulator, table generichttp.RouteTable)

HTTPAOIManipulator injects routes to manipulate the AOI of a camera into a route table

func HTTPEMGainManager

func HTTPEMGainManager(e EMGainManager, table generichttp.RouteTable)

HTTPEMGainManager binds routes that control EM gain to the table

func HTTPExtendedShutterController

func HTTPExtendedShutterController(e ExtendedShutterController, table generichttp.RouteTable)

HTTPExtendedShutterController injects methods for Set and GetShutterSpeed into table, bound by closure to e

func HTTPFeatureManager

func HTTPFeatureManager(f FeatureManager, rt generichttp.RouteTable)

HTTPFeatureManager adds routes to rt for feature management

func HTTPPicture

func HTTPPicture(p PictureTaker, table generichttp.RouteTable, rec *imgrec.Recorder)

HTTPPicture injects HTTP methods into a route table for a picture taker

func HTTPShutterController

func HTTPShutterController(s ShutterController, table generichttp.RouteTable)

HTTPShutterController binds routes to control the shutter to a route table

func HTTPThermalManager

func HTTPThermalManager(t ThermalManager, table generichttp.RouteTable)

HTTPThermalManager binds routes for thermal management on the table

func SetAOI

SetAOI returns an HTTP handler func that sets the AOI of the camera

func SetBinning

func SetBinning(a AOIManipulator) http.HandlerFunc

SetBinning sets the binning over HTTP as JSON

func SetCooling

func SetCooling(t ThermalManager) http.HandlerFunc

SetCooling returns an HTTP handler func that turns the fan on or off over HTTP

func SetEMGain

func SetEMGain(e EMGainManager) http.HandlerFunc

SetEMGain sets the EM gain over HTTP as JSON

func SetEMGainMode

func SetEMGainMode(e EMGainManager) http.HandlerFunc

SetEMGainMode sets the EM gain mode over HTTP as JSON

func SetExposureTime

func SetExposureTime(p PictureTaker) http.HandlerFunc

SetExposureTime sets the exposure time on a POST request. it can be provided either as a query parameter exposureTime, formatted in a way that is parsable by golang/time.ParseDuration, or a json payload with key f64, holding the exposure time in seconds.

func SetFan

SetFan returns an HTTP handler func that sets the fan status over hTTP

func SetFeature

func SetFeature(f FeatureManager) http.HandlerFunc

SetFeature sets a particular feature on f

func SetShutter

func SetShutter(s ShutterController) http.HandlerFunc

SetShutter opens or closes the shutter over HTTP as JSON

func SetShutterAuto

func SetShutterAuto(s ShutterController) http.HandlerFunc

SetShutterAuto opens or closes the shutter over HTTP as JSON

func SetShutterSpeed

func SetShutterSpeed(e ExtendedShutterController) http.HandlerFunc

SetShutterSpeed decodes a duration from the message body as json {'f64': texp} and sets the camera by converting floating point seconds to a duration

func SetTemperatureSetpoint

func SetTemperatureSetpoint(t ThermalManager) http.HandlerFunc

SetTemperatureSetpoint returns an HTTP handler func that sets the temperature setpoint over HTTP

func WriteFits

func WriteFits(w io.Writer, metadata []fitsio.Card, imgs []image.Image) error

WriteFits streams a fits file to w

Types

type AOI

type AOI struct {
	// Left is the left pixel index.  1-based
	Left int `json:"left"`

	// Top is the top pixel index.  1-based
	Top int `json:"top"`

	// Width is the width in pixels
	Width int `json:"width"`

	// Height is the height in pixels
	Height int `json:"height"`
}

AOI describes an area of interest on the camera

func (AOI) Bottom

func (a AOI) Bottom() int

Bottom is shorthand for a.Top+a.Height

func (AOI) Right

func (a AOI) Right() int

Right is shorthand for a.Left+a.Width

type AOIManipulator

type AOIManipulator interface {
	// SetAOI allows the AOI to be set
	SetAOI(AOI) error

	// GetAOI retrieves the current AOI
	GetAOI() (AOI, error)

	// SetBinning sets the binning option of the camera
	SetBinning(Binning) error

	// GetBinning returns the binning option of the camera
	GetBinning() (Binning, error)
}

AOIManipulator is an interface to a camera's AOI manipulating functions

type Binning

type Binning struct {
	// H is the horizontal binning factor
	H int `json:"h"`

	// V is the vertical binning factor
	V int `json:"v"`
}

Binning encapsulates information about pixel addition on camera

func HxVToBin

func HxVToBin(hxv string) Binning

HxVToBin converts a string like "3x3" => Binning{3,3}

func (Binning) HxV

func (b Binning) HxV() string

HxV is a shorthand for "{h}x{v}", e.g. b.H, b.V = 1,1 => "1x1" or 3,3 => "3x3"

type BurstWrapper

type BurstWrapper struct {

	// B is the bursty camera
	B Burster
	// contains filtered or unexported fields
}

BurstWrapper is a type that holds the internal buffer for a burst of camera frames

func (*BurstWrapper) Inject

func (b *BurstWrapper) Inject(table generichttp.RouteTable)

Inject puts burst management routes on a table

func (*BurstWrapper) ReadAllFrames

func (b *BurstWrapper) ReadAllFrames(w http.ResponseWriter, r *http.Request)

ReadAllFrames reads all of the frames from the camera and writes them as a cube to a single FITS file

func (*BurstWrapper) ReadFrame

func (b *BurstWrapper) ReadFrame(w http.ResponseWriter, r *http.Request)

ReadFrame returns one frame from the buffer, as FITS, over HTTP

func (*BurstWrapper) SetupBurst

func (b *BurstWrapper) SetupBurst(w http.ResponseWriter, r *http.Request)

SetupBurst returns a function which triggers the burst on the camera

type Burster

type Burster interface {
	// Burst takes N frames at a certain framerate and writes them to the provided channel
	Burst(int, float64, chan<- image.Image) error
}

Burster describes an interface of a camera that may take a burst of frames

type Camera

type Camera interface {
	// GetFrame returns a frame from the device as a strided array
	GetFrame() (image.Image, error)
}

Camera describes the most basic camera possible

type EMGainManager

type EMGainManager interface {
	// GetEMGainMode returns how the EM gain is applied in the camera
	GetEMGainMode() (string, error)

	// SetEMGainMode changes how the EM gain is applied in the camera
	SetEMGainMode(string) error

	// GetEMGainRange returns the lower, upper limits on EM gain
	GetEMGainRange() (int, int, error)

	// GetEMGain returns the current EM gain setting
	GetEMGain() (int, error)

	// SetEMGain sets the current EM gain setting
	SetEMGain(int) error
}

EMGainManager describes an interface that can manage its electron multiplying gain

type ExtendedShutterController

type ExtendedShutterController interface {
	ShutterController

	// SetShutterSpeed sets the shutter speed (opening/closing time)
	SetShutterSpeed(time.Duration) error

	// GetShutterSpeed returns the shutter speed (opening/closing time)
	GetShutterSpeed() (time.Duration, error)
}

ExtendedShutterController is a device which can manipulate its shutter speed

type FeatureManager

type FeatureManager interface {
	// Features returns a mapping of feature names to types, as strings
	Features() (map[string]string, error)

	// GetFeature returns the value of a given feature, as its associated
	// type
	GetFeature(string) (interface{}, error)

	// GetFeatureInfo returns information about a given feature, including
	// its type, range of values, etc
	GetFeatureInfo(string) (map[string]interface{}, error)

	// SetFeature sets the value of a given feature
	SetFeature(string, interface{}) error
}

FeatureManager is a type that can manage many features in a generic capacity

type HTTPCamera

type HTTPCamera struct {
	PictureTaker

	RouteTable generichttp.RouteTable
}

HTTPCamera is a camera which exposes an HTTP interface to itself

func NewHTTPCamera

func NewHTTPCamera(p PictureTaker, rec *imgrec.Recorder) HTTPCamera

NewHTTPCamera returns a new HTTP wrapper around a camera

func (HTTPCamera) RT

RT satisfies generichttp.HTTPer

type MetadataMaker

type MetadataMaker interface {
	// CollectHeaderMetadata produces an array of FITS cards
	CollectHeaderMetadata() []fitsio.Card
}

MetadataMaker can produce an array of FITS cards

type PictureTaker

type PictureTaker interface {
	Camera

	// SetExposureTime sets the exposure time
	SetExposureTime(time.Duration) error

	// GetExposureTime gets the exposure time
	GetExposureTime() (time.Duration, error)
}

PictureTaker describes an interface to a camera which can capture images

type ShutterController

type ShutterController interface {
	// SetShutter sets the shutter to be open or closed
	SetShutter(bool) error

	// GetShutter returns if the shutter is open or closed
	GetShutter() (bool, error)

	// SetShutterAuto puts the shutter into automatic (camera controlled) or
	// manual (user controlled) mode
	SetShutterAuto(bool) error

	// GetShutterAuto returns if the shutter is automatically (camera) controlled
	// or user controlled
	GetShutterAuto() (bool, error)
}

ShutterController describes an interface to a camera which may manipulate its shutter

type ThermalManager

type ThermalManager interface {
	// GetCooling queries if focal plane cooling is currently active
	GetCooling() (bool, error)

	// SetCooling turns focal plane cooling on or off
	SetCooling(bool) error

	// GetTemperature gets the current focal plane temperature in Celsius
	GetTemperature() (float64, error)

	// GetTemperatureSetpoints returns the valid temperature setpoints.  Could return a discrete list, or min/max
	GetTemperatureSetpoints() ([]string, error)

	// GetTemperatureSetpoint gets the temperature setpoint, as a string for andor SDK3 compatibility
	GetTemperatureSetpoint() (string, error)

	// SetTemperatureSetpoint sets the temperature setpoint, as a string for andor SDk3 compatibility
	SetTemperatureSetpoint(string) error

	// GetTemperatureStatus gets the status of the sensor cooling subsystem
	GetTemperatureStatus() (string, error)

	// GetFan queries if the fan is on or off
	GetFan() (bool, error)

	// SetFan turns the fan on or off
	SetFan(bool) error
}

ThermalManager describes an interface to a camera which can manage its thermal performance

Jump to

Keyboard shortcuts

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