|
|
|
|
@ -2,12 +2,69 @@ package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"time" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
CAN_ID_100 = 0x100 |
|
|
|
|
CAN_ID_101 = 0x101 |
|
|
|
|
CAN_ID_102 = 0x102 |
|
|
|
|
CAN_ID_108 = 0x108 |
|
|
|
|
CAN_ID_109 = 0x109 |
|
|
|
|
|
|
|
|
|
DISABLED VehicleChargingEnabled = iota |
|
|
|
|
ENABLED |
|
|
|
|
|
|
|
|
|
PARKING ShiftLeverPosition = iota |
|
|
|
|
OTHER |
|
|
|
|
|
|
|
|
|
NORMAL SystemFault = iota |
|
|
|
|
FAULT |
|
|
|
|
|
|
|
|
|
CONTACTOR_CLOSED ContactorVehicleStatus = iota |
|
|
|
|
CONTACTOR_OPEN |
|
|
|
|
|
|
|
|
|
NO_REQUEST StopRequest = iota |
|
|
|
|
STOP_REQUEST |
|
|
|
|
|
|
|
|
|
VEHICLE_WELDING_DETECTION_SUPPORTED SuppVehicleWeldingDetection = iota |
|
|
|
|
VEHICLE_WELDING_DETECTION_NOT_SUPPORTED |
|
|
|
|
|
|
|
|
|
STANDBY StationState = iota |
|
|
|
|
CHARGING |
|
|
|
|
|
|
|
|
|
CONNECTOR_LOCKED ConnectorLock = iota |
|
|
|
|
CONNECTOR_UNLOCKED |
|
|
|
|
|
|
|
|
|
BATTERY_COMPATIBLE BatteryCompatible = iota |
|
|
|
|
BATTERY_INCOMPATIBLE |
|
|
|
|
|
|
|
|
|
OPERATING StopControl = iota |
|
|
|
|
SHUTDOWN_STOP |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type VehicleChargingEnabled uint8 |
|
|
|
|
|
|
|
|
|
type ShiftLeverPosition uint8 |
|
|
|
|
|
|
|
|
|
type SystemFault uint8 |
|
|
|
|
|
|
|
|
|
type ContactorVehicleStatus uint8 |
|
|
|
|
|
|
|
|
|
type StopRequest uint8 |
|
|
|
|
|
|
|
|
|
type SuppVehicleWeldingDetection uint8 |
|
|
|
|
|
|
|
|
|
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{}, *time.Time) |
|
|
|
|
GetValue() (interface{}, *string) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type frame struct { |
|
|
|
|
@ -267,142 +324,252 @@ func getChargerStopControl(bytes *[]uint8) StopControl { |
|
|
|
|
return OPERATING |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (m MaximumBatteryVoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return bytesToUint16((*m.payload)[4:6]), m.date |
|
|
|
|
func (m MaximumBatteryVoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return bytesToUint16(m.payload[4:6]), &m.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ConstChargingRateInd) GetValue() (interface{}, *string) { |
|
|
|
|
return c.payload[6], &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BatteryCapacity) GetValue() (interface{}, *string) { |
|
|
|
|
return 0.1 * float32(bytesToUint16(b.payload[5:7])), &b.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ConstChargingRateInd) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*c.payload)[6], c.date |
|
|
|
|
func (m MaxChargingTimeS) GetValue() (interface{}, *string) { |
|
|
|
|
return 10 * uint16(m.payload[1]), &m.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BatteryCapacity) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return 0.1 * float32(bytesToUint16((*b.payload)[5:7])), b.date |
|
|
|
|
func (m MaxChargingTimeM) GetValue() (interface{}, *string) { |
|
|
|
|
return m.payload[2], &m.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (m MaxChargingTimeS) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return 10 * uint16((*m.payload)[1]), m.date |
|
|
|
|
func (e EstChargingTimeM) GetValue() (interface{}, *string) { |
|
|
|
|
return e.payload[3], &e.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (m MaxChargingTimeM) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*m.payload)[2], m.date |
|
|
|
|
func (c EVControlProtocolNumber) GetValue() (interface{}, *string) { |
|
|
|
|
return c.payload[0], &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e EstChargingTimeM) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*e.payload)[3], e.date |
|
|
|
|
func (t TargetBatteryVoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return bytesToUint16(t.payload[1:3]), &t.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c EVControlProtocolNumber) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*c.payload)[0], c.date |
|
|
|
|
func (c ChargingCurrentReq) GetValue() (interface{}, *string) { |
|
|
|
|
return c.payload[3], &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (t TargetBatteryVoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return bytesToUint16((*t.payload)[1:3]), t.date |
|
|
|
|
func (c ChargingRate) GetValue() (interface{}, *string) { |
|
|
|
|
return c.payload[6], &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ChargingCurrentReq) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*c.payload)[3], c.date |
|
|
|
|
func (s ShiftLever) GetValue() (interface{}, *string) { |
|
|
|
|
return getVehicleShiftLever(&s.payload), &s.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ChargingRate) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*c.payload)[6], c.date |
|
|
|
|
func (v VehicleCharging) GetValue() (interface{}, *string) { |
|
|
|
|
return getVehicleCharging(&v.payload), &v.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s ShiftLever) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getVehicleShiftLever(s.payload), s.date |
|
|
|
|
func (c ChargingSystemFault) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&c.payload, 5, 2), &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (v VehicleCharging) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getVehicleCharging(v.payload), v.date |
|
|
|
|
func (v VehicleStatus) GetValue() (interface{}, *string) { |
|
|
|
|
return getVehicleStatus(&v.payload), &v.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ChargingSystemFault) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(c.payload, 5, 2), c.date |
|
|
|
|
func (n NormalStopReq) GetValue() (interface{}, *string) { |
|
|
|
|
return getNormalStopReq(&n.payload), &n.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (v VehicleStatus) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getVehicleStatus(v.payload), v.date |
|
|
|
|
func (b BattOvervoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&b.payload, 4, 0), &b.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (n NormalStopReq) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getNormalStopReq(n.payload), n.date |
|
|
|
|
func (b BattUndervoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&b.payload, 4, 1), &b.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BattOvervoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(b.payload, 4, 0), b.date |
|
|
|
|
func (b BattCurrentDeviationErr) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&b.payload, 4, 2), &b.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BattUndervoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(b.payload, 4, 1), b.date |
|
|
|
|
func (h HighBattTemperature) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&h.payload, 4, 3), &h.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BattCurrentDeviationErr) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(b.payload, 4, 2), b.date |
|
|
|
|
func (b BattVoltageDeviationErr) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&b.payload, 4, 4), &b.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (h HighBattTemperature) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(h.payload, 4, 3), h.date |
|
|
|
|
func (e EVcontWeldingDetectSupport) GetValue() (interface{}, *string) { |
|
|
|
|
return evWeldingDetectionSupport(&e.payload), &e.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BattVoltageDeviationErr) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(b.payload, 4, 4), b.date |
|
|
|
|
func (a AvailableOutputVoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return bytesToUint16(a.payload[1:3]), &a.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e EVcontWeldingDetectSupport) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return evWeldingDetectionSupport(e.payload), e.date |
|
|
|
|
func (a AvailableOutputCurrent) GetValue() (interface{}, *string) { |
|
|
|
|
return a.payload[3], &a.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a AvailableOutputVoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return bytesToUint16((*a.payload)[1:3]), a.date |
|
|
|
|
func (t ThresholdVoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return bytesToUint16(t.payload[4:6]), &t.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a AvailableOutputCurrent) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*a.payload)[3], a.date |
|
|
|
|
func (e EVSEControlProtocolNumber) GetValue() (interface{}, *string) { |
|
|
|
|
return e.payload[0], &e.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (t ThresholdVoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return bytesToUint16((*t.payload)[4:6]), t.date |
|
|
|
|
func (o OutputVoltage) GetValue() (interface{}, *string) { |
|
|
|
|
return bytesToUint16(o.payload[1:3]), &o.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e EVSEControlProtocolNumber) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*e.payload)[0], e.date |
|
|
|
|
func (o OutputCurrent) GetValue() (interface{}, *string) { |
|
|
|
|
return o.payload[3], &o.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (o OutputVoltage) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return bytesToUint16((*o.payload)[1:3]), o.date |
|
|
|
|
func (r RemainingChargingTimeS) GetValue() (interface{}, *string) { |
|
|
|
|
return r.payload[6] * 10, &r.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (o OutputCurrent) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*o.payload)[3], o.date |
|
|
|
|
func (r RemainingChargingTimeM) GetValue() (interface{}, *string) { |
|
|
|
|
return r.payload[7], &r.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r RemainingChargingTimeS) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*r.payload)[6] * 10, r.date |
|
|
|
|
func (s StationStatus) GetValue() (interface{}, *string) { |
|
|
|
|
return getStationState(&s.payload), &s.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r RemainingChargingTimeM) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return (*r.payload)[7], r.date |
|
|
|
|
func (s StationMalfunction) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&s.payload, 5, 1), &s.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s StationStatus) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getStationState(s.payload), s.date |
|
|
|
|
func (v VehicleConnectorLock) GetValue() (interface{}, *string) { |
|
|
|
|
return getConnectorLock(&v.payload), &v.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s StationMalfunction) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(s.payload, 5, 1), s.date |
|
|
|
|
func (b BatteryIncompatibility) GetValue() (interface{}, *string) { |
|
|
|
|
return getBatteryCompatibility(&b.payload), &b.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (v VehicleConnectorLock) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getConnectorLock(v.payload), v.date |
|
|
|
|
func (c ChargingSystemMalfunction) GetValue() (interface{}, *string) { |
|
|
|
|
return getFault(&c.payload, 5, 4), &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b BatteryIncompatibility) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getBatteryCompatibility(b.payload), b.date |
|
|
|
|
func (c ChargerStopControl) GetValue() (interface{}, *string) { |
|
|
|
|
return getChargerStopControl(&c.payload), &c.date |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ChargingSystemMalfunction) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getFault(c.payload, 5, 4), c.date |
|
|
|
|
func (v VehicleChargingEnabled) String() string { |
|
|
|
|
switch v { |
|
|
|
|
case DISABLED: |
|
|
|
|
return "disabled" |
|
|
|
|
case ENABLED: |
|
|
|
|
return "enabled" |
|
|
|
|
default: |
|
|
|
|
panic("VehicleChargingEnabled not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s ShiftLeverPosition) String() string { |
|
|
|
|
switch s { |
|
|
|
|
case PARKING: |
|
|
|
|
return "parking" |
|
|
|
|
case OTHER: |
|
|
|
|
return "other" |
|
|
|
|
default: |
|
|
|
|
panic("ShiftLeverPosition not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s SystemFault) String() string { |
|
|
|
|
switch s { |
|
|
|
|
case NORMAL: |
|
|
|
|
return "normal" |
|
|
|
|
case FAULT: |
|
|
|
|
return "fault" |
|
|
|
|
default: |
|
|
|
|
panic("SystemFault not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ContactorVehicleStatus) String() string { |
|
|
|
|
switch c { |
|
|
|
|
case CONTACTOR_CLOSED: |
|
|
|
|
return "contactor closed" |
|
|
|
|
case CONTACTOR_OPEN: |
|
|
|
|
return "contactor open" |
|
|
|
|
default: |
|
|
|
|
panic("ContactorVehicleStatus not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s StopRequest) String() string { |
|
|
|
|
switch s { |
|
|
|
|
case NO_REQUEST: |
|
|
|
|
return "no request" |
|
|
|
|
case STOP_REQUEST: |
|
|
|
|
return "stop request" |
|
|
|
|
default: |
|
|
|
|
panic("StopRequest not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ChargerStopControl) GetValue() (interface{}, *time.Time) { |
|
|
|
|
return getChargerStopControl(c.payload), c.date |
|
|
|
|
func (s SuppVehicleWeldingDetection) String() string { |
|
|
|
|
switch s { |
|
|
|
|
case VEHICLE_WELDING_DETECTION_NOT_SUPPORTED: |
|
|
|
|
return "not supported" |
|
|
|
|
case VEHICLE_WELDING_DETECTION_SUPPORTED: |
|
|
|
|
return "supported" |
|
|
|
|
default: |
|
|
|
|
panic("SuppVehicleWeldingDetection not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s StationState) String() string { |
|
|
|
|
switch s { |
|
|
|
|
case CHARGING: |
|
|
|
|
return "charging" |
|
|
|
|
case STANDBY: |
|
|
|
|
return "standby" |
|
|
|
|
default: |
|
|
|
|
panic("StationState not implemented") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c ConnectorLock) String() string { |
|
|
|
|
switch c { |
|
|
|
|
case CONNECTOR_LOCKED: |
|
|
|
|
return "locked" |
|
|
|
|
case CONNECTOR_UNLOCKED: |
|
|
|
|
return "unlocked" |
|
|
|
|
default: |
|
|
|
|
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") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|