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