Skip to content

Commit 9062f9c

Browse files
authored
SMHE-2415: Change sag and swell settings (#1610)
* SMHE-2415: Add sag and swell threshold objects to config Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Update SetSpecificAttributeValue to accept a list of values to set Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Fix SetSpecificAttributeValueRequest constructor Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Fix SetSpecificAttributeValueRequestFactory Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Fix valueToSetDto Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Clean up code Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Add sag and swell thresholds to simulator Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Add cucumber test for Set specific values with multiple values Signed-off-by: stefanermens <stefan.ermens@alliander.com> * SMHE-2415: Update SetSpecificAttributeValueRequestFactory Signed-off-by: stefanermens <stefan.ermens@alliander.com> --------- Signed-off-by: stefanermens <stefan.ermens@alliander.com>
1 parent 9d873b7 commit 9062f9c

File tree

17 files changed

+716
-107
lines changed

17 files changed

+716
-107
lines changed

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/support/ws/smartmetering/adhoc/SetSpecificAttributeValueRequestFactory.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.AllowedObjectType;
1010
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueAsyncRequest;
1111
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueRequest;
12+
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ValueToSet;
1213
import org.opensmartgridplatform.cucumber.platform.smartmetering.PlatformSmartmeteringKeys;
1314
import org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.RequestFactoryHelper;
1415

@@ -23,10 +24,22 @@ public static SetSpecificAttributeValueRequest fromParameterMap(
2324
final SetSpecificAttributeValueRequest request = new SetSpecificAttributeValueRequest();
2425
request.setDeviceIdentification(
2526
parameters.get(PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION));
26-
request.setObjectType(
27+
final ValueToSet valueToSet = new ValueToSet();
28+
valueToSet.setObjectType(
2729
AllowedObjectType.valueOf(parameters.get(PlatformSmartmeteringKeys.OBJECT_TYPE)));
28-
request.setAttribute(new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE)));
29-
request.setIntValue(new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE)));
30+
valueToSet.setAttribute(new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE)));
31+
valueToSet.setIntValue(new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE)));
32+
request.getValuesToSet().add(valueToSet);
33+
if (parameters.containsKey(PlatformSmartmeteringKeys.OBJECT_TYPE + "_2")) {
34+
final ValueToSet valueToSet2 = new ValueToSet();
35+
valueToSet2.setObjectType(
36+
AllowedObjectType.valueOf(parameters.get(PlatformSmartmeteringKeys.OBJECT_TYPE + "_2")));
37+
valueToSet2.setAttribute(
38+
new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE + "_2")));
39+
valueToSet2.setIntValue(
40+
new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE + "_2")));
41+
request.getValuesToSet().add(valueToSet2);
42+
}
3043
return request;
3144
}
3245

integration-tests/cucumber-tests-platform-smartmetering/src/test/resources/features/osgp-adapter-ws-smartmetering/ad-hoc/SetSpecificAttributeValue.feature

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,34 @@ Feature: SmartMetering AdHoc
3535
| TEST1028000000001 | SMR | 5.1 | OK |
3636
| TEST1029000000001 | SMR | 5.2 | OK |
3737
| TEST1030000000001 | SMR | 5.5 | OK |
38+
39+
Scenario Outline: Set sag and swell settings for a <protocol> <version> device
40+
Given a dlms device
41+
| DeviceIdentification | <deviceIdentification> |
42+
| DeviceType | SMART_METER_E |
43+
| Protocol | <protocol> |
44+
| ProtocolVersion | <version> |
45+
When the Set Specific Attribute Value request is received
46+
| DeviceIdentification | <deviceIdentification> |
47+
| ObjectType | THRESHOLD_VOLTAGE_SWELL |
48+
| Attribute | 2 |
49+
| IntValue | 200 |
50+
| ObjectType_2 | TIME_THRESHOLD_VOLTAGE_SWELL |
51+
| Attribute_2 | 2 |
52+
| IntValue_2 | 60 |
53+
Then the Set Specific Attribute Value response should be returned
54+
| DeviceIdentification | <deviceIdentification> |
55+
| Result | <response> |
56+
57+
Examples:
58+
| deviceIdentification | protocol | version | response |
59+
| TEST1024000000001 | DSMR | 4.2.2 | OK |
60+
@NightlyBuildOnly
61+
Examples:
62+
| deviceIdentification | protocol | version | response |
63+
| TEST1024000000001 | DSMR | 2.2 | OK |
64+
| TEST1031000000001 | SMR | 4.3 | OK |
65+
| TEST1027000000001 | SMR | 5.0.0 | OK |
66+
| TEST1028000000001 | SMR | 5.1 | OK |
67+
| TEST1029000000001 | SMR | 5.2 | OK |
68+
| TEST1030000000001 | SMR | 5.5 | OK |

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/AdhocService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package org.opensmartgridplatform.adapter.domain.smartmetering.application.services;
66

77
import java.io.Serializable;
8+
import java.util.List;
89
import lombok.extern.slf4j.Slf4j;
910
import ma.glasnost.orika.MapperFactory;
1011
import org.opensmartgridplatform.adapter.domain.smartmetering.application.mapping.ConfigurationMapper;
@@ -27,6 +28,7 @@
2728
import org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecificAttributeValueRequestDto;
2829
import org.opensmartgridplatform.dto.valueobjects.smartmetering.SynchronizeTimeRequestDto;
2930
import org.opensmartgridplatform.dto.valueobjects.smartmetering.TestAlarmSchedulerRequestDto;
31+
import org.opensmartgridplatform.dto.valueobjects.smartmetering.ValueToSetDto;
3032
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
3133
import org.opensmartgridplatform.shared.exceptionhandling.OsgpException;
3234
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata;
@@ -264,9 +266,18 @@ public void setSpecificAttributeValue(
264266
final SmartMeter smartMeter =
265267
this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
266268

269+
final List<ValueToSetDto> valuesToSet =
270+
request.getValuesToSet().stream()
271+
.map(
272+
valueToSet ->
273+
new ValueToSetDto(
274+
valueToSet.getObjectType(),
275+
valueToSet.getAttribute(),
276+
valueToSet.getIntValue()))
277+
.toList();
278+
267279
final SetSpecificAttributeValueRequestDto requestDto =
268-
new SetSpecificAttributeValueRequestDto(
269-
request.getObjectType(), request.getAttribute(), request.getIntValue());
280+
new SetSpecificAttributeValueRequestDto(valuesToSet);
270281

271282
this.osgpCoreRequestMessageSender.send(
272283
requestDto,

osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/valueobjects/smartmetering/SetSpecificAttributeValueRequest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
package org.opensmartgridplatform.domain.core.valueobjects.smartmetering;
66

7+
import java.util.List;
8+
79
public class SetSpecificAttributeValueRequest extends SetSpecificAttributeValueRequestData {
810

911
private static final long serialVersionUID = 1;
1012

1113
private final String deviceIdentification;
1214

1315
public SetSpecificAttributeValueRequest(
14-
final String objectType,
15-
final int attribute,
16-
final int intValue,
17-
final String deviceIdentification) {
18-
super(objectType, attribute, intValue);
16+
final List<ValueToSet> valuesToSet, final String deviceIdentification) {
17+
super(valuesToSet);
1918
this.deviceIdentification = deviceIdentification;
2019
}
2120

osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/valueobjects/smartmetering/SetSpecificAttributeValueRequestData.java

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,23 @@
55
package org.opensmartgridplatform.domain.core.valueobjects.smartmetering;
66

77
import java.io.Serializable;
8+
import java.util.List;
89
import org.opensmartgridplatform.domain.core.valueobjects.DeviceFunction;
910
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
1011

1112
public class SetSpecificAttributeValueRequestData implements Serializable, ActionRequest {
1213

1314
private static final long serialVersionUID = -7326169764207317011L;
1415

15-
private final String objectType;
16-
private final int attribute;
17-
private final int intValue;
16+
private final List<ValueToSet> valuesToSet;
1817

19-
public SetSpecificAttributeValueRequestData(
20-
final String objectType, final int attribute, final int intValue) {
18+
public SetSpecificAttributeValueRequestData(final List<ValueToSet> valuesToSet) {
2119
super();
22-
this.objectType = objectType;
23-
this.attribute = attribute;
24-
this.intValue = intValue;
20+
this.valuesToSet = valuesToSet;
2521
}
2622

27-
public String getObjectType() {
28-
return this.objectType;
29-
}
30-
31-
public int getAttribute() {
32-
return this.attribute;
33-
}
34-
35-
public int getIntValue() {
36-
return this.intValue;
23+
public List<ValueToSet> getValuesToSet() {
24+
return this.valuesToSet;
3725
}
3826

3927
@Override
@@ -45,9 +33,9 @@ public void validate() throws FunctionalException {
4533
public int hashCode() {
4634
final int prime = 31;
4735
int result = 1;
48-
result = (prime * result) + this.attribute;
49-
result = (prime * result) + this.intValue;
50-
result = (prime * result) + this.objectType.hashCode();
36+
for (final ValueToSet valueToSet : this.valuesToSet) {
37+
result = (prime * result) + valueToSet.hashCode();
38+
}
5139
return result;
5240
}
5341

@@ -63,18 +51,10 @@ public boolean equals(final Object obj) {
6351
return false;
6452
}
6553
final SetSpecificAttributeValueRequestData other = (SetSpecificAttributeValueRequestData) obj;
66-
if (this.attribute != other.attribute) {
67-
return false;
68-
}
69-
if (this.intValue != other.intValue) {
70-
return false;
71-
}
72-
if (this.objectType == null) {
73-
if (other.objectType != null) {
54+
for (int i = 0; i < this.valuesToSet.size(); i++) {
55+
if (!this.valuesToSet.get(i).equals(other.valuesToSet.get(i))) {
7456
return false;
7557
}
76-
} else if (!this.objectType.equals(other.objectType)) {
77-
return false;
7858
}
7959
return true;
8060
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.opensmartgridplatform.domain.core.valueobjects.smartmetering;
6+
7+
import java.io.Serializable;
8+
9+
public class ValueToSet implements Serializable {
10+
11+
private static final long serialVersionUID = 3413354995054664052L;
12+
13+
private final String objectType;
14+
private final int attribute;
15+
private final int intValue;
16+
17+
public ValueToSet(final String objectType, final int attribute, final int intValue) {
18+
super();
19+
this.objectType = objectType;
20+
this.attribute = attribute;
21+
this.intValue = intValue;
22+
}
23+
24+
public String getObjectType() {
25+
return this.objectType;
26+
}
27+
28+
public int getAttribute() {
29+
return this.attribute;
30+
}
31+
32+
public int getIntValue() {
33+
return this.intValue;
34+
}
35+
36+
@Override
37+
public int hashCode() {
38+
final int prime = 31;
39+
int result = 1;
40+
result = (prime * result) + this.attribute;
41+
result = (prime * result) + this.intValue;
42+
result = (prime * result) + this.objectType.hashCode();
43+
return result;
44+
}
45+
46+
@Override
47+
public boolean equals(final Object obj) {
48+
if (this == obj) {
49+
return true;
50+
}
51+
if (obj == null) {
52+
return false;
53+
}
54+
if (this.getClass() != obj.getClass()) {
55+
return false;
56+
}
57+
final ValueToSet other = (ValueToSet) obj;
58+
if (this.attribute != other.attribute) {
59+
return false;
60+
}
61+
if (this.intValue != other.intValue) {
62+
return false;
63+
}
64+
if (this.objectType == null) {
65+
if (other.objectType != null) {
66+
return false;
67+
}
68+
} else if (!this.objectType.equals(other.objectType)) {
69+
return false;
70+
}
71+
return true;
72+
}
73+
}

osgp/protocol-adapter-dlms/osgp-dlms/src/main/java/org/opensmartgridplatform/dlms/objectconfig/DlmsObjectType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ public enum DlmsObjectType {
5757
AVERAGE_VOLTAGE_L3,
5858
NUMBER_OF_POWER_FAILURES,
5959
NUMBER_OF_LONG_POWER_FAILURES,
60+
THRESHOLD_VOLTAGE_SAG,
61+
TIME_THRESHOLD_VOLTAGE_SAG,
6062
NUMBER_OF_VOLTAGE_SAGS_FOR_L1,
6163
NUMBER_OF_VOLTAGE_SAGS_FOR_L2,
6264
NUMBER_OF_VOLTAGE_SAGS_FOR_L3,
65+
THRESHOLD_VOLTAGE_SWELL,
66+
TIME_THRESHOLD_VOLTAGE_SWELL,
6367
NUMBER_OF_VOLTAGE_SWELLS_FOR_L1,
6468
NUMBER_OF_VOLTAGE_SWELLS_FOR_L2,
6569
NUMBER_OF_VOLTAGE_SWELLS_FOR_L3,

0 commit comments

Comments
 (0)