Search in sources :

Example 91 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class AddDeviceSteps method aRequestToTheDeviceCanBePerformedAfterActivation.

@Then("^a request to the device can be performed after activation$")
public void aRequestToTheDeviceCanBePerformedAfterActivation() throws Throwable {
    final Device device = this.activateDevice();
    /*
     * Fire any request that causes communication to the device, and check
     * that the actual response is not an error.
     */
    final GetAdministrativeStatusRequest request = new GetAdministrativeStatusRequest();
    request.setDeviceIdentification(device.getDeviceIdentification());
    final GetAdministrativeStatusAsyncResponse getAdministrativeStatusAsyncResponse = this.smartMeteringConfigurationClient.getAdministrativeStatus(request);
    final GetAdministrativeStatusAsyncRequest asyncRequest = new GetAdministrativeStatusAsyncRequest();
    asyncRequest.setCorrelationUid(getAdministrativeStatusAsyncResponse.getCorrelationUid());
    asyncRequest.setDeviceIdentification(device.getDeviceIdentification());
    final GetAdministrativeStatusResponse getAdministrativeStatusResponse = this.smartMeteringConfigurationClient.retrieveGetAdministrativeStatusResponse(asyncRequest);
    assertThat(getAdministrativeStatusResponse.getEnabled()).as("Administrative status should contain information if it is enabled").isNotNull();
}
Also used : GetAdministrativeStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncResponse) Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetAdministrativeStatusRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusRequest) GetAdministrativeStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusAsyncRequest) GetAdministrativeStatusResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetAdministrativeStatusResponse) Then(io.cucumber.java.en.Then)

Example 92 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method enqueueSetLightRequest.

public String enqueueSetLightRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Size(min = 1, max = 6) @Valid final List<LightValue> lightValues, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT);
    this.domainHelperService.isInMaintenance(device);
    LOGGER.debug("enqueueSetLightRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final LightValueMessageDataContainer lightValueMessageDataContainer = new LightValueMessageDataContainer(lightValues);
    final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightValueMessageDataContainer).build();
    this.messageSender.send(message);
    return correlationUid;
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) LightValueMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.LightValueMessageDataContainer) Device(org.opensmartgridplatform.domain.core.entities.Device) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) PublicLightingRequestMessage(org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)

Example 93 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method enqueueResumeScheduleRequest.

public String enqueueResumeScheduleRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Valid final ResumeScheduleData resumeScheduleData, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.RESUME_SCHEDULE);
    this.domainHelperService.isInMaintenance(device);
    LOGGER.debug("enqueueResumeScheduleRequest called with organisation {}, device {} and resumeScheduleData {} ", organisationIdentification, deviceIdentification, resumeScheduleData);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.RESUME_SCHEDULE.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(resumeScheduleData).build();
    this.messageSender.send(message);
    return correlationUid;
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Device(org.opensmartgridplatform.domain.core.entities.Device) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) PublicLightingRequestMessage(org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)

Example 94 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class DeviceManagementService method setDeviceVerificationKey.

@Transactional(value = "transactionManager")
public void setDeviceVerificationKey(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String verificationKey, final String messageType, final int messagePriority) throws FunctionalException {
    LOGGER.debug("SetDeviceVerificationKey called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    if (verificationKey == null) {
        LOGGER.info("Verification key is empty, skip sending a request to device");
        return;
    }
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, verificationKey), messageType, messagePriority, device.getIpAddress());
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Transactional(org.springframework.transaction.annotation.Transactional)

Example 95 with Device

use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.

the class DeviceManagementService method setEventNotifications.

@Transactional(value = "transactionManager")
public void setEventNotifications(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final List<EventNotificationType> eventNotifications, final String messageType, final int messagePriority) throws FunctionalException {
    LOGGER.debug("setEventNotifications called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    final List<org.opensmartgridplatform.dto.valueobjects.EventNotificationTypeDto> eventNotificationsDto = this.domainCoreMapper.mapAsList(eventNotifications, org.opensmartgridplatform.dto.valueobjects.EventNotificationTypeDto.class);
    final EventNotificationMessageDataContainerDto eventNotificationMessageDataContainer = new EventNotificationMessageDataContainerDto(eventNotificationsDto);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, eventNotificationMessageDataContainer), messageType, messagePriority, device.getIpAddress());
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) EventNotificationMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Device (org.opensmartgridplatform.domain.core.entities.Device)179 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)49 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)36 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)35 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)32 Test (org.junit.jupiter.api.Test)27 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)27 Transactional (org.springframework.transaction.annotation.Transactional)24 Then (io.cucumber.java.en.Then)21 DeviceAuthorization (org.opensmartgridplatform.domain.core.entities.DeviceAuthorization)18 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)17 CommonRequestMessage (org.opensmartgridplatform.adapter.ws.core.infra.jms.CommonRequestMessage)15 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)15 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)12 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)12 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)11 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)11 Date (java.util.Date)10 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)10 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)9