Skip to content

Commit

Permalink
feat!: update data type in ResourceProperties
Browse files Browse the repository at this point in the history
BREAKING CHANGE: update mask,shift,base,scale,offset to numeric data type

also rename 'Others' to 'Optional' for the consistency with
message broker settings.

closes #770

Signed-off-by: Chris Hung <[email protected]>
  • Loading branch information
Chris Hung committed Feb 23, 2023
1 parent 7d700bc commit 9353c25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
5 changes: 3 additions & 2 deletions dtos/deviceprofile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var testAttributes = map[string]interface{}{
}
var testMappings = map[string]string{"0": "off", "1": "on"}
var testTags = map[string]any{"TestTagsKey": "TestTagsValue"}
var testOptional = map[string]any{"isVirtual": false}

var testDeviceProfile = models.DeviceProfile{
Name: TestDeviceProfileName,
Expand All @@ -37,7 +38,7 @@ var testDeviceProfile = models.DeviceProfile{
Properties: models.ResourceProperties{
ValueType: common.ValueTypeInt16,
ReadWrite: common.ReadWrite_RW,
Others: testTags,
Optional: testOptional,
},
Tags: testTags,
}},
Expand Down Expand Up @@ -68,7 +69,7 @@ func profileData() DeviceProfile {
Properties: ResourceProperties{
ValueType: common.ValueTypeInt16,
ReadWrite: common.ReadWrite_RW,
Others: testTags,
Optional: testOptional,
},
Tags: testTags,
}},
Expand Down
16 changes: 8 additions & 8 deletions dtos/resourceproperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ type ResourceProperties struct {
Minimum string `json:"minimum,omitempty" yaml:"minimum"`
Maximum string `json:"maximum,omitempty" yaml:"maximum"`
DefaultValue string `json:"defaultValue,omitempty" yaml:"defaultValue"`
Mask string `json:"mask,omitempty" yaml:"mask"`
Shift string `json:"shift,omitempty" yaml:"shift"`
Scale string `json:"scale,omitempty" yaml:"scale"`
Offset string `json:"offset,omitempty" yaml:"offset"`
Base string `json:"base,omitempty" yaml:"base"`
Mask uint64 `json:"mask,omitempty" yaml:"mask"`
Shift int64 `json:"shift,omitempty" yaml:"shift"`
Scale float64 `json:"scale,omitempty" yaml:"scale"`
Offset float64 `json:"offset,omitempty" yaml:"offset"`
Base float64 `json:"base,omitempty" yaml:"base"`
Assertion string `json:"assertion,omitempty" yaml:"assertion"`
MediaType string `json:"mediaType,omitempty" yaml:"mediaType"`
Others map[string]any `json:"others,omitempty" yaml:"others"`
Optional map[string]any `json:"optional,omitempty" yaml:"optional"`
}

// ToResourcePropertiesModel transforms the ResourceProperties DTO to the ResourceProperties model
Expand All @@ -44,7 +44,7 @@ func ToResourcePropertiesModel(p ResourceProperties) models.ResourceProperties {
Base: p.Base,
Assertion: p.Assertion,
MediaType: p.MediaType,
Others: p.Others,
Optional: p.Optional,
}
}

Expand All @@ -64,6 +64,6 @@ func FromResourcePropertiesModelToDTO(p models.ResourceProperties) ResourcePrope
Base: p.Base,
Assertion: p.Assertion,
MediaType: p.MediaType,
Others: p.Others,
Optional: p.Optional,
}
}
12 changes: 6 additions & 6 deletions models/resourceproperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type ResourceProperties struct {
Minimum string
Maximum string
DefaultValue string
Mask string
Shift string
Scale string
Offset string
Base string
Mask uint64
Shift int64
Scale float64
Offset float64
Base float64
Assertion string
MediaType string
Others map[string]any
Optional map[string]any
}

0 comments on commit 9353c25

Please sign in to comment.