109 full impl

Signed-off-by: didinst <9f6129a2ddff0d0c6d03169eaa75e3fea1c1770f>
feature-evse-to-ev
didinst 3 years ago
parent 213f5b5bd5
commit 8642581449
Signed by untrusted user who does not match committer: didinst
GPG Key ID: 2EA0BE33BF9516AD
  1. 61
      chademo.go

@ -34,6 +34,12 @@ const (
CONNECTOR_LOCKED ConnectorLock = iota
CONNECTOR_UNLOCKED
BATTERY_COMPATIBLE BatteryCompatible = iota
BATTERY_INCOMPATIBLE
OPERATING StopControl = iota
SHUTDOWN_STOP
)
type VehicleChargingEnabled uint8
@ -52,6 +58,10 @@ type StationState uint8
type ConnectorLock uint8
type BatteryCompatible uint8
type StopControl uint8
type ChademoEvent interface {
// GetValue Return processed/calculated value and timestamp string
GetValue() (interface{}, *string)
@ -213,6 +223,9 @@ func FromCanFrames(frames <-chan *CanFrame) <-chan ChademoEvent {
events <- &StationStatus{frame}
events <- &StationMalfunction{frame}
events <- &VehicleConnectorLock{frame}
events <- &BatteryIncompatibility{frame}
events <- &ChargingSystemMalfunction{frame}
events <- &ChargerStopControl{frame}
}
}
}()
@ -297,6 +310,20 @@ func getConnectorLock(bytes *[]byte) ConnectorLock {
return CONNECTOR_UNLOCKED
}
func getBatteryCompatibility(bytes *[]uint8) BatteryCompatible {
if isBitSet((*bytes)[5], 3) {
return BATTERY_INCOMPATIBLE
}
return BATTERY_COMPATIBLE
}
func getChargerStopControl(bytes *[]uint8) StopControl {
if isBitSet((*bytes)[5], 5) {
return SHUTDOWN_STOP
}
return OPERATING
}
func (m MaximumBatteryVoltage) GetValue() (interface{}, *string) {
return bytesToUint16(m.payload[4:6]), &m.date
}
@ -425,6 +452,18 @@ func (v VehicleConnectorLock) GetValue() (interface{}, *string) {
return getConnectorLock(&v.payload), &v.date
}
func (b BatteryIncompatibility) GetValue() (interface{}, *string) {
return getBatteryCompatibility(&b.payload), &b.date
}
func (c ChargingSystemMalfunction) GetValue() (interface{}, *string) {
return getFault(&c.payload, 5, 4), &c.date
}
func (c ChargerStopControl) GetValue() (interface{}, *string) {
return getChargerStopControl(&c.payload), &c.date
}
func (v VehicleChargingEnabled) String() string {
switch v {
case DISABLED:
@ -512,3 +551,25 @@ func (c ConnectorLock) String() string {
panic("ConnectorLock not implemented")
}
}
func (b BatteryCompatible) String() string {
switch b {
case BATTERY_COMPATIBLE:
return "compatible"
case BATTERY_INCOMPATIBLE:
return "incompatible"
default:
panic("BatteryCompatible not implemented")
}
}
func (s StopControl) String() string {
switch s {
case OPERATING:
return "operating"
case SHUTDOWN_STOP:
return "shutdown or stop charging"
default:
panic("StopControl not implemented")
}
}

Loading…
Cancel
Save