Search in sources :

Example 11 with NodeWriteException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project open-smart-grid-platform by OSGP.

the class NodeContainer method writeFloatArray.

public void writeFloatArray(final SubDataAttribute child, final Float[] values) throws NodeWriteException {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    if (array.size() != values.length) {
        throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
    }
    for (int i = 0; i < values.length; i++) {
        final BdaFloat32 bdaFloat = (BdaFloat32) array.getChild(i);
        bdaFloat.setFloat(values[i]);
    }
    this.writeNode(array);
}
Also used : Array(com.beanit.openiec61850.Array) NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException) BdaFloat32(com.beanit.openiec61850.BdaFloat32)

Example 12 with NodeWriteException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project open-smart-grid-platform by OSGP.

the class NodeContainer method writeDateArray.

public void writeDateArray(final SubDataAttribute child, final Date[] values) throws NodeWriteException {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    if (array.size() != values.length) {
        throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
    }
    for (int i = 0; i < values.length; i++) {
        final BdaTimestamp bdaTimestamp = (BdaTimestamp) array.getChild(i);
        bdaTimestamp.setDate(values[i]);
    }
    this.writeNode(array);
}
Also used : Array(com.beanit.openiec61850.Array) NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp)

Example 13 with NodeWriteException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project open-smart-grid-platform by OSGP.

the class Iec61850Client method sendCommandWithRetry.

/**
 * Executes the apply method of the given {@link Function} with retries and message logging.
 *
 * @return The given T.
 */
public <T> T sendCommandWithRetry(final Function<T> function, final String functionName, final String deviceIdentification) throws ProtocolAdapterException {
    T output = null;
    final DeviceMessageLog deviceMessageLog = new DeviceMessageLog(IED.FLEX_OVL, LogicalDevice.LIGHTING, functionName);
    try {
        output = function.apply(deviceMessageLog);
    } catch (final NodeWriteException | NodeReadException e) {
        if (ConnectionState.OK.equals(e.getConnectionState())) {
            // ServiceError means we have to retry.
            LOGGER.error("Caught ServiceError, retrying", e);
            this.sendCommandWithRetry(function, deviceIdentification, 1, deviceMessageLog);
        } else {
            LOGGER.error("Caught IOException, connection with device is broken.", e);
        }
    } catch (final ProtocolAdapterException e) {
        throw e;
    } catch (final Exception e) {
        throw new ProtocolAdapterException(e.getMessage() == null ? COULD_NOT_EXECUTE_COMMAND : e.getMessage(), e);
    }
    return output;
}
Also used : DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) IOException(java.io.IOException) SclParseException(com.beanit.openiec61850.SclParseException) NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)

Example 14 with NodeWriteException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project open-smart-grid-platform by OSGP.

the class Iec61850SetScheduleFunction method writeScheduleEntryForRelay.

private void writeScheduleEntryForRelay(final DeviceMessageLog deviceMessageLog, final List<ScheduleEntry> scheduleEntries, final LogicalNode logicalNode, final NodeContainer schedule, final int i) throws NodeWriteException {
    final ScheduleEntry scheduleEntry = scheduleEntries.get(i);
    final String scheduleEntryName = SubDataAttribute.SCHEDULE_ENTRY.getDescription() + (i + 1);
    final NodeContainer scheduleNode = schedule.getChild(scheduleEntryName);
    this.setEnabled(deviceMessageLog, logicalNode, scheduleEntry, scheduleEntryName, scheduleNode);
    this.setDay(deviceMessageLog, logicalNode, scheduleEntry, scheduleEntryName, scheduleNode);
    this.setSwitchTimes(deviceMessageLog, logicalNode, scheduleEntry, scheduleEntryName, scheduleNode);
    this.setMinimumTimeOn(deviceMessageLog, logicalNode, scheduleEntry, scheduleEntryName, scheduleNode);
    this.setTriggerWindow(deviceMessageLog, logicalNode, scheduleEntry, scheduleEntryName, scheduleNode);
}
Also used : ScheduleEntry(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.ScheduleEntry)

Aggregations

NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)7 NodeWriteException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)5 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)2 Array (com.beanit.openiec61850.Array)2 IOException (java.io.IOException)2 Array (org.openmuc.openiec61850.Array)2 NodeReadException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException)2 NodeContainer (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 Iec61850EnableReportingCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850EnableReportingCommand)1 Iec61850SetGpsCoordinatesCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850SetGpsCoordinatesCommand)1 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)1 BdaFloat32 (com.beanit.openiec61850.BdaFloat32)1 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)1 Brcb (com.beanit.openiec61850.Brcb)1 Rcb (com.beanit.openiec61850.Rcb)1 SclParseException (com.beanit.openiec61850.SclParseException)1