Search in sources :

Example 16 with AttributeAddress

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

the class SetActivityCalendarCommandExecutorTest method verifySetParameterWeekProfiles.

private void verifySetParameterWeekProfiles(final SetParameter setParameter, final List<String> weekNames, final List<Short> dayIds) {
    final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
    assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID);
    assertThat(attributeAddress.getInstanceId()).isEqualTo(OBIS_CODE);
    assertThat(attributeAddress.getId()).isEqualTo(ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
    final DataObject dataObject = setParameter.getData();
    assertThat(dataObject.getType()).isEqualTo(Type.ARRAY);
    final List<DataObject> weeks = dataObject.getValue();
    this.verifyWeeks(weeks, weekNames, dayIds);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress)

Example 17 with AttributeAddress

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

the class GetFirmwareVersionsCommandExecutorTest method returns4FirmwareVersionsForSmr51Device.

@Test
public void returns4FirmwareVersionsForSmr51Device() throws Exception {
    final DlmsDevice device = new DlmsDevice();
    device.setProtocol(Protocol.SMR_5_1);
    final GetResult getResult1 = new GetResultBuilder().build();
    final GetResult getResult2 = new GetResultBuilder().build();
    final GetResult getResult3 = new GetResultBuilder().build();
    final GetResult getResult4 = new GetResultBuilder().build();
    when(this.helperService.getAndCheck(same(this.connectionHolder), same(device), eq("retrieve firmware versions"), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_COMMUNICATION_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_MBUS_DRIVER_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)))).thenReturn(asList(getResult1, getResult2, getResult3, getResult4));
    when(this.helperService.readString(getResult1.getResultData(), FirmwareModuleType.ACTIVE_FIRMWARE.getDescription())).thenReturn("string1");
    when(this.helperService.readString(getResult2.getResultData(), FirmwareModuleType.MODULE_ACTIVE.getDescription())).thenReturn("string2");
    when(this.helperService.readString(getResult3.getResultData(), FirmwareModuleType.COMMUNICATION.getDescription())).thenReturn("string3");
    when(this.helperService.readString(getResult4.getResultData(), FirmwareModuleType.M_BUS_DRIVER_ACTIVE.getDescription())).thenReturn("string4");
    final List<FirmwareVersionDto> result = this.executor.execute(this.connectionHolder, device, null, this.messageMetadata);
    Assertions.assertThat(result).usingRecursiveFieldByFieldElementComparator().containsExactly(new FirmwareVersionDto(FirmwareModuleType.ACTIVE_FIRMWARE, "string1"), new FirmwareVersionDto(FirmwareModuleType.MODULE_ACTIVE, "string2"), new FirmwareVersionDto(FirmwareModuleType.COMMUNICATION, "string3"), new FirmwareVersionDto(FirmwareModuleType.M_BUS_DRIVER_ACTIVE, "string4"));
}
Also used : GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetResultBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultBuilder) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) Test(org.junit.jupiter.api.Test)

Example 18 with AttributeAddress

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

the class GetFirmwareVersionsCommandExecutorTest method returns3FirmwareVersionsForDsmr422Device.

@Test
public void returns3FirmwareVersionsForDsmr422Device() throws Exception {
    final DlmsDevice device = new DlmsDevice();
    final GetResult getResult1 = new GetResultBuilder().build();
    final GetResult getResult2 = new GetResultBuilder().build();
    final GetResult getResult3 = new GetResultBuilder().build();
    when(this.helperService.getAndCheck(same(this.connectionHolder), same(device), eq("retrieve firmware versions"), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_COMMUNICATION_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)))).thenReturn(asList(getResult1, getResult2, getResult3));
    when(this.helperService.readString(getResult1.getResultData(), FirmwareModuleType.ACTIVE_FIRMWARE.getDescription())).thenReturn("string1");
    when(this.helperService.readString(getResult2.getResultData(), FirmwareModuleType.MODULE_ACTIVE.getDescription())).thenReturn("string2");
    when(this.helperService.readString(getResult3.getResultData(), FirmwareModuleType.COMMUNICATION.getDescription())).thenReturn("string3");
    final List<FirmwareVersionDto> result = this.executor.execute(this.connectionHolder, device, null, this.messageMetadata);
    Assertions.assertThat(result).usingRecursiveFieldByFieldElementComparator().containsExactly(new FirmwareVersionDto(FirmwareModuleType.ACTIVE_FIRMWARE, "string1"), new FirmwareVersionDto(FirmwareModuleType.MODULE_ACTIVE, "string2"), new FirmwareVersionDto(FirmwareModuleType.COMMUNICATION, "string3"));
}
Also used : GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetResultBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultBuilder) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) Test(org.junit.jupiter.api.Test)

Example 19 with AttributeAddress

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

the class DlmsObjectConfigServiceTest method testOneMatchingObjectWithChannel.

@Test
void testOneMatchingObjectWithChannel() {
    // SETUP
    final Integer channel = 1;
    final AttributeAddress expectedAddress = new AttributeAddress(this.registerWithChannel.getClassId(), this.getObisCodeWithChannel(this.registerWithChannel.getObisCodeAsString(), channel), this.registerWithChannel.getDefaultAttributeId(), null);
    // CALL
    final Optional<AttributeAddress> attributeAddress = this.service.findAttributeAddress(this.device422, DlmsObjectType.MBUS_MASTER_VALUE, channel);
    // VERIFY
    assertThat(attributeAddress).isPresent();
    AttributeAddressAssert.is(attributeAddress.get(), expectedAddress);
}
Also used : AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

Example 20 with AttributeAddress

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

the class SetPushSetupAlarmCommandExecutorTest method verifyPushObjectListParameter.

private void verifyPushObjectListParameter(final SetParameter setParameter) {
    final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
    assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID);
    assertThat(attributeAddress.getInstanceId()).isEqualTo(OBIS_CODE);
    assertThat(attributeAddress.getId()).isEqualTo(ATTRIBUTE_ID_PUSH_OBJECT_LIST);
    final DataObject dataObject = setParameter.getData();
    assertThat(dataObject.getType()).isEqualTo(Type.ARRAY);
    final List<DataObject> values = dataObject.getValue();
    assertThat(values).hasSize(PUSH_OBJECT_LIST.size());
    this.verifyPushObject(values.get(0), PUSH_OBJECT_1_CLASS_ID, PUSH_OBJECT_1_OBIS_CODE.toByteArray(), (byte) PUSH_OBJECT_1_ATTRIBUTE_ID, PUSH_OBJECT_1_DATA_INDEX);
    this.verifyPushObject(values.get(1), PUSH_OBJECT_2_CLASS_ID, PUSH_OBJECT_2_OBIS_CODE.toByteArray(), (byte) PUSH_OBJECT_2_ATTRIBUTE_ID, PUSH_OBJECT_2_DATA_INDEX);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress)

Aggregations

AttributeAddress (org.openmuc.jdlms.AttributeAddress)77 DataObject (org.openmuc.jdlms.datatypes.DataObject)38 ObisCode (org.openmuc.jdlms.ObisCode)18 Test (org.junit.jupiter.api.Test)16 GetResult (org.openmuc.jdlms.GetResult)16 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)16 SetParameter (org.openmuc.jdlms.SetParameter)15 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)14 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)8 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)8 DateTime (org.joda.time.DateTime)7 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)7 AccessResultCode (org.openmuc.jdlms.AccessResultCode)6 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)6 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)6 PeriodTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto)6 Collectors (java.util.stream.Collectors)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5