Search in sources :

Example 31 with SetParameter

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

the class CosemObjectAccessor method writeAttribute.

public void writeAttribute(final AttributeClass attributeClass, final DataObject data) throws ProtocolAdapterException {
    final AttributeAddress attributeAddress = this.createAttributeAddress(attributeClass);
    final SetParameter setParameter = new SetParameter(attributeAddress, data);
    final AccessResultCode accessResultCode;
    try {
        accessResultCode = this.connector.getConnection().set(setParameter);
    } catch (final IOException e) {
        throw new ProtocolAdapterException(String.format(EXCEPTION_MSG_WRITING_ATTRIBUTE, attributeClass, this.classId, this.obisCode), e);
    }
    if (accessResultCode != AccessResultCode.SUCCESS) {
        throw new ProtocolAdapterException(String.format(EXCEPTION_MSG_ACCESS_RESULT_NOT_SUCCESS, accessResultCode.name(), attributeClass, this.classId, this.obisCode));
    }
}
Also used : AttributeAddress(org.openmuc.jdlms.AttributeAddress) AccessResultCode(org.openmuc.jdlms.AccessResultCode) IOException(java.io.IOException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) SetParameter(org.openmuc.jdlms.SetParameter)

Aggregations

SetParameter (org.openmuc.jdlms.SetParameter)31 AttributeAddress (org.openmuc.jdlms.AttributeAddress)14 DataObject (org.openmuc.jdlms.datatypes.DataObject)12 AccessResultCode (org.openmuc.jdlms.AccessResultCode)11 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)5 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)4 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)4 ActivityCalendarDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto)4 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)3 CosemTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)3 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)3 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 CosemDateTime (org.openmuc.jdlms.datatypes.CosemDateTime)1 DlmsObjectConfigConfiguration (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration)1 DlmsObjectConfigService (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService)1