Search in sources :

Example 1 with PushSetupSmsDto

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

the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithLists.

// To test Mapping if lists contain values
@Test
public void testPushSetupSmsMappingWithLists() {
    // build test data
    final CosemObisCode logicalName = new CosemObisCode(new int[] { 1, 2, 3, 4, 5, 6 });
    final CosemObjectDefinition cosemObjectDefinition = new CosemObjectDefinition(1, logicalName, 2);
    final CosemDateTime startTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
    final CosemDateTime endTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
    final WindowElement windowElement = new WindowElement(startTime, endTime);
    final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
    // actual mapping
    final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
    // check values
    this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
    this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
    this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
    this.checkNonEmptyListMapping(pushSetupSms, pushSetupSmsDto);
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) PushSetupSms(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) Test(org.junit.jupiter.api.Test)

Example 2 with PushSetupSmsDto

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

the class PushSetupSmsMappingTest method testPushSetupSmsMappingNull.

// To test if a PushSetupAlarm can be mapped if instance variables are
// null.
@Test
public void testPushSetupSmsMappingNull() {
    // build test data
    final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withNullValues().build();
    // actual mapping
    final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
    // check values
    assertThat(pushSetupSmsDto).isNotNull();
    assertThat(pushSetupSmsDto.getLogicalName()).isNull();
    assertThat(pushSetupSmsDto.getPushObjectList()).isNull();
    assertThat(pushSetupSmsDto.getSendDestinationAndMethod()).isNull();
    assertThat(pushSetupSmsDto.getCommunicationWindow()).isNull();
    assertThat(pushSetupSmsDto.getRandomisationStartInterval()).isNull();
    assertThat(pushSetupSmsDto.getNumberOfRetries()).isNull();
    assertThat(pushSetupSmsDto.getRepetitionDelay()).isNull();
}
Also used : PushSetupSms(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto) Test(org.junit.jupiter.api.Test)

Example 3 with PushSetupSmsDto

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

the class SetPushSetupSmsRequestMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(PushSetupSmsDto.class, requestObject);
    final PushSetupSmsDto pushSetupSms = (PushSetupSmsDto) requestObject;
    this.configurationService.setPushSetupSms(conn, device, pushSetupSms, messageMetadata);
    return null;
}
Also used : PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)

Example 4 with PushSetupSmsDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto 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)

Example 5 with PushSetupSmsDto

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

the class ConfigurationService method setPushSetupSms.

public void setPushSetupSms(final MessageMetadata messageMetadata, final PushSetupSms pushSetupSms) throws FunctionalException {
    log.info("setPushSetupSms for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final PushSetupSmsDto requestDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)

Aggregations

PushSetupSmsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)6 Test (org.junit.jupiter.api.Test)3 PushSetupSms (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)2 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)2 ArrayList (java.util.ArrayList)1 GetResult (org.openmuc.jdlms.GetResult)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)1 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)1 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)1 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)1 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1