Search in sources :

Example 1 with ProfilePair

use of com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850ScheduleAbsTimeCommand method executeWrite.

@Override
public void executeWrite(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex, final ProfileDto profile) throws NodeWriteException {
    this.checkProfile(profile);
    final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, this.logicalNode, DATA_ATTRIBUTE, FC);
    final ProfilePair profilePair = this.convert(profile.getProfileEntries());
    containingNode.writeFloatArray(SubDataAttribute.VALUES, profilePair.getValues());
    containingNode.writeDateArray(SubDataAttribute.TIMES, profilePair.getTimes());
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) ProfilePair(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair)

Example 2 with ProfilePair

use of com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850ScheduleAbsTimeCommand method convert.

private ProfilePair convert(final List<ProfileEntryDto> profileEntries) {
    final Float[] values = new Float[ARRAY_SIZE];
    final Date[] times = new Date[ARRAY_SIZE];
    for (final ProfileEntryDto pe : profileEntries) {
        final int i = pe.getId() - 1;
        values[i] = (float) pe.getValue();
        times[i] = pe.getTime().toDate();
    }
    // Fill rest of array with default values
    final int start = profileEntries.size();
    final int end = ARRAY_SIZE;
    for (int i = start; i < end; i++) {
        values[i] = DEFAULT_VALUE;
        times[i] = DEFAULT_TIME;
    }
    return new ProfilePair(values, times);
}
Also used : ProfileEntryDto(com.alliander.osgp.dto.valueobjects.microgrids.ProfileEntryDto) ProfilePair(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair) Date(java.util.Date)

Aggregations

ProfilePair (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair)2 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)1 ProfileEntryDto (com.alliander.osgp.dto.valueobjects.microgrids.ProfileEntryDto)1 Date (java.util.Date)1