-
Notifications
You must be signed in to change notification settings - Fork 110
/
control.go
37 lines (33 loc) · 1.42 KB
/
control.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Package control package for feedback loop controls
// This is an Experimental package
package control
import (
"context"
)
// Controllable controllable type for a DC motor.
type Controllable interface {
// SetPower set the power and direction of the motor
SetPower(ctx context.Context, power float64, extra map[string]interface{}) error
// Position returns the current encoder count value
Position(ctx context.Context, extra map[string]interface{}) (float64, error)
}
// Config configuration of the control loop.
type Config struct {
Blocks []BlockConfig `json:"blocks"` // Blocks Control Block Config
Frequency float64 `json:"frequency"` // Frequency loop Frequency
}
// Control control interface can be used to interfact with a control loop to query signals, change config, start/stop the loop etc...
type Control interface {
// OutputAt returns the Signal at the block name, error when the block doesn't exist
OutputAt(ctx context.Context, name string) ([]Signal, error)
// ConfigAt returns the Configl at the block name, error when the block doesn't exist
ConfigAt(ctx context.Context, name string) (BlockConfig, error)
// BlockList returns the list of blocks in a control loop error when the list is empty
BlockList(ctx context.Context) ([]string, error)
// Frequency returns the loop's frequency
Frequency(ctx context.Context) (float64, error)
// Start starts the loop
Start() error
// Stop stops the loop
Stop()
}