Search in sources :

Example 1 with DomainTypeDto

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

the class BaseTask method sendRequestMessageToDevice.

protected void sendRequestMessageToDevice(final Device device, final DeviceFunction deviceFunction) {
    final String deviceIdentification = device.getDeviceIdentification();
    // Try to use the identification of the owner organization.
    final String organisation = device.getOwner() == null ? "" : device.getOwner().getOrganisationIdentification();
    // Creating message with OSGP System CorrelationUID. This way the
    // responses for scheduled tasks can be filtered out.
    final String correlationUid = OsgpSystemCorrelationUid.CORRELATION_UID;
    final String deviceFunctionString = deviceFunction.name();
    final DomainTypeDto domain = DomainTypeDto.PUBLIC_LIGHTING;
    String ipAddress = null;
    if (device.getNetworkAddress() == null) {
        // In case the device does not have a known IP address, don't send
        // a request message.
        LOGGER.warn("Unable to create protocol request message because the IP address is empty for device: {}", deviceIdentification);
        return;
    } else {
        ipAddress = device.getNetworkAddress().getHostAddress();
    }
    final RequestMessage requestMessage = new RequestMessage(correlationUid, organisation, deviceIdentification, domain);
    this.osgpCoreRequestMessageSender.send(requestMessage, deviceFunctionString, MessagePriorityEnum.LOW.getPriority(), ipAddress);
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainTypeDto(org.opensmartgridplatform.dto.valueobjects.DomainTypeDto)

Example 2 with DomainTypeDto

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

the class BaseTask method sendConnectRequestToDevice.

protected void sendConnectRequestToDevice(final LightMeasurementDevice lightMeasurementDevice) {
    final String deviceIdentification = getDeviceIdentification(lightMeasurementDevice);
    final String organisation = getOwnerOrganisation(lightMeasurementDevice);
    // Creating message with OSGP System CorrelationUID. This way the
    // responses for scheduled tasks can be filtered out.
    final String correlationUid = OsgpSystemCorrelationUid.CORRELATION_UID;
    final String messageType = DeviceFunction.CONNECT.name();
    final DomainTypeDto domain = DomainTypeDto.PUBLIC_LIGHTING;
    final String ipAddress = getIpAddress(lightMeasurementDevice);
    if (ipAddress == null) {
        LOGGER.warn("Unable to create connect request because no IP address is known for device: {}", deviceIdentification);
        return;
    }
    final RequestMessage requestMessage = new RequestMessage(correlationUid, organisation, deviceIdentification, domain);
    this.osgpCoreRequestMessageSender.send(requestMessage, messageType, MessagePriorityEnum.LOW.getPriority(), ipAddress);
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainTypeDto(org.opensmartgridplatform.dto.valueobjects.DomainTypeDto)

Aggregations

DomainTypeDto (org.opensmartgridplatform.dto.valueobjects.DomainTypeDto)2 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)2