use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsCommandExecutorIntegrationTest method getScalerUnitAttributeAddresses.
private List<AttributeAddress> getScalerUnitAttributeAddresses(final PeriodTypeDto type) throws Exception {
final List<AttributeAddress> attributeAddresses = new ArrayList<>();
switch(type) {
case MONTHLY:
case DAILY:
attributeAddresses.add(new AttributeAddress(this.CLASS_ID_REGISTER, this.OBIS_ACTIVE_ENERGY_IMPORT_RATE_1, this.ATTR_ID_SCALER_UNIT, null));
attributeAddresses.add(new AttributeAddress(this.CLASS_ID_REGISTER, this.OBIS_ACTIVE_ENERGY_IMPORT_RATE_2, this.ATTR_ID_SCALER_UNIT, null));
attributeAddresses.add(new AttributeAddress(this.CLASS_ID_REGISTER, this.OBIS_ACTIVE_ENERGY_EXPORT_RATE_1, this.ATTR_ID_SCALER_UNIT, null));
attributeAddresses.add(new AttributeAddress(this.CLASS_ID_REGISTER, this.OBIS_ACTIVE_ENERGY_EXPORT_RATE_2, this.ATTR_ID_SCALER_UNIT, null));
break;
case INTERVAL:
attributeAddresses.add(new AttributeAddress(this.CLASS_ID_REGISTER, this.OBIS_ACTIVE_ENERGY_IMPORT, this.ATTR_ID_SCALER_UNIT, null));
attributeAddresses.add(new AttributeAddress(this.CLASS_ID_REGISTER, this.OBIS_ACTIVE_ENERGY_EXPORT, this.ATTR_ID_SCALER_UNIT, null));
break;
default:
throw new Exception("Unexpected period type " + type);
}
return attributeAddresses;
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsCommandExecutorIntegrationTest method testExecute.
private void testExecute(final Protocol protocol, final PeriodTypeDto type, final boolean useNullData) throws Exception {
// SETUP
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
// Reset stub
this.connectionStub.clearRequestedAttributeAddresses();
// Create device with requested protocol version
final DlmsDevice device = this.createDlmsDevice(protocol);
// Create request object
final PeriodicMeterReadsRequestDto request = new PeriodicMeterReadsRequestDto(type, this.timeFrom, this.timeTo);
// Get expected values
final AttributeAddress expectedAddressProfile = this.createAttributeAddress(protocol, type, this.timeFrom, this.timeTo);
final List<AttributeAddress> expectedScalerUnitAddresses = this.getScalerUnitAttributeAddresses(type);
final int expectedTotalNumberOfAttributeAddresses = expectedScalerUnitAddresses.size() + 1;
// Set response in stub
this.setResponseForProfile(expectedAddressProfile, protocol, type, useNullData);
this.setResponsesForScalerUnit(expectedScalerUnitAddresses);
// CALL
final PeriodicMeterReadsResponseDto response = this.executor.execute(this.connectionManagerStub, device, request, messageMetadata);
// VERIFY
// Get resulting requests from connection stub
final List<AttributeAddress> requestedAttributeAddresses = this.connectionStub.getRequestedAttributeAddresses();
assertThat(requestedAttributeAddresses.size()).isEqualTo(expectedTotalNumberOfAttributeAddresses);
// There should be 1 request to the buffer (id = 2) of a profile
// (class-id = 7)
final AttributeAddress actualAttributeAddressProfile = requestedAttributeAddresses.stream().filter(a -> a.getClassId() == this.CLASS_ID_PROFILE).collect(Collectors.toList()).get(0);
AttributeAddressAssert.is(actualAttributeAddressProfile, expectedAddressProfile);
// Check the amount of requests to the scaler_units of the meter values
// in the registers
final List<AttributeAddress> attributeAddressesScalerUnit = requestedAttributeAddresses.stream().filter(a -> a.getClassId() == this.CLASS_ID_REGISTER && a.getId() == this.ATTR_ID_SCALER_UNIT).collect(Collectors.toList());
assertThat(attributeAddressesScalerUnit.size()).isEqualTo(expectedScalerUnitAddresses.size());
// Check response
assertThat(response.getPeriodType()).isEqualTo(type);
final List<PeriodicMeterReadsResponseItemDto> periodicMeterReads = response.getPeriodicMeterReads();
assertThat(periodicMeterReads.size()).isEqualTo(this.AMOUNT_OF_PERIODS);
this.checkClockValues(periodicMeterReads, type, useNullData);
this.checkValues(periodicMeterReads, type);
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setResponsesForScalerUnit.
private void setResponsesForScalerUnit(final List<AttributeAddress> attributeAddressesForScalerUnit) {
final int DLMS_ENUM_VALUE_M3 = 14;
final DataObject responseDataObject = DataObject.newStructureData(DataObject.newInteger8Data((byte) 0), DataObject.newEnumerateData(DLMS_ENUM_VALUE_M3));
for (final AttributeAddress attributeAddress : attributeAddressesForScalerUnit) {
this.connectionStub.addReturnValue(attributeAddress, responseDataObject);
}
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithOneMedium.
@Test
void testProfileWithOneMedium() {
// SETUP
final Integer channel = null;
final Medium filterMedium = Medium.ELECTRICITY;
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileE.getClassId(), this.profileE.getObisCodeAsString(), this.profileE.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.INTERVAL_VALUES, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsE);
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithMediumCombinedAndNoFilterMedium.
@Test
void testProfileWithMediumCombinedAndNoFilterMedium() {
// SETUP
final Integer channel = 1;
final Medium filterMedium = null;
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileCombined.getClassId(), this.profileCombined.getObisCodeAsString(), this.profileCombined.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.DAILY_LOAD_PROFILE, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsCombined);
}
Aggregations