From d5f89c767706ef411fc622cd6771c479b7fd1b26 Mon Sep 17 00:00:00 2001 From: David Sapir Date: Tue, 22 Oct 2024 11:03:37 +0300 Subject: [PATCH 1/2] Fix: Correct Data Types for Setpoint Description, Selector, and HVAC 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. --- model/hvac.go | 2 +- model/setpoint.go | 26 +++++++++++++------------- spine/function_data_factory.go | 4 ++-- spine/function_data_factory_test.go | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/model/hvac.go b/model/hvac.go index 060d3d5..e5d867f 100644 --- a/model/hvac.go +++ b/model/hvac.go @@ -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 { diff --git a/model/setpoint.go b/model/setpoint.go index c082e23..6fc4f99 100644 --- a/model/setpoint.go +++ b/model/setpoint.go @@ -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 { @@ -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"` } diff --git a/spine/function_data_factory.go b/spine/function_data_factory.go index e6feb01..01c5330 100644 --- a/spine/function_data_factory.go +++ b/spine/function_data_factory.go @@ -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), diff --git a/spine/function_data_factory_test.go b/spine/function_data_factory_test.go index 1399f34..ef9f67a 100644 --- a/spine/function_data_factory_test.go +++ b/spine/function_data_factory_test.go @@ -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) From f75c7febb382068a207bdb2ca89669fe7d3a510b Mon Sep 17 00:00:00 2001 From: David Sapir Date: Wed, 23 Oct 2024 18:55:46 +0300 Subject: [PATCH 2/2] Add eebus:"key" for foreign identifiers in SetpointDescriptionDataType class --- model/setpoint.go | 4 ++-- model/setpoint_additions_test.go | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/model/setpoint.go b/model/setpoint.go index 6fc4f99..5650f9f 100644 --- a/model/setpoint.go +++ b/model/setpoint.go @@ -65,8 +65,8 @@ type SetpointConstraintsListDataSelectorsType struct { type SetpointDescriptionDataType struct { SetpointId *SetpointIdType `json:"setpointId,omitempty" eebus:"key"` - MeasurementId *SetpointIdType `json:"measurementId,omitempty"` - TimeTableId *SetpointIdType `json:"timeTableId,omitempty"` + MeasurementId *SetpointIdType `json:"measurementId,omitempty" eebus:"key"` + TimeTableId *SetpointIdType `json:"timeTableId,omitempty" eebus:"key"` SetpointType *SetpointTypeType `json:"setpointType,omitempty"` Unit *UnitOfMeasurementType `json:"unit,omitempty"` ScopeType *ScopeTypeType `json:"scopeType,omitempty"` diff --git a/model/setpoint_additions_test.go b/model/setpoint_additions_test.go index 98d97c2..2fb2f71 100644 --- a/model/setpoint_additions_test.go +++ b/model/setpoint_additions_test.go @@ -50,12 +50,16 @@ func TestSetpointDescriptionListDataType_Update(t *testing.T) { sut := SetpointDescriptionListDataType{ SetpointDescriptionData: []SetpointDescriptionDataType{ { - SetpointId: util.Ptr(SetpointIdType(0)), - Description: util.Ptr(DescriptionType("old")), + SetpointId: util.Ptr(SetpointIdType(0)), + MeasurementId: util.Ptr(SetpointIdType(0)), + TimeTableId: util.Ptr(SetpointIdType(0)), + Description: util.Ptr(DescriptionType("old")), }, { - SetpointId: util.Ptr(SetpointIdType(1)), - Description: util.Ptr(DescriptionType("old")), + SetpointId: util.Ptr(SetpointIdType(1)), + MeasurementId: util.Ptr(SetpointIdType(1)), + TimeTableId: util.Ptr(SetpointIdType(1)), + Description: util.Ptr(DescriptionType("old")), }, }, } @@ -63,8 +67,10 @@ func TestSetpointDescriptionListDataType_Update(t *testing.T) { newData := SetpointDescriptionListDataType{ SetpointDescriptionData: []SetpointDescriptionDataType{ { - SetpointId: util.Ptr(SetpointIdType(1)), - Description: util.Ptr(DescriptionType("new")), + SetpointId: util.Ptr(SetpointIdType(1)), + MeasurementId: util.Ptr(SetpointIdType(1)), + TimeTableId: util.Ptr(SetpointIdType(1)), + Description: util.Ptr(DescriptionType("new")), }, }, }