forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vehicles: move more properties to /vehicles (BC) (evcc-io#11181)
- Loading branch information
Showing
26 changed files
with
182 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package api | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// ChargeMode is the charge operation mode. Valid values are off, now, minpv and pv | ||
type ChargeMode string | ||
|
||
// Charge modes | ||
const ( | ||
ModeEmpty ChargeMode = "" | ||
ModeOff ChargeMode = "off" | ||
ModeNow ChargeMode = "now" | ||
ModeMinPV ChargeMode = "minpv" | ||
ModePV ChargeMode = "pv" | ||
) | ||
|
||
// String implements Stringer | ||
func (c ChargeMode) String() string { | ||
return string(c) | ||
} | ||
|
||
// ChargeStatus is the EV's charging status from A to F | ||
type ChargeStatus string | ||
|
||
// Charging states | ||
const ( | ||
StatusNone ChargeStatus = "" | ||
StatusA ChargeStatus = "A" // Fzg. angeschlossen: nein Laden aktiv: nein Ladestation betriebsbereit, Fahrzeug getrennt | ||
StatusB ChargeStatus = "B" // Fzg. angeschlossen: ja Laden aktiv: nein Fahrzeug verbunden, Netzspannung liegt nicht an | ||
StatusC ChargeStatus = "C" // Fzg. angeschlossen: ja Laden aktiv: ja Fahrzeug lädt, Netzspannung liegt an | ||
StatusD ChargeStatus = "D" // Fzg. angeschlossen: ja Laden aktiv: ja Fahrzeug lädt mit externer Belüfungsanforderung (für Blei-Säure-Batterien) | ||
StatusE ChargeStatus = "E" // Fzg. angeschlossen: ja Laden aktiv: nein Fehler Fahrzeug / Kabel (CP-Kurzschluss, 0V) | ||
StatusF ChargeStatus = "F" // Fzg. angeschlossen: ja Laden aktiv: nein Fehler EVSE oder Abstecken simulieren (CP-Wake-up, -12V) | ||
) | ||
|
||
var StatusEasA = map[ChargeStatus]ChargeStatus{StatusE: StatusA} | ||
|
||
// ChargeStatusString converts a string to ChargeStatus | ||
func ChargeStatusString(status string) (ChargeStatus, error) { | ||
s := strings.ToUpper(strings.Trim(status, "\x00 ")) | ||
|
||
if len(s) == 0 { | ||
return StatusNone, fmt.Errorf("invalid status: %s", status) | ||
} | ||
|
||
switch s1 := s[:1]; s1 { | ||
case "A", "B": | ||
return ChargeStatus(s1), nil | ||
|
||
case "C", "D": | ||
if s == "C1" || s == "D1" { | ||
return StatusB, nil | ||
} | ||
return StatusC, nil | ||
|
||
case "E", "F": | ||
return ChargeStatus(s1), fmt.Errorf("invalid status: %s", s) | ||
|
||
default: | ||
return StatusNone, fmt.Errorf("invalid status: %s", status) | ||
} | ||
} | ||
|
||
// ChargeStatusStringWithMapping converts a string to ChargeStatus. In case of error, mapping is applied. | ||
func ChargeStatusStringWithMapping(s string, m map[ChargeStatus]ChargeStatus) (ChargeStatus, error) { | ||
status, err := ChargeStatusString(s) | ||
if mappedStatus, ok := m[status]; ok && err != nil { | ||
return mappedStatus, nil | ||
} | ||
return status, err | ||
} | ||
|
||
// String implements Stringer | ||
func (c ChargeStatus) String() string { | ||
return string(c) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.