Search in sources :

Example 1 with ActivityCalendarType

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType in project open-smart-grid-platform by OSGP.

the class SetActivityCalendarRequestBuilder method getActivityCalendarType.

private ActivityCalendarType getActivityCalendarType() {
    final ActivityCalendarType act = new ActivityCalendarType();
    act.setCalendarName(this.activityCalendar.getName());
    act.setActivatePassiveCalendarTime(DatatypeConverter.parseHexBinary(this.activityCalendar.getActivatePassiveCalendarTime()));
    act.setSeasonProfile(this.getSeasonsType());
    return act;
}
Also used : ActivityCalendarType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType)

Example 2 with ActivityCalendarType

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType in project open-smart-grid-platform by OSGP.

the class ActivityCalendarTypeMappingTest method testActivityCalendarTypeMapping.

/**
 * Method to test mapping from ActivityCalendarType to ActivityCalendar.
 */
@Test
public void testActivityCalendarTypeMapping() {
    // build test data
    final ActivityCalendarType activityCalendarType = this.buildActivityCalendarTypeObject();
    // actual mapping
    final ActivityCalendar activityCalendar = this.configurationMapper.map(activityCalendarType, ActivityCalendar.class);
    // check mapping
    assertThat(activityCalendar).isNotNull();
    assertThat(activityCalendar.getSeasonProfileList()).isNotNull();
    assertThat(activityCalendar.getSeasonProfileList().get(0)).isNotNull();
    // For more info on byte[] to CosemDateTime object mapping, refer to the
    // CosemDateTimeConverterTest.
    assertThat(activityCalendar.getActivatePassiveCalendarTime()).isNotNull();
    assertThat(activityCalendar.getSeasonProfileList().get(0).getSeasonStart()).isNotNull();
    assertThat(activityCalendar.getCalendarName()).isEqualTo(CALENDARNAME);
    assertThat(activityCalendar.getSeasonProfileList().get(0).getSeasonProfileName()).isEqualTo(SEASONPROFILENAME);
    this.checkWeekProfileMapping(activityCalendar.getSeasonProfileList().get(0).getWeekProfile());
}
Also used : ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) ActivityCalendarType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType) Test(org.junit.jupiter.api.Test)

Example 3 with ActivityCalendarType

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType in project open-smart-grid-platform by OSGP.

the class SetActivityCalendarRequestFactory method fetchActivityCalendar.

private static ActivityCalendarType fetchActivityCalendar() {
    final ActivityCalendarType activityCalendarType = new ActivityCalendarType();
    final String activatePassiveCalendarTime = "FFFFFFFEFFFFFFFFFF000000";
    final byte[] decodedActivatePassiveCalendarTime;
    try {
        decodedActivatePassiveCalendarTime = Hex.decodeHex(activatePassiveCalendarTime.toCharArray());
        activityCalendarType.setActivatePassiveCalendarTime(decodedActivatePassiveCalendarTime);
    } catch (final DecoderException e) {
        LOGGER.error("Unexpected exception during decode activatePassiveCalendarTime.", e);
    }
    activityCalendarType.setCalendarName("Cal Name");
    final SeasonsType seasonsType = new SeasonsType();
    final List<SeasonType> seasons = new ArrayList<>();
    final SeasonType season = new SeasonType();
    season.setSeasonProfileName("1");
    final String seasonStart = "FFFF0C03FFFFFFFFFF000000";
    final byte[] decodedSeasonStart;
    try {
        decodedSeasonStart = Hex.decodeHex(seasonStart.toCharArray());
        season.setSeasonStart(decodedSeasonStart);
    } catch (final DecoderException e) {
        LOGGER.error("Unexpected exception during decode seasonStart.", e);
    }
    final WeekType weekType = new WeekType();
    final DayType normalDay = createDayType(1, "06050000");
    final DayType weekendDay = createDayType(2, "07050000");
    weekType.setMonday(normalDay);
    weekType.setTuesday(normalDay);
    weekType.setWednesday(normalDay);
    weekType.setThursday(normalDay);
    weekType.setFriday(normalDay);
    weekType.setSaturday(weekendDay);
    weekType.setSunday(weekendDay);
    weekType.setWeekProfileName("1");
    season.setWeekProfile(weekType);
    seasons.add(season);
    seasonsType.getSeason().addAll(seasons);
    activityCalendarType.setSeasonProfile(seasonsType);
    return activityCalendarType;
}
Also used : SeasonsType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SeasonsType) DecoderException(org.apache.commons.codec.DecoderException) SeasonType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SeasonType) ActivityCalendarType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType) ArrayList(java.util.ArrayList) DayType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayType) WeekType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.WeekType)

Example 4 with ActivityCalendarType

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType in project open-smart-grid-platform by OSGP.

the class SetActivityCalendarRequestFactory method fromParameterMap.

public static SetActivityCalendarRequest fromParameterMap(final Map<String, String> requestParameters) {
    final SetActivityCalendarRequest setActivityCalendarRequest = new SetActivityCalendarRequest();
    setActivityCalendarRequest.setDeviceIdentification(requestParameters.get(PlatformSmartmeteringKeys.KEY_DEVICE_IDENTIFICATION));
    final ActivityCalendarType activityCalendarType = fetchActivityCalendar();
    final SetActivityCalendarRequestData setActivityCalendarRequestData = new SetActivityCalendarRequestData();
    setActivityCalendarRequestData.setActivityCalendar(activityCalendarType);
    setActivityCalendarRequest.setActivityCalendarData(setActivityCalendarRequestData);
    return setActivityCalendarRequest;
}
Also used : SetActivityCalendarRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetActivityCalendarRequest) ActivityCalendarType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType) SetActivityCalendarRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetActivityCalendarRequestData)

Example 5 with ActivityCalendarType

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType in project open-smart-grid-platform by OSGP.

the class ActivityCalendarTypeMappingTest method buildActivityCalendarTypeObject.

/**
 * Method to build an ActivityCalendarType object
 */
private ActivityCalendarType buildActivityCalendarTypeObject() {
    // Build a DayType
    final DayProfileActionsType dayProfileActionsType = new DayProfileActionsType();
    final DayProfileActionType dayProfileActionType = new DayProfileActionType();
    dayProfileActionType.setScriptSelector(BigInteger.ZERO);
    dayProfileActionType.setStartTime(COSEMTIME_BYTE_ARRAY);
    dayProfileActionsType.getDayProfileAction().add(dayProfileActionType);
    final DayType dayType = new DayType();
    dayType.setDayId(BigInteger.TEN);
    dayType.setDaySchedule(dayProfileActionsType);
    // Build a WeekType
    final WeekType weekType = new WeekType();
    weekType.setWeekProfileName(WEEKPROFILENAME);
    weekType.setSunday(dayType);
    weekType.setMonday(dayType);
    weekType.setTuesday(dayType);
    weekType.setWednesday(dayType);
    weekType.setThursday(dayType);
    weekType.setFriday(dayType);
    weekType.setSaturday(dayType);
    // Build a SeasonType
    final SeasonType seasonType = new SeasonType();
    seasonType.setSeasonProfileName(SEASONPROFILENAME);
    seasonType.setSeasonStart(COSEMDATETIME_BYTE_ARRAY);
    seasonType.setWeekProfile(weekType);
    // Build an ActivityCalendarType.
    final ActivityCalendarType activityCalendarType = new ActivityCalendarType();
    final SeasonsType seasonsType = new SeasonsType();
    seasonsType.getSeason().add(seasonType);
    activityCalendarType.setActivatePassiveCalendarTime(COSEMDATETIME_BYTE_ARRAY);
    activityCalendarType.setCalendarName(CALENDARNAME);
    activityCalendarType.setSeasonProfile(seasonsType);
    return activityCalendarType;
}
Also used : SeasonsType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SeasonsType) SeasonType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SeasonType) DayProfileActionType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayProfileActionType) ActivityCalendarType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType) DayProfileActionsType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayProfileActionsType) DayType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayType) WeekType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.WeekType)

Aggregations

ActivityCalendarType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ActivityCalendarType)5 DayType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayType)2 SeasonType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SeasonType)2 SeasonsType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SeasonsType)2 WeekType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.WeekType)2 ArrayList (java.util.ArrayList)1 DecoderException (org.apache.commons.codec.DecoderException)1 Test (org.junit.jupiter.api.Test)1 DayProfileActionType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayProfileActionType)1 DayProfileActionsType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.DayProfileActionsType)1 SetActivityCalendarRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetActivityCalendarRequest)1 SetActivityCalendarRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetActivityCalendarRequestData)1 ActivityCalendar (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar)1