engine

package
v0.0.0-...-3475d41 Latest Latest
Warning

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

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

Documentation

Overview

Implements simple, delta and 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(halkoConfig *types.HalkoConfig, storage *storage.FileStorage, endpoints *types.APIEndpoints) *ControlEngine

func (*ControlEngine) CurrentStatus

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

func (*ControlEngine) GetDefaults

func (engine *ControlEngine) GetDefaults() *types.Defaults

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) Update

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

Update the controller state.

type PidControllerState

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

PidControllerState holds mutable state for a PidController.

type PowerCommand

type PowerCommand struct {
	Percent uint8 `json:"percent"`
}

type PowerController

type PowerController struct {
	PidController     *PidController
	TargetTemperature float32
	Settings          *types.PowerPidSettings
}

func NewPowerController

func NewPowerController(targetTemperature float32, settings *types.PowerPidSettings) *PowerController

New power controller with the given configuration and settings.

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 {
	Percent int `json:"percent"`
}

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