Skip to content

Commit

Permalink
Fix: Correct Data Types for Setpoint Description, Selector, and HVAC
Browse files Browse the repository at this point in the history
This commit addresses the data type issues in the `Setpoint` and `HVAC` model messages, specifically
for `SetpointDescriptionDataType`, `SetpointDescriptionListDataSelectorsType`, and
`HvacSystemFunctionSetpointRelationDataType`. It also corrects invalid types in `function_data_factory.go`
for `FunctionTypeHvacOperationModeDescriptionListData` and `FunctionTypeHvacSystemFunctionDescriptionListData`.

Changes include:
1. Updating `SetpointId` in `hvacSystemFunctionSetpointRelationListData` to be a list, as specified in the EEBus
   SPINE Technical Specification Resource Specification.
2. Correcting data types for fields in `SetpointDescriptionDataType` and `SetpointDescriptionListDataSelectorsType`
   also according to the Resource Specification.

Before this commit, sending `FunctionTypeHvacOperationModeDescriptionListData` and
`FunctionTypeHvacSystemFunctionOperationModeRelationListData` failed due to invalid
data types provided to `createFunctionData` in the factory.

Additionally, the `SetpointId` field needed to be a list, not a single value.  According to the specification, an
operation mode can have multiple setpoints (up to four), such as for the "auto" operation mode.

Sending `FunctionTypeSetpointDescriptionListData` also failed due to incorrect field data types.

With these fixes, requests for `FunctionTypeSetpointDescriptionListData`, `FunctionTypeHvacOperationModeDescriptionListData`,
and `FunctionTypeHvacSystemFunctionOperationModeRelationListData` now work correctly.
  • Loading branch information
halom.be committed Oct 22, 2024
1 parent 0eef075 commit b66b575
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion model/hvac.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type HvacSystemFunctionOperationModeRelationListDataSelectorsType struct {
type HvacSystemFunctionSetpointRelationDataType struct {
SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty" eebus:"key"`
OperationModeId *HvacOperationModeIdType `json:"operationModeId,omitempty"`
SetpointId *SetpointIdType `json:"setpointId,omitempty"`
SetpointId []SetpointIdType `json:"setpointId,omitempty"`
}

type HvacSystemFunctionSetpointRelationDataElementsType struct {
Expand Down
26 changes: 13 additions & 13 deletions model/setpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ type SetpointConstraintsListDataSelectorsType struct {
}

type SetpointDescriptionDataType struct {
SetpointId *SetpointIdType `json:"setpointId,omitempty" eebus:"key"`
MeasurementId *SetpointIdType `json:"measurementId,omitempty"`
TimeTableId *SetpointIdType `json:"timeTableId,omitempty"`
SetpointType *SetpointTypeType `json:"setpointType,omitempty"`
Unit *ScaledNumberType `json:"unit,omitempty"`
ScopeType *ScaledNumberType `json:"scopeType,omitempty"`
Label *LabelType `json:"label,omitempty"`
Description *DescriptionType `json:"description,omitempty"`
SetpointId *SetpointIdType `json:"setpointId,omitempty" eebus:"key"`
MeasurementId *SetpointIdType `json:"measurementId,omitempty"`
TimeTableId *SetpointIdType `json:"timeTableId,omitempty"`
SetpointType *SetpointTypeType `json:"setpointType,omitempty"`
Unit *UnitOfMeasurementType `json:"unit,omitempty"`
ScopeType *ScopeTypeType `json:"scopeType,omitempty"`
Label *LabelType `json:"label,omitempty"`
Description *DescriptionType `json:"description,omitempty"`
}

type SetpointDescriptionDataElementsType struct {
Expand All @@ -90,9 +90,9 @@ type SetpointDescriptionListDataType struct {
}

type SetpointDescriptionListDataSelectorsType struct {
SetpointId *SetpointIdType `json:"setpointId,omitempty"`
MeasurementId *SetpointIdType `json:"measurementId,omitempty"`
TimeTableId *SetpointIdType `json:"timeTableId,omitempty"`
SetpointType *SetpointIdType `json:"setpointType,omitempty"`
ScopeType *ScaledNumberType `json:"scopeType,omitempty"`
SetpointId *SetpointIdType `json:"setpointId,omitempty"`
MeasurementId *MeasurementIdType `json:"measurementId,omitempty"`
TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"`
SetpointType *SetpointTypeType `json:"setpointType,omitempty"`
ScopeType *ScopeTypeType `json:"scopeType,omitempty"`
}
4 changes: 2 additions & 2 deletions spine/function_data_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func CreateFunctionData[F any](featureType model.FeatureTypeType) []F {

if featureType == model.FeatureTypeTypeHvac || featureType == model.FeatureTypeTypeGeneric {
result = append(result, []F{
createFunctionData[model.HvacOperationModeDescriptionDataType, F](model.FunctionTypeHvacOperationModeDescriptionListData),
createFunctionData[model.HvacOperationModeDescriptionListDataType, F](model.FunctionTypeHvacOperationModeDescriptionListData),
createFunctionData[model.HvacOverrunDescriptionListDataType, F](model.FunctionTypeHvacOverrunDescriptionListData),
createFunctionData[model.HvacOverrunListDataType, F](model.FunctionTypeHvacOverrunListData),
createFunctionData[model.HvacSystemFunctionDescriptionDataType, F](model.FunctionTypeHvacSystemFunctionDescriptionListData),
createFunctionData[model.HvacSystemFunctionDescriptionListDataType, F](model.FunctionTypeHvacSystemFunctionDescriptionListData),
createFunctionData[model.HvacSystemFunctionListDataType, F](model.FunctionTypeHvacSystemFunctionListData),
createFunctionData[model.HvacSystemFunctionOperationModeRelationListDataType, F](model.FunctionTypeHvacSystemFunctionOperationModeRelationListData),
createFunctionData[model.HvacSystemFunctionPowerSequenceRelationListDataType, F](model.FunctionTypeHvacSystemFunctionPowerSequenceRelationListData),
Expand Down
4 changes: 2 additions & 2 deletions spine/function_data_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func TestFunctionDataFactory_FunctionData(t *testing.T) {

result = CreateFunctionData[api.FunctionDataInterface](model.FeatureTypeTypeHvac)
assert.Equal(t, 8, len(result))
assert.IsType(t, &FunctionData[model.HvacOperationModeDescriptionDataType]{}, result[0])
assert.IsType(t, &FunctionData[model.HvacOperationModeDescriptionListDataType]{}, result[0])
assert.IsType(t, &FunctionData[model.HvacOverrunDescriptionListDataType]{}, result[1])
assert.IsType(t, &FunctionData[model.HvacOverrunListDataType]{}, result[2])
assert.IsType(t, &FunctionData[model.HvacSystemFunctionDescriptionDataType]{}, result[3])
assert.IsType(t, &FunctionData[model.HvacSystemFunctionDescriptionListDataType]{}, result[3])
assert.IsType(t, &FunctionData[model.HvacSystemFunctionListDataType]{}, result[4])

result = CreateFunctionData[api.FunctionDataInterface](model.FeatureTypeTypeIdentification)
Expand Down

0 comments on commit b66b575

Please sign in to comment.