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);
}
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);
}
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;
}
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);
}
Aggregations