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;
}
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());
}
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;
}
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;
}
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;
}
Aggregations