use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto in project open-smart-grid-platform by OSGP.
the class AssociationLnListTypeMappingTest method testAssociationLnListTypeDtoMappingWithNonEmptyLists.
@Test
public void testAssociationLnListTypeDtoMappingWithNonEmptyLists() {
// build test data
final List<AttributeAccessItemDto> listAttributeAccessItemDto = new ArrayList<>();
final AttributeAccessModeTypeDto accessMode = AttributeAccessModeTypeDto.NO_ACCESS;
final List<Integer> listInteger = new ArrayList<>();
final AccessSelectorListDto accessSelectors = new AccessSelectorListDto(listInteger);
listAttributeAccessItemDto.add(new AttributeAccessItemDto(1, accessMode, accessSelectors));
final AttributeAccessDescriptorDto attributeAccessDescriptorDto = new AttributeAccessDescriptorDto(listAttributeAccessItemDto);
final List<MethodAccessItemDto> listMethodAccessItemDto = new ArrayList<>();
final MethodAccessDescriptorDto methodAccessDescriptorDto = new MethodAccessDescriptorDto(listMethodAccessItemDto);
final AssociationLnListElementDto associationLnElementDto = new AssociationLnListElementDto(72, 2, new CosemObisCodeDto(new int[] { 1, 1, 1, 1, 1, 1 }), new AccessRightDto(attributeAccessDescriptorDto, methodAccessDescriptorDto));
final AssociationLnListTypeDto associationLnListTypeDto = new AssociationLnListTypeDtoBuilder().withNonEmptyLists(associationLnElementDto).build();
// actual mapping
final AssociationLnListType associationLnListType = this.configurationMapper.map(associationLnListTypeDto, AssociationLnListType.class);
// check values
assertThat(associationLnListType).isNotNull();
this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto in project open-smart-grid-platform by OSGP.
the class DlmsHelper method readObjectDefinition.
public CosemObjectDefinitionDto readObjectDefinition(final DataObject resultData, final String description) throws ProtocolAdapterException {
final List<DataObject> objectDefinitionElements = this.readList(resultData, description);
if (objectDefinitionElements == null) {
return null;
}
if (objectDefinitionElements.size() != 4) {
LOGGER.error("Unexpected ResultData for Object Definition value: {}", this.getDebugInfo(resultData));
throw new ProtocolAdapterException("Expected list for Object Definition to contain 4 elements, got: " + objectDefinitionElements.size());
}
final Long classId = this.readLongNotNull(objectDefinitionElements.get(0), "Class ID from " + description);
final CosemObisCodeDto logicalName = this.readLogicalName(objectDefinitionElements.get(1), "Logical Name from " + description);
final Long attributeIndex = this.readLongNotNull(objectDefinitionElements.get(2), "Attribute Index from " + description);
final Long dataIndex = this.readLongNotNull(objectDefinitionElements.get(3), "Data Index from " + description);
return new CosemObjectDefinitionDto(classId.intValue(), logicalName, attributeIndex.intValue(), dataIndex.intValue());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto in project open-smart-grid-platform by OSGP.
the class GetPushSetupAlarmCommandExecutor method execute.
@Override
public PushSetupAlarmDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final Void useless, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
conn.getDlmsMessageListener().setDescription("GetPushSetupAlarm, retrieve attributes: " + JdlmsObjectToStringUtil.describeAttributes(ATTRIBUTE_ADDRESSES));
LOGGER.info("Retrieving Push Setup Alarm");
final List<GetResult> getResultList = this.dlmsHelper.getWithList(conn, device, ATTRIBUTE_ADDRESSES);
GetPushSetupCommandExecutor.checkResultList(getResultList, ATTRIBUTE_ADDRESSES);
final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
pushSetupAlarmBuilder.withLogicalName(new CosemObisCodeDto(OBIS_CODE.bytes()));
pushSetupAlarmBuilder.withPushObjectList(this.dlmsHelper.readListOfObjectDefinition(getResultList.get(INDEX_PUSH_OBJECT_LIST), "Push Object List"));
pushSetupAlarmBuilder.withSendDestinationAndMethod(this.dlmsHelper.readSendDestinationAndMethod(getResultList.get(INDEX_SEND_DESTINATION_AND_METHOD), "Send Destination And Method"));
pushSetupAlarmBuilder.withCommunicationWindow(this.dlmsHelper.readListOfWindowElement(getResultList.get(INDEX_COMMUNICATION_WINDOW), "Communication Window"));
pushSetupAlarmBuilder.withRandomisationStartInterval(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_RANDOMISATION_START_INTERVAL), "Randomisation Start Interval").intValue());
pushSetupAlarmBuilder.withNumberOfRetries(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_NUMBER_OF_RETRIES), "Number of Retries").intValue());
pushSetupAlarmBuilder.withRepetitionDelay(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_REPETITION_DELAY), "Repetition Delay").intValue());
return pushSetupAlarmBuilder.build();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto in project open-smart-grid-platform by OSGP.
the class GetPushSetupSmsCommandExecutor method execute.
@Override
public PushSetupSmsDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final Void useless, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
conn.getDlmsMessageListener().setDescription("GetPushSetupSms, retrieve attributes: " + JdlmsObjectToStringUtil.describeAttributes(ATTRIBUTE_ADDRESSES));
LOGGER.info("Retrieving Push Setup SMS");
final List<GetResult> getResultList = this.dlmsHelper.getWithList(conn, device, ATTRIBUTE_ADDRESSES);
GetPushSetupCommandExecutor.checkResultList(getResultList, ATTRIBUTE_ADDRESSES);
final PushSetupSmsDto.Builder pushSetupSmsBuilder = new PushSetupSmsDto.Builder();
pushSetupSmsBuilder.withLogicalName(new CosemObisCodeDto(OBIS_CODE.bytes()));
pushSetupSmsBuilder.withPushObjectList(this.dlmsHelper.readListOfObjectDefinition(getResultList.get(INDEX_PUSH_OBJECT_LIST), "Push Object List"));
pushSetupSmsBuilder.withSendDestinationAndMethod(this.dlmsHelper.readSendDestinationAndMethod(getResultList.get(INDEX_SEND_DESTINATION_AND_METHOD), "Send Destination And Method"));
pushSetupSmsBuilder.withCommunicationWindow(this.dlmsHelper.readListOfWindowElement(getResultList.get(INDEX_COMMUNICATION_WINDOW), "Communication Window"));
pushSetupSmsBuilder.withRandomisationStartInterval(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_RANDOMISATION_START_INTERVAL), "Randomisation Start Interval").intValue());
pushSetupSmsBuilder.withNumberOfRetries(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_NUMBER_OF_RETRIES), "Number of Retries").intValue());
pushSetupSmsBuilder.withRepetitionDelay(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_REPETITION_DELAY), "Repetition Delay").intValue());
return pushSetupSmsBuilder.build();
}
Aggregations