Search in sources :

Example 1 with ProfileEntryDto

use of com.alliander.osgp.dto.valueobjects.microgrids.ProfileEntryDto 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)

Example 2 with ProfileEntryDto

use of com.alliander.osgp.dto.valueobjects.microgrids.ProfileEntryDto in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850ScheduleAbsTimeCommand method convert.

private List<ProfileEntryDto> convert(final NodeContainer profileNode) {
    final Float[] values = profileNode.getFloatArray(SubDataAttribute.VALUES);
    final Date[] times = profileNode.getDateArray(SubDataAttribute.TIMES);
    final List<ProfileEntryDto> profileEntries = new ArrayList<>();
    for (int i = 0; i < ARRAY_SIZE; i++) {
        final double value = values[i];
        final Date time;
        if (times[i] == null) {
            time = DEFAULT_TIME;
        } else {
            time = times[i];
        }
        if (!time.equals(DEFAULT_TIME)) {
            profileEntries.add(new ProfileEntryDto(i + 1, new DateTime(time), value));
        }
    }
    return profileEntries;
}
Also used : ProfileEntryDto(com.alliander.osgp.dto.valueobjects.microgrids.ProfileEntryDto) ArrayList(java.util.ArrayList) Date(java.util.Date) DateTime(org.joda.time.DateTime)

Aggregations

ProfileEntryDto (com.alliander.osgp.dto.valueobjects.microgrids.ProfileEntryDto)2 Date (java.util.Date)2 ProfilePair (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1