Search in sources :

Example 41 with ObisCode

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

the class ScanMbusChannelsCommandExecutor method makeAttributeAddressesShortIds.

/**
 * @see #ATTRIBUTE_IDS_SHORT_ID
 * @see #channelShortIdsFromGetResults(List, Protocol)
 */
private static AttributeAddress[] makeAttributeAddressesShortIds() {
    final AttributeAddress[] shortIdAddresses = new AttributeAddress[NUMBER_OF_CHANNELS * NUMBER_OF_SHORT_ID_ATTRIBUTES_PER_CHANNEL];
    int index = 0;
    for (int channel = 1; channel <= NUMBER_OF_CHANNELS; channel++) {
        final ObisCode obisCode = getObisCodeMbusClientSetup(channel);
        for (int i = 0; i < NUMBER_OF_SHORT_ID_ATTRIBUTES_PER_CHANNEL; i++) {
            shortIdAddresses[index++] = new AttributeAddress(CLASS_ID, obisCode, ATTRIBUTE_IDS_SHORT_ID[i]);
        }
    }
    return shortIdAddresses;
}
Also used : AttributeAddress(org.openmuc.jdlms.AttributeAddress) ObisCode(org.openmuc.jdlms.ObisCode)

Example 42 with ObisCode

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

the class GetMbusEncryptionKeyStatusCommandExecutor method getEncryptionKeyStatusTypeDto.

public EncryptionKeyStatusTypeDto getEncryptionKeyStatusTypeDto(final short channel, final DlmsConnectionManager conn) throws ProtocolAdapterException {
    final ObisCode obisCode = OBIS_CODES.get(channel);
    final AttributeAddress getParameter = new AttributeAddress(CLASS_ID, obisCode, ATTRIBUTE_ID);
    conn.getDlmsMessageListener().setDescription("GetMbusEncryptionKeyStatusByChannel, retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(getParameter));
    LOGGER.info("Retrieving current M-Bus encryption key status by issuing get request for class id: {}, obis code: " + "{}, attribute id: {}", CLASS_ID, obisCode, ATTRIBUTE_ID);
    final DataObject dataObject = this.getValidatedResultData(conn, getParameter);
    return EncryptionKeyStatusTypeDto.valueOf(EncryptionKeyStatusType.fromValue(dataObject.getValue()).name());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ObisCode(org.openmuc.jdlms.ObisCode)

Example 43 with ObisCode

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

the class SimulatedAlarmObjectSteps method deviceHasSomeAlarmsRegistered.

@Given("^device \"([^\"]*)\" has alarm register \"([^\"]*)\" with some value$")
public void deviceHasSomeAlarmsRegistered(final String deviceIdentification, final int alarmRegisterNr) {
    this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
    final ObisCode alarmRegisterObisCode = this.getAlarmRegisterObisCode(alarmRegisterNr);
    final ObjectNode attributeValue = this.jsonObjectCreator.createAttributeValue("double-long-unsigned", ALARM_VALUE);
    this.deviceSimulatorSteps.setDlmsAttributeValue(CLASS_ID, alarmRegisterObisCode, ATTRIBUTE_ID_VALUE, attributeValue, OBJECT_DESCRIPTION);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObisCode(org.openmuc.jdlms.ObisCode) Given(io.cucumber.java.en.Given)

Example 44 with ObisCode

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

the class DeviceChannelsHelperTest method testGetObisCode.

@Test
void testGetObisCode() throws ProtocolAdapterException {
    final int channel = 1;
    final ObisCode obisCode = this.deviceChannelsHelper.getObisCode(this.device, channel);
    assertThat(obisCode.asDecimalString()).isEqualTo(OBIS_CODE_MBUS_CHANNEL_ONE);
}
Also used : ObisCode(org.openmuc.jdlms.ObisCode) Test(org.junit.jupiter.api.Test)

Example 45 with ObisCode

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

the class MBusClientObjectSteps method theValuesForMbusClientOnDeviceSimulatorAre.

@Then("^the values for the M-Bus client for channel (\\d+) on device simulator \"([^\"]*)\" are$")
public void theValuesForMbusClientOnDeviceSimulatorAre(final int channel, final String deviceIdentification, final Map<String, String> expectedAttributes) throws Throwable {
    final ObisCode obisCode = new ObisCode(0, channel, 24, 1, 0, 255);
    final ObjectNode attributeValuesNode = this.deviceSimulatorSteps.getDlmsAttributeValues(CLASS_ID, obisCode, "M-Bus client attributes");
    expectedAttributes.forEach((key, value) -> {
        switch(key) {
            case MBUS_PRIMARY_ADDRESS:
                this.verifyStandardAttribute(attributeValuesNode, ATTRIBUTE_ID_PRIMARY_ADDRESS, value);
                break;
            case MBUS_VERSION:
                this.verifyStandardAttribute(attributeValuesNode, ATTRIBUTE_ID_VERSION, value);
                break;
            case MBUS_DEVICE_TYPE_IDENTIFICATION:
                this.verifyStandardAttribute(attributeValuesNode, ATTRIBUTE_ID_DEVICE_TYPE, value);
                break;
            case MBUS_IDENTIFICATION_NUMBER:
                this.verifyIdentificationNumber(attributeValuesNode, value);
                break;
            case MBUS_MANUFACTURER_IDENTIFICATION:
                this.verifyManufacturerIdentification(attributeValuesNode, value);
                break;
            default:
                throw new IllegalArgumentException("Unsupported attribute: " + key);
        }
    });
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) 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