use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeNotFoundException in project open-smart-grid-platform by OSGP.
the class Iec61850SetConfigurationFunction method setClockConfiguration.
private void setClockConfiguration(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final ConfigurationDto configuration, final DeviceMessageLog deviceMessageLog) throws NodeNotFoundException, NodeReadException, NodeWriteException {
final NodeContainer clock = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), clock.getFcmodelNode());
if (configuration.getTimeSyncFrequency() != null) {
LOGGER.info("Updating TimeSyncFrequency to {}", configuration.getTimeSyncFrequency());
clock.writeUnsignedShort(SubDataAttribute.TIME_SYNC_FREQUENCY, configuration.getTimeSyncFrequency());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.TIME_SYNC_FREQUENCY, Integer.toString(configuration.getTimeSyncFrequency()));
}
if (configuration.isAutomaticSummerTimingEnabled() != null) {
LOGGER.info("Updating AutomaticSummerTimingEnabled to {}", configuration.isAutomaticSummerTimingEnabled());
clock.writeBoolean(SubDataAttribute.AUTOMATIC_SUMMER_TIMING_ENABLED, configuration.isAutomaticSummerTimingEnabled());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.AUTOMATIC_SUMMER_TIMING_ENABLED, Boolean.toString(configuration.isAutomaticSummerTimingEnabled()));
}
/*
* Perform some effort to create dstBegT/dstEndt information
* based on provided DateTime values. This will work in a
* number of cases, but to be able to do this accurately in
* an international context, DST transition times will
* probably have to be based on information about the
* time-zone the device is operating in, instead of a
* particular DateTime provided by the caller without
* further information.
*/
final DaylightSavingTimeTransition.DstTransitionFormat dstFormatMwd = DaylightSavingTimeTransition.DstTransitionFormat.DAY_OF_WEEK_OF_MONTH;
final DateTime summerTimeDetails = configuration.getSummerTimeDetails();
final DateTime winterTimeDetails = configuration.getWinterTimeDetails();
if (summerTimeDetails != null) {
final String mwdValueForBeginOfDst = DaylightSavingTimeTransition.forDateTimeAccordingToFormat(summerTimeDetails, dstFormatMwd).getTransition();
LOGGER.info("Updating DstBeginTime to {} based on SummerTimeDetails {}", mwdValueForBeginOfDst, summerTimeDetails);
clock.writeString(SubDataAttribute.SUMMER_TIME_DETAILS, mwdValueForBeginOfDst);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.SUMMER_TIME_DETAILS, mwdValueForBeginOfDst);
}
if (winterTimeDetails != null) {
final String mwdValueForEndOfDst = DaylightSavingTimeTransition.forDateTimeAccordingToFormat(winterTimeDetails, dstFormatMwd).getTransition();
LOGGER.info("Updating DstEndTime to {} based on WinterTimeDetails {}", mwdValueForEndOfDst, winterTimeDetails);
clock.writeString(SubDataAttribute.WINTER_TIME_DETAILS, mwdValueForEndOfDst);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.WINTER_TIME_DETAILS, mwdValueForEndOfDst);
}
if (configuration.getNtpEnabled() != null) {
LOGGER.info("Updating ntpEnabled to {}", configuration.getNtpEnabled());
clock.writeBoolean(SubDataAttribute.NTP_ENABLED, configuration.getNtpEnabled());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.NTP_ENABLED, Boolean.toString(configuration.getNtpEnabled()));
}
if (configuration.getNtpHost() != null) {
LOGGER.info("Updating ntpHost to {}", configuration.getNtpHost());
clock.writeString(SubDataAttribute.NTP_HOST, configuration.getNtpHost());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.NTP_HOST, configuration.getNtpHost());
}
if (configuration.getNtpSyncInterval() != null) {
LOGGER.info("Updating ntpSyncInterval to {}", configuration.getNtpSyncInterval());
clock.writeUnsignedShort(SubDataAttribute.NTP_SYNC_INTERVAL, configuration.getNtpSyncInterval());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.NTP_SYNC_INTERVAL, configuration.getNtpSyncInterval().toString());
}
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeNotFoundException in project open-smart-grid-platform by OSGP.
the class DeviceConnection method getFcModelNode.
/**
* Returns a {@link NodeContainer} for the given {@link ObjectReference} data and the Functional
* constraint.
*
* @throws NodeNotFoundException
*/
public NodeContainer getFcModelNode(final LogicalDevice logicalDevice, final LogicalNode logicalNode, final DataAttribute dataAttribute, final Fc fc) throws NodeNotFoundException {
final ObjectReference objectReference = this.createObjectReference(logicalDevice, logicalNode, dataAttribute);
final FcModelNode fcModelNode = (FcModelNode) this.connection.getServerModel().findModelNode(objectReference, fc);
if (fcModelNode == null) {
LOGGER.error("FcModelNode is null, most likely the data attribute: {} does not exist", dataAttribute.getDescription());
throw new NodeNotFoundException(String.format("FcModelNode with objectReference %s does not exist", objectReference));
}
return new NodeContainer(this, fcModelNode);
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeNotFoundException in project open-smart-grid-platform by OSGP.
the class DeviceConnection method getFcModelNode.
/**
* Returns a {@link NodeContainer} for the given {@link ObjectReference} data and the Functional
* constraint.
*
* @throws NodeNotFoundException
*/
public NodeContainer getFcModelNode(final LogicalDevice logicalDevice, final int logicalDeviceIndex, final LogicalNode logicalNode, final DataAttribute dataAttribute, final Fc fc) throws NodeNotFoundException {
final ObjectReference objectReference = this.createObjectReference(logicalDevice, logicalDeviceIndex, logicalNode, dataAttribute);
final FcModelNode fcModelNode = (FcModelNode) this.connection.getServerModel().findModelNode(objectReference, fc);
if (fcModelNode == null) {
LOGGER.error("FcModelNode is null, most likely the data attribute: {} does not exist", dataAttribute.getDescription());
throw new NodeNotFoundException(String.format("FcModelNode with objectReference %s does not exist", objectReference));
}
return new NodeContainer(this, fcModelNode);
}
Aggregations