Search in sources :

Example 1 with AssociationLnListElementDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto 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());
}
Also used : AccessRightDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto) AttributeAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto) AssociationLnListElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto) ArrayList(java.util.ArrayList) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto) AccessSelectorListDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto) AssociationLnListType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) AttributeAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto) MethodAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto) MethodAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto) AttributeAccessModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessModeTypeDto) Test(org.junit.jupiter.api.Test)

Example 2 with AssociationLnListElementDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto in project open-smart-grid-platform by OSGP.

the class GetAssociationLnObjectsCommandExecutor method execute.

@Override
public AssociationLnListTypeDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final Void object, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final AttributeAddress attributeAddress = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
    conn.getDlmsMessageListener().setDescription("GetAssociationLnObjects, retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
    LOGGER.debug("Retrieving Association LN objects for class id: {}, obis code: {}, attribute id: {}", CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
    final List<GetResult> getResultList = this.dlmsHelper.getAndCheck(conn, device, "Association LN Objects", attributeAddress);
    final DataObject resultData = getResultList.get(0).getResultData();
    if (!resultData.isComplex()) {
        throw new ProtocolAdapterException("Unexpected type of element");
    }
    final List<DataObject> associationLnListObjects = resultData.getValue();
    final List<AssociationLnListElementDto> elements = this.convertAssociationLnList(associationLnListObjects);
    return new AssociationLnListTypeDto(elements);
}
Also used : AssociationLnListElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 3 with AssociationLnListElementDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto in project open-smart-grid-platform by OSGP.

the class GetAssociationLnObjectsCommandExecutor method convertAssociationLnList.

private List<AssociationLnListElementDto> convertAssociationLnList(final List<DataObject> resultDataValue) throws ProtocolAdapterException {
    final List<AssociationLnListElementDto> elements = new ArrayList<>();
    for (final DataObject obisCodeMetaData : resultDataValue) {
        final List<DataObject> obisCodeMetaDataList = obisCodeMetaData.getValue();
        final short version = obisCodeMetaDataList.get(VERSION_INDEX).getValue();
        final AssociationLnListElementDto element = new AssociationLnListElementDto(this.dlmsHelper.readLong(obisCodeMetaDataList.get(CLASS_ID_INDEX), "classId"), version, this.dlmsHelper.readLogicalName(obisCodeMetaDataList.get(OBIS_CODE_INDEX), "AssociationLN Element"), this.convertAccessRights(obisCodeMetaDataList.get(ACCESS_RIGHTS_INDEX)));
        elements.add(element);
    }
    return elements;
}
Also used : AssociationLnListElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

Aggregations

AssociationLnListElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto)3 ArrayList (java.util.ArrayList)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 AssociationLnListTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto)2 Test (org.junit.jupiter.api.Test)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 GetResult (org.openmuc.jdlms.GetResult)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 AssociationLnListType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType)1 AccessRightDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto)1 AccessSelectorListDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto)1 AttributeAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto)1 AttributeAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto)1 AttributeAccessModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessModeTypeDto)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1 MethodAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)1 MethodAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto)1