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