use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutor method getWeekProfileTableExecutor.
private DataObjectAttrExecutor getWeekProfileTableExecutor(final Set<WeekProfileDto> weekProfileSet) {
final AttributeAddress weekProfileTablePassive = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
final DataObject weekArray = DataObject.newArrayData(this.configurationMapper.mapAsList(weekProfileSet, DataObject.class));
LOGGER.info("WeekProfileTablePassive to set is: {}", this.dlmsHelper.getDebugInfo(weekArray));
return new DataObjectAttrExecutor("WEEKS", weekProfileTablePassive, weekArray, CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final ActivityCalendarDto activityCalendar, final MessageMetadata messageMetadata) throws ProtocolAdapterException, FunctionalException {
LOGGER.debug("SetActivityCalendarCommandExecutor.execute {} called", activityCalendar.getCalendarName());
ActivityCalendarValidator.validate(activityCalendar);
final List<SeasonProfileDto> seasonProfileList = activityCalendar.getSeasonProfileList();
final Set<WeekProfileDto> weekProfileSet = this.getWeekProfileSet(seasonProfileList);
final Set<DayProfileDto> dayProfileSet = this.getDayProfileSet(weekProfileSet);
final DataObjectAttrExecutors dataObjectExecutors = new DataObjectAttrExecutors("SetActivityCalendar").addExecutor(this.getCalendarNameExecutor(activityCalendar)).addExecutor(this.getSeasonProfileExecutor(seasonProfileList)).addExecutor(this.getWeekProfileTableExecutor(weekProfileSet)).addExecutor(this.getDayProfileTablePassiveExecutor(dayProfileSet));
conn.getDlmsMessageListener().setDescription("SetActivityCalendar for calendar " + activityCalendar.getCalendarName() + ", set attributes: " + dataObjectExecutors.describeAttributes());
dataObjectExecutors.execute(conn);
LOGGER.info("Finished setting the passive activity calendar");
// in the exception to throw
try {
this.setActivityCalendarCommandActivationExecutor.execute(conn, device, null, messageMetadata);
LOGGER.info("Finished activating the passive to the active activity calendar");
} catch (final ProtocolAdapterException e) {
final StringBuilder message = new StringBuilder();
for (final DataObjectAttrExecutor executor : dataObjectExecutors.getDataObjectAttrExecutorList()) {
message.append(executor.createRequestAndResultCodeInfo());
}
throw new ProtocolAdapterException(e.getMessage() + message, e);
}
return AccessResultCode.SUCCESS;
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutor method getDayProfileTablePassiveExecutor.
private DataObjectAttrExecutor getDayProfileTablePassiveExecutor(final Set<DayProfileDto> dayProfileSet) {
final AttributeAddress dayProfileTablePassive = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_DAY_PROFILE_TABLE_PASSIVE);
final DataObject dayArray = DataObject.newArrayData(this.configurationMapper.mapAsList(dayProfileSet, DataObject.class));
LOGGER.info("DayProfileTablePassive to set is: {}", this.dlmsHelper.getDebugInfo(dayArray));
return new DataObjectAttrExecutor("DAYS", dayProfileTablePassive, dayArray, CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_DAY_PROFILE_TABLE_PASSIVE);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutor method getSeasonProfileExecutor.
private DataObjectAttrExecutor getSeasonProfileExecutor(final List<SeasonProfileDto> seasonProfileList) {
final AttributeAddress seasonProfilePassive = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_SEASON_PROFILE_PASSIVE);
final DataObject seasonsArray = DataObject.newArrayData(this.configurationMapper.mapAsList(seasonProfileList, DataObject.class));
LOGGER.info("SeasonProfilePassive to set is: {}", this.dlmsHelper.getDebugInfo(seasonsArray));
return new DataObjectAttrExecutor("SEASONS", seasonProfilePassive, seasonsArray, CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_SEASON_PROFILE_PASSIVE);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutor method getCalendarNameExecutor.
private DataObjectAttrExecutor getCalendarNameExecutor(final ActivityCalendarDto activityCalendar) {
final AttributeAddress calendarNamePassive = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_CALENDAR_NAME_PASSIVE);
final DataObject value = DataObject.newOctetStringData(activityCalendar.getCalendarName().getBytes());
return new DataObjectAttrExecutor("CALENDARNAME", calendarNamePassive, value, CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_CALENDAR_NAME_PASSIVE);
}
Aggregations