configuration

package
v0.0.0-...-8b25b9d Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FunctionSum computes the sum of all referenced curves
	FunctionSum = "sum"
	// FunctionDifference computes the difference of all referenced curves
	FunctionDifference = "difference"
	// FunctionAverage computes the average value of all referenced
	// curves using the arithmetic mean
	FunctionAverage = "average"
	// FunctionDelta computes the difference between the biggest and the smallest
	// value of all referenced curves
	FunctionDelta = "delta"
	// FunctionMinimum computes the smallest value of all referenced curves
	FunctionMinimum = "minimum"
	// FunctionMaximum computes the biggest value of all referenced curves
	FunctionMaximum = "maximum"
)

Variables

This section is empty.

Functions

func DetectAndReadConfigFile

func DetectAndReadConfigFile() string

DetectAndReadConfigFile detects the path of the first existing config file

func GetFilePath

func GetFilePath() string

GetFilePath this is only populated _after_ readInConfig()

func InitConfig

func InitConfig(cfgFile string)

InitConfig reads in config file and ENV variables if set.

func LoadConfig

func LoadConfig()

func Validate

func Validate(configPath string) error

Types

type ApiConfig

type ApiConfig struct {
	Enabled bool   `json:"enabled"`
	Host    string `json:"host"`
	Port    int    `json:"port"`
}

type CmdFanConfig

type CmdFanConfig struct {
	SetPwm *ExecConfig `json:"setPwm,omitempty"`
	GetPwm *ExecConfig `json:"getPwm,omitempty"`
	GetRpm *ExecConfig `json:"getRpm,omitempty"`
}

type CmdSensorConfig

type CmdSensorConfig struct {
	Exec string   `json:"exec"`
	Args []string `json:"args"`
}

type Configuration

type Configuration struct {
	DbPath string `json:"dbPath"`

	RunFanInitializationInParallel bool    `json:"runFanInitializationInParallel"`
	MaxRpmDiffForSettledFan        float64 `json:"maxRpmDiffForSettledFan"`
	FanResponseDelay               int     `json:"fanResponseDelay"`

	TempSensorPollingRate time.Duration `json:"tempSensorPollingRate"`
	TempRollingWindowSize int           `json:"tempRollingWindowSize"`

	RpmPollingRate       time.Duration `json:"rpmPollingRate"`
	RpmRollingWindowSize int           `json:"rpmRollingWindowSize"`

	ControllerAdjustmentTickRate time.Duration `json:"controllerAdjustmentTickRate"`

	Fans    []FanConfig    `json:"fans"`
	Sensors []SensorConfig `json:"sensors"`
	Curves  []CurveConfig  `json:"curves"`

	Api        ApiConfig        `json:"api"`
	Statistics StatisticsConfig `json:"statistics"`
	Profiling  ProfilingConfig  `json:"profiling"`
}
var CurrentConfig Configuration

type ControlAlgorithm

type ControlAlgorithm string
const (
	Pid    ControlAlgorithm = "pid"
	Direct ControlAlgorithm = "direct"
)

type ControlAlgorithmConfig

type ControlAlgorithmConfig struct {
	Direct *DirectControlAlgorithmConfig `json:"direct,omitempty"`
	Pid    *PidControlAlgorithmConfig    `json:"pid,omitempty"`
}

func (*ControlAlgorithmConfig) UnmarshalText

func (s *ControlAlgorithmConfig) UnmarshalText(text []byte) error

UnmarshalText is a custom unmarshaler for ControlAlgorithmConfig to handle string enum values

type ControlLoopConfig

type ControlLoopConfig struct {
	P float64 `json:"p"`
	I float64 `json:"i"`
	D float64 `json:"d"`
}

type CurveConfig

type CurveConfig struct {
	ID       string               `json:"id"`
	Linear   *LinearCurveConfig   `json:"linear,omitempty"`
	PID      *PidCurveConfig      `json:"pid,omitempty"`
	Function *FunctionCurveConfig `json:"function,omitempty"`
}

type DirectControlAlgorithmConfig

type DirectControlAlgorithmConfig struct {
	MaxPwmChangePerCycle *int `json:"maxPwmChangePerCycle,omitempty"`
}

type ExecConfig

type ExecConfig struct {
	Exec string   `json:"exec"`
	Args []string `json:"args"`
}

type FanConfig

type FanConfig struct {
	ID        string `json:"id"`
	NeverStop bool   `json:"neverStop"`
	// MinPwm defines the lowest PWM value where the fans are still spinning, when spinning previously
	MinPwm *int `json:"minPwm,omitempty"`
	// StartPwm defines the lowest PWM value where the fans are able to start spinning from a standstill
	StartPwm *int `json:"startPwm,omitempty"`
	// MaxPwm defines the highest PWM value that yields an RPM increase
	MaxPwm           *int                    `json:"maxPwm,omitempty"`
	PwmMap           *map[int]int            `json:"pwmMap,omitempty"`
	Curve            string                  `json:"curve"`
	ControlAlgorithm *ControlAlgorithmConfig `json:"controlAlgorithm,omitempty"`
	HwMon            *HwMonFanConfig         `json:"hwMon,omitempty"`
	File             *FileFanConfig          `json:"file,omitempty"`
	Cmd              *CmdFanConfig           `json:"cmd,omitempty"`

	// ControlLoop is a configuration for a PID control loop.
	//
	// Deprecated: HeaderMap exists for historical compatibility
	// and should not be used. To access the headers returned by a handler,
	// use the Response.Header map as returned by the Result method.
	ControlLoop *ControlLoopConfig `json:"controlLoop,omitempty"`
}

type FileFanConfig

type FileFanConfig struct {
	Path    string `json:"path"`
	RpmPath string `json:"rpmPath"`
}

type FileSensorConfig

type FileSensorConfig struct {
	Path string `json:"path"`
}

type FunctionCurveConfig

type FunctionCurveConfig struct {
	Type   string   `json:"type"`
	Curves []string `json:"curves"`
}

type HwMonFanConfig

type HwMonFanConfig struct {
	Platform      string `json:"platform"`
	Index         int    `json:"index"`
	RpmChannel    int    `json:"rpmChannel"`
	PwmChannel    int    `json:"pwmChannel"`
	SysfsPath     string
	RpmInputPath  string
	PwmPath       string
	PwmEnablePath string
}

type HwMonSensorConfig

type HwMonSensorConfig struct {
	Platform  string `json:"platform"`
	Index     int    `json:"index"`
	TempInput string
}

type LinearCurveConfig

type LinearCurveConfig struct {
	Sensor string          `json:"sensor"`
	Min    int             `json:"min"`
	Max    int             `json:"max"`
	Steps  map[int]float64 `json:"steps"`
}

type PidControlAlgorithmConfig

type PidControlAlgorithmConfig struct {
	P float64 `json:"p"`
	I float64 `json:"i"`
	D float64 `json:"d"`
}

type PidCurveConfig

type PidCurveConfig struct {
	Sensor   string  `json:"sensor"`
	SetPoint float64 `json:"setPoint"`
	P        float64 `json:"p"`
	I        float64 `json:"i"`
	D        float64 `json:"d"`
}

type ProfilingConfig

type ProfilingConfig struct {
	Enabled bool   `json:"enabled"`
	Host    string `json:"host"`
	Port    int    `json:"port,omitempty"`
}

type SensorConfig

type SensorConfig struct {
	ID    string             `json:"id"`
	HwMon *HwMonSensorConfig `json:"hwMon,omitempty"`
	File  *FileSensorConfig  `json:"file,omitempty"`
	Cmd   *CmdSensorConfig   `json:"cmd,omitempty"`
}

type StatisticsConfig

type StatisticsConfig struct {
	Enabled bool `json:"enabled"`
	Port    int  `json:"port,omitempty"`
}

Jump to

Keyboard shortcuts

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