Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/smhe 1740 config service test alarm scheduler command executor #1087

Merged
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
@@ -1,29 +1,32 @@
# SPDX-FileCopyrightText: Contributors to the GXF project
#
# SPDX-License-Identifier: Apache-2.0

@SmartMetering @Platform @SmartMeteringAdHoc @NightlyBuildOnly
Feature: SmartMetering schedule test alarms
As a grid operator
I want to be able to set a test alarm on a device
So scheduled alarms will be sent

Scenario: Set test alarm PARTIAL_POWER_OUTAGE on a device
Scenario Outline: Set test alarm PARTIAL_POWER_OUTAGE on a <protocol> <version> device
Given a dlms device
| DeviceIdentification | TEST1027000000001 |
| DeviceType | SMART_METER_E |
| Protocol | SMR |
| ProtocolVersion | 5.0.0 |
| Port | 1027 |
| Protocol | <protocol> |
| ProtocolVersion | <version> |
When receiving a test alarm scheduler request
| DeviceIdentification | TEST1027000000001 |
| TestAlarmType | PARTIAL_POWER_OUTAGE |
| Time | 2088-01-01T00:00:00Z |
Then a response is received
| DeviceIdentification | TEST1027000000001 |

Examples:
| protocol | version |
| SMR | 5.1 |
| SMR | 5.2 |
| SMR | 5.5 |

Scenario: Set test alarm LAST_GASP on a device
Scenario: Set test alarm LAST_GASP on a SMR 5.5 device
Given a dlms device
| DeviceIdentification | TEST1030000000001 |
| DeviceType | SMART_METER_E |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public enum DlmsDataType {
TIME,
@JsonProperty("dont-care")
DONT_CARE,
@JsonProperty("script")
SCRIPT,

// Data types for specific classes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public enum DlmsObjectType {
ALARM_FILTER_2,
ALARM_FILTER_3,
READ_MBUS_STATUS,
CLEAR_MBUS_STATUS;
CLEAR_MBUS_STATUS,
PHASE_OUTAGE_TEST,
LAST_GASP_TEST;

public String value() {
return this.name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@
"access": "RW"
}
]
},
{
"tag": "PHASE_OUTAGE_TEST",
"description": "Phase outage test scheduler",
"note": null,
"class-id": 22,
"version": 0,
"obis": "0.0.15.1.4.255",
"group": "ELECTRICITY",
"meterTypes": ["PP"],
"properties": {},
"attributes": [
{
"id": 2,
"description": "executed_script",
"datatype": "script",
"valuetype": "DYNAMIC",
"access": "R"
},
{
"id": 3,
"description": "type",
"datatype": "enum",
"valuetype": "DYNAMIC",
"value": "1",
"access": "R"
},
{
"id": 4,
"description": "execution time",
"datatype": "array",
"valuetype": "SET_BY_CLIENT",
"access": "RW"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,41 @@
"access": "RW"
}
]
}]
},
{
"tag": "LAST_GASP_TEST",
"description": "Last gasp test scheduler",
"note": "Specified in addendum for SMR5.5",
"class-id": 22,
"version": 0,
"obis": "0.0.15.2.4.255",
"group": "ELECTRICITY",
"meterTypes": ["PP"],
"properties": {},
"attributes": [
{
"id": 2,
"description": "executed_script",
"datatype": "script",
"valuetype": "DYNAMIC",
"access": "R"
},
{
"id": 3,
"description": "type",
"datatype": "enum",
"valuetype": "DYNAMIC",
"value": "1",
"access": "R"
},
{
"id": 4,
"description": "execution time",
"datatype": "array",
"valuetype": "SET_BY_CLIENT",
"access": "RW"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public enum Protocol {
SMR_4_3("SMR", "4.3", 46, 11, 27, 6, 14, 6, 13, 6, 7, true, false),
SMR_5_0_0("SMR", "5.0.0", 52, 11, 27, 6, 14, 6, 15, 9, 14, true, true),

SMR_5_1("SMR", "5.1", 53, 11, 27, 6, 14, 6, 15, 9, 14, true, true),
SMR_5_2("SMR", "5.2", 56, 11, 27, 6, 14, 6, 15, 10, 15, true, true),
SMR_5_5("SMR", "5.5", 59, 11, 27, 6, 14, 6, 15, 10, 15, true, true);
SMR_5_1("SMR", "5.1", 54, 11, 27, 6, 14, 6, 15, 9, 14, true, true),
SMR_5_2("SMR", "5.2", 57, 11, 27, 6, 14, 6, 15, 10, 15, true, true),
SMR_5_5("SMR", "5.5", 61, 11, 27, 6, 14, 6, 15, 10, 15, true, true);

private final String name;
private final String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import org.openmuc.jdlms.datatypes.CosemTime;
import org.openmuc.jdlms.datatypes.DataObject;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.AbstractCommandExecutor;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsDateTimeConverter;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ObjectConfigServiceHelper;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager;
import org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException;
import org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException;
Expand All @@ -39,7 +39,7 @@
public class TestAlarmSchedulerCommandExecutor
extends AbstractCommandExecutor<TestAlarmSchedulerRequestDto, AccessResultCode> {

@Autowired private DlmsObjectConfigService dlmsObjectConfigService;
@Autowired private ObjectConfigServiceHelper objectConfigServiceHelper;

public TestAlarmSchedulerCommandExecutor() {
super(TestAlarmSchedulerRequestDto.class);
Expand Down Expand Up @@ -79,17 +79,19 @@ public AccessResultCode execute(

final DlmsObjectType alarmObjectType = toAlarmObjectType(alarmTypeDto);

final DlmsObject dlmsObject =
this.dlmsObjectConfigService.getDlmsObject(device, alarmObjectType);
final DateTime convertedDateTime =
DlmsDateTimeConverter.toDateTime(scheduleDate, device.getTimezone());
final Protocol protocol = Protocol.forDevice(device);

final AttributeAddress attributeAddress =
new AttributeAddress(
dlmsObject.getClassId(),
dlmsObject.getObisCode(),
this.objectConfigServiceHelper.findAttributeAddress(
device,
protocol,
alarmObjectType,
null,
SingleActionScheduleAttribute.EXECUTION_TIME.attributeId());

final DateTime convertedDateTime =
DlmsDateTimeConverter.toDateTime(scheduleDate, device.getTimezone());

final DataObject timeDataObject = getDataObjectTime(convertedDateTime);
final DataObject dateDataObject = getDataObjectDate(convertedDateTime);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
import org.openmuc.jdlms.datatypes.CosemDate;
import org.openmuc.jdlms.datatypes.CosemTime;
import org.openmuc.jdlms.datatypes.DataObject;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DateTimeParserUtil;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ObjectConfigServiceHelper;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice;
import org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol;
import org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException;
import org.opensmartgridplatform.dlms.interfaceclass.InterfaceClass;
import org.opensmartgridplatform.dlms.interfaceclass.attribute.SingleActionScheduleAttribute;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.TestAlarmSchedulerRequestDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.TestAlarmTypeDto;
Expand All @@ -59,11 +61,7 @@ class TestAlarmSchedulerCommandExecutorTest {

@Mock private MessageMetadata messageMetadata;

@Mock private DlmsObjectConfigService dlmsObjectConfigService;

@Mock private DlmsObject dlmsObject;

@Mock private ObisCode obisCode;
@Mock private ObjectConfigServiceHelper objectConfigServiceHelper;

private DlmsConnectionManagerStub connectionManagerStub;
private DlmsConnectionStub connectionStub;
Expand Down Expand Up @@ -189,14 +187,24 @@ private void setupAlarmSchedulerRequest(final String alarmType, final Date date)

private void setupConfigService(final String alarmType, final String obisCodeString)
throws ProtocolAdapterException {
when(this.dlmsObjectConfigService.getDlmsObject(
final AttributeAddress attributeAddress =
new AttributeAddress(
InterfaceClass.SINGLE_ACTION_SCHEDULE.id(),
new ObisCode(obisCodeString),
SingleActionScheduleAttribute.EXECUTION_TIME.attributeId());

when(this.objectConfigServiceHelper.findAttributeAddress(
this.device,
TestAlarmSchedulerCommandExecutor.toAlarmObjectType(
TestAlarmTypeDto.valueOf(alarmType))))
.thenReturn(this.dlmsObject);
Protocol.OTHER_PROTOCOL,
toAlarmObjectType(TestAlarmTypeDto.valueOf(alarmType)),
null,
SingleActionScheduleAttribute.EXECUTION_TIME.attributeId()))
.thenReturn(attributeAddress);
}

when(this.obisCode.toString()).thenReturn(obisCodeString);
when(this.dlmsObject.getClassId()).thenReturn(SINGLE_ACTION_CLASS_ID);
when(this.dlmsObject.getObisCode()).thenReturn(this.obisCode);
protected static DlmsObjectType toAlarmObjectType(final TestAlarmTypeDto alarmTypeDto) {
return TestAlarmTypeDto.PARTIAL_POWER_OUTAGE.equals(alarmTypeDto)
? DlmsObjectType.PHASE_OUTAGE_TEST
: DlmsObjectType.LAST_GASP_TEST;
}
}
Loading