From aeaecfd6eac1295918faf93d83f90cca92ee7e7b Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 24 Apr 2024 09:15:26 +0200 Subject: [PATCH] chore: rename api.ChargeTimer (#13561) --- api/api.go | 2 +- charger/bender.go | 4 ++-- charger/em2go-home.go | 4 ++-- charger/em2go.go | 4 ++-- charger/etrel.go | 4 ++-- charger/hesotec.go | 4 ++-- charger/mcc.go | 4 ++-- charger/mcc_test.go | 6 +++--- charger/mennekes-compact.go | 4 ++-- charger/openevse.go | 2 +- charger/phoenix-charx.go | 4 ++-- charger/phoenix-em-eth.go | 4 ++-- charger/schneider-v3.go | 4 ++-- charger/twc3.go | 4 ++-- charger/vestel.go | 4 ++-- charger/webasto-next.go | 4 ++-- cmd/dumper.go | 2 +- core/loadpoint.go | 2 +- core/loadpoint_test.go | 2 +- core/wrapper/chargetimer.go | 4 ++-- core/wrapper/chargetimer_test.go | 4 ++-- 21 files changed, 38 insertions(+), 38 deletions(-) diff --git a/api/api.go b/api/api.go index 6dab022f5..77500df08 100644 --- a/api/api.go +++ b/api/api.go @@ -93,7 +93,7 @@ type Diagnosis interface { // ChargeTimer provides current charge cycle duration type ChargeTimer interface { - ChargingTime() (time.Duration, error) + ChargeDuration() (time.Duration, error) } // ChargeRater provides charged energy amount in kWh diff --git a/charger/bender.go b/charger/bender.go index d50bc12e5..1267103af 100644 --- a/charger/bender.go +++ b/charger/bender.go @@ -203,8 +203,8 @@ func (wb *BenderCC) MaxCurrent(current int64) error { var _ api.ChargeTimer = (*BenderCC)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *BenderCC) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *BenderCC) ChargeDuration() (time.Duration, error) { if wb.legacy { b, err := wb.conn.ReadHoldingRegisters(bendRegChargingDurationLegacy, 1) if err != nil { diff --git a/charger/em2go-home.go b/charger/em2go-home.go index c65acb8b5..d0a185c67 100644 --- a/charger/em2go-home.go +++ b/charger/em2go-home.go @@ -233,8 +233,8 @@ func (wb *Em2GoHome) ChargedEnergy() (float64, error) { var _ api.ChargeTimer = (*Em2GoHome)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *Em2GoHome) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *Em2GoHome) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(em2GoHomeRegChargeDuration, 2) if err != nil { return 0, err diff --git a/charger/em2go.go b/charger/em2go.go index 501b2da23..23cef9883 100644 --- a/charger/em2go.go +++ b/charger/em2go.go @@ -221,8 +221,8 @@ func (wb *Em2Go) ChargedEnergy() (float64, error) { var _ api.ChargeTimer = (*Em2Go)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *Em2Go) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *Em2Go) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(em2GoRegChargeDuration, 2) if err != nil { return 0, err diff --git a/charger/etrel.go b/charger/etrel.go index 92ac23bba..0e5e807bc 100644 --- a/charger/etrel.go +++ b/charger/etrel.go @@ -221,8 +221,8 @@ func (wb *Etrel) Currents() (float64, float64, float64, error) { // var _ api.ChargeTimer = (*Etrel)(nil) // -// // ChargingTime implements the api.ChargeTimer interface -// func (wb *Etrel) ChargingTime() (time.Duration, error) { +// // ChargeDuration implements the api.ChargeTimer interface +// func (wb *Etrel) ChargeDuration() (time.Duration, error) { // b, err := wb.conn.ReadInputRegisters(wb.base+etrelRegChargeTime, 4) // if err != nil { // return 0, err diff --git a/charger/hesotec.go b/charger/hesotec.go index 1b5910874..9a6b913e7 100644 --- a/charger/hesotec.go +++ b/charger/hesotec.go @@ -154,8 +154,8 @@ func (wb *Hesotec) CurrentPower() (float64, error) { var _ api.ChargeTimer = (*Hesotec)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *Hesotec) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *Hesotec) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(hesotecRegDuration, 2) if err != nil { return 0, err diff --git a/charger/mcc.go b/charger/mcc.go index 4dc7cca05..d3784247c 100644 --- a/charger/mcc.go +++ b/charger/mcc.go @@ -340,8 +340,8 @@ func (mcc *MobileConnect) ChargedEnergy() (float64, error) { var _ api.ChargeTimer = (*MobileConnect)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (mcc *MobileConnect) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (mcc *MobileConnect) ChargeDuration() (time.Duration, error) { var currentSession MCCCurrentSession if err := mcc.getEscapedJSON(mcc.apiURL(mccAPICurrentSession), ¤tSession); err != nil { return 0, err diff --git a/charger/mcc_test.go b/charger/mcc_test.go index 9720f6a7c..1cfa41ba5 100644 --- a/charger/mcc_test.go +++ b/charger/mcc_test.go @@ -369,13 +369,13 @@ func TestMobileConnectChargingTime(t *testing.T) { t.Run(tc.name, func(t *testing.T) { mcc := NewTestMobileConnect(t, tc.responses) - got, err := mcc.ChargingTime() + got, err := mcc.ChargeDuration() if (err != nil) != tc.wantErr { - t.Errorf("MobileConnect.ChargingTime() error = %v, wantErr %v", err, tc.wantErr) + t.Errorf("MobileConnect.ChargeDuration() error = %v, wantErr %v", err, tc.wantErr) return } if got != tc.want { - t.Errorf("MobileConnect.ChargingTime() = %v, want %v", got, tc.want) + t.Errorf("MobileConnect.ChargeDuration() = %v, want %v", got, tc.want) } }) } diff --git a/charger/mennekes-compact.go b/charger/mennekes-compact.go index b713d0cc8..36415328a 100644 --- a/charger/mennekes-compact.go +++ b/charger/mennekes-compact.go @@ -248,8 +248,8 @@ func (wb *MennekesCompact) ChargedEnergy() (float64, error) { var _ api.ChargeTimer = (*MennekesCompact)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *MennekesCompact) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *MennekesCompact) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(mennekesRegDurationSession, 2) if err != nil { return 0, err diff --git a/charger/openevse.go b/charger/openevse.go index 9aacdc0c0..a0cab2951 100644 --- a/charger/openevse.go +++ b/charger/openevse.go @@ -205,7 +205,7 @@ func (c *OpenEVSE) ChargedEnergy() (float64, error) { var _ api.ChargeTimer = (*OpenEVSE)(nil) -func (c *OpenEVSE) ChargingTime() (time.Duration, error) { +func (c *OpenEVSE) ChargeDuration() (time.Duration, error) { res, err := c.statusG.Get() if err != nil { return 0, err diff --git a/charger/phoenix-charx.go b/charger/phoenix-charx.go index 7b3357cbb..4aa61a079 100644 --- a/charger/phoenix-charx.go +++ b/charger/phoenix-charx.go @@ -180,8 +180,8 @@ func (wb *PhoenixCharx) MaxCurrent(current int64) error { var _ api.ChargeTimer = (*PhoenixCharx)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *PhoenixCharx) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *PhoenixCharx) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(wb.register(charxRegChargeTime), 2) if err != nil { return 0, err diff --git a/charger/phoenix-em-eth.go b/charger/phoenix-em-eth.go index 7000834fa..7d02b531e 100644 --- a/charger/phoenix-em-eth.go +++ b/charger/phoenix-em-eth.go @@ -128,8 +128,8 @@ func (wb *PhoenixEMEth) MaxCurrent(current int64) error { var _ api.ChargeTimer = (*PhoenixEMEth)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *PhoenixEMEth) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *PhoenixEMEth) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadInputRegisters(phxEMEthRegChargeTime, 2) if err != nil { return 0, err diff --git a/charger/schneider-v3.go b/charger/schneider-v3.go index f743b064d..569a8b5a7 100644 --- a/charger/schneider-v3.go +++ b/charger/schneider-v3.go @@ -227,8 +227,8 @@ func (wb *Schneider) getPhaseValues(reg uint16) (float64, float64, float64, erro var _ api.ChargeTimer = (*Schneider)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *Schneider) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *Schneider) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(schneiderRegSessionChargingTime, 2) if err != nil { return 0, err diff --git a/charger/twc3.go b/charger/twc3.go index 416e8848b..9cb49ae3c 100644 --- a/charger/twc3.go +++ b/charger/twc3.go @@ -168,8 +168,8 @@ func (v *Twc3) ChargedEnergy() (float64, error) { var _ api.ChargeTimer = (*Twc3)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (v *Twc3) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (v *Twc3) ChargeDuration() (time.Duration, error) { res, err := v.vitalsG() return time.Duration(res.SessionS) * time.Second, err } diff --git a/charger/vestel.go b/charger/vestel.go index 210b7d5d1..f67be0d40 100644 --- a/charger/vestel.go +++ b/charger/vestel.go @@ -182,8 +182,8 @@ func (wb *Vestel) MaxCurrent(current int64) error { var _ api.ChargeTimer = (*Vestel)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *Vestel) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *Vestel) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadInputRegisters(vestelRegChargeTime, 2) if err != nil { return 0, err diff --git a/charger/webasto-next.go b/charger/webasto-next.go index d827ec907..4f009df33 100644 --- a/charger/webasto-next.go +++ b/charger/webasto-next.go @@ -181,8 +181,8 @@ func (wb *WebastoNext) MaxCurrent(current int64) error { var _ api.ChargeTimer = (*WebastoNext)(nil) -// ChargingTime implements the api.ChargeTimer interface -func (wb *WebastoNext) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (wb *WebastoNext) ChargeDuration() (time.Duration, error) { b, err := wb.conn.ReadHoldingRegisters(tqRegChargingTime, 2) if err != nil { return 0, err diff --git a/cmd/dumper.go b/cmd/dumper.go index 3b82d1f45..afc0e5255 100644 --- a/cmd/dumper.go +++ b/cmd/dumper.go @@ -133,7 +133,7 @@ func (d *dumper) Dump(name string, v interface{}) { } if v, ok := v.(api.ChargeTimer); ok { - if duration, err := v.ChargingTime(); err != nil { + if duration, err := v.ChargeDuration(); err != nil { fmt.Fprintf(w, "Duration:\t%v\n", err) } else { fmt.Fprintf(w, "Duration:\t%v\n", duration.Truncate(time.Second)) diff --git a/core/loadpoint.go b/core/loadpoint.go index 7f9aba93e..3a2c6508c 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -1394,7 +1394,7 @@ func (lp *Loadpoint) publishChargeProgress() { lp.log.ERROR.Printf("charge rater: %v", err) } - if d, err := lp.chargeTimer.ChargingTime(); err == nil { + if d, err := lp.chargeTimer.ChargeDuration(); err == nil { lp.chargeDuration = d.Round(time.Second) } else { lp.log.ERROR.Printf("charge timer: %v", err) diff --git a/core/loadpoint_test.go b/core/loadpoint_test.go index ecd6e4721..92ecbaf1a 100644 --- a/core/loadpoint_test.go +++ b/core/loadpoint_test.go @@ -29,7 +29,7 @@ func (n *Null) ChargedEnergy() (float64, error) { return 0, nil } -func (n *Null) ChargingTime() (time.Duration, error) { +func (n *Null) ChargeDuration() (time.Duration, error) { return 0, nil } diff --git a/core/wrapper/chargetimer.go b/core/wrapper/chargetimer.go index bf3f44ce5..8279fe88e 100644 --- a/core/wrapper/chargetimer.go +++ b/core/wrapper/chargetimer.go @@ -48,8 +48,8 @@ func (m *ChargeTimer) StopCharge() { m.duration += m.clck.Since(m.start) } -// ChargingTime implements the api.ChargeTimer interface -func (m *ChargeTimer) ChargingTime() (time.Duration, error) { +// ChargeDuration implements the api.ChargeTimer interface +func (m *ChargeTimer) ChargeDuration() (time.Duration, error) { m.Lock() defer m.Unlock() diff --git a/core/wrapper/chargetimer_test.go b/core/wrapper/chargetimer_test.go index a75192ca1..f97461660 100644 --- a/core/wrapper/chargetimer_test.go +++ b/core/wrapper/chargetimer_test.go @@ -17,7 +17,7 @@ func TestTimer(t *testing.T) { ct.StopCharge() clck.Add(time.Hour) - if d, err := ct.ChargingTime(); d != 1*time.Hour || err != nil { + if d, err := ct.ChargeDuration(); d != 1*time.Hour || err != nil { t.Error(d, err) } @@ -26,7 +26,7 @@ func TestTimer(t *testing.T) { clck.Add(2 * time.Hour) ct.StopCharge() - if d, err := ct.ChargingTime(); d != 3*time.Hour || err != nil { + if d, err := ct.ChargeDuration(); d != 3*time.Hour || err != nil { t.Error(d, err) } }