Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocpp1.6/core/get_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const GetConfigurationFeatureName = "GetConfiguration"
type ConfigurationKey struct {
Key string `json:"key" validate:"required,max=50"`
Readonly bool `json:"readonly"`
Value *string `json:"value,omitempty" validate:"omitempty,max=500"`
Value *string `json:"value,omitempty" validate:"omitempty,max=2000"`
Comment thread
andig marked this conversation as resolved.
Outdated
}

// The field definition of the GetConfiguration request payload sent by the Central System to the Charge Point.
Expand Down
11 changes: 6 additions & 5 deletions ocpp2.0.1/provisioning/get_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ type GetVariableData struct {
}

type GetVariableResult struct {
AttributeStatus GetVariableStatus `json:"attributeStatus" validate:"required,getVariableStatus"`
AttributeType types.Attribute `json:"attributeType,omitempty" validate:"omitempty,attribute"`
AttributeValue string `json:"attributeValue,omitempty" validate:"omitempty,max=1000"`
Component types.Component `json:"component" validate:"required"`
Variable types.Variable `json:"variable" validate:"required"`
AttributeStatus GetVariableStatus `json:"attributeStatus" validate:"required,getVariableStatus"`
AttributeStatusInfo *types.StatusInfo `json:"attributeStatusInfo,omitempty"`
AttributeType types.Attribute `json:"attributeType,omitempty" validate:"omitempty,attribute"`
AttributeValue string `json:"attributeValue,omitempty" validate:"omitempty,max=2500"`
Component types.Component `json:"component" validate:"required"`
Variable types.Variable `json:"variable" validate:"required"`
}

// The field definition of the GetVariables request payload sent by the CSMS to the Charging Station.
Expand Down
7 changes: 5 additions & 2 deletions ocpp2.0.1/smartcharging/get_composite_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ func isValidGetCompositeScheduleStatus(fl validator.FieldLevel) bool {
}

type CompositeSchedule struct {
StartDateTime *types.DateTime `json:"startDateTime,omitempty" validate:"omitempty"`
ChargingSchedule *types.ChargingSchedule `json:"chargingSchedule,omitempty" validate:"omitempty"`
EvseId int `json:"evseId" validate:"gte=0"`
Duration int `json:"duration" validate:"gte=0"`
ScheduleStart *types.DateTime `json:"scheduleStart" validate:"required"`
ChargingRateUnit types.ChargingRateUnitType `json:"chargingRateUnit" validate:"required,chargingRateUnit201"`
ChargingSchedulePeriod []types.ChargingSchedulePeriod `json:"chargingSchedulePeriod" validate:"required,min=1,dive"`
}

// The field definition of the GetCompositeSchedule request payload sent by the CSMS to the Charging System.
Expand Down
8 changes: 5 additions & 3 deletions ocpp2.0.1/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type OCSPRequestDataType struct {
IssuerNameHash string `json:"issuerNameHash" validate:"required,max=128"`
IssuerKeyHash string `json:"issuerKeyHash" validate:"required,max=128"`
SerialNumber string `json:"serialNumber" validate:"required,max=40"`
ResponderURL string `json:"responderURL,omitempty" validate:"max=512"`
ResponderURL string `json:"responderURL" validate:"required,max=512"`
}

// CertificateHashDataType
Expand Down Expand Up @@ -283,6 +283,7 @@ type IdTokenInfo struct {
ChargingPriority int `json:"chargingPriority,omitempty" validate:"min=-9,max=9"`
Language1 string `json:"language1,omitempty" validate:"max=8"`
Language2 string `json:"language2,omitempty" validate:"max=8"`
EvseId []int `json:"evseId,omitempty" validate:"omitempty,min=1,dive,gte=0"`
GroupIdToken *GroupIdToken `json:"groupIdToken,omitempty"`
PersonalMessage *MessageContent `json:"personalMessage,omitempty"`
}
Expand Down Expand Up @@ -386,7 +387,7 @@ type CostType struct {
// Contains price information and/or alternative costs.
type ConsumptionCost struct {
StartValue float64 `json:"startValue"` // The lowest level of consumption that defines the starting point of this consumption block
Cost []CostType `json:"cost" validate:"required,max=3,dive"` // Contains the cost details.
Cost []CostType `json:"cost" validate:"required,min=1,max=3,dive"` // Contains the cost details.
}

// NewConsumptionCost instantiates a new ConsumptionCost struct. No additional parameters need to be set.
Expand All @@ -401,7 +402,7 @@ func NewConsumptionCost(startValue float64, cost []CostType) ConsumptionCost {
type SalesTariffEntry struct {
EPriceLevel *int `json:"ePriceLevel,omitempty" validate:"omitempty,gte=0"` // The price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry.
RelativeTimeInterval RelativeTimeInterval `json:"relativeTimeInterval" validate:"required"` // The time interval the SalesTariffEntry is valid for, based upon relative times.
ConsumptionCost []ConsumptionCost `json:"consumptionCost,omitempty" validate:"omitempty,max=3,dive"` // Additional means for further relative price information and/or alternative costs.
ConsumptionCost []ConsumptionCost `json:"consumptionCost,omitempty" validate:"omitempty,min=1,max=3,dive"` // Additional means for further relative price information and/or alternative costs.
}

// Sales tariff associated with this charging schedule.
Expand Down Expand Up @@ -500,6 +501,7 @@ type ChargingSchedulePeriod struct {
StartPeriod int `json:"startPeriod" validate:"gte=0"`
Limit float64 `json:"limit" validate:"gte=0"`
NumberPhases *int `json:"numberPhases,omitempty" validate:"omitempty,gte=0"`
PhaseToUse *int `json:"phaseToUse,omitempty" validate:"omitempty,gte=1,lte=3"`
}

func NewChargingSchedulePeriod(startPeriod int, limit float64) ChargingSchedulePeriod {
Expand Down
7 changes: 4 additions & 3 deletions ocpp2.0.1_test/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ func (suite *OcppV2TestSuite) TestSalesTariffEntryValidation() {
var testTable = []GenericTestEntry{
{types.SalesTariffEntry{EPriceLevel: newInt(8), RelativeTimeInterval: types.RelativeTimeInterval{Start: 500, Duration: newInt(1200)}, ConsumptionCost: []types.ConsumptionCost{dummyCostType}}, true},
{types.SalesTariffEntry{EPriceLevel: newInt(8), RelativeTimeInterval: types.RelativeTimeInterval{Start: 500}}, true},
{types.SalesTariffEntry{EPriceLevel: newInt(8), RelativeTimeInterval: types.RelativeTimeInterval{Start: 0}}, true},
{types.SalesTariffEntry{RelativeTimeInterval: types.RelativeTimeInterval{Start: 0}}, true},
{types.SalesTariffEntry{RelativeTimeInterval: types.RelativeTimeInterval{Start: 0}}, true},
{types.SalesTariffEntry{EPriceLevel: newInt(8), RelativeTimeInterval: types.RelativeTimeInterval{}}, true},
{types.SalesTariffEntry{RelativeTimeInterval: types.RelativeTimeInterval{}}, true},
{types.SalesTariffEntry{}, true},
{types.SalesTariffEntry{EPriceLevel: newInt(-1), RelativeTimeInterval: types.RelativeTimeInterval{Start: 500, Duration: newInt(1200)}, ConsumptionCost: []types.ConsumptionCost{dummyCostType}}, false},
{types.SalesTariffEntry{EPriceLevel: newInt(8), RelativeTimeInterval: types.RelativeTimeInterval{Start: 500, Duration: newInt(-1)}, ConsumptionCost: []types.ConsumptionCost{dummyCostType}}, false},
{types.SalesTariffEntry{EPriceLevel: newInt(8), RelativeTimeInterval: types.RelativeTimeInterval{Start: 500, Duration: newInt(1200)}, ConsumptionCost: []types.ConsumptionCost{dummyCostType, dummyCostType, dummyCostType, dummyCostType}}, false},
Expand All @@ -169,7 +170,7 @@ func (suite *OcppV2TestSuite) TestSalesTariffEntryValidation() {
}

func (suite *OcppV2TestSuite) TestSalesTariffValidation() {
dummySalesTariffEntry := types.SalesTariffEntry{}
dummySalesTariffEntry := types.SalesTariffEntry{RelativeTimeInterval: types.RelativeTimeInterval{Start: 0}}
var testTable = []GenericTestEntry{
{types.SalesTariff{ID: 1, SalesTariffDescription: "someDesc", NumEPriceLevels: newInt(1), SalesTariffEntry: []types.SalesTariffEntry{dummySalesTariffEntry}}, true},
{types.SalesTariff{ID: 1, NumEPriceLevels: newInt(1), SalesTariffEntry: []types.SalesTariffEntry{dummySalesTariffEntry}}, true},
Expand Down
59 changes: 28 additions & 31 deletions ocpp2.0.1_test/get_composite_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ func (suite *OcppV2TestSuite) TestGetCompositeScheduleRequestValidation() {

func (suite *OcppV2TestSuite) TestGetCompositeScheduleConfirmationValidation() {
t := suite.T()
chargingSchedule := types.NewChargingSchedule(1, types.ChargingRateUnitWatts, types.NewChargingSchedulePeriod(0, 10.0))
chargingSchedule.Duration = newInt(600)
chargingSchedule.MinChargingRate = newFloat(6.0)
chargingSchedule.StartSchedule = types.NewDateTime(time.Now())
chargingSchedulePeriod := types.NewChargingSchedulePeriod(0, 10.0)
compositeSchedule := smartcharging.CompositeSchedule{
StartDateTime: types.NewDateTime(time.Now()),
ChargingSchedule: chargingSchedule,
EvseId: 1,
Duration: 600,
ScheduleStart: types.NewDateTime(time.Now()),
ChargingRateUnit: types.ChargingRateUnitWatts,
ChargingSchedulePeriod: []types.ChargingSchedulePeriod{chargingSchedulePeriod},
}
var confirmationTable = []GenericTestEntry{
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("reasoncode", ""), Schedule: &compositeSchedule}, true},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("reasoncode", ""), Schedule: &smartcharging.CompositeSchedule{}}, true},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("reasoncode", "")}, true},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted}, true},
{smartcharging.GetCompositeScheduleResponse{}, false},
{smartcharging.GetCompositeScheduleResponse{Status: "invalidGetCompositeScheduleStatus"}, false},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("invalidreasoncodeasitslongerthan20", "")}, false},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("", ""), Schedule: &smartcharging.CompositeSchedule{StartDateTime: types.NewDateTime(time.Now()), ChargingSchedule: types.NewChargingSchedule(1, "invalidChargingRateUnit")}}, false},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("", ""), Schedule: &smartcharging.CompositeSchedule{EvseId: 1, Duration: 600, ScheduleStart: types.NewDateTime(time.Now()), ChargingRateUnit: "invalidChargingRateUnit", ChargingSchedulePeriod: []types.ChargingSchedulePeriod{chargingSchedulePeriod}}}, false},
{smartcharging.GetCompositeScheduleResponse{Status: smartcharging.GetCompositeScheduleStatusAccepted, StatusInfo: types.NewStatusInfo("", ""), Schedule: &smartcharging.CompositeSchedule{EvseId: 1, Duration: 600, ScheduleStart: types.NewDateTime(time.Now()), ChargingRateUnit: types.ChargingRateUnitWatts, ChargingSchedulePeriod: []types.ChargingSchedulePeriod{}}}, false},
}
ExecuteGenericTestTable(t, confirmationTable)
}
Expand All @@ -62,17 +62,20 @@ func (suite *OcppV2TestSuite) TestGetCompositeScheduleE2EMocked() {
scheduleStart := types.NewDateTime(time.Now())
chargingSchedulePeriod := types.NewChargingSchedulePeriod(0, 10.0)
chargingSchedulePeriod.NumberPhases = newInt(3)
chargingSchedule := types.NewChargingSchedule(1, chargingRateUnit, chargingSchedulePeriod)
chargingSchedule.Duration = newInt(600)
chargingSchedule.StartSchedule = types.NewDateTime(time.Now())
chargingSchedule.MinChargingRate = newFloat(6.0)
statusInfo := types.NewStatusInfo("reasonCode", "")
compositeSchedule := smartcharging.CompositeSchedule{StartDateTime: scheduleStart, ChargingSchedule: chargingSchedule}
compositeSchedule := smartcharging.CompositeSchedule{
EvseId: evseID,
Duration: duration,
ScheduleStart: scheduleStart,
ChargingRateUnit: chargingRateUnit,
ChargingSchedulePeriod: []types.ChargingSchedulePeriod{chargingSchedulePeriod},
}
requestJson := fmt.Sprintf(`[2,"%v","%v",{"duration":%v,"chargingRateUnit":"%v","evseId":%v}]`,
messageId, smartcharging.GetCompositeScheduleFeatureName, duration, chargingRateUnit, evseID)
responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v","statusInfo":{"reasonCode":"%v"},"schedule":{"startDateTime":"%v","chargingSchedule":{"id":%v,"startSchedule":"%v","duration":%v,"chargingRateUnit":"%v","minChargingRate":%v,"chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v,"numberPhases":%v}]}}}]`,
messageId, status, statusInfo.ReasonCode, compositeSchedule.StartDateTime.FormatTimestamp(), chargingSchedule.ID, chargingSchedule.StartSchedule.FormatTimestamp(), *chargingSchedule.Duration, chargingSchedule.ChargingRateUnit, *chargingSchedule.MinChargingRate, chargingSchedulePeriod.StartPeriod, chargingSchedulePeriod.Limit, *chargingSchedulePeriod.NumberPhases)
responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v","statusInfo":{"reasonCode":"%v"},"schedule":{"evseId":%v,"duration":%v,"scheduleStart":"%v","chargingRateUnit":"%v","chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v,"numberPhases":%v}]}}]`,
messageId, status, statusInfo.ReasonCode, evseID, duration, compositeSchedule.ScheduleStart.FormatTimestamp(), chargingRateUnit, chargingSchedulePeriod.StartPeriod, chargingSchedulePeriod.Limit, *chargingSchedulePeriod.NumberPhases)
getCompositeScheduleConfirmation := smartcharging.NewGetCompositeScheduleResponse(status)
getCompositeScheduleConfirmation.StatusInfo = statusInfo
getCompositeScheduleConfirmation.Schedule = &compositeSchedule
channel := NewMockWebSocket(wsId)

Expand All @@ -98,22 +101,16 @@ func (suite *OcppV2TestSuite) TestGetCompositeScheduleE2EMocked() {
assert.Equal(t, status, confirmation.Status)
assert.Equal(t, statusInfo.ReasonCode, confirmation.StatusInfo.ReasonCode)
require.NotNil(t, confirmation.Schedule)
require.NotNil(t, confirmation.Schedule.StartDateTime)
assert.Equal(t, compositeSchedule.StartDateTime.FormatTimestamp(), confirmation.Schedule.StartDateTime.FormatTimestamp())
require.NotNil(t, confirmation.Schedule.ChargingSchedule)
assert.Equal(t, chargingSchedule.ID, confirmation.Schedule.ChargingSchedule.ID)
assert.Equal(t, chargingSchedule.ChargingRateUnit, confirmation.Schedule.ChargingSchedule.ChargingRateUnit)
require.NotNil(t, confirmation.Schedule.ChargingSchedule.Duration)
assert.Equal(t, *chargingSchedule.Duration, *confirmation.Schedule.ChargingSchedule.Duration)
require.NotNil(t, confirmation.Schedule.ChargingSchedule.MinChargingRate)
assert.Equal(t, *chargingSchedule.MinChargingRate, *confirmation.Schedule.ChargingSchedule.MinChargingRate)
require.NotNil(t, confirmation.Schedule.ChargingSchedule.StartSchedule)
assert.Equal(t, chargingSchedule.StartSchedule.FormatTimestamp(), confirmation.Schedule.ChargingSchedule.StartSchedule.FormatTimestamp())
require.Len(t, confirmation.Schedule.ChargingSchedule.ChargingSchedulePeriod, len(chargingSchedule.ChargingSchedulePeriod))
assert.Equal(t, chargingSchedule.ChargingSchedulePeriod[0].Limit, confirmation.Schedule.ChargingSchedule.ChargingSchedulePeriod[0].Limit)
assert.Equal(t, chargingSchedule.ChargingSchedulePeriod[0].StartPeriod, confirmation.Schedule.ChargingSchedule.ChargingSchedulePeriod[0].StartPeriod)
require.NotNil(t, confirmation.Schedule.ChargingSchedule.ChargingSchedulePeriod[0].NumberPhases)
assert.Equal(t, *chargingSchedule.ChargingSchedulePeriod[0].NumberPhases, *confirmation.Schedule.ChargingSchedule.ChargingSchedulePeriod[0].NumberPhases)
assert.Equal(t, evseID, confirmation.Schedule.EvseId)
assert.Equal(t, duration, confirmation.Schedule.Duration)
require.NotNil(t, confirmation.Schedule.ScheduleStart)
assert.Equal(t, compositeSchedule.ScheduleStart.FormatTimestamp(), confirmation.Schedule.ScheduleStart.FormatTimestamp())
assert.Equal(t, chargingRateUnit, confirmation.Schedule.ChargingRateUnit)
require.Len(t, confirmation.Schedule.ChargingSchedulePeriod, 1)
assert.Equal(t, chargingSchedulePeriod.Limit, confirmation.Schedule.ChargingSchedulePeriod[0].Limit)
assert.Equal(t, chargingSchedulePeriod.StartPeriod, confirmation.Schedule.ChargingSchedulePeriod[0].StartPeriod)
require.NotNil(t, confirmation.Schedule.ChargingSchedulePeriod[0].NumberPhases)
assert.Equal(t, *chargingSchedulePeriod.NumberPhases, *confirmation.Schedule.ChargingSchedulePeriod[0].NumberPhases)
resultChannel <- true
}, duration, evseID, func(request *smartcharging.GetCompositeScheduleRequest) {
request.ChargingRateUnit = chargingRateUnit
Expand Down
Loading
Loading