@@ -10,6 +10,115 @@ import (
10
10
"github.com/stretchr/testify/assert"
11
11
)
12
12
13
+ func (s * UtilSuite ) Test_LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScopeLocal () {
14
+ limitType := model .LoadControlLimitTypeTypeMaxValueLimit
15
+ scope := model .ScopeTypeTypeSelfConsumption
16
+ category := model .LoadControlCategoryTypeObligation
17
+ direction := model .EnergyDirectionType ("" )
18
+
19
+ payload := spineapi.EventPayload {
20
+ Entity : s .mockRemoteEntity ,
21
+ }
22
+
23
+ exists := LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope (true , s .service , payload , limitType , category , direction , scope )
24
+ assert .False (s .T (), exists )
25
+
26
+ payload .Entity = s .monitoredEntity
27
+
28
+ exists = LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope (true , s .service , payload , limitType , category , direction , scope )
29
+ assert .False (s .T (), exists )
30
+
31
+ descData := & model.LoadControlLimitDescriptionListDataType {
32
+ LoadControlLimitDescriptionData : []model.LoadControlLimitDescriptionDataType {
33
+ {
34
+ LimitId : eebusutil .Ptr (model .LoadControlLimitIdType (0 )),
35
+ LimitCategory : eebusutil .Ptr (category ),
36
+ MeasurementId : eebusutil .Ptr (model .MeasurementIdType (0 )),
37
+ LimitType : eebusutil .Ptr (limitType ),
38
+ ScopeType : eebusutil .Ptr (scope ),
39
+ },
40
+ {
41
+ LimitId : eebusutil .Ptr (model .LoadControlLimitIdType (1 )),
42
+ LimitCategory : eebusutil .Ptr (category ),
43
+ MeasurementId : eebusutil .Ptr (model .MeasurementIdType (1 )),
44
+ LimitType : eebusutil .Ptr (limitType ),
45
+ ScopeType : eebusutil .Ptr (scope ),
46
+ },
47
+ {
48
+ LimitId : eebusutil .Ptr (model .LoadControlLimitIdType (2 )),
49
+ LimitCategory : eebusutil .Ptr (category ),
50
+ MeasurementId : eebusutil .Ptr (model .MeasurementIdType (2 )),
51
+ LimitType : eebusutil .Ptr (limitType ),
52
+ ScopeType : eebusutil .Ptr (scope ),
53
+ },
54
+ },
55
+ }
56
+
57
+ entity := s .service .LocalDevice ().EntityForType (model .EntityTypeTypeCEM )
58
+ feature := entity .FeatureOfTypeAndRole (model .FeatureTypeTypeLoadControl , model .RoleTypeServer )
59
+ feature .SetData (model .FunctionTypeLoadControlLimitDescriptionListData , descData )
60
+
61
+ exists = LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope (true , s .service , payload , limitType , category , direction , scope )
62
+ assert .False (s .T (), exists )
63
+
64
+ paramData := & model.ElectricalConnectionParameterDescriptionListDataType {
65
+ ElectricalConnectionParameterDescriptionData : []model.ElectricalConnectionParameterDescriptionDataType {
66
+ {
67
+ ElectricalConnectionId : eebusutil .Ptr (model .ElectricalConnectionIdType (0 )),
68
+ ParameterId : eebusutil .Ptr (model .ElectricalConnectionParameterIdType (0 )),
69
+ MeasurementId : eebusutil .Ptr (model .MeasurementIdType (0 )),
70
+ AcMeasuredPhases : eebusutil .Ptr (model .ElectricalConnectionPhaseNameTypeA ),
71
+ },
72
+ {
73
+ ElectricalConnectionId : eebusutil .Ptr (model .ElectricalConnectionIdType (0 )),
74
+ ParameterId : eebusutil .Ptr (model .ElectricalConnectionParameterIdType (1 )),
75
+ MeasurementId : eebusutil .Ptr (model .MeasurementIdType (1 )),
76
+ AcMeasuredPhases : eebusutil .Ptr (model .ElectricalConnectionPhaseNameTypeB ),
77
+ },
78
+ {
79
+ ElectricalConnectionId : eebusutil .Ptr (model .ElectricalConnectionIdType (0 )),
80
+ ParameterId : eebusutil .Ptr (model .ElectricalConnectionParameterIdType (2 )),
81
+ MeasurementId : eebusutil .Ptr (model .MeasurementIdType (2 )),
82
+ AcMeasuredPhases : eebusutil .Ptr (model .ElectricalConnectionPhaseNameTypeC ),
83
+ },
84
+ },
85
+ }
86
+
87
+ elFeature := entity .FeatureOfTypeAndRole (model .FeatureTypeTypeElectricalConnection , model .RoleTypeServer )
88
+ elFeature .SetData (model .FunctionTypeElectricalConnectionParameterDescriptionListData , paramData )
89
+
90
+ exists = LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope (true , s .service , payload , limitType , category , direction , scope )
91
+ assert .False (s .T (), exists )
92
+
93
+ limitData := & model.LoadControlLimitListDataType {
94
+ LoadControlLimitData : []model.LoadControlLimitDataType {},
95
+ }
96
+
97
+ payload .Data = limitData
98
+ exists = LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope (true , s .service , payload , limitType , category , direction , scope )
99
+ assert .False (s .T (), exists )
100
+
101
+ limitData = & model.LoadControlLimitListDataType {
102
+ LoadControlLimitData : []model.LoadControlLimitDataType {
103
+ {
104
+ LimitId : eebusutil .Ptr (model .LoadControlLimitIdType (0 )),
105
+ Value : model .NewScaledNumberType (16 ),
106
+ },
107
+ {
108
+ LimitId : eebusutil .Ptr (model .LoadControlLimitIdType (1 )),
109
+ Value : model .NewScaledNumberType (16 ),
110
+ },
111
+ {
112
+ LimitId : eebusutil .Ptr (model .LoadControlLimitIdType (2 )),
113
+ },
114
+ },
115
+ }
116
+
117
+ payload .Data = limitData
118
+ exists = LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope (true , s .service , payload , limitType , category , direction , scope )
119
+ assert .True (s .T (), exists )
120
+ }
121
+
13
122
func (s * UtilSuite ) Test_LoadControlLimitsCheckPayloadDataForTypeCategoryDirectionScope () {
14
123
limitType := model .LoadControlLimitTypeTypeMaxValueLimit
15
124
scope := model .ScopeTypeTypeSelfConsumption
0 commit comments