wrapper

package
v0.0.0-...-e6e1b3f Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChargeMeter

type ChargeMeter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ChargeMeter is a replacement for a physical charge meter. It uses the charger's actual or max current to calculate power consumption.

func (*ChargeMeter) CurrentPower

func (m *ChargeMeter) CurrentPower() (float64, error)

CurrentPower implements the api.Meter interface

func (*ChargeMeter) SetPower

func (m *ChargeMeter) SetPower(power float64)

SetPower updates meter's current power

type ChargeRater

type ChargeRater struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ChargeRater is responsible for providing charged energy amount by implementing api.ChargeRater. It uses the charge meter's TotalEnergy or keeps track of consumed energy by regularly updating consumed power.

func NewChargeRater

func NewChargeRater(log *util.Logger, meter api.Meter) *ChargeRater

NewChargeRater creates charge rater and initializes realtime clock

func (*ChargeRater) ChargedEnergy

func (cr *ChargeRater) ChargedEnergy() (float64, error)

ChargedEnergy implements the ChargeRater interface. It returns energy consumption since charge start in kWh.

func (*ChargeRater) SetChargePower

func (cr *ChargeRater) SetChargePower(power float64)

SetChargePower increments consumed energy by amount in kWh since last update

func (*ChargeRater) StartCharge

func (cr *ChargeRater) StartCharge(continued bool)

StartCharge records meter start energy. If meter does not supply TotalEnergy, start time is recorded and charged energy set to zero.

func (*ChargeRater) StopCharge

func (cr *ChargeRater) StopCharge()

StopCharge records meter stop energy. If meter does not supply TotalEnergy, stop time is recorded and accumulating energy though SetChargePower stopped.

type ChargeTimer

type ChargeTimer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ChargeTimer measures charging time between start and stop events

func NewChargeTimer

func NewChargeTimer() *ChargeTimer

NewChargeTimer creates ChargeTimer for tracking duration between start and stop events

func (*ChargeTimer) ChargingTime

func (m *ChargeTimer) ChargingTime() (time.Duration, error)

ChargingTime implements the api.ChargeTimer interface

func (*ChargeTimer) StartCharge

func (m *ChargeTimer) StartCharge(continued bool)

StartCharge signals charge timer start

func (*ChargeTimer) StopCharge

func (m *ChargeTimer) StopCharge()

StopCharge signals charge timer stop

Jump to

Keyboard shortcuts

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