Skip to content

Commit

Permalink
chore: idiomatically rename AlarmClock to Resurrector
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jul 27, 2022
1 parent 346c818 commit 51c68bc
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ type VehicleChargeController interface {
StopCharge() error
}

// AlarmClock provides wakeup calls to the vehicle with an API call or a CP interrupt from the charger
type AlarmClock interface {
// Resurrector provides wakeup calls to the vehicle with an API call or a CP interrupt from the charger
type Resurrector interface {
WakeUp() error
}

Expand Down
4 changes: 2 additions & 2 deletions charger/abl.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ func (wb *ABLeMH) Diagnose() {
}
}

var _ api.AlarmClock = (*ABLeMH)(nil)
var _ api.Resurrector = (*ABLeMH)(nil)

// WakeUp implements the api.AlarmClock interface
// WakeUp implements the api.Resurrector interface
func (wb *ABLeMH) WakeUp() error {
// temporary jump to status E0 (Outlet disabled)
err := wb.set(ablRegModifyState, 0xE0E0)
Expand Down
4 changes: 2 additions & 2 deletions charger/evsewifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ func (wb *EVSEWifi) identify() (string, error) {
// return params.Energy, err
// }

var _ api.AlarmClock = (*EVSEWifi)(nil)
var _ api.Resurrector = (*EVSEWifi)(nil)

// WakeUp implements the AlarmClock interface
// WakeUp implements the Resurrector interface
func (wb *EVSEWifi) WakeUp() error {
uri := fmt.Sprintf("%s/interruptCp", wb.uri)
_, err := wb.GetBody(uri)
Expand Down
4 changes: 2 additions & 2 deletions charger/heidelberg-ec.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ func (wb *HeidelbergEC) Diagnose() {
}
}

var _ api.AlarmClock = (*HeidelbergEC)(nil)
var _ api.Resurrector = (*HeidelbergEC)(nil)

// WakeUp implements the api.AlarmClock interface
// WakeUp implements the api.Resurrector interface
func (wb *HeidelbergEC) WakeUp() error {
// force status F by locking
err := wb.set(hecRegRemoteLock, 0)
Expand Down
4 changes: 2 additions & 2 deletions charger/openwb.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ func (m *OpenWB) Authorize(key string) error {
return m.authS(key)
}

var _ api.AlarmClock = (*OpenWB)(nil)
var _ api.Resurrector = (*OpenWB)(nil)

// WakeUp implements the api.AlarmClock interface
// WakeUp implements the api.Resurrector interface
func (m *OpenWB) WakeUp() error {
return m.wakeupS(1)
}
2 changes: 1 addition & 1 deletion cmd/charger.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func runCharger(cmd *cobra.Command, args []string) {
if cmd.PersistentFlags().Lookup(flagWakeup).Changed {
flagUsed = true

if vv, ok := v.(api.AlarmClock); ok {
if vv, ok := v.(api.Resurrector); ok {
if err := vv.WakeUp(); err != nil {
log.ERROR.Println("wakeup:", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/vehicle.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func runVehicle(cmd *cobra.Command, args []string) {
if cmd.PersistentFlags().Lookup(flagWakeup).Changed {
flagUsed = true

if vv, ok := v.(api.AlarmClock); ok {
if vv, ok := v.(api.Resurrector); ok {
if err := vv.WakeUp(); err != nil {
log.ERROR.Println("wakeup:", err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ func (lp *LoadPoint) setActiveVehicle(vehicle api.Vehicle) {

func (lp *LoadPoint) wakeUpVehicle() {
// charger
if c, ok := lp.charger.(api.AlarmClock); ok {
if c, ok := lp.charger.(api.Resurrector); ok {
if err := c.WakeUp(); err != nil {
lp.log.ERROR.Printf("wake-up charger: %v", err)
}
Expand All @@ -843,7 +843,7 @@ func (lp *LoadPoint) wakeUpVehicle() {

// vehicle
if lp.vehicle != nil {
if vs, ok := lp.vehicle.(api.AlarmClock); ok {
if vs, ok := lp.vehicle.(api.Resurrector); ok {
if err := vs.WakeUp(); err != nil {
lp.log.ERROR.Printf("wake-up vehicle: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (site *Site) DumpConfig() {
_, energy := lp.charger.(api.MeterEnergy)
_, currents := lp.charger.(api.MeterCurrent)
_, phases := lp.charger.(api.ChargePhases)
_, wakeup := lp.charger.(api.AlarmClock)
_, wakeup := lp.charger.(api.Resurrector)

lp.log.INFO.Printf(" charger: power %s energy %s currents %s phases %s wakeup %s",
presence[power],
Expand All @@ -218,7 +218,7 @@ func (site *Site) DumpConfig() {
_, finish := v.(api.VehicleFinishTimer)
_, status := v.(api.ChargeState)
_, climate := v.(api.VehicleClimater)
_, wakeup := v.(api.AlarmClock)
_, wakeup := v.(api.Resurrector)
lp.log.INFO.Printf(" vehicle %d: range %s finish %s status %s climate %s wakeup %s",
i+1, presence[rng], presence[finish], presence[status], presence[climate], presence[wakeup],
)
Expand Down
4 changes: 2 additions & 2 deletions vehicle/ford/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ func (v *Provider) Position() (float64, float64, error) {
return res.VehicleStatus.Gps.Latitude, res.VehicleStatus.Gps.Longitude, err
}

var _ api.AlarmClock = (*Provider)(nil)
var _ api.Resurrector = (*Provider)(nil)

// WakeUp implements the api.AlarmClock interface
// WakeUp implements the api.Resurrector interface
func (v *Provider) WakeUp() error {
return v.wakeup()
}
4 changes: 2 additions & 2 deletions vehicle/renault/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp floa
return false, 0, 0, err
}

var _ api.AlarmClock = (*Provider)(nil)
var _ api.Resurrector = (*Provider)(nil)

// WakeUp implements the api.AlarmClock interface
// WakeUp implements the api.Resurrector interface
func (v *Provider) WakeUp() error {
_, err := v.wakeup()
return err
Expand Down

0 comments on commit 51c68bc

Please sign in to comment.