Search in sources :

Example 6 with AlarmNotificationsDto

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

the class SetAlarmNotificationsCommandExecutor method executeForAlarmFilter.

private AccessResultCode executeForAlarmFilter(final DlmsConnectionManager conn, final AttributeAddress alarmFilterAttributeAddress, final AlarmNotificationsDto alarmNotifications, final DlmsObjectType alarmRegisterDlmsObjectType) throws ProtocolAdapterException {
    try {
        final AlarmNotificationsDto alarmNotificationsOnDevice = this.retrieveCurrentAlarmNotifications(conn, alarmFilterAttributeAddress, alarmRegisterDlmsObjectType);
        LOGGER.info("Alarm Filter on device before setting notifications: {}", alarmNotificationsOnDevice);
        final Set<AlarmTypeDto> alarmTypesForRegister = this.alarmHelperService.alarmTypesForRegister(alarmRegisterDlmsObjectType);
        final Set<AlarmNotificationDto> alarmNotificationsSet = alarmNotifications.getAlarmNotificationsSet().stream().filter(alarmNotificationDto -> alarmTypesForRegister.contains(alarmNotificationDto.getAlarmType())).collect(Collectors.toSet());
        final long alarmFilterLongValueOnDevice = this.alarmFilterLongValue(alarmNotificationsOnDevice);
        final long updatedAlarmFilterLongValue = this.calculateAlarmFilterLongValue(alarmNotificationsOnDevice, alarmNotificationsSet);
        if (alarmFilterLongValueOnDevice == updatedAlarmFilterLongValue) {
            return AccessResultCode.SUCCESS;
        }
        LOGGER.info("Modified Alarm Filter long value for device: {}", updatedAlarmFilterLongValue);
        return this.writeUpdatedAlarmNotifications(conn, updatedAlarmFilterLongValue, alarmFilterAttributeAddress);
    } catch (final IOException e) {
        throw new ConnectionException(e);
    }
}
Also used : DlmsObjectType(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType) ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) GetResult(org.openmuc.jdlms.GetResult) LoggerFactory(org.slf4j.LoggerFactory) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Autowired(org.springframework.beans.factory.annotation.Autowired) TreeSet(java.util.TreeSet) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) SetAlarmNotificationsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetAlarmNotificationsRequestDto) AccessResultCode(org.openmuc.jdlms.AccessResultCode) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) Logger(org.slf4j.Logger) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException) SetParameter(org.openmuc.jdlms.SetParameter) AbstractCommandExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.AbstractCommandExecutor) Set(java.util.Set) DataObject(org.openmuc.jdlms.datatypes.DataObject) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ActionRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionRequestDto) Component(org.springframework.stereotype.Component) AlarmNotificationsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto) Optional(java.util.Optional) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) AlarmNotificationDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationDto) BitSet(java.util.BitSet) JdlmsObjectToStringUtil(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.JdlmsObjectToStringUtil) AlarmNotificationDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationDto) AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) IOException(java.io.IOException) AlarmNotificationsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)

Example 7 with AlarmNotificationsDto

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

the class ConfigurationService method setAlarmNotifications.

public void setAlarmNotifications(final MessageMetadata messageMetadata, final AlarmNotifications alarmNotifications) throws FunctionalException {
    log.info("setAlarmNotifications for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final AlarmNotificationsDto requestDto = this.configurationMapper.map(alarmNotifications, AlarmNotificationsDto.class);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) AlarmNotificationsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto)

Aggregations

AlarmNotificationsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto)7 TreeSet (java.util.TreeSet)4 AlarmNotificationDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationDto)4 BitSet (java.util.BitSet)2 Test (org.junit.jupiter.api.Test)2 AlarmNotification (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotification)2 AlarmNotifications (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications)2 AlarmTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AccessResultCode (org.openmuc.jdlms.AccessResultCode)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 GetResult (org.openmuc.jdlms.GetResult)1 SetParameter (org.openmuc.jdlms.SetParameter)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 AbstractCommandExecutor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.AbstractCommandExecutor)1 DlmsObjectConfigService (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService)1