Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partial read support #85

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 61 additions & 16 deletions api/featuresclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ type DeviceClassificationClientInterface interface {
type DeviceConfigurationClientInterface interface {
DeviceConfigurationCommonInterface

// request DeviceConfigurationDescriptionListData from a remote entity
RequestDescriptions() (*model.MsgCounterType, error)
// request DeviceConfigurationKeyValueDescriptionDataType from a remote entity
RequestKeyValueDescriptions(
selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType,
elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType,
) (*model.MsgCounterType, error)

// request DeviceConfigurationKeyValueListData from a remote entity
RequestKeyValues() (*model.MsgCounterType, error)
RequestKeyValues(
selector *model.DeviceConfigurationKeyValueListDataSelectorsType,
elements *model.DeviceConfigurationKeyValueDataElementsType,
) (*model.MsgCounterType, error)

// write key values
// returns an error if this failed
Expand All @@ -31,16 +37,28 @@ type DeviceDiagnosisClientInterface interface {

type ElectricalConnectionClientInterface interface {
// request ElectricalConnectionDescriptionListDataType from a remote entity
RequestDescriptions() (*model.MsgCounterType, error)
RequestDescriptions(
selector *model.ElectricalConnectionDescriptionListDataSelectorsType,
elements *model.ElectricalConnectionDescriptionDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeElectricalConnectionParameterDescriptionListData from a remote entity
RequestParameterDescriptions() (*model.MsgCounterType, error)
RequestParameterDescriptions(
selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType,
elements *model.ElectricalConnectionParameterDescriptionDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeElectricalConnectionPermittedValueSetListData from a remote entity
RequestPermittedValueSets() (*model.MsgCounterType, error)
RequestPermittedValueSets(
selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType,
elements *model.ElectricalConnectionPermittedValueSetDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeElectricalConnectionCharacteristicListData from a remote entity
RequestCharacteristics() (*model.MsgCounterType, error)
RequestCharacteristics(
selector *model.ElectricalConnectionCharacteristicListDataSelectorsType,
elements *model.ElectricalConnectionCharacteristicDataElementsType,
) (*model.MsgCounterType, error)
}

type IdentificationClientInterface interface {
Expand Down Expand Up @@ -69,13 +87,22 @@ type IncentiveTableClientInterface interface {

type LoadControlClientInterface interface {
// request FunctionTypeLoadControlLimitDescriptionListData from a remote device
RequestLimitDescriptions() (*model.MsgCounterType, error)
RequestLimitDescriptions(
selector *model.LoadControlLimitDescriptionListDataSelectorsType,
elements *model.LoadControlLimitDescriptionDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeLoadControlLimitConstraintsListData from a remote device
RequestLimitConstraints() (*model.MsgCounterType, error)
RequestLimitConstraints(
selector *model.LoadControlLimitConstraintsListDataSelectorsType,
elements *model.LoadControlLimitConstraintsDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeLoadControlLimitListData from a remote device
RequestLimitData() (*model.MsgCounterType, error)
RequestLimitData(
selector *model.LoadControlLimitListDataSelectorsType,
elements *model.LoadControlLimitDataElementsType,
) (*model.MsgCounterType, error)

// write load control limits
// returns an error if this failed
Expand All @@ -88,13 +115,22 @@ type LoadControlClientInterface interface {

type MeasurementClientInterface interface {
// request FunctionTypeMeasurementDescriptionListData from a remote device
RequestDescriptions() (*model.MsgCounterType, error)
RequestDescriptions(
selector *model.MeasurementDescriptionListDataSelectorsType,
elements *model.MeasurementDescriptionDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeMeasurementConstraintsListData from a remote entity
RequestConstraints() (*model.MsgCounterType, error)
RequestConstraints(
selector *model.MeasurementConstraintsListDataSelectorsType,
elements *model.MeasurementConstraintsDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeMeasurementListData from a remote entity
RequestData() (*model.MsgCounterType, error)
RequestData(
selector *model.MeasurementListDataSelectorsType,
elements *model.MeasurementDataElementsType,
) (*model.MsgCounterType, error)
}

type SmartEnergyManagementPsClientInterface interface {
Expand All @@ -108,13 +144,22 @@ type SmartEnergyManagementPsClientInterface interface {

type TimeSeriesClientInterface interface {
// request FunctionTypeTimeSeriesDescriptionListData from a remote entity
RequestDescriptions() (*model.MsgCounterType, error)
RequestDescriptions(
selector *model.TimeSeriesDescriptionListDataSelectorsType,
elements *model.TimeSeriesDescriptionDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeTimeSeriesConstraintsListData from a remote entity
RequestConstraints() (*model.MsgCounterType, error)
RequestConstraints(
selector *model.TimeSeriesConstraintsListDataSelectorsType,
elements *model.TimeSeriesConstraintsDataElementsType,
) (*model.MsgCounterType, error)

// request FunctionTypeTimeSeriesListData from a remote device
RequestData() (*model.MsgCounterType, error)
RequestData(
selector *model.TimeSeriesListDataSelectorsType,
elements *model.TimeSeriesDataElementsType,
) (*model.MsgCounterType, error)

// write Time Series values
// returns an error if this failed
Expand Down
9 changes: 4 additions & 5 deletions features/client/deviceclassification_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package client_test
package client

import (
"testing"

features "github.com/enbility/eebus-go/features/client"
shipapi "github.com/enbility/ship-go/api"
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/model"
Expand All @@ -21,7 +20,7 @@ type DeviceClassificationSuite struct {
localEntity spineapi.EntityLocalInterface
remoteEntity spineapi.EntityRemoteInterface

deviceClassification *features.DeviceClassification
deviceClassification *DeviceClassification
sentMessage []byte
}

Expand All @@ -46,11 +45,11 @@ func (s *DeviceClassificationSuite) BeforeTest(suiteName, testName string) {
)

var err error
s.deviceClassification, err = features.NewDeviceClassification(s.localEntity, nil)
s.deviceClassification, err = NewDeviceClassification(s.localEntity, nil)
assert.NotNil(s.T(), err)
assert.Nil(s.T(), s.deviceClassification)

s.deviceClassification, err = features.NewDeviceClassification(s.localEntity, s.remoteEntity)
s.deviceClassification, err = NewDeviceClassification(s.localEntity, s.remoteEntity)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), s.deviceClassification)
}
Expand Down
18 changes: 12 additions & 6 deletions features/client/deviceconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ func NewDeviceConfiguration(

var _ api.DeviceConfigurationClientInterface = (*DeviceConfiguration)(nil)

// request DeviceConfiguration data from a remote entity
func (d *DeviceConfiguration) RequestDescriptions() (*model.MsgCounterType, error) {
return d.requestData(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, nil, nil)
// request DeviceConfigurationKeyValueDescriptionDataType from a remote entity
func (d *DeviceConfiguration) RequestKeyValueDescriptions(
selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType,
elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType,
) (*model.MsgCounterType, error) {
return d.requestData(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, selector, elements)
}

// request DeviceConfigurationKeyValueListDataType from a remote entity
func (d *DeviceConfiguration) RequestKeyValues() (*model.MsgCounterType, error) {
return d.requestData(model.FunctionTypeDeviceConfigurationKeyValueListData, nil, nil)
// request DeviceConfigurationKeyValueListData from a remote entity
func (d *DeviceConfiguration) RequestKeyValues(
selector *model.DeviceConfigurationKeyValueListDataSelectorsType,
elements *model.DeviceConfigurationKeyValueDataElementsType,
) (*model.MsgCounterType, error) {
return d.requestData(model.FunctionTypeDeviceConfigurationKeyValueListData, selector, elements)
}

// write key values
Expand Down
29 changes: 21 additions & 8 deletions features/client/deviceconfiguration_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package client_test
package client

import (
"testing"

features "github.com/enbility/eebus-go/features/client"
shipmocks "github.com/enbility/ship-go/mocks"
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/mocks"
Expand All @@ -25,7 +24,7 @@ type DeviceConfigurationSuite struct {
remoteEntity spineapi.EntityRemoteInterface
mockRemoteEntity *mocks.EntityRemoteInterface

deviceConfiguration *features.DeviceConfiguration
deviceConfiguration *DeviceConfiguration
}

const remoteSki string = "testremoteski"
Expand Down Expand Up @@ -60,23 +59,37 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) {
mockRemoteFeature.EXPECT().DataCopy(mock.Anything).Return(mock.Anything).Maybe()

var err error
s.deviceConfiguration, err = features.NewDeviceConfiguration(s.localEntity, nil)
s.deviceConfiguration, err = NewDeviceConfiguration(s.localEntity, nil)
assert.NotNil(s.T(), err)
assert.Nil(s.T(), s.deviceConfiguration)

s.deviceConfiguration, err = features.NewDeviceConfiguration(s.localEntity, s.remoteEntity)
s.deviceConfiguration, err = NewDeviceConfiguration(s.localEntity, s.remoteEntity)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), s.deviceConfiguration)
}

func (s *DeviceConfigurationSuite) Test_RequestDescriptions() {
counter, err := s.deviceConfiguration.RequestDescriptions()
func (s *DeviceConfigurationSuite) Test_RequestKeyValueDescriptions() {
counter, err := s.deviceConfiguration.RequestKeyValueDescriptions(nil, nil)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), counter)

counter, err = s.deviceConfiguration.RequestKeyValueDescriptions(
&model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType{},
&model.DeviceConfigurationKeyValueDescriptionDataElementsType{},
)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), counter)
}

func (s *DeviceConfigurationSuite) Test_RequestKeyValueList() {
counter, err := s.deviceConfiguration.RequestKeyValues()
counter, err := s.deviceConfiguration.RequestKeyValues(nil, nil)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), counter)

counter, err = s.deviceConfiguration.RequestKeyValues(
&model.DeviceConfigurationKeyValueListDataSelectorsType{},
&model.DeviceConfigurationKeyValueDataElementsType{},
)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), counter)
}
Expand Down
9 changes: 4 additions & 5 deletions features/client/devicediagnosis_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package client_test
package client

import (
"testing"

features "github.com/enbility/eebus-go/features/client"
shipapi "github.com/enbility/ship-go/api"
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/model"
Expand All @@ -21,7 +20,7 @@ type DeviceDiagnosisSuite struct {
localEntity spineapi.EntityLocalInterface
remoteEntity spineapi.EntityRemoteInterface

deviceDiagnosis *features.DeviceDiagnosis
deviceDiagnosis *DeviceDiagnosis
sentMessage []byte
}

Expand All @@ -47,11 +46,11 @@ func (s *DeviceDiagnosisSuite) BeforeTest(suiteName, testName string) {
)

var err error
s.deviceDiagnosis, err = features.NewDeviceDiagnosis(s.localEntity, nil)
s.deviceDiagnosis, err = NewDeviceDiagnosis(s.localEntity, nil)
assert.NotNil(s.T(), err)
assert.Nil(s.T(), s.deviceDiagnosis)

s.deviceDiagnosis, err = features.NewDeviceDiagnosis(s.localEntity, s.remoteEntity)
s.deviceDiagnosis, err = NewDeviceDiagnosis(s.localEntity, s.remoteEntity)
assert.Nil(s.T(), err)
assert.NotNil(s.T(), s.deviceDiagnosis)
}
Expand Down
28 changes: 20 additions & 8 deletions features/client/electricalconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,33 @@ func NewElectricalConnection(
var _ api.ElectricalConnectionClientInterface = (*ElectricalConnection)(nil)

// request ElectricalConnectionDescriptionListDataType from a remote entity
func (e *ElectricalConnection) RequestDescriptions() (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionDescriptionListData, nil, nil)
func (e *ElectricalConnection) RequestDescriptions(
selector *model.ElectricalConnectionDescriptionListDataSelectorsType,
elements *model.ElectricalConnectionDescriptionDataElementsType,
) (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionDescriptionListData, selector, elements)
}

// request FunctionTypeElectricalConnectionParameterDescriptionListData from a remote entity
func (e *ElectricalConnection) RequestParameterDescriptions() (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionParameterDescriptionListData, nil, nil)
func (e *ElectricalConnection) RequestParameterDescriptions(
selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType,
elements *model.ElectricalConnectionParameterDescriptionDataElementsType,
) (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionParameterDescriptionListData, selector, elements)
}

// request FunctionTypeElectricalConnectionPermittedValueSetListData from a remote entity
func (e *ElectricalConnection) RequestPermittedValueSets() (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionPermittedValueSetListData, nil, nil)
func (e *ElectricalConnection) RequestPermittedValueSets(
selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType,
elements *model.ElectricalConnectionPermittedValueSetDataElementsType,
) (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionPermittedValueSetListData, selector, elements)
}

// request FunctionTypeElectricalConnectionCharacteristicListData from a remote entity
func (e *ElectricalConnection) RequestCharacteristics() (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionCharacteristicListData, nil, nil)
func (e *ElectricalConnection) RequestCharacteristics(
selector *model.ElectricalConnectionCharacteristicListDataSelectorsType,
elements *model.ElectricalConnectionCharacteristicDataElementsType,
) (*model.MsgCounterType, error) {
return e.requestData(model.FunctionTypeElectricalConnectionCharacteristicListData, selector, elements)
}
Loading