diff --git a/api/configuration.go b/api/configuration.go index 9d5f40c8..150e3a5d 100644 --- a/api/configuration.go +++ b/api/configuration.go @@ -64,11 +64,6 @@ type Configuration struct { // The certificate used for the service and its connections, required certificate tls.Certificate - // The sites grid voltage - // This is useful when e.g. power values are not available and therefor - // need to be calculated using the current values - voltage float64 - // The timeout to be used for sending heartbeats heartbeatTimeout time.Duration @@ -86,13 +81,11 @@ func NewConfiguration( entityTypes []model.EntityTypeType, port int, certificate tls.Certificate, - voltage float64, heartbeatTimeout time.Duration, ) (*Configuration, error) { configuration := &Configuration{ certificate: certificate, port: port, - voltage: voltage, heartbeatTimeout: heartbeatTimeout, mdnsProviderSelection: mdns.MdnsProviderSelectionGoZeroConfOnly, } @@ -242,11 +235,6 @@ func (s *Configuration) SetCertificate(cert tls.Certificate) { s.certificate = cert } -// return the sites predefined grid voltage -func (s *Configuration) Voltage() float64 { - return s.voltage -} - func (s *Configuration) HeartbeatTimeout() time.Duration { return s.heartbeatTimeout } diff --git a/api/configuration_test.go b/api/configuration_test.go index 6b2e388c..5e4bfbaa 100644 --- a/api/configuration_test.go +++ b/api/configuration_test.go @@ -27,54 +27,53 @@ func (s *ConfigurationSuite) Test_Configuration() { model := "model" serial := "serial" port := 4567 - volt := 230.0 heartbeatTimeout := time.Second * 4 entityTypes := []spinemodel.EntityTypeType{spinemodel.EntityTypeTypeCEM} config, err := NewConfiguration("", brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, 0, certificate, volt, heartbeatTimeout) + entityTypes, 0, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration("", brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, volt, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, "", model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, "", serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, "", spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, serial, "", - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - []spinemodel.EntityTypeType{}, port, certificate, 230, heartbeatTimeout) + []spinemodel.EntityTypeType{}, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.NotNil(s.T(), config) assert.Nil(s.T(), err) @@ -110,9 +109,6 @@ func (s *ConfigurationSuite) Test_Configuration() { id = config.MdnsServiceName() assert.Equal(s.T(), alternate, id) - voltage := config.Voltage() - assert.Equal(s.T(), volt, voltage) - portValue := config.Port() assert.Equal(s.T(), port, portValue) diff --git a/cmd/controlbox/main.go b/cmd/controlbox/main.go index 77647385..3452e5a2 100644 --- a/cmd/controlbox/main.go +++ b/cmd/controlbox/main.go @@ -78,7 +78,7 @@ func (h *controlbox) run() { "Demo", "Demo", "ControlBox", "123456789", model.DeviceTypeTypeElectricitySupplySystem, []model.EntityTypeType{model.EntityTypeTypeGridGuard}, - port, certificate, 230, time.Second*60) + port, certificate, time.Second*60) if err != nil { log.Fatal(err) } diff --git a/cmd/evse/main.go b/cmd/evse/main.go index b43e0bf2..11a2a8a5 100644 --- a/cmd/evse/main.go +++ b/cmd/evse/main.go @@ -74,7 +74,7 @@ func (h *evse) run() { "Demo", "Demo", "EVSE", "234567890", model.DeviceTypeTypeChargingStation, []model.EntityTypeType{model.EntityTypeTypeEVSE}, - port, certificate, 230, time.Second*4) + port, certificate, time.Second*4) if err != nil { log.Fatal(err) } diff --git a/cmd/hems/main.go b/cmd/hems/main.go index 1afc046f..9d825a85 100644 --- a/cmd/hems/main.go +++ b/cmd/hems/main.go @@ -80,7 +80,7 @@ func (h *hems) run() { "Demo", "Demo", "HEMS", "123456789", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - port, certificate, 230, time.Second*4) + port, certificate, time.Second*4) if err != nil { log.Fatal(err) } diff --git a/features/client/feature.go b/features/client/feature.go index 58ed51b2..cc695970 100644 --- a/features/client/feature.go +++ b/features/client/feature.go @@ -2,6 +2,7 @@ package client import ( "errors" + "fmt" "github.com/enbility/eebus-go/api" spineapi "github.com/enbility/spine-go/api" @@ -135,7 +136,8 @@ func (f *Feature) requestData(function model.FunctionType, selectors any, elemen fTypes := f.featureRemote.Operations() op, exists := fTypes[function] if !exists || !op.Read() { - return nil, api.ErrOperationOnFunctionNotSupported + errWithFunction := fmt.Sprintf("%s %s", api.ErrOperationOnFunctionNotSupported.Error(), function) + return nil, errors.New(errWithFunction) } // remove the selectors if the remote does not allow partial reads diff --git a/features/client/feature_test.go b/features/client/feature_test.go index 326c50ee..cf49aa07 100644 --- a/features/client/feature_test.go +++ b/features/client/feature_test.go @@ -155,6 +155,14 @@ func (s *FeatureSuite) Test_requestData() { assert.Nil(s.T(), err) assert.NotNil(s.T(), counter) + counter, err = s.testFeature2.requestData(model.FunctionTypeMeasurementDescriptionListData, nil, nil) + assert.NotNil(s.T(), err) + assert.Nil(s.T(), counter) + + counter, err = s.testFeature2.requestData(model.FunctionTypeLoadControlLimitListData, nil, nil) + assert.Nil(s.T(), err) + assert.NotNil(s.T(), counter) + selectors2 := &model.LoadControlLimitListDataSelectorsType{ LimitId: util.Ptr(model.LoadControlLimitIdType(0)), } diff --git a/features/server/deviceconfiguration_test.go b/features/server/deviceconfiguration_test.go index 77d96133..576bbe43 100644 --- a/features/server/deviceconfiguration_test.go +++ b/features/server/deviceconfiguration_test.go @@ -42,7 +42,7 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/devicediagnosis_test.go b/features/server/devicediagnosis_test.go index aac1de9d..26ac0afe 100644 --- a/features/server/devicediagnosis_test.go +++ b/features/server/devicediagnosis_test.go @@ -42,7 +42,7 @@ func (s *DeviceDiagnosisSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/electricalconnection_test.go b/features/server/electricalconnection_test.go index 5488c479..7400fe5b 100644 --- a/features/server/electricalconnection_test.go +++ b/features/server/electricalconnection_test.go @@ -42,7 +42,7 @@ func (s *ElectricalConnectionSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/feature_test.go b/features/server/feature_test.go index 22b4a0d1..f6643f73 100644 --- a/features/server/feature_test.go +++ b/features/server/feature_test.go @@ -47,7 +47,7 @@ func (s *FeatureSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/loadcontrol_test.go b/features/server/loadcontrol_test.go index aed2a4ea..2bd071f0 100644 --- a/features/server/loadcontrol_test.go +++ b/features/server/loadcontrol_test.go @@ -42,7 +42,7 @@ func (s *LoadControlSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/measurement_test.go b/features/server/measurement_test.go index 00fee5f7..3b526b90 100644 --- a/features/server/measurement_test.go +++ b/features/server/measurement_test.go @@ -42,7 +42,7 @@ func (s *MeasurementSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/go.mod b/go.mod index 53936cf7..c42d1275 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/enbility/eebus-go go 1.21.1 require ( - github.com/enbility/ship-go v0.5.1 - github.com/enbility/spine-go v0.6.0 + github.com/enbility/ship-go v0.5.2 + github.com/enbility/spine-go v0.6.1 github.com/stretchr/testify v1.9.0 ) diff --git a/go.sum b/go.sum index 9656024a..f44f23bc 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/ahmetb/go-linq/v3 v3.2.0 h1:BEuMfp+b59io8g5wYzNoFe9pWPalRklhlhbiU3hYZ github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/kLZh/cj9U= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/enbility/ship-go v0.5.1 h1:8Vax1MpyI/C+kQlMFAzQ7/h/xJ7fuumSLJy9FYgEkcE= -github.com/enbility/ship-go v0.5.1/go.mod h1:jewJWYQ10jNhsnhS1C4jESx3CNmDa5HNWZjBhkTug5Y= -github.com/enbility/spine-go v0.6.0 h1:sd5x9ZckvhI9b07HrdxKEZAcpF1Jt+xMC46o3VpuwoY= -github.com/enbility/spine-go v0.6.0/go.mod h1:1SJ6+ihCkjzVALXXbB3xdjDGp2ITqq9gnJQiPsF3fb0= +github.com/enbility/ship-go v0.5.2 h1:T9+YuP5ZpofKd463PLKq78fAaPAcGMnRAcv8c8aD5yU= +github.com/enbility/ship-go v0.5.2/go.mod h1:jewJWYQ10jNhsnhS1C4jESx3CNmDa5HNWZjBhkTug5Y= +github.com/enbility/spine-go v0.6.1 h1:6NAPE7PmCQsmfiZy/dLpnFZXEw8RK9H4USGniIw9r+Q= +github.com/enbility/spine-go v0.6.1/go.mod h1:pRGS+C5rZ5rhxTAA1whU8fC9p7lH5ixyut++yEZe470= github.com/enbility/zeroconf/v2 v2.0.0-20240210101930-d0004078577b h1:sg3c6LJ4eWffwtt9SW0lgcIX4Oh274vwdJnNFNNrDco= github.com/enbility/zeroconf/v2 v2.0.0-20240210101930-d0004078577b/go.mod h1:BjzRRiYX6mWdOgku1xxDE+NsV8PijTby7Q7BkYVdfDU= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= diff --git a/service/service_test.go b/service/service_test.go index 848c6d6c..62a70bfa 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -50,7 +50,7 @@ func (s *ServiceSuite) BeforeTest(suiteName, testName string) { var err error s.config, err = api.NewConfiguration( "vendor", "brand", "model", "serial", model.DeviceTypeTypeEnergyManagementSystem, - []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, 230.0, time.Second*4) + []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, time.Second*4) assert.Nil(s.T(), nil, err) s.sut = NewService(s.config, s.serviceReader) @@ -179,7 +179,7 @@ func (s *ServiceSuite) Test_Setup_IANA() { certificate := tls.Certificate{} s.config, err = api.NewConfiguration( "12345", "brand", "model", "serial", model.DeviceTypeTypeEnergyManagementSystem, - []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, 230.0, time.Second*4) + []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, time.Second*4) assert.Nil(s.T(), nil, err) s.sut = NewService(s.config, s.serviceReader) @@ -219,7 +219,7 @@ func (s *ServiceSuite) Test_Setup_Error_DeviceName() { "modelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodel", "serialserialserialserialserialserialserialserialserialserialserialserialserialserialserialserialserial", model.DeviceTypeTypeEnergyManagementSystem, - []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, 230.0, time.Second*4) + []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, time.Second*4) assert.Nil(s.T(), nil, err) s.sut = NewService(s.config, s.serviceReader) diff --git a/usecases/README.md b/usecases/README.md index 230ee146..47a977b1 100644 --- a/usecases/README.md +++ b/usecases/README.md @@ -29,12 +29,8 @@ Actors: - `lpc`: Limitation of Power Consumption - `lpp`: Limitation of Power Production -- `gcp`: Grid Connection Point - - Use Cases: - - `mgcp`: Monitoring of Grid Connection Point - - `ma`: Monitoring Appliance Use Cases: - `mpc`: Monitoring of Power Consumption + - `mgcp`: Monitoring of Grid Connection Point diff --git a/usecases/cem/cevc/testhelper_test.go b/usecases/cem/cevc/testhelper_test.go index 63bc0855..1d665f30 100644 --- a/usecases/cem/cevc/testhelper_test.go +++ b/usecases/cem/cevc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemCEVCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evcc/testhelper_test.go b/usecases/cem/evcc/testhelper_test.go index 738dd956..b2ee9b21 100644 --- a/usecases/cem/evcc/testhelper_test.go +++ b/usecases/cem/evcc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVCCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evcem/public.go b/usecases/cem/evcem/public.go index 3373402f..ff1a9051 100644 --- a/usecases/cem/evcem/public.go +++ b/usecases/cem/evcem/public.go @@ -1,8 +1,6 @@ package evcem import ( - "time" - "github.com/enbility/eebus-go/api" "github.com/enbility/eebus-go/features/client" ucapi "github.com/enbility/eebus-go/usecases/api" @@ -64,8 +62,6 @@ func (e *EVCEM) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float6 } var result []float64 - refetch := true - compare := time.Now().UTC().Add(-1 * time.Minute) for _, phase := range ucapi.PhaseNameMapping { for _, item := range data { @@ -84,32 +80,9 @@ func (e *EVCEM) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float6 phaseValue := item.Value.GetValue() result = append(result, phaseValue) - - if item.Timestamp == nil { - continue - } - - if timestamp, err := item.Timestamp.GetTime(); err == nil { - refetch = timestamp.Before(compare) - } - - // the MEB cars report the wrong NTP time by 1 or 2 hours (depending on DST) - // and PMCC uses NTP from the EV, so check these cases as well - for i := 0; i < 2 && refetch; i++ { - compare = compare.Add(-1 * time.Hour) - if timestamp, err := item.Timestamp.GetTime(); err == nil { - refetch = timestamp.Before(compare) - } - } } } - // if there was no timestamp provided or the time for the last value - // is older than 1 minute, send a read request - if refetch { - _, _ = evMeasurement.RequestData(nil, nil) - } - return result, nil } @@ -131,23 +104,15 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, var data []model.MeasurementDataType - powerAvailable := true filter := model.MeasurementDescriptionDataType{ MeasurementType: util.Ptr(model.MeasurementTypeTypePower), CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), ScopeType: util.Ptr(model.ScopeTypeTypeACPower), } data, err = evMeasurement.GetDataForFilter(filter) - if err != nil || len(data) == 0 { - powerAvailable = false - - // If power is not provided, fall back to power calculations via currents - filter.MeasurementType = util.Ptr(model.MeasurementTypeTypeCurrent) - filter.ScopeType = util.Ptr(model.ScopeTypeTypeACCurrent) - data, err = evMeasurement.GetDataForFilter(filter) - if err != nil || len(data) == 0 { - return nil, api.ErrDataNotAvailable - } + // Elli Charger Connect/Pro (Gen1) returns power descriptions, but only measurements without actual values, see test case Test_EVPowerPerPhase_Current + if err != nil || len(data) == 0 || data[0].Value == nil { + return nil, api.ErrDataNotAvailable } var result []float64 @@ -168,10 +133,6 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, } phaseValue := item.Value.GetValue() - if !powerAvailable { - phaseValue *= e.service.Configuration().Voltage() - } - result = append(result, phaseValue) } } diff --git a/usecases/cem/evcem/public_test.go b/usecases/cem/evcem/public_test.go index 8f65541f..72c11adf 100644 --- a/usecases/cem/evcem/public_test.go +++ b/usecases/cem/evcem/public_test.go @@ -249,9 +249,58 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { { ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeAbc), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(1)), MeasurementId: util.Ptr(model.MeasurementIdType(0)), ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(2)), + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(3)), + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(4)), + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(5)), + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(6)), + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(7)), + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeAbc), + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), }, }, } @@ -271,6 +320,49 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeCharge), + Unit: util.Ptr(model.UnitOfMeasurementTypeWh), }, }, } @@ -287,7 +379,27 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { MeasurementData: []model.MeasurementDataType{ { MeasurementId: util.Ptr(model.MeasurementIdType(0)), - Value: model.NewScaledNumberType(10), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + Value: model.NewScaledNumberType(4.04), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), }, }, } @@ -296,8 +408,8 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { assert.Nil(s.T(), fErr) data, err = s.sut.PowerPerPhase(s.evEntity) - assert.Nil(s.T(), err) - assert.Equal(s.T(), 2300.0, data[0]) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0, len(data)) } func (s *CemEVCEMSuite) Test_EVChargedEnergy() { @@ -344,3 +456,111 @@ func (s *CemEVCEMSuite) Test_EVChargedEnergy() { assert.Nil(s.T(), err) assert.Equal(s.T(), 80.0, data) } + +func (s *CemEVCEMSuite) Test_EVChargedEnergy_ElliGen1() { + data, err := s.sut.EnergyCharged(s.mockRemoteEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) + + data, err = s.sut.EnergyCharged(s.evEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) + + measDesc := &model.MeasurementDescriptionListDataType{ + MeasurementDescriptionData: []model.MeasurementDescriptionDataType{ + { + MeasurementId: util.Ptr(model.MeasurementIdType(0)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeCharge), + Unit: util.Ptr(model.UnitOfMeasurementTypeWh), + }, + }, + } + + rFeature := s.remoteDevice.FeatureByEntityTypeAndRole(s.evEntity, model.FeatureTypeTypeMeasurement, model.RoleTypeServer) + fErr := rFeature.UpdateData(model.FunctionTypeMeasurementDescriptionListData, measDesc, nil, nil) + assert.Nil(s.T(), fErr) + + data, err = s.sut.EnergyCharged(s.evEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) + + measData := &model.MeasurementListDataType{ + MeasurementData: []model.MeasurementDataType{ + { + MeasurementId: util.Ptr(model.MeasurementIdType(0)), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + Value: model.NewScaledNumberType(4.04), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + }, + }, + } + + fErr = rFeature.UpdateData(model.FunctionTypeMeasurementListData, measData, nil, nil) + assert.Nil(s.T(), fErr) + + data, err = s.sut.EnergyCharged(s.evEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) +} diff --git a/usecases/cem/evcem/testhelper_test.go b/usecases/cem/evcem/testhelper_test.go index bdd26daa..ad02cdbd 100644 --- a/usecases/cem/evcem/testhelper_test.go +++ b/usecases/cem/evcem/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVCEMSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evsecc/testhelper_test.go b/usecases/cem/evsecc/testhelper_test.go index e3a17306..70127455 100644 --- a/usecases/cem/evsecc/testhelper_test.go +++ b/usecases/cem/evsecc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVSECCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evsoc/testhelper_test.go b/usecases/cem/evsoc/testhelper_test.go index d94b7d8d..f0595c63 100644 --- a/usecases/cem/evsoc/testhelper_test.go +++ b/usecases/cem/evsoc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVSOCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/opev/testhelper_test.go b/usecases/cem/opev/testhelper_test.go index 80ab3c4c..459787da 100644 --- a/usecases/cem/opev/testhelper_test.go +++ b/usecases/cem/opev/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemOPEVSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/oscev/testhelper_test.go b/usecases/cem/oscev/testhelper_test.go index 13978e7c..96ca7648 100644 --- a/usecases/cem/oscev/testhelper_test.go +++ b/usecases/cem/oscev/testhelper_test.go @@ -47,7 +47,7 @@ func (s *CemOSCEVSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/vabd/testhelper_test.go b/usecases/cem/vabd/testhelper_test.go index 856282ba..5fd1f410 100644 --- a/usecases/cem/vabd/testhelper_test.go +++ b/usecases/cem/vabd/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemVABDSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/vapd/testhelper_test.go b/usecases/cem/vapd/testhelper_test.go index cc71d100..03cfb358 100644 --- a/usecases/cem/vapd/testhelper_test.go +++ b/usecases/cem/vapd/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemVAPDSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cs/lpc/testhelper_test.go b/usecases/cs/lpc/testhelper_test.go index 1e816430..09ca06f7 100644 --- a/usecases/cs/lpc/testhelper_test.go +++ b/usecases/cs/lpc/testhelper_test.go @@ -51,7 +51,7 @@ func (s *CsLPCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cs/lpp/testhelper_test.go b/usecases/cs/lpp/testhelper_test.go index cd3ac0d0..f2a46b9f 100644 --- a/usecases/cs/lpp/testhelper_test.go +++ b/usecases/cs/lpp/testhelper_test.go @@ -51,7 +51,7 @@ func (s *CsLPPSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/eg/lpc/testhelper_test.go b/usecases/eg/lpc/testhelper_test.go index 45020781..a6fa5f68 100644 --- a/usecases/eg/lpc/testhelper_test.go +++ b/usecases/eg/lpc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *EgLPCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/eg/lpp/testhelper_test.go b/usecases/eg/lpp/testhelper_test.go index ea7cb8b8..e11f62b7 100644 --- a/usecases/eg/lpp/testhelper_test.go +++ b/usecases/eg/lpp/testhelper_test.go @@ -48,7 +48,7 @@ func (s *EgLPPSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/internal/testhelper_test.go b/usecases/internal/testhelper_test.go index 4bdb7dd3..a74ce91e 100644 --- a/usecases/internal/testhelper_test.go +++ b/usecases/internal/testhelper_test.go @@ -48,7 +48,7 @@ func (s *InternalSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/ma/mgcp/testhelper_test.go b/usecases/ma/mgcp/testhelper_test.go index a409e481..01778c5c 100644 --- a/usecases/ma/mgcp/testhelper_test.go +++ b/usecases/ma/mgcp/testhelper_test.go @@ -48,7 +48,7 @@ func (s *GcpMGCPSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/ma/mpc/testhelper_test.go b/usecases/ma/mpc/testhelper_test.go index bb4a8844..adc5fb7c 100644 --- a/usecases/ma/mpc/testhelper_test.go +++ b/usecases/ma/mpc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *MaMPCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/usecase/testhelper_test.go b/usecases/usecase/testhelper_test.go index 488c53a6..4e8fe2d0 100644 --- a/usecases/usecase/testhelper_test.go +++ b/usecases/usecase/testhelper_test.go @@ -57,7 +57,7 @@ func (s *UseCaseSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe()