Search in sources :

Example 6 with ChannelElementValuesDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.

the class CoupleMbusDeviceByChannelCommandExecutor method execute.

@Override
public CoupleMbusDeviceByChannelResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final CoupleMbusDeviceByChannelRequestDataDto requestDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    log.info("Retrieving values for mbus channel {} on device {}", requestDto.getChannel(), device.getDeviceIdentification());
    final ChannelElementValuesDto channelElementValuesDto = this.deviceChannelsHelper.getChannelElementValues(conn, device, requestDto.getChannel());
    /*
     * Couple M-Bus device by channel is created to couple the M-Bus device
     * in the platform based on a new M-Bus device discovered alarm for a
     * particular channel. As such there is no write action to the M-Bus
     * Client Setup involved, since the platform depends on the attributes
     * on the gateway device to be able to determine which M-Bus device was
     * actually involved when the alarm was triggered for the channel from
     * the request.
     */
    return new CoupleMbusDeviceByChannelResponseDto(channelElementValuesDto);
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) CoupleMbusDeviceByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)

Example 7 with ChannelElementValuesDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto 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)

Example 8 with ChannelElementValuesDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.

the class DeviceChannelsHelper method findCandidateChannelsForDevice.

public List<ChannelElementValuesDto> findCandidateChannelsForDevice(final DlmsConnectionManager conn, final DlmsDevice device, final MbusChannelElementsDto requestDto) throws ProtocolAdapterException {
    final List<ChannelElementValuesDto> channelElementValuesList = new ArrayList<>();
    for (short channel = FIRST_CHANNEL; channel < FIRST_CHANNEL + NR_OF_CHANNELS; channel++) {
        final ChannelElementValuesDto channelElementValues = this.getChannelElementValues(conn, device, channel);
        channelElementValuesList.add(channelElementValues);
        if (requestDto != null && FindMatchingChannelHelper.matches(requestDto, channelElementValues)) {
            /*
         * A complete match for all attributes from the request has been
         * found. Stop retrieving M-Bus Client Setup attributes for
         * other channels. Return a list returning the values retrieved
         * so far and don't retrieve any additional M-Bus Client Setup
         * data from the device.
         */
            return channelElementValuesList;
        }
    }
    /*
     * A complete match for all attributes from the request has not been
     * found. The best partial match that has no conflicting attribute
     * values, or the first free channel has to be picked from this list.
     */
    return channelElementValuesList;
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) ArrayList(java.util.ArrayList)

Example 9 with ChannelElementValuesDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.

the class FindMatchingChannelHelperTest method testAllFilled.

@Test
public void testAllFilled() {
    /*
     * All attributes for requestData and channelValues are defined and
     * matching.
     */
    final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
    final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
    assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should match " + channelValues).isTrue();
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) MbusChannelElementsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto) Test(org.junit.jupiter.api.Test)

Example 10 with ChannelElementValuesDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.

the class FindMatchingChannelHelperTest method testNoAttributesInRequestAllInRetrievedValues.

@Test
public void testNoAttributesInRequestAllInRetrievedValues() {
    final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.noIdentificationNumber, this.noManufacturerIdentification, null, null);
    final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
    assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should match " + channelValues).isTrue();
    assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
    final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(channelValues);
    assertThat(FindMatchingChannelHelper.bestMatch(requestData, channelValuesList)).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) MbusChannelElementsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto) Test(org.junit.jupiter.api.Test)

Aggregations

ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)23 Test (org.junit.jupiter.api.Test)14 MbusChannelElementsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto)7 ArrayList (java.util.ArrayList)4 GetResult (org.openmuc.jdlms.GetResult)3 ObisCode (org.openmuc.jdlms.ObisCode)3 GetMBusDeviceOnChannelRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMBusDeviceOnChannelRequestDataDto)3 CosemObjectAccessor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.CosemObjectAccessor)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2 CoupleMbusDeviceByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)2 DecoupleMbusDeviceResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto)2 MbusChannelElementsResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsResponseDto)2 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)1 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)1 DataObjectAttrExecutors (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutors)1 EncryptionKeyStatusTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EncryptionKeyStatusTypeDto)1 GMeterInfoDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto)1