Documentation ¶
Index ¶
- Variables
- func ClearControllers()
- func DeleteTemperatureControllerByID(id string) []*string
- func GpioInUse(identifier string) bool
- func ShutdownAllSwitches()
- type HysteriaSettings
- type ManualSettings
- type OutPin
- type OutputControl
- func (o *OutputControl) AfterDelete(tx *gorm.DB)
- func (o *OutputControl) CalculateOutput()
- func (o *OutputControl) RegisterGpios()
- func (o *OutputControl) Reset()
- func (o *OutputControl) RunControl(quit chan struct{})
- func (o *OutputControl) UpdateGpios(parentName string, heatGpio string, coolGpio string) error
- type PidSettings
- type Switch
- type TempProbeDetail
- type TemperatureController
- func AllTemperatureControllers() []*TemperatureController
- func CreateTemperatureController(name string, probe *TempProbeDetail) (*TemperatureController, error)
- func FindTemperatureControllerByID(id string) *TemperatureController
- func FindTemperatureControllerByName(name string) *TemperatureController
- func FindTemperatureControllerForProbe(physAddr string) *TemperatureController
- func (c *TemperatureController) ApplySettings(newSettings model.TemperatureControllerSettingsInput) error
- func (c *TemperatureController) AverageTemperature() physic.Temperature
- func (c *TemperatureController) Calculate(averageTemperature physic.Temperature, now func() time.Time) int64
- func (c *TemperatureController) RemoveProbe(physAddr string) error
- func (c *TemperatureController) RunControl()
- func (c *TemperatureController) SetPoint() string
- func (c *TemperatureController) UpdateOutput()
- func (c *TemperatureController) UpdateSetPoint(newValue string) error
Constants ¶
This section is empty.
Variables ¶
var CancelFunc = cancelFunc
CancelFunc - Call this to shutdown the app
var Context = contextDecl
Context - The global context object
Functions ¶
func DeleteTemperatureControllerByID ¶
DeleteTemperatureControllerByID - Delete a temperature controller with the ID specified and return the probes that are now freed
func ShutdownAllSwitches ¶
func ShutdownAllSwitches()
ShutdownAllSwitches - Turn off all switches that are configured, does not cover output control pins
Types ¶
type HysteriaSettings ¶
type HysteriaSettings struct { gorm.Model MaxTempRaw physic.Temperature MinTempRaw physic.Temperature MinTime int64 // In seconds Configured bool TemperatureControllerID uint }
HysteriaSettings are used for Hysteria mode
func (*HysteriaSettings) ApplySettings ¶
func (h *HysteriaSettings) ApplySettings(newSettings *model.HysteriaSettingsInput) error
ApplySettings - Update the current hysteria settings
func (*HysteriaSettings) MaxTemp ¶
func (h *HysteriaSettings) MaxTemp() string
MaxTemp -> For hysteria, this is the string for the max temp to turn off
func (*HysteriaSettings) MinTemp ¶
func (h *HysteriaSettings) MinTemp() string
MinTemp -> For hysteria, this is the string for the min temp to turn on
type ManualSettings ¶
type ManualSettings struct { gorm.Model DutyCycle int64 CycleTime int64 Configured bool TemperatureControllerID uint }
ManualSettings are used for manually controlling the output
func (*ManualSettings) ApplySettings ¶
func (s *ManualSettings) ApplySettings(newSettings *model.ManualSettingsInput) error
ApplySettings - Update the current manual settings
type OutPin ¶
type OutPin struct { gorm.Model Identifier string FriendlyName string PinIO gpio.PinIO `gorm:"-"` // contains filtered or unexported fields }
OutPin represents a stored output pin with a friendly name
type OutputControl ¶
type OutputControl struct { gorm.Model HeatOutput *OutPin CoolOutput *OutPin DutyCycle int64 `gorm:"-"` CycleTime int64 `gorm:"-"` }
OutputControl is a basic struct to handle heating outputs with a duty cyclke
func (*OutputControl) AfterDelete ¶
func (o *OutputControl) AfterDelete(tx *gorm.DB)
AfterDelete - After deleting a switch, remove the output pin
func (*OutputControl) CalculateOutput ¶
func (o *OutputControl) CalculateOutput()
CalculateOutput - Turn on and off the output pin for this output control depending on the duty cycle
func (*OutputControl) RegisterGpios ¶
func (o *OutputControl) RegisterGpios()
RegisterGpios - Register the outpins with the master list
func (*OutputControl) RunControl ¶
func (o *OutputControl) RunControl(quit chan struct{})
RunControl -> Run the output controller for a heating output
func (*OutputControl) UpdateGpios ¶
func (o *OutputControl) UpdateGpios(parentName string, heatGpio string, coolGpio string) error
UpdateGpios - Update the heating and cooling outputs to their new pins
type PidSettings ¶
type PidSettings struct { gorm.Model Proportional float64 Integral float64 Derivative float64 CycleTime int64 Delay int64 Configured bool TemperatureControllerID uint TemperatureControllerType string Gpio string }
PidSettings define the actual values for heating/cooling as persisted
func (*PidSettings) ApplySettings ¶
func (s *PidSettings) ApplySettings(newSettings *model.PidSettingsInput) error
ApplySettings - Update the current pid settings
type Switch ¶
type Switch struct { gorm.Model OutputID uint Output *OutPin `gorm:"ForeignKey:OutputID"` Inverted bool }
Switch - Represents a thin wrapper around an OutPin to define a switch
func AllSwitches ¶
func AllSwitches() []*Switch
AllSwitches returns all the switches, loading from the Database if none are configured
func CreateSwitch ¶
CreateSwitch - Create a new switch, checking for the GPIO/Name already existing
func DeleteSwitchByID ¶
DeleteSwitchByID - Does what it says on the tin, clearing up the Outpin too
func FindSwitchByID ¶
FindSwitchByID - Find a temperature controller by id, preloading everything
func (*Switch) AfterDelete ¶
AfterDelete - After deleting a switch, remove the output pin
func (*Switch) Off ¶
func (s *Switch) Off()
Off - Switch off the output pin, if it's inverted, the pin goes to on
func (*Switch) On ¶
func (s *Switch) On()
On - Switch on the output pin, if it's inverted, the pin goes to off
func (*Switch) State ¶
func (s *Switch) State() model.SwitchMode
State - Returns on if this switch is on
func (*Switch) UpdateIdentifier ¶
UpdateIdentifier - update the identifier (GPIO)
type TempProbeDetail ¶
type TempProbeDetail struct { gorm.Model TemperatureControllerID uint PhysAddr string FriendlyName string ReadingRaw physic.Temperature `gorm:"-"` Updated time.Time }
TempProbeDetail is the persisted model for TemperatureProbe this is to simplify loading data so that TemperatureProbe represents the physical state and this represents the cached state
func (*TempProbeDetail) Reading ¶
func (t *TempProbeDetail) Reading() string
Reading The current temperature reading for the probe
func (*TempProbeDetail) UpdateReading ¶
func (t *TempProbeDetail) UpdateReading()
UpdateReading - Update the reading from the associated probe
func (*TempProbeDetail) UpdateTemperature ¶
func (t *TempProbeDetail) UpdateTemperature(newTemp string) error
UpdateTemperature Set the temperature on the Temperature Probe from a string
type TemperatureController ¶
type TemperatureController struct { gorm.Model Name string LastReadings []physic.Temperature `gorm:"-"` TempProbeDetails []*TempProbeDetail CoolSettings PidSettings `gorm:"polymorphic:TemperatureController;polymorphicValue:coolSettings"` // CoolSettingsID uint HeatSettings PidSettings `gorm:"polymorphic:TemperatureController;polymorphicValue:heatSettings"` // HeatSettingsID uint HysteriaSettings HysteriaSettings // HysteriaSettingsID uint ManualSettings ManualSettings Mode model.ControllerMode // Mode of this controller DutyCycle int64 CalculatedDuty int64 SetPointRaw *physic.Temperature PreviousCalculationTime time.Time `gorm:"-"` TotalDiff float64 `gorm:"-"` // Always in Fahrenheit (internal calculation) OutputControl *OutputControl `gorm:"-"` Running bool `gorm:"-"` // contains filtered or unexported fields }
TemperatureController defines a mapping of temperature probes to their control settings
func AllTemperatureControllers ¶
func AllTemperatureControllers() []*TemperatureController
AllTemperatureControllers returns all the temperature controllers
func CreateTemperatureController ¶
func CreateTemperatureController(name string, probe *TempProbeDetail) (*TemperatureController, error)
CreateTemperatureController Create a new PID controller for the Temperature probe name -> The name of the PID Controller probe -> The probe to associate with the controller If a PID controller exists with the same name, the probe will be added to it (or no-op if it is already assigned) If the passed in TemperatureProbe is associated with a different PID Controller, an error will be returned and no PID controller will be returned
func FindTemperatureControllerByID ¶
func FindTemperatureControllerByID(id string) *TemperatureController
FindTemperatureControllerByID - Find a temperature controller by id, preloading everything
func FindTemperatureControllerByName ¶
func FindTemperatureControllerByName(name string) *TemperatureController
FindTemperatureControllerByName returns the pid controller with a specific name
func FindTemperatureControllerForProbe ¶
func FindTemperatureControllerForProbe(physAddr string) *TemperatureController
FindTemperatureControllerForProbe returns the pid controller associated with the TemperatureProbe
func (*TemperatureController) ApplySettings ¶
func (c *TemperatureController) ApplySettings(newSettings model.TemperatureControllerSettingsInput) error
ApplySettings - Update the current temperature controller settings
func (*TemperatureController) AverageTemperature ¶
func (c *TemperatureController) AverageTemperature() physic.Temperature
AverageTemperature Calculate the average temperature for a temperature controller over all the probes
func (*TemperatureController) Calculate ¶
func (c *TemperatureController) Calculate(averageTemperature physic.Temperature, now func() time.Time) int64
Calculate does the calculation for the probe
func (*TemperatureController) RemoveProbe ¶
func (c *TemperatureController) RemoveProbe(physAddr string) error
RemoveProbe removes a temperature probe from this controller
func (*TemperatureController) RunControl ¶
func (c *TemperatureController) RunControl()
RunControl -> Run the output controller for a heating output
func (*TemperatureController) SetPoint ¶
func (c *TemperatureController) SetPoint() string
SetPoint -> Te target Setpoint for this controller
func (*TemperatureController) UpdateOutput ¶
func (c *TemperatureController) UpdateOutput()
UpdateOutput updates the temperatures and decides how to control the outputs
func (*TemperatureController) UpdateSetPoint ¶
func (c *TemperatureController) UpdateSetPoint(newValue string) error
UpdateSetPoint -> Update the current set point value, empty string will clear the value