Search in sources :

Example 1 with DataObjectAttrExecutor

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DataObjectAttrExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)

Example 2 with DataObjectAttrExecutor

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;
}
Also used : DataObjectAttrExecutors(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutors) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) SeasonProfileDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SeasonProfileDto) WeekProfileDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.WeekProfileDto) DayProfileDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DayProfileDto) DataObjectAttrExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)

Example 3 with DataObjectAttrExecutor

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DataObjectAttrExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)

Example 4 with DataObjectAttrExecutor

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DataObjectAttrExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)

Example 5 with DataObjectAttrExecutor

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DataObjectAttrExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)

Aggregations

DataObjectAttrExecutor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)5 AttributeAddress (org.openmuc.jdlms.AttributeAddress)4 DataObject (org.openmuc.jdlms.datatypes.DataObject)4 DataObjectAttrExecutors (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutors)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 DayProfileDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DayProfileDto)1 SeasonProfileDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SeasonProfileDto)1 WeekProfileDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.WeekProfileDto)1