use of org.openmuc.jdlms.SelectiveAccessDescription in project open-smart-grid-platform by OSGP.
the class AbstractGetPowerQualityProfileHandler method retrieveBuffer.
private List<GetResult> retrieveBuffer(final DlmsConnectionManager conn, final DlmsDevice device, final ObisCode obisCode, final DateTime beginDateTime, final DateTime endDateTime, final List<CaptureObjectDefinitionDto> selectableCaptureObjects) throws ProtocolAdapterException {
final DataObject selectableValues = this.convertSelectableCaptureObjects(selectableCaptureObjects);
final SelectiveAccessDescription selectiveAccessDescription = this.getSelectiveAccessDescription(beginDateTime, endDateTime, selectableValues);
final AttributeAddress bufferAttributeAddress = new AttributeAddress(InterfaceClass.PROFILE_GENERIC.id(), obisCode, ProfileGenericAttribute.BUFFER.attributeId(), selectiveAccessDescription);
return this.dlmsHelper.getAndCheck(conn, device, "retrieve profile generic buffer", bufferAttributeAddress);
}
use of org.openmuc.jdlms.SelectiveAccessDescription in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutor method execute.
@Override
public List<EventDto> execute(final DlmsConnectionManager conn, final DlmsDevice device, final FindEventsRequestDto findEventsQuery, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final SelectiveAccessDescription selectiveAccessDescription = this.getSelectiveAccessDescription(device, findEventsQuery.getFrom(), findEventsQuery.getUntil());
final DlmsObject eventLogObject = this.dlmsObjectConfigService.getDlmsObject(device, EVENT_LOG_CATEGORY_OBISCODE_MAP.get(findEventsQuery.getEventLogCategory()));
final AttributeAddress eventLogBuffer = new AttributeAddress(eventLogObject.getClassId(), eventLogObject.getObisCode(), eventLogObject.getDefaultAttributeId(), selectiveAccessDescription);
conn.getDlmsMessageListener().setDescription("RetrieveEvents for " + findEventsQuery.getEventLogCategory() + " from " + findEventsQuery.getFrom() + " until " + findEventsQuery.getUntil() + ", retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(eventLogBuffer));
final GetResult getResult;
try {
getResult = conn.getConnection().get(eventLogBuffer);
} catch (final IOException e) {
throw new ConnectionException(e);
}
if (getResult == null) {
throw new ProtocolAdapterException("No GetResult received while retrieving event register " + findEventsQuery.getEventLogCategory());
}
if (!AccessResultCode.SUCCESS.equals(getResult.getResultCode())) {
LOGGER.info("Result of getting events for {} is {}", findEventsQuery.getEventLogCategory(), getResult.getResultCode());
throw new ProtocolAdapterException("Getting the events for " + findEventsQuery.getEventLogCategory() + " from the meter resulted in: " + getResult.getResultCode());
}
final DataObject resultData = getResult.getResultData();
return this.dataObjectToEventListConverter.convert(resultData, findEventsQuery.getEventLogCategory());
}
use of org.openmuc.jdlms.SelectiveAccessDescription in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithMediumCombinedAndFilterMedium.
@Test
void testProfileWithMediumCombinedAndFilterMedium() {
// SETUP
final Integer channel = null;
final Medium filterMedium = Medium.ELECTRICITY;
final List<DlmsCaptureObject> expectedSelectedObjects = this.captureObjectsCombined.stream().filter(c -> !(c.getRelatedObject() instanceof DlmsRegister) || ((DlmsRegister) c.getRelatedObject()).getMedium() == filterMedium).collect(Collectors.toList());
final DataObject selectedValues = DataObject.newArrayData(expectedSelectedObjects.stream().map(o -> this.getDataObject(o.getRelatedObject())).collect(Collectors.toList()));
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(expectedSelectedObjects);
}
use of org.openmuc.jdlms.SelectiveAccessDescription in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsCommandExecutorIntegrationTest method createSelectiveAccessDescriptionSmr5.
private SelectiveAccessDescription createSelectiveAccessDescriptionSmr5(final DataObject from, final DataObject to) {
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject expectedAccessParam = DataObject.newStructureData(Arrays.asList(this.CLOCK, from, to, selectedValues));
return new SelectiveAccessDescription(1, expectedAccessParam);
}
use of org.openmuc.jdlms.SelectiveAccessDescription in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsCommandExecutorIntegrationTest method createSelectiveAccessDescriptionDsmr4Monthly.
private SelectiveAccessDescription createSelectiveAccessDescriptionDsmr4Monthly(final DataObject from, final DataObject to) {
final DataObject selectedValues = DataObject.newArrayData(Arrays.asList(this.CLOCK, this.ACTIVE_ENERGY_IMPORT_RATE_1, this.ACTIVE_ENERGY_IMPORT_RATE_2, this.ACTIVE_ENERGY_EXPORT_RATE_1, this.ACTIVE_ENERGY_EXPORT_RATE_2));
final DataObject expectedAccessParam = DataObject.newStructureData(Arrays.asList(this.CLOCK, from, to, selectedValues));
return new SelectiveAccessDescription(1, expectedAccessParam);
}
Aggregations