Search in sources :

Example 26 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SsldDeviceService method getStatus.

@Override
public void getStatus(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    DeviceConnection devCon = null;
    try {
        final DeviceConnection deviceConnection = this.connectToDevice(deviceRequest);
        devCon = deviceConnection;
        // Getting the SSLD for the device output-settings.
        final Ssld ssld = this.ssldDataService.findDevice(deviceRequest.getDeviceIdentification());
        final DeviceStatusDto deviceStatus = new Iec61850GetStatusCommand().getStatusFromDevice(this.iec61850Client, deviceConnection, ssld);
        final GetStatusDeviceResponse deviceResponse = new GetStatusDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceStatus);
        deviceResponseHandler.handleResponse(deviceResponse);
        this.enableReporting(deviceConnection, deviceRequest);
    } catch (final ConnectionFailureException se) {
        this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
        this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
    } catch (final Exception e) {
        this.handleException(deviceRequest, deviceResponseHandler, e);
        this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
    }
}
Also used : Iec61850GetStatusCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850GetStatusCommand) GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetStatusDeviceResponse) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) FunctionalException(com.alliander.osgp.shared.exceptionhandling.FunctionalException) JMSException(javax.jms.JMSException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) Ssld(com.alliander.osgp.core.db.api.iec61850.entities.Ssld)

Example 27 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 by OSGP.

the class DeviceMessageLoggingService method logMessage.

public static void logMessage(final DeviceRequest deviceRequest, final boolean incoming, final boolean valid, final String message, final int size) {
    final String deviceIdentification = deviceRequest.getDeviceIdentification();
    final String organisationIdentification = deviceRequest.getOrganisationIdentification();
    final String command = deviceRequest.getClass().getSimpleName();
    final Iec61850LogItemRequestMessage iec61850LogItemRequestMessage = new Iec61850LogItemRequestMessage(deviceIdentification, organisationIdentification, incoming, valid, command + " - " + message, size);
    LOGGER.info("Sending iec61850LogItemRequestMessage for device: {}", deviceIdentification);
    iec61850LogItemRequestMessageSender.send(iec61850LogItemRequestMessage);
}
Also used : Iec61850LogItemRequestMessage(com.alliander.osgp.adapter.protocol.iec61850.infra.messaging.Iec61850LogItemRequestMessage)

Example 28 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 by OSGP.

the class PublicLightingSetScheduleRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing public lighting set schedule request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    Boolean isScheduled = null;
    int retryCount = 0;
    ScheduleMessageDataContainerDto scheduleMessageDataContainer = 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);
        isScheduled = message.getBooleanProperty(Constants.IS_SCHEDULED);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        scheduleMessageDataContainer = (ScheduleMessageDataContainerDto) 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);
        LOGGER.debug("scheduled: {}", isScheduled);
        return;
    }
    final RequestMessageData requestMessageData = new RequestMessageData(scheduleMessageDataContainer, domain, domainVersion, messageType, retryCount, isScheduled, correlationUid, organisationIdentification, deviceIdentification);
    this.printDomainInfo(messageType, domain, domainVersion);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final SetScheduleDeviceRequest deviceRequest = new SetScheduleDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, scheduleMessageDataContainer, RelayTypeDto.LIGHT, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.setSchedule(deviceRequest, iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) ScheduleMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.ScheduleMessageDataContainerDto) SetScheduleDeviceRequest(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetScheduleDeviceRequest) JMSException(javax.jms.JMSException) RequestMessageData(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Example 29 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 by OSGP.

the class MicrogridsGetDataRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing microgrids get 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;
    GetDataRequestDto getDataRequest = 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);
        isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
        getDataRequest = (GetDataRequestDto) 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);
    this.printDomainInfo(messageType, domain, domainVersion);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final GetDataDeviceRequest deviceRequest = new GetDataDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, getDataRequest, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.getData(deviceRequest, iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) GetDataRequestDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataRequestDto) GetDataDeviceRequest(com.alliander.osgp.adapter.protocol.iec61850.device.rtu.requests.GetDataDeviceRequest) JMSException(javax.jms.JMSException) RequestMessageData(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Example 30 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 by OSGP.

the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing public lighting get power usage history request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    Boolean isScheduled = null;
    int retryCount = 0;
    int messagePriority = 0;
    Long scheduleTime = null;
    PowerUsageHistoryMessageDataContainerDto powerUsageHistoryMessageDataContainerDto;
    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);
        isScheduled = message.getBooleanProperty(Constants.IS_SCHEDULED);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        messagePriority = message.getJMSPriority();
        scheduleTime = message.propertyExists(Constants.SCHEDULE_TIME) ? message.getLongProperty(Constants.SCHEDULE_TIME) : null;
        powerUsageHistoryMessageDataContainerDto = (PowerUsageHistoryMessageDataContainerDto) 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);
        LOGGER.debug("scheduled: {}", isScheduled);
        LOGGER.debug("retryCount: {}", retryCount);
        LOGGER.debug("messagePriority: {}", messagePriority);
        LOGGER.debug("scheduleTime: {}", scheduleTime);
        return;
    }
    final RequestMessageData requestMessageData = new RequestMessageData(powerUsageHistoryMessageDataContainerDto, domain, domainVersion, messageType, retryCount, isScheduled, correlationUid, organisationIdentification, deviceIdentification, ipAddress, messagePriority, scheduleTime);
    this.printDomainInfo(messageType, domain, domainVersion);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final GetPowerUsageHistoryDeviceRequest deviceRequest = new GetPowerUsageHistoryDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, powerUsageHistoryMessageDataContainerDto, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.getPowerUsageHistory(deviceRequest, iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) GetPowerUsageHistoryDeviceRequest(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.GetPowerUsageHistoryDeviceRequest) PowerUsageHistoryMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryMessageDataContainerDto) JMSException(javax.jms.JMSException) RequestMessageData(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Aggregations

JMSException (javax.jms.JMSException)36 RequestMessageData (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)20 Iec61850DeviceResponseHandler (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)20 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)17 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)16 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)16 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)13 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)13 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)13 DeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest)8 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)7 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)6 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)3 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)3 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)3 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)3 ServerModel (org.openmuc.openiec61850.ServerModel)3 SetScheduleDeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetScheduleDeviceRequest)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)2 SystemService (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.SystemService)2