Search in sources :

Example 1 with RelayType

use of org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType in project open-smart-grid-platform by OSGP.

the class Iec61850SetScheduleCommand method createScheduleEntries.

/**
 * Returns a map of schedule entries, grouped by the internal index.
 */
private Map<Integer, List<ScheduleEntry>> createScheduleEntries(final List<ScheduleEntryDto> scheduleList, final Ssld ssld, final RelayTypeDto relayTypeDto) throws FunctionalException {
    final Map<Integer, List<ScheduleEntry>> relaySchedulesEntries = new HashMap<>();
    final RelayType relayType = RelayType.valueOf(relayTypeDto.name());
    final List<DeviceOutputSetting> settings = this.ssldDataService.findByRelayType(ssld, relayType);
    for (final ScheduleEntryDto schedule : scheduleList) {
        for (final LightValueDto lightValue : schedule.getLightValue()) {
            this.setScheduleEntry(ssld, relaySchedulesEntries, relayType, settings, schedule, lightValue);
        }
    }
    return relaySchedulesEntries;
}
Also used : RelayType(org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType) ScheduleEntryDto(org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) DeviceOutputSetting(org.opensmartgridplatform.core.db.api.iec61850.entities.DeviceOutputSetting) LightValueDto(org.opensmartgridplatform.dto.valueobjects.LightValueDto)

Example 2 with RelayType

use of org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType in project open-smart-grid-platform by OSGP.

the class Iec61850GetConfigurationCommand method checkRelayType.

private void checkRelayType(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final DeviceOutputSetting deviceOutputSetting, final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
    final RelayType registeredRelayType = deviceOutputSetting.getRelayType();
    final int expectedSwType;
    if (RelayType.LIGHT.equals(registeredRelayType)) {
        expectedSwType = SWITCH_TYPE_LIGHT;
    } else if (RelayType.TARIFF.equals(registeredRelayType) || RelayType.TARIFF_REVERSED.equals(registeredRelayType)) {
        expectedSwType = SWITCH_TYPE_TARIFF;
    } else {
        throw new ProtocolAdapterException("DeviceOutputSetting (internal index = " + deviceOutputSetting.getInternalId() + ", external index = " + deviceOutputSetting.getExternalId() + ") does not have a known RelayType: " + registeredRelayType);
    }
    final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(deviceOutputSetting.getInternalId());
    final NodeContainer switchType = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.SWITCH_TYPE, Fc.ST);
    iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), switchType.getFcmodelNode());
    final int switchTypeValue = switchType.getByte(SubDataAttribute.STATE).getValue();
    if (expectedSwType != switchTypeValue) {
        throw new ProtocolAdapterException("DeviceOutputSetting (internal index = " + deviceOutputSetting.getInternalId() + ", external index = " + deviceOutputSetting.getExternalId() + ") has a RelayType (" + registeredRelayType + ") that does not match the SwType on the device: " + (switchTypeValue == SWITCH_TYPE_TARIFF ? "Tariff switch (0)" : (switchTypeValue == SWITCH_TYPE_LIGHT ? "Light switch (1)" : "Unknown value: " + switchTypeValue)));
    }
    deviceMessageLog.addVariable(logicalNode, DataAttribute.SWITCH_TYPE, Fc.ST, SubDataAttribute.STATE, Integer.toString(switchTypeValue));
}
Also used : RelayType(org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType) NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) LogicalNode(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)

Aggregations

RelayType (org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 LogicalNode (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)1 NodeContainer (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)1 DeviceOutputSetting (org.opensmartgridplatform.core.db.api.iec61850.entities.DeviceOutputSetting)1 LightValueDto (org.opensmartgridplatform.dto.valueobjects.LightValueDto)1 ScheduleEntryDto (org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto)1