Search in sources :

Example 1 with CosemObisCodeDto

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());
}
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 CosemObisCodeDto

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());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)

Example 3 with CosemObisCodeDto

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();
}
Also used : GetResult(org.openmuc.jdlms.GetResult) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)

Example 4 with CosemObisCodeDto

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();
}
Also used : GetResult(org.openmuc.jdlms.GetResult) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)

Aggregations

CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)4 GetResult (org.openmuc.jdlms.GetResult)2 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)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 AssociationLnListElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto)1 AssociationLnListTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto)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 CosemObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto)1 MethodAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)1 MethodAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto)1 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)1 PushSetupSmsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)1