Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.AllowedObjectType;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueAsyncRequest;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueRequest;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ValueToSet;
import org.opensmartgridplatform.cucumber.platform.smartmetering.PlatformSmartmeteringKeys;
import org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.RequestFactoryHelper;

Expand All @@ -23,10 +24,22 @@ public static SetSpecificAttributeValueRequest fromParameterMap(
final SetSpecificAttributeValueRequest request = new SetSpecificAttributeValueRequest();
request.setDeviceIdentification(
parameters.get(PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION));
request.setObjectType(
final ValueToSet valueToSet = new ValueToSet();
valueToSet.setObjectType(
AllowedObjectType.valueOf(parameters.get(PlatformSmartmeteringKeys.OBJECT_TYPE)));
request.setAttribute(new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE)));
request.setIntValue(new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE)));
valueToSet.setAttribute(new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE)));
valueToSet.setIntValue(new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE)));
request.getValuesToSet().add(valueToSet);
if (parameters.containsKey(PlatformSmartmeteringKeys.OBJECT_TYPE + "_2")) {
final ValueToSet valueToSet2 = new ValueToSet();
valueToSet2.setObjectType(
AllowedObjectType.valueOf(parameters.get(PlatformSmartmeteringKeys.OBJECT_TYPE + "_2")));
valueToSet2.setAttribute(
new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE + "_2")));
valueToSet2.setIntValue(
new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE + "_2")));
request.getValuesToSet().add(valueToSet2);
}
return request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,34 @@ Feature: SmartMetering AdHoc
| TEST1028000000001 | SMR | 5.1 | OK |
| TEST1029000000001 | SMR | 5.2 | OK |
| TEST1030000000001 | SMR | 5.5 | OK |

Scenario Outline: Set sag and swell settings for a <protocol> <version> device
Given a dlms device
| DeviceIdentification | <deviceIdentification> |
| DeviceType | SMART_METER_E |
| Protocol | <protocol> |
| ProtocolVersion | <version> |
When the Set Specific Attribute Value request is received
| DeviceIdentification | <deviceIdentification> |
| ObjectType | THRESHOLD_VOLTAGE_SWELL |
| Attribute | 2 |
| IntValue | 200 |
| ObjectType_2 | TIME_THRESHOLD_VOLTAGE_SWELL |
| Attribute_2 | 2 |
| IntValue_2 | 60 |
Then the Set Specific Attribute Value response should be returned
| DeviceIdentification | <deviceIdentification> |
| Result | <response> |

Examples:
| deviceIdentification | protocol | version | response |
| TEST1024000000001 | DSMR | 4.2.2 | OK |
@NightlyBuildOnly
Examples:
| deviceIdentification | protocol | version | response |
| TEST1024000000001 | DSMR | 2.2 | OK |
| TEST1031000000001 | SMR | 4.3 | OK |
| TEST1027000000001 | SMR | 5.0.0 | OK |
| TEST1028000000001 | SMR | 5.1 | OK |
| TEST1029000000001 | SMR | 5.2 | OK |
| TEST1030000000001 | SMR | 5.5 | OK |
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.opensmartgridplatform.adapter.domain.smartmetering.application.services;

import java.io.Serializable;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import ma.glasnost.orika.MapperFactory;
import org.opensmartgridplatform.adapter.domain.smartmetering.application.mapping.ConfigurationMapper;
Expand All @@ -27,6 +28,7 @@
import org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecificAttributeValueRequestDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.SynchronizeTimeRequestDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.TestAlarmSchedulerRequestDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.ValueToSetDto;
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
import org.opensmartgridplatform.shared.exceptionhandling.OsgpException;
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata;
Expand Down Expand Up @@ -264,9 +266,18 @@ public void setSpecificAttributeValue(
final SmartMeter smartMeter =
this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());

final List<ValueToSetDto> valuesToSet =
request.getValuesToSet().stream()
.map(
valueToSet ->
new ValueToSetDto(
valueToSet.getObjectType(),
valueToSet.getAttribute(),
valueToSet.getIntValue()))
.toList();

final SetSpecificAttributeValueRequestDto requestDto =
new SetSpecificAttributeValueRequestDto(
request.getObjectType(), request.getAttribute(), request.getIntValue());
new SetSpecificAttributeValueRequestDto(valuesToSet);

this.osgpCoreRequestMessageSender.send(
requestDto,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

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

import java.util.List;

public class SetSpecificAttributeValueRequest extends SetSpecificAttributeValueRequestData {

private static final long serialVersionUID = 1;

private final String deviceIdentification;

public SetSpecificAttributeValueRequest(
final String objectType,
final int attribute,
final int intValue,
final String deviceIdentification) {
super(objectType, attribute, intValue);
final List<ValueToSet> valuesToSet, final String deviceIdentification) {
super(valuesToSet);
this.deviceIdentification = deviceIdentification;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,23 @@
package org.opensmartgridplatform.domain.core.valueobjects.smartmetering;

import java.io.Serializable;
import java.util.List;
import org.opensmartgridplatform.domain.core.valueobjects.DeviceFunction;
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;

public class SetSpecificAttributeValueRequestData implements Serializable, ActionRequest {

private static final long serialVersionUID = -7326169764207317011L;

private final String objectType;
private final int attribute;
private final int intValue;
private final List<ValueToSet> valuesToSet;

public SetSpecificAttributeValueRequestData(
final String objectType, final int attribute, final int intValue) {
public SetSpecificAttributeValueRequestData(final List<ValueToSet> valuesToSet) {
super();
this.objectType = objectType;
this.attribute = attribute;
this.intValue = intValue;
this.valuesToSet = valuesToSet;
}

public String getObjectType() {
return this.objectType;
}

public int getAttribute() {
return this.attribute;
}

public int getIntValue() {
return this.intValue;
public List<ValueToSet> getValuesToSet() {
return this.valuesToSet;
}

@Override
Expand All @@ -45,9 +33,9 @@ public void validate() throws FunctionalException {
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + this.attribute;
result = (prime * result) + this.intValue;
result = (prime * result) + this.objectType.hashCode();
for (final ValueToSet valueToSet : this.valuesToSet) {
result = (prime * result) + valueToSet.hashCode();
}
return result;
}

Expand All @@ -63,18 +51,10 @@ public boolean equals(final Object obj) {
return false;
}
final SetSpecificAttributeValueRequestData other = (SetSpecificAttributeValueRequestData) obj;
if (this.attribute != other.attribute) {
return false;
}
if (this.intValue != other.intValue) {
return false;
}
if (this.objectType == null) {
if (other.objectType != null) {
for (int i = 0; i < this.valuesToSet.size(); i++) {
if (!this.valuesToSet.get(i).equals(other.valuesToSet.get(i))) {
return false;
}
} else if (!this.objectType.equals(other.objectType)) {
return false;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project
//
// SPDX-License-Identifier: Apache-2.0

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

import java.io.Serializable;

public class ValueToSet implements Serializable {

private static final long serialVersionUID = 3413354995054664052L;

private final String objectType;
private final int attribute;
private final int intValue;

public ValueToSet(final String objectType, final int attribute, final int intValue) {
super();
this.objectType = objectType;
this.attribute = attribute;
this.intValue = intValue;
}

public String getObjectType() {
return this.objectType;
}

public int getAttribute() {
return this.attribute;
}

public int getIntValue() {
return this.intValue;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + this.attribute;
result = (prime * result) + this.intValue;
result = (prime * result) + this.objectType.hashCode();
return result;
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
final ValueToSet other = (ValueToSet) obj;
if (this.attribute != other.attribute) {
return false;
}
if (this.intValue != other.intValue) {
return false;
}
if (this.objectType == null) {
if (other.objectType != null) {
return false;
}
} else if (!this.objectType.equals(other.objectType)) {
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ public enum DlmsObjectType {
AVERAGE_VOLTAGE_L3,
NUMBER_OF_POWER_FAILURES,
NUMBER_OF_LONG_POWER_FAILURES,
THRESHOLD_VOLTAGE_SAG,
TIME_THRESHOLD_VOLTAGE_SAG,
NUMBER_OF_VOLTAGE_SAGS_FOR_L1,
NUMBER_OF_VOLTAGE_SAGS_FOR_L2,
NUMBER_OF_VOLTAGE_SAGS_FOR_L3,
THRESHOLD_VOLTAGE_SWELL,
TIME_THRESHOLD_VOLTAGE_SWELL,
NUMBER_OF_VOLTAGE_SWELLS_FOR_L1,
NUMBER_OF_VOLTAGE_SWELLS_FOR_L2,
NUMBER_OF_VOLTAGE_SWELLS_FOR_L3,
Expand Down
Loading