Search in sources :

Example 1 with GetPQValuesResponseDto

use of org.opensmartgridplatform.dto.da.GetPQValuesResponseDto in project open-smart-grid-platform by OSGP.

the class GetPQValuesResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing DA Power Quality response message");
    String correlationUid = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    ResponseMessage responseMessage = null;
    ResponseMessageResultType responseMessageResultType = null;
    OsgpException osgpException = null;
    Object dataObject = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        responseMessage = (ResponseMessage) message.getObject();
        responseMessageResultType = responseMessage.getResult();
        osgpException = responseMessage.getOsgpException();
        dataObject = responseMessage.getDataObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("osgpException", osgpException);
        return;
    }
    try {
        LOGGER.info("Calling application service function to handle response: {}", messageType);
        final GetPQValuesResponseDto dataResponse = (GetPQValuesResponseDto) dataObject;
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.monitoringService.handleGetPQValuesResponse(dataResponse, ids, messageType, responseMessageResultType, osgpException);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) GetPQValuesResponseDto(org.opensmartgridplatform.dto.da.GetPQValuesResponseDto) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException)

Example 2 with GetPQValuesResponseDto

use of org.opensmartgridplatform.dto.da.GetPQValuesResponseDto in project open-smart-grid-platform by OSGP.

the class Iec61850ClientDaRTUEventListener method processReport.

private void processReport(final Report report, final String reportDescription) throws ProtocolAdapterException {
    final List<FcModelNode> dataSetMembers = report.getValues();
    final List<LogicalDevice> logicalDevices = new ArrayList<>();
    if (CollectionUtils.isEmpty(dataSetMembers)) {
        this.logger.warn("No dataSet members available for {}", reportDescription);
        return;
    }
    for (final FcModelNode member : dataSetMembers) {
        // we are only interested in measurements
        if (member.getFc() == Fc.MX) {
            this.processMeasurementNode(logicalDevices, member);
        }
    }
    final List<LogicalDeviceDto> logicalDevicesDtos = new ArrayList<>();
    for (final LogicalDevice logicalDevice : logicalDevices) {
        final List<LogicalNodeDto> logicalNodeDtos = new ArrayList<>();
        for (final LogicalNode logicalNode : logicalDevice.getLogicalNodes()) {
            final LogicalNodeDto logicalNodeDto = new LogicalNodeDto(logicalNode.getName(), logicalNode.getDataSamples());
            logicalNodeDtos.add(logicalNodeDto);
        }
        final LogicalDeviceDto logicalDeviceDto = new LogicalDeviceDto(logicalDevice.getName(), logicalNodeDtos);
        logicalDevicesDtos.add(logicalDeviceDto);
    }
    final GetPQValuesResponseDto response = new GetPQValuesResponseDto(logicalDevicesDtos);
    this.deviceManagementService.sendPqValues(this.deviceIdentification, report.getRptId(), response);
}
Also used : GetPQValuesResponseDto(org.opensmartgridplatform.dto.da.GetPQValuesResponseDto) LogicalDeviceDto(org.opensmartgridplatform.dto.da.iec61850.LogicalDeviceDto) LogicalNodeDto(org.opensmartgridplatform.dto.da.iec61850.LogicalNodeDto) ArrayList(java.util.ArrayList) FcModelNode(com.beanit.openiec61850.FcModelNode)

Example 3 with GetPQValuesResponseDto

use of org.opensmartgridplatform.dto.da.GetPQValuesResponseDto in project open-smart-grid-platform by OSGP.

the class GetPQValuesPeriodicResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing DA Power Quality Periodic response message");
    String correlationUid = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    ResponseMessage responseMessage = null;
    ResponseMessageResultType responseMessageResultType = null;
    OsgpException osgpException = null;
    Object dataObject = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        responseMessage = (ResponseMessage) message.getObject();
        responseMessageResultType = responseMessage.getResult();
        osgpException = responseMessage.getOsgpException();
        dataObject = responseMessage.getDataObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("osgpException", osgpException);
        return;
    }
    try {
        LOGGER.info("Calling application service function to handle response: {}", messageType);
        final GetPQValuesResponseDto dataResponse = (GetPQValuesResponseDto) dataObject;
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.monitoringService.handleGetPQValuesResponse(dataResponse, ids, messageType, responseMessageResultType, osgpException);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) GetPQValuesResponseDto(org.opensmartgridplatform.dto.da.GetPQValuesResponseDto) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException)

Aggregations

GetPQValuesResponseDto (org.opensmartgridplatform.dto.da.GetPQValuesResponseDto)3 JMSException (javax.jms.JMSException)2 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)2 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)2 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)2 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)2 FcModelNode (com.beanit.openiec61850.FcModelNode)1 ArrayList (java.util.ArrayList)1 LogicalDeviceDto (org.opensmartgridplatform.dto.da.iec61850.LogicalDeviceDto)1 LogicalNodeDto (org.opensmartgridplatform.dto.da.iec61850.LogicalNodeDto)1