Search in sources :

Example 1 with CosemObjectAccessor

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.CosemObjectAccessor in project open-smart-grid-platform by OSGP.

the class DecoupleMBusDeviceCommandExecutor method execute.

@Override
public DecoupleMbusDeviceResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final DecoupleMbusDeviceDto decoupleMbusDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final Short channel = decoupleMbusDto.getChannel();
    log.debug("Decouple channel {} on gateway device {}", channel, device.getDeviceIdentification());
    final ObisCode obisCode = this.deviceChannelsHelper.getObisCode(device, channel);
    // Get the current channel element values before resetting the channel
    final ChannelElementValuesDto channelElementValues = this.deviceChannelsHelper.getChannelElementValues(conn, device, channel);
    // Deinstall and reset channel
    final CosemObjectAccessor mBusSetup = new CosemObjectAccessor(conn, obisCode, InterfaceClass.MBUS_CLIENT.id());
    this.deviceChannelsHelper.deinstallSlave(conn, device, channel, mBusSetup);
    this.deviceChannelsHelper.resetMBusClientAttributeValues(conn, device, channel, this.getClass().getSimpleName());
    // return the channel element values as before decoupling
    return new DecoupleMbusDeviceResponseDto(channelElementValues);
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) CosemObjectAccessor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.CosemObjectAccessor) DecoupleMbusDeviceResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto) ObisCode(org.openmuc.jdlms.ObisCode)

Aggregations

ObisCode (org.openmuc.jdlms.ObisCode)1 CosemObjectAccessor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.CosemObjectAccessor)1 ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)1 DecoupleMbusDeviceResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto)1