Search in sources :

Example 11 with SetParameter

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

the class SetAlarmNotificationsCommandExecutorTest method setUp.

@BeforeEach
public void setUp() {
    this.setParametersReceived = new ArrayList<>();
    this.device = new DlmsDevice("SuperAwesomeHeroicRockstarDevice");
    this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
    final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(new DlmsHelper(), dlmsObjectConfigConfiguration.getDlmsObjectConfigs()) {

        @Override
        public Optional<AttributeAddress> findAttributeAddress(final DlmsDevice device, final DlmsObjectType type, final Integer channel) {
            switch(type) {
                case ALARM_FILTER_1:
                    return Optional.of(new AttributeAddress(40, "0.0.97.98.10.255", 2));
                case ALARM_FILTER_2:
                    return Optional.of(new AttributeAddress(40, "0.0.97.98.11.255", 2));
            }
            return Optional.empty();
        }
    };
    this.executor = new SetAlarmNotificationsCommandExecutor(dlmsObjectConfigService);
    final DlmsConnectionStub conn = new DlmsConnectionStub() {

        @Override
        public AccessResultCode set(final SetParameter setParameter) {
            SetAlarmNotificationsCommandExecutorTest.this.setParametersReceived.add(setParameter);
            return AccessResultCode.SUCCESS;
        }
    };
    // Set the return value to 10 (0b1010):
    // REPLACE_BATTERY enabled, AUXILIARY_EVENT enabled.
    conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.10.255", 2), DataObject.newInteger32Data(10));
    conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.11.255", 2), DataObject.newInteger32Data(0));
    this.connMgr = new DlmsConnectionManagerStub(conn);
}
Also used : DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DlmsConnectionManagerStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) SetParameter(org.openmuc.jdlms.SetParameter) DlmsObjectType(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with SetParameter

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

the class SetConfigurationObjectCommandExecutorDsmr4IT method captureSetParameterStructureData.

private List<DataObject> captureSetParameterStructureData() throws IOException {
    verify(this.dlmsConnection).set(this.setParameterArgumentCaptor.capture());
    final SetParameter setParameter = this.setParameterArgumentCaptor.getValue();
    final DataObject setParameterData = setParameter.getData();
    return setParameterData.getValue();
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SetParameter(org.openmuc.jdlms.SetParameter)

Example 13 with SetParameter

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

the class SetAdministrativeStatusCommandExecutor method execute.

@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final AdministrativeStatusTypeDto administrativeStatusType, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    LOGGER.info("Set administrative status by issuing get request for class id: {}, obis code: {}, attribute id: {}", CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
    final AttributeAddress attributeAddress = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
    final DataObject value = DataObject.newEnumerateData(this.configurationMapper.map(administrativeStatusType, Integer.class));
    final SetParameter setParameter = new SetParameter(attributeAddress, value);
    conn.getDlmsMessageListener().setDescription("SetAdminstrativeStatus to " + administrativeStatusType + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
    try {
        return conn.getConnection().set(setParameter);
    } catch (final IOException e) {
        throw new ConnectionException(e);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) IOException(java.io.IOException) SetParameter(org.openmuc.jdlms.SetParameter) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)

Example 14 with SetParameter

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

the class SetPushSetupSmsCommandExecutor method execute.

@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final PushSetupSmsDto pushSetupSms, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final SetParameter setParameterSendDestinationAndMethod = this.getSetParameter(pushSetupSms);
    final AccessResultCode resultCode = this.doSetRequest("PushSetupSms, Send destination and method", conn, setParameterSendDestinationAndMethod);
    if (resultCode != null) {
        return resultCode;
    } else {
        throw new ProtocolAdapterException("Error setting Sms push setup data.");
    }
}
Also used : AccessResultCode(org.openmuc.jdlms.AccessResultCode) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) SetParameter(org.openmuc.jdlms.SetParameter)

Example 15 with SetParameter

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

the class ConfigureDefinableLoadProfileCommandExecutor method writeCaptureObjects.

private void writeCaptureObjects(final DlmsConnectionManager conn, final List<CaptureObjectDefinitionDto> captureObjects) throws ProtocolAdapterException {
    this.dlmsLogWrite(conn, ATTRIBUTE_CAPTURE_OBJECTS, ATTRIBUTE_NAME_CAPTURE_OBJECTS);
    this.writeAttribute(conn, new SetParameter(ATTRIBUTE_CAPTURE_OBJECTS, DataObject.newArrayData(this.mapCaptureObjects(captureObjects))), ATTRIBUTE_NAME_CAPTURE_OBJECTS);
}
Also used : 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