Search in sources :

Example 1 with ProfileEntryDto

use of org.opensmartgridplatform.dto.valueobjects.microgrids.ProfileEntryDto in project open-smart-grid-platform 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(org.opensmartgridplatform.dto.valueobjects.microgrids.ProfileEntryDto) ProfilePair(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.ProfilePair) Date(java.util.Date)

Example 2 with ProfileEntryDto

use of org.opensmartgridplatform.dto.valueobjects.microgrids.ProfileEntryDto in project open-smart-grid-platform 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(org.opensmartgridplatform.dto.valueobjects.microgrids.ProfileEntryDto) ArrayList(java.util.ArrayList) Date(java.util.Date) DateTime(org.joda.time.DateTime)

Aggregations

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