Skip to content

Commit 05f7b21

Browse files
author
David Sapir
committed
Add HvacOperationModeType to usecase types
1 parent fe2b702 commit 05f7b21

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

usecases/api/ca_cdt.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,33 @@ package api
33
import (
44
"github.com/enbility/eebus-go/api"
55
spineapi "github.com/enbility/spine-go/api"
6-
"github.com/enbility/spine-go/model"
76
)
87

98
type CaCDTInterface interface {
109
api.UseCaseInterface
1110

1211
// Scenario 1
1312

14-
// Return the current setpoints data
13+
// Return the setpoints.
1514
//
1615
// parameters:
1716
// - entity: the entity to get the setpoints data from
1817
//
1918
// return values:
20-
// - setpoints: A map of the setpoints for supported modes
19+
// - setpoints: A list of setpoints
2120
//
2221
// possible errors:
2322
// - ErrDataNotAvailable if no such limit is (yet) available
2423
// - and others
2524
Setpoints(entity spineapi.EntityRemoteInterface) ([]Setpoint, error)
2625

27-
// Return the constraints for the setpoints
26+
// Return the constraints for the setpoints.
2827
//
2928
// parameters:
3029
// - entity: the entity to get the setpoints constraints from
3130
//
3231
// return values:
33-
// - setpointConstraints: A map of the constraints for supported modes
32+
// - setpointConstraints: A list of setpoint constraints
3433
//
3534
// possible errors:
3635
// - ErrDataNotAvailable if no such limit is (yet) available
@@ -42,6 +41,6 @@ type CaCDTInterface interface {
4241
// parameters:
4342
// - entity: the entity to write the setpoint to
4443
// - mode: the mode to write the setpoint for
45-
// - degC: the temperature setpoint value to write
46-
WriteSetpoint(entity spineapi.EntityRemoteInterface, mode model.HvacOperationModeTypeType, degC float64) error
44+
// - temperature: the temperature setpoint value to write
45+
WriteSetpoint(entity spineapi.EntityRemoteInterface, mode HvacOperationModeType, temperature float64) error
4746
}

usecases/api/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ const (
1717
EVChargeStateTypeFinished EVChargeStateType = "finished"
1818
)
1919

20+
type HvacOperationModeType string
21+
22+
const (
23+
HvacOperationModeTypeAuto HvacOperationModeType = "auto"
24+
HvacOperationModeTypeOn HvacOperationModeType = "on"
25+
HvacOperationModeTypeOff HvacOperationModeType = "off"
26+
HvacOperationModeTypeEco HvacOperationModeType = "eco"
27+
)
28+
2029
// Defines a phase specific limit data set
2130
type LoadLimitsPhase struct {
2231
Phase model.ElectricalConnectionPhaseNameType // the phase

usecases/ca/cdt/public.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ func (e *CDT) mapSetpointsToModes(entity spineapi.EntityRemoteInterface) error {
194194
// - Other errors: Any other errors encountered during the process.
195195
func (e *CDT) WriteSetpoint(
196196
entity spineapi.EntityRemoteInterface,
197-
mode model.HvacOperationModeTypeType,
197+
mode usecasesapi.HvacOperationModeType,
198198
temperature float64,
199199
) error {
200-
if mode == model.HvacOperationModeTypeTypeAuto {
200+
if model.HvacOperationModeTypeType(mode) == model.HvacOperationModeTypeTypeAuto {
201201
// 'Auto' mode is controlled by a timetable, meaning the current setpoint
202202
// for the HVAC system function changes according to the timetable.
203203
// Only the 'Off', 'On', and 'Eco' modes can be directly controlled by a setpoint.
@@ -208,7 +208,7 @@ func (e *CDT) WriteSetpoint(
208208
return api.ErrDataNotAvailable
209209
}
210210

211-
setpointId, found := e.modes[mode]
211+
setpointId, found := e.modes[model.HvacOperationModeTypeType(mode)]
212212
if !found {
213213
return api.ErrDataNotAvailable
214214
}

0 commit comments

Comments
 (0)