Search in sources :

Example 16 with ServerModel

use of com.beanit.openiec61850.ServerModel in project open-smart-grid-platform by OSGP.

the class RtuSimulator method addLightMeasurementDevice.

private void addLightMeasurementDevice(final ServerModel serverModel) {
    final String logicalDeviceName = "LD0";
    final ModelNode lightMeasurementRtuNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    if (lightMeasurementRtuNode != null) {
        // Light Measurement RTU found in the server model.
        LOGGER.info("Adding lmRtu {}", logicalDeviceName);
        this.logicalDevices.add(new LightMeasurementRtu(this.getDeviceName(), logicalDeviceName, serverModel));
    }
}
Also used : LightMeasurementRtu(org.opensmartgridplatform.simulator.protocol.iec61850.server.logicaldevices.LightMeasurementRtu) ModelNode(com.beanit.openiec61850.ModelNode)

Example 17 with ServerModel

use of com.beanit.openiec61850.ServerModel in project open-smart-grid-platform by OSGP.

the class RtuSimulator method addWindDevices.

private void addWindDevices(final ServerModel serverModel) {
    final String windPrefix = "WIND";
    int i = 1;
    String logicalDeviceName = windPrefix + i;
    ModelNode windNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    while (windNode != null) {
        this.logicalDevices.add(new Wind(this.getDeviceName(), logicalDeviceName, serverModel));
        i += 1;
        logicalDeviceName = windPrefix + i;
        windNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    }
}
Also used : Wind(org.opensmartgridplatform.simulator.protocol.iec61850.server.logicaldevices.Wind) ModelNode(com.beanit.openiec61850.ModelNode)

Example 18 with ServerModel

use of com.beanit.openiec61850.ServerModel in project open-smart-grid-platform by OSGP.

the class UpdateHealthStatusEventListener method updateServerValue.

private void updateServerValue(final ServerSap serverSap) {
    LOGGER.debug("updateServerValue");
    final ServerModel serverModel = serverSap.getModelCopy();
    final ModelNode modelNode = serverModel.findModelNode(HEALTH_NODE, Fc.ST);
    if (modelNode != null) {
        final ModelNode dataNode = modelNode.getChild(STATUS_VALUE);
        if (dataNode != null && dataNode instanceof BdaInt8) {
            final List<BasicDataAttribute> changedAttributes = new ArrayList<>();
            final BdaInt8 bda = (BdaInt8) dataNode;
            bda.setValue(bda.getValue() == OK ? WARNING : (bda.getValue() == WARNING ? ALARM : OK));
            changedAttributes.add(bda);
            serverSap.setValues(changedAttributes);
        }
    }
}
Also used : BdaInt8(com.beanit.openiec61850.BdaInt8) ServerModel(com.beanit.openiec61850.ServerModel) ArrayList(java.util.ArrayList) BasicDataAttribute(com.beanit.openiec61850.BasicDataAttribute) ModelNode(com.beanit.openiec61850.ModelNode)

Example 19 with ServerModel

use of com.beanit.openiec61850.ServerModel in project open-smart-grid-platform by OSGP.

the class Iec61850RtuDeviceService method setData.

@Override
public void setData(final SetDataDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    try {
        final String serverName = this.getServerName(deviceRequest);
        final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
        final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
        this.handleSetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.OK);
        deviceResponseHandler.handleResponse(deviceResponse);
    } catch (final ConnectionFailureException se) {
        LOGGER.error("Could not connect to device after all retries", se);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
    } catch (final Exception e) {
        LOGGER.error("Unexpected exception during Set Data", e);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleException(e, deviceResponse);
    }
}
Also used : ServerModel(com.beanit.openiec61850.ServerModel) Iec61850Connection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) Iec61850ClientAssociation(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(com.beanit.openiec61850.ClientAssociation) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) JMSException(javax.jms.JMSException) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 20 with ServerModel

use of com.beanit.openiec61850.ServerModel in project open-smart-grid-platform by OSGP.

the class Iec61850DeviceConnectionService method readServerModel.

private ServerModel readServerModel(final ClientAssociation clientAssociation, final String deviceIdentification, final Iec61850Device iec61850Device) throws ProtocolAdapterException {
    ServerModel serverModel;
    try {
        serverModel = this.readServerModelConfiguredForDevice(clientAssociation, deviceIdentification, iec61850Device);
        if (serverModel != null) {
            return serverModel;
        }
    } catch (final ProtocolAdapterException e) {
        LOGGER.warn("Ignore exception reading server model based on per device configuration for device: {}.", deviceIdentification, e);
    }
    try {
        serverModel = this.readServerModelFromConfiguredIcdFile(clientAssociation);
        if (serverModel != null) {
            return serverModel;
        }
    } catch (final ProtocolAdapterException e) {
        LOGGER.warn("Ignore exception reading server model based on configured ICD file.", e);
    }
    LOGGER.info("Reading ServerModel from device: {} using readServerModelFromDevice()", deviceIdentification);
    return this.iec61850Client.readServerModelFromDevice(clientAssociation);
}
Also used : ServerModel(com.beanit.openiec61850.ServerModel) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Aggregations

ServerModel (org.openmuc.openiec61850.ServerModel)17 ModelNode (com.beanit.openiec61850.ModelNode)16 ServerModel (com.beanit.openiec61850.ServerModel)12 ModelNode (org.openmuc.openiec61850.ModelNode)10 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)8 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)7 JMSException (javax.jms.JMSException)6 ClientAssociation (com.beanit.openiec61850.ClientAssociation)5 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)4 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)4 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)4 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)4 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)4 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)4 Iec61850ClientAssociation (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)4 Iec61850Connection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection)4 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)4 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)3 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)3 BasicDataAttribute (com.beanit.openiec61850.BasicDataAttribute)2