Search in sources :

Example 1 with SetDataRequestDto

use of com.alliander.osgp.dto.valueobjects.microgrids.SetDataRequestDto in project Protocol-Adapter-IEC61850 by OSGP.

the class MicrogridsSetDataRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.info("Processing microgrids set data request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    int retryCount = 0;
    boolean isScheduled = false;
    SetDataRequestDto setDataRequest = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        domain = message.getStringProperty(Constants.DOMAIN);
        domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        if (message.propertyExists(Constants.IS_SCHEDULED)) {
            isScheduled = message.getBooleanProperty(Constants.IS_SCHEDULED);
        } else {
            isScheduled = false;
        }
        setDataRequest = (SetDataRequestDto) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("domain: {}", domain);
        LOGGER.debug("domainVersion: {}", domainVersion);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("ipAddress: {}", ipAddress);
        return;
    }
    final RequestMessageData requestMessageData = new RequestMessageData(null, domain, domainVersion, messageType, retryCount, isScheduled, correlationUid, organisationIdentification, deviceIdentification);
    LOGGER.info("Calling DeviceService function: {} for domain: {} {}", messageType, domain, domainVersion);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final SetDataDeviceRequest deviceRequest = new SetDataDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, setDataRequest, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.setData(deviceRequest, iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) SetDataRequestDto(com.alliander.osgp.dto.valueobjects.microgrids.SetDataRequestDto) SetDataDeviceRequest(com.alliander.osgp.adapter.protocol.iec61850.device.rtu.requests.SetDataDeviceRequest) JMSException(javax.jms.JMSException) RequestMessageData(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Example 2 with SetDataRequestDto

use of com.alliander.osgp.dto.valueobjects.microgrids.SetDataRequestDto in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850RtuDeviceService method handleSetData.

private void handleSetData(final DeviceConnection connection, final SetDataDeviceRequest deviceRequest) throws ProtocolAdapterException {
    final SetDataRequestDto setDataRequest = deviceRequest.getSetDataRequest();
    final String serverName = this.getServerName(deviceRequest);
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws Exception {
            final Iec61850RtuDeviceReportingService reportingService = new Iec61850RtuDeviceReportingService(serverName);
            reportingService.enableReportingOnDevice(connection, deviceRequest.getDeviceIdentification());
            for (final SetDataSystemIdentifierDto identifier : setDataRequest.getSetDataSystemIdentifiers()) {
                final SystemService systemService = Iec61850RtuDeviceService.this.systemServiceFactory.getSystemService(identifier.getSystemType());
                systemService.setData(identifier, Iec61850RtuDeviceService.this.iec61850Client, connection);
            }
            return null;
        }
    };
    this.iec61850Client.sendCommandWithRetry(function, deviceRequest.getDeviceIdentification());
}
Also used : Function(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) SystemService(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.SystemService) SetDataRequestDto(com.alliander.osgp.dto.valueobjects.microgrids.SetDataRequestDto) Iec61850RtuDeviceReportingService(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.reporting.Iec61850RtuDeviceReportingService) SetDataSystemIdentifierDto(com.alliander.osgp.dto.valueobjects.microgrids.SetDataSystemIdentifierDto)

Aggregations

SetDataRequestDto (com.alliander.osgp.dto.valueobjects.microgrids.SetDataRequestDto)2 SetDataDeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.rtu.requests.SetDataDeviceRequest)1 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 SystemService (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.SystemService)1 Function (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function)1 RequestMessageData (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850RtuDeviceReportingService (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.reporting.Iec61850RtuDeviceReportingService)1 Iec61850DeviceResponseHandler (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 SetDataSystemIdentifierDto (com.alliander.osgp.dto.valueobjects.microgrids.SetDataSystemIdentifierDto)1 JMSException (javax.jms.JMSException)1