instruments

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package instruments provides a high-level client for management of imaging instruments

Index

Constants

This section is empty.

Variables

View Source
var MigrationFiles []string = []string{
	"1-initialize-schema-v0.1.7",
	"2-rename-user-to-identity-v0.1.11",
	"3-add-camera-controller-index-v0.1.15",
	"4-add-enabled-flag-v0.3.4",
	"5-enabled-not-null-v0.3.5",
	"6-add-automation-jobs-v0.3.5",
	"7-add-names-v0.3.5",
}

Functions

func HandleSleepAction added in v0.3.5

func HandleSleepAction(ctx context.Context, _ InstrumentID, name string, params hcl.Body) error

func NewDomainEmbeds added in v0.1.7

func NewDomainEmbeds() database.DomainEmbeds

Types

type Action added in v0.3.5

type Action struct {
	Type   string   `hcl:"type,label"`
	Name   string   `hcl:"name,label"`
	Remain hcl.Body `hcl:",remain"`
}

type ActionHandler added in v0.3.5

type ActionHandler func(
	ctx context.Context, instrumentID InstrumentID, name string, params hcl.Body,
) error

type AdminID added in v0.3.4

type AdminID string

type AutomationJob added in v0.3.5

type AutomationJob struct {
	ID            AutomationJobID
	InstrumentID  InstrumentID
	Enabled       bool
	Name          string
	Description   string
	Type          string
	Specification string
}

func (AutomationJob) GetID added in v0.3.6

func (j AutomationJob) GetID() AutomationJobID

func (AutomationJob) GetInstrumentID added in v0.3.6

func (j AutomationJob) GetInstrumentID() InstrumentID

func (AutomationJob) NewDelete added in v0.3.6

func (j AutomationJob) NewDelete() map[string]interface{}

func (AutomationJob) NewInsertion added in v0.3.6

func (j AutomationJob) NewInsertion() map[string]interface{}

func (AutomationJob) NewUpdate added in v0.3.6

func (j AutomationJob) NewUpdate() map[string]interface{}

type AutomationJobID added in v0.3.5

type AutomationJobID int64

type Camera added in v0.1.7

type Camera struct {
	ID           CameraID
	InstrumentID InstrumentID
	Enabled      bool
	Name         string
	Description  string
	Protocol     string
	URL          string
}

func (Camera) GetID added in v0.3.6

func (c Camera) GetID() CameraID

func (Camera) GetInstrumentID added in v0.3.6

func (c Camera) GetInstrumentID() InstrumentID

func (Camera) NewDelete added in v0.3.6

func (c Camera) NewDelete() map[string]interface{}

func (Camera) NewInsertion added in v0.3.6

func (c Camera) NewInsertion() map[string]interface{}

func (Camera) NewUpdate added in v0.3.6

func (c Camera) NewUpdate() map[string]interface{}

type CameraID added in v0.3.4

type CameraID int64

type Controller added in v0.1.7

type Controller struct {
	ID           ControllerID
	InstrumentID InstrumentID
	Enabled      bool
	Name         string
	Description  string
	Protocol     string
	URL          string
}

func (Controller) GetID added in v0.3.6

func (c Controller) GetID() ControllerID

func (Controller) GetInstrumentID added in v0.3.6

func (c Controller) GetInstrumentID() InstrumentID

func (Controller) NewDelete added in v0.3.6

func (c Controller) NewDelete() map[string]interface{}

func (Controller) NewInsertion added in v0.3.6

func (c Controller) NewInsertion() map[string]interface{}

func (Controller) NewUpdate added in v0.3.6

func (c Controller) NewUpdate() map[string]interface{}

type ControllerAction added in v0.3.5

type ControllerAction struct {
	Controller string   `hcl:"controller"`
	Command    string   `hcl:"command"`
	Params     hcl.Body `hcl:",remain"`
}

type ControllerActionRunner added in v0.3.5

type ControllerActionRunner interface {
	RunControllerAction(ctx context.Context, command string, params hcl.Body) error
}

type ControllerActionRunnerGetter added in v0.3.5

type ControllerActionRunnerGetter func(id ControllerID) (a ControllerActionRunner, ok bool)

type ControllerActionRunnerStore added in v0.3.5

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

func NewControllerActionRunnerStore added in v0.3.5

func NewControllerActionRunnerStore(
	instruments *Store, protocolGetters map[string]ControllerActionRunnerGetter,
) *ControllerActionRunnerStore

func (*ControllerActionRunnerStore) GetActionRunner added in v0.3.5

func (s *ControllerActionRunnerStore) GetActionRunner(
	ctx context.Context, iid InstrumentID, controllerName string,
) (runners map[ControllerID]ControllerActionRunner, err error)

func (*ControllerActionRunnerStore) HandleControllerAction added in v0.3.5

func (s *ControllerActionRunnerStore) HandleControllerAction(
	ctx context.Context, iid InstrumentID, name string, params hcl.Body,
) error

type ControllerID added in v0.3.4

type ControllerID int64

type Deletable added in v0.3.6

type Deletable[ID ~int64] interface {
	Identifiable[ID]
	NewDelete() map[string]interface{}
}

type Identifiable added in v0.3.6

type Identifiable[ID ~int64] interface {
	GetID() ID
}

type Insertable added in v0.3.6

type Insertable[ID ~int64] interface {
	Identifiable[ID]
	NewInsertion() map[string]interface{}
}

type Instrument

type Instrument struct {
	ID             InstrumentID
	Name           string
	Description    string
	AdminID        AdminID
	Cameras        map[CameraID]Camera
	Controllers    map[ControllerID]Controller
	AutomationJobs map[AutomationJobID]AutomationJob
}

func (Instrument) GetID added in v0.3.6

func (i Instrument) GetID() InstrumentID

func (Instrument) NewDelete added in v0.3.6

func (i Instrument) NewDelete() map[string]interface{}

type InstrumentID added in v0.3.4

type InstrumentID int64

type JobOrchestrator added in v0.3.5

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

func NewJobOrchestrator added in v0.3.5

func NewJobOrchestrator(
	actionHandlers map[string]ActionHandler, logger godest.Logger,
) *JobOrchestrator

func (*JobOrchestrator) Add added in v0.3.5

func (o *JobOrchestrator) Add(
	id AutomationJobID, instrumentID InstrumentID, name, specType, rawSpec string,
) error

func (*JobOrchestrator) Close added in v0.3.5

func (o *JobOrchestrator) Close()

func (*JobOrchestrator) Get added in v0.3.5

func (*JobOrchestrator) Orchestrate added in v0.3.5

func (o *JobOrchestrator) Orchestrate(ctx context.Context) error

func (*JobOrchestrator) Remove added in v0.3.5

func (o *JobOrchestrator) Remove(id AutomationJobID)

func (*JobOrchestrator) Update added in v0.3.5

func (o *JobOrchestrator) Update(
	id AutomationJobID, instrumentID InstrumentID, name, specType, rawSpec string,
) error

type OrchestratedJob added in v0.3.5

type OrchestratedJob struct {
	ID           AutomationJobID
	InstrumentID InstrumentID
	Name         string
	Type         string
	RawSpec      string
	ParsedSpec   ParsedSpecification
	// contains filtered or unexported fields
}

func NewOrchestratedJob added in v0.3.5

func NewOrchestratedJob(
	id AutomationJobID, instrumentID InstrumentID, name, specType, rawSpec string,
) (job *OrchestratedJob, err error)

func (*OrchestratedJob) Cancel added in v0.3.5

func (j *OrchestratedJob) Cancel()

func (*OrchestratedJob) Run added in v0.3.5

func (j *OrchestratedJob) Run(ctx context.Context, handlers map[string]ActionHandler) error

type ParsedSpecification added in v0.3.5

type ParsedSpecification struct {
	Schedule Schedule `hcl:"schedule,block"`
	// TODO: allow non-controller actions
	Actions []Action `hcl:"action,block"`
}

type Schedule added in v0.3.5

type Schedule struct {
	Interval string `hcl:"interval"`       // a string that parses with time.ParseDuration()
	Start    string `hcl:"start,optional"` // An RFC3339 timestamp
}

func (Schedule) DecodeStart added in v0.3.5

func (s Schedule) DecodeStart() (*time.Time, error)

type SleepAction added in v0.3.5

type SleepAction struct {
	Duration string `hcl:"duration"`
}

type Store added in v0.1.7

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

func NewStore added in v0.1.7

func NewStore(db *database.DB) *Store

func (*Store) AddAutomationJob added in v0.3.5

func (s *Store) AddAutomationJob(
	ctx context.Context, c AutomationJob,
) (automationJobID AutomationJobID, err error)

func (*Store) AddCamera added in v0.1.7

func (s *Store) AddCamera(ctx context.Context, c Camera) (cameraID CameraID, err error)

func (*Store) AddController added in v0.1.7

func (s *Store) AddController(ctx context.Context, c Controller) (cid ControllerID, err error)

func (*Store) AddInstrument added in v0.1.7

func (s *Store) AddInstrument(
	ctx context.Context, i Instrument,
) (instrumentID InstrumentID, err error)

func (*Store) DeleteAutomationJob added in v0.3.5

func (s *Store) DeleteAutomationJob(ctx context.Context, id AutomationJobID) (err error)

func (*Store) DeleteCamera added in v0.1.7

func (s *Store) DeleteCamera(ctx context.Context, id CameraID) (err error)

func (*Store) DeleteController added in v0.1.7

func (s *Store) DeleteController(ctx context.Context, id ControllerID) (err error)

func (*Store) DeleteInstrument added in v0.1.7

func (s *Store) DeleteInstrument(ctx context.Context, id InstrumentID) (err error)

func (*Store) GetCamera added in v0.2.4

func (s *Store) GetCamera(ctx context.Context, id CameraID) (i Camera, err error)

func (*Store) GetEnabledAutomationJobs added in v0.3.5

func (s *Store) GetEnabledAutomationJobs(ctx context.Context) (jobs []AutomationJob, err error)

func (*Store) GetEnabledControllersByProtocol added in v0.3.5

func (s *Store) GetEnabledControllersByProtocol(
	ctx context.Context, protocol string,
) (controllers []Controller, err error)

func (*Store) GetInstrument added in v0.1.7

func (s *Store) GetInstrument(ctx context.Context, id InstrumentID) (i Instrument, err error)

func (*Store) GetInstrumentControllersByName added in v0.3.5

func (s *Store) GetInstrumentControllersByName(
	ctx context.Context, instrumentID InstrumentID, name string,
) (controllers []Controller, err error)

func (*Store) GetInstruments added in v0.1.7

func (s *Store) GetInstruments(ctx context.Context) (instruments []Instrument, err error)

func (*Store) GetInstrumentsByAdminID added in v0.1.7

func (s *Store) GetInstrumentsByAdminID(
	ctx context.Context, adminID AdminID,
) (instruments []Instrument, err error)

func (*Store) UpdateAutomationJob added in v0.3.5

func (s *Store) UpdateAutomationJob(ctx context.Context, c AutomationJob) (err error)

func (*Store) UpdateCamera added in v0.1.7

func (s *Store) UpdateCamera(ctx context.Context, c Camera) (err error)

func (*Store) UpdateController added in v0.1.7

func (s *Store) UpdateController(ctx context.Context, c Controller) (err error)

func (*Store) UpdateInstrumentDescription added in v0.1.7

func (s *Store) UpdateInstrumentDescription(
	ctx context.Context, id InstrumentID, description string,
) (err error)

func (*Store) UpdateInstrumentName added in v0.1.7

func (s *Store) UpdateInstrumentName(
	ctx context.Context, id InstrumentID, name string,
) (err error)

type Subcomponent added in v0.3.6

type Subcomponent interface {
	GetInstrumentID() InstrumentID
}

type SubcomponentInsertable added in v0.3.6

type SubcomponentInsertable[ID ~int64] interface {
	Subcomponent
	Insertable[ID]
}

type Updateable added in v0.3.6

type Updateable[ID ~int64] interface {
	Identifiable[ID]
	NewUpdate() map[string]interface{}
}

Jump to

Keyboard shortcuts

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