Search in sources :

Example 6 with ObisCode

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

the class DeviceSimulatorSteps method deviceSimulationOfEquipmentIdentifier.

public void deviceSimulationOfEquipmentIdentifier(final String deviceIdentification) {
    final ObisCode obisCodeEquipmentIdentifier = new ObisCode(0, 0, 96, 1, 1, 255);
    final ObjectNode attributeValues = this.jsonObjectCreator.convertTableToJsonObject(Arrays.asList(Arrays.asList("2", "octet-string", Hex.encodeHexString(deviceIdentification.getBytes(StandardCharsets.US_ASCII)))));
    this.setDlmsAttributeValues(InterfaceClass.DATA.id(), obisCodeEquipmentIdentifier, attributeValues, "the E-meter Equipment Identifier");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObisCode(org.openmuc.jdlms.ObisCode)

Example 7 with ObisCode

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

the class DlmsObjectConfigService method getAttributeAddressForProfile.

private AttributeAddressForProfile getAttributeAddressForProfile(final AddressRequest addressRequest) {
    final List<DlmsCaptureObject> selectedObjects = new ArrayList<>();
    final SelectiveAccessDescription access = this.getAccessDescription(addressRequest, selectedObjects);
    final DlmsObject dlmsObject = addressRequest.getDlmsObject();
    final ObisCode obisCode = this.replaceChannel(dlmsObject.getObisCodeAsString(), addressRequest.getChannel());
    return new AttributeAddressForProfile(new AttributeAddress(dlmsObject.getClassId(), obisCode, dlmsObject.getDefaultAttributeId(), access), selectedObjects);
}
Also used : SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) ArrayList(java.util.ArrayList) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ObisCode(org.openmuc.jdlms.ObisCode) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)

Example 8 with ObisCode

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

the class Smr5Profile method configurationObject.

@Bean
public ConfigurationObject configurationObject() {
    final Byte[] bytes = new Byte[this.configurationObjectFlags.size()];
    this.configurationObjectFlags.toArray(bytes);
    this.dynamicValues().setDefaultAttributeValue(InterfaceClass.DATA.id(), new ObisCode(0, 1, 94, 31, 3, 255), ConfigurationObject.ATTRIBUTE_ID_VALUE, DataObject.newBitStringData(new BitString(ArrayUtils.toPrimitive(bytes), 16)));
    return new ConfigurationObject();
}
Also used : BitString(org.openmuc.jdlms.datatypes.BitString) ConfigurationObject(org.opensmartgridplatform.simulator.protocol.dlms.cosem.ConfigurationObject) ObisCode(org.openmuc.jdlms.ObisCode) Bean(org.springframework.context.annotation.Bean)

Example 9 with ObisCode

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

the class DynamicValues method getDlmsAttributeValue.

public DataObject getDlmsAttributeValue(final CosemInterfaceObject cosemInterfaceObject, final Integer attributeId) {
    final int classId = cosemInterfaceObject.getClass().getAnnotation(CosemClass.class).id();
    final ObisCode obisCode = cosemInterfaceObject.getInstanceId();
    final DataObject result = this.getDlmsAttributeValue(classId, obisCode, attributeId);
    if (result != null) {
        return result;
    }
    return this.getDefaultAttributeValue(classId, obisCode, attributeId);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ObisCode(org.openmuc.jdlms.ObisCode) CosemClass(org.openmuc.jdlms.CosemClass)

Example 10 with ObisCode

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

the class DynamicValues method setDlmsAttributeValue.

/**
 * This methods sends a json request to the dlmsAttributeValuesClient, to store the given
 * attribute with the associated obiscode and attributeId, so that a next get request will
 * retrieve this value.
 */
public void setDlmsAttributeValue(final CosemInterfaceObject cosemInterfaceObject, final Integer attributeId, final DataObject dataObject) {
    try {
        final int classId = cosemInterfaceObject.getClass().getAnnotation(CosemClass.class).id();
        final ObisCode obisCode = cosemInterfaceObject.getInstanceId();
        this.dlmsAttributeValuesClient.setDlmsAttributeValue(classId, obisCode, attributeId, dataObject);
    } catch (final DlmsAttributeValuesClientException e) {
        LOGGER.error("An error occured while setting a attribute on the simulator", e);
        throw new WebApplicationException("Error accessing DLMS Attribute Values Service", e);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) DlmsAttributeValuesClientException(org.opensmartgridplatform.simulator.protocol.dlms.rest.client.DlmsAttributeValuesClientException) ObisCode(org.openmuc.jdlms.ObisCode) CosemClass(org.openmuc.jdlms.CosemClass)

Aggregations

ObisCode (org.openmuc.jdlms.ObisCode)46 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)8 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