engine

package
v0.0.0-...-094b2d4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Implements simple PID based power controller.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProgramAlreadyRunning = errors.New("program already running")
	ErrNoProgramRunning      = errors.New("no program running")
)

Functions

This section is empty.

Types

type ControlEngine

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

func NewEngine

func NewEngine(config *types.ExecutorConfig, storage *storage.ProgramStorage) *ControlEngine

func (*ControlEngine) CurrentStatus

func (engine *ControlEngine) CurrentStatus() *types.ExecutionStatus

func (*ControlEngine) StartEngine

func (engine *ControlEngine) StartEngine(program *types.Program) error

func (*ControlEngine) StopEngine

func (engine *ControlEngine) StopEngine() error

type PidController

type PidController struct {
	Config *types.PidSettings
	State  PidControllerState
}

func NewPidController

func NewPidController(config *types.PidSettings) *PidController

func (*PidController) Reset

func (c *PidController) Reset()

func (*PidController) Update

func (c *PidController) Update(reference float64, actual float64) float64

Update the controller state.

type PidControllerState

type PidControllerState struct {
	CurrentError           float64
	CurrentErrorIntegral   float64
	CurrentErrorDerivative float64
	PreviousUpdate         int64
}

PidControllerState holds mutable state for a PidController.

type PowerCommand

type PowerCommand struct {
	Command PowerStatus `json:"command"`
	Percent uint8       `json:"percent,omitempty"`
}

type PowerController

type PowerController struct {
	PidController     *PidController
	ConstantPower     uint8
	TargetTemperature float64
	MaxDelta          float64
}

func NewPowerController

func NewPowerController(targetTemperature float64, settings *types.PowerPidSettings, defaultPidSettings *types.PidSettings) *PowerController

New power controller with the given configuration and settings. If the Power is set to non zero value, the PID settings are ignored.

func (*PowerController) Update

func (c *PowerController) Update(power uint8, owenTemperature float32, woodTemperature float32) uint8

Update the power controller with the current temperature and power. Returns the new power percentage to use.

type PowerResponse

type PowerResponse struct {
	Status  PowerStatus `json:"status"`
	Percent int         `json:"percent,omitempty"`
}

type PowerStatus

type PowerStatus string
const (
	PowerOn  PowerStatus = "On"
	PowerOff PowerStatus = "Off"
)

type PowerStatusResponse

type PowerStatusResponse struct {
	Data map[string]PowerResponse `json:"data"`
}

Jump to

Keyboard shortcuts

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