Search in sources :

Example 1 with ObisCode

use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.

the class SimulatedAlarmObjectSteps method deviceAlarmRegistersHasNotBeenCleared.

@Then("^alarm register \"([^\"]*)\" of device \"([^\"]*)\" has not been cleared$")
public void deviceAlarmRegistersHasNotBeenCleared(final int alarmRegisterNr, final String deviceIdentification) {
    this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
    final ObisCode alarmRegisterObisCode = this.getAlarmRegisterObisCode(alarmRegisterNr);
    final ObjectNode result = this.deviceSimulatorSteps.getDlmsAttributeValue(CLASS_ID, alarmRegisterObisCode, ATTRIBUTE_ID_VALUE, OBJECT_DESCRIPTION);
    assertThat(result.get("value").intValue()).isNotZero();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObisCode(org.openmuc.jdlms.ObisCode) Then(io.cucumber.java.en.Then)

Example 2 with ObisCode

use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.

the class SimulatedAlarmObjectSteps method deviceAlarmRegistersHasBeenCleared.

@Then("^alarm register \"([^\"]*)\" of device \"([^\"]*)\" has been cleared$")
public void deviceAlarmRegistersHasBeenCleared(final int alarmRegisterNr, final String deviceIdentification) {
    this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
    final ObisCode alarmRegisterObisCode = this.getAlarmRegisterObisCode(alarmRegisterNr);
    final ObjectNode result = this.deviceSimulatorSteps.getDlmsAttributeValue(CLASS_ID, alarmRegisterObisCode, ATTRIBUTE_ID_VALUE, OBJECT_DESCRIPTION);
    assertThat(result.get("value").intValue()).isZero();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObisCode(org.openmuc.jdlms.ObisCode) Then(io.cucumber.java.en.Then)

Example 3 with ObisCode

use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.

the class MBusClientObjectSteps method deviceSimulationOfMBusClientObject.

@Given("^device simulation of \"([^\"]*)\" with M-Bus client version (\\d+) values for channel (\\d+)$")
public void deviceSimulationOfMBusClientObject(final String deviceIdentification, final int version, final int channel, final Map<String, String> inputSettings) throws Throwable {
    this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
    final ObisCode obisCode = new ObisCode(0, channel, 24, 1, 0, 255);
    inputSettings.forEach((key, value) -> {
        switch(key) {
            case MBUS_PRIMARY_ADDRESS:
                this.setStandardAttribute(value, "unsigned", ATTRIBUTE_ID_PRIMARY_ADDRESS, obisCode);
                break;
            case MBUS_IDENTIFICATION_NUMBER:
                this.setIdentificationNumberAttribute(value, obisCode, version);
                break;
            case MBUS_MANUFACTURER_IDENTIFICATION:
                this.setManufacturerIdAttribute(value, obisCode);
                break;
            case MBUS_VERSION:
                this.setStandardAttribute(value, "unsigned", ATTRIBUTE_ID_VERSION, obisCode);
                break;
            case MBUS_DEVICE_TYPE_IDENTIFICATION:
                this.setStandardAttribute(value, "unsigned", ATTRIBUTE_ID_DEVICE_TYPE, obisCode);
                break;
            case MBUS_ENCRYPTION_KEY_STATUS:
                this.setStandardAttribute(value, "enumerate", ATTRIBUTE_ID_ENCRYPTION_KEY_STATUS, obisCode);
                break;
            default:
                throw new IllegalArgumentException("Unsupported attribute: " + key);
        }
    });
}
Also used : ObisCode(org.openmuc.jdlms.ObisCode) Given(io.cucumber.java.en.Given)

Example 4 with ObisCode

use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.

the class DeviceSimulatorSteps method deviceSimulationOfObisCodeWithClassIdAndAttributes.

@Given("^device simulation of \"([^\"]*)\" with classid (\\d+) obiscode \"([^\"]*)\" and attributes$")
public void deviceSimulationOfObisCodeWithClassIdAndAttributes(final String deviceIdentification, final int classId, final String obisCode, final List<List<String>> attributes) throws Throwable {
    /*
     * Currently the first argument: deviceIdentification, is not used yet,
     * because in all scenarios created so far that make use of dynamic
     * device simulator properties, only one meter was read. In future
     * scenarios it may be possible that within a single scenario two (or
     * more) meters should be read, and that both meters should read their
     * own set of dynamic properties. In that case the deviceIdentification
     * parameter can be used to make this distinction.
     */
    this.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
    this.setDlmsAttributeValues(classId, new ObisCode(obisCode), this.jsonObjectCreator.convertTableToJsonObject(attributes), GENERIC_ATTRIBUTES_FROM_SCENARIO);
}
Also used : ObisCode(org.openmuc.jdlms.ObisCode) Given(io.cucumber.java.en.Given)

Example 5 with ObisCode

use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.

the class DeviceSimulatorSteps method theValuesForClassidObiscodeOnDeviceSimulatorAre.

@Then("^the values for classid (\\d+) obiscode \"([^\"]*)\" on device simulator \"([^\"]*)\" are$")
public void theValuesForClassidObiscodeOnDeviceSimulatorAre(final int classId, final String obisCode, final String deviceIdentification, final List<List<String>> expectedAttributes) throws Throwable {
    final ObjectNode attributeValuesNode = this.getDlmsAttributeValues(classId, new ObisCode(obisCode), GENERIC_ATTRIBUTES_FROM_SCENARIO);
    final ObjectNode expectedAttributeValuesNode = this.jsonObjectCreator.convertTableToJsonObject(expectedAttributes);
    expectedAttributeValuesNode.fields().forEachRemaining(field -> {
        final String attributeId = field.getKey();
        final JsonNode expectedAttributeValue = field.getValue();
        final JsonNode actualAttributeValue = attributeValuesNode.get(attributeId);
        assertThat(actualAttributeValue).as("a value must be available for attributeId: " + attributeId).isNotNull();
        assertThat(actualAttributeValue).as("value for attributeId: " + attributeId).isEqualTo(expectedAttributeValue);
    });
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObisCode(org.openmuc.jdlms.ObisCode) Then(io.cucumber.java.en.Then)

Aggregations

ObisCode (org.openmuc.jdlms.ObisCode)45 AttributeAddress (org.openmuc.jdlms.AttributeAddress)14 Bean (org.springframework.context.annotation.Bean)9 BitString (org.openmuc.jdlms.datatypes.BitString)8 DataObject (org.openmuc.jdlms.datatypes.DataObject)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 OctetStringData (org.opensmartgridplatform.simulator.protocol.dlms.cosem.OctetStringData)6 Then (io.cucumber.java.en.Then)4 GetResult (org.openmuc.jdlms.GetResult)4 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)4 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)4 Given (io.cucumber.java.en.Given)3 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)3 CosemClass (org.openmuc.jdlms.CosemClass)3 ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)3 IOException (java.io.IOException)2 DlmsCaptureObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsCaptureObject)2 CosemObjectAccessor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.CosemObjectAccessor)2 DataObjectAttrExecutors (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutors)2