Search in sources :

Example 1 with SmartMeter

use of org.opensmartgridplatform.domain.core.entities.SmartMeter in project open-smart-grid-platform by OSGP.

the class SetDeviceLifecycleStatusByChannel method theSetDeviceLifecycleStatusByChannelResponseIsReturned.

@Then("^the set device lifecycle status by channel response is returned$")
public void theSetDeviceLifecycleStatusByChannelResponseIsReturned(final Map<String, String> settings) throws Throwable {
    final SetDeviceLifecycleStatusByChannelAsyncRequest asyncRequest = SetDeviceLifecycleStatusByChannelRequestFactory.fromScenarioContext();
    final SetDeviceLifecycleStatusByChannelResponse response = this.smManagementResponseClient.getResponse(asyncRequest);
    assertThat(response.getResult()).as(OPERATION + ", Checking result:").isEqualTo(OsgpResultType.OK);
    assertThat(response.getSetDeviceLifecycleStatusByChannelResponseData().getGatewayDeviceIdentification()).as(OPERATION + ", Checking gatewayDeviceId:").isEqualTo(settings.get(PlatformSmartmeteringKeys.KEY_DEVICE_IDENTIFICATION));
    assertThat(response.getSetDeviceLifecycleStatusByChannelResponseData().getChannel()).as(OPERATION + ", Checking channel:").isEqualTo(Short.parseShort(settings.get(PlatformSmartmeteringKeys.CHANNEL)));
    final SmartMeter gatewayDevice = this.smartMeterRepository.findByDeviceIdentification(settings.get(PlatformSmartmeteringKeys.KEY_DEVICE_IDENTIFICATION));
    final List<SmartMeter> mbusDevices = this.smartMeterRepository.getMbusDevicesForGateway(gatewayDevice.getId());
    SmartMeter mbusDevice = null;
    for (final SmartMeter device : mbusDevices) {
        if (device.getChannel().equals(Short.parseShort(settings.get(PlatformSmartmeteringKeys.CHANNEL)))) {
            mbusDevice = device;
            break;
        }
    }
    assertThat(mbusDevice.getDeviceIdentification()).as(OPERATION + ", Checking mbusDeviceIdentification:").isEqualTo(response.getSetDeviceLifecycleStatusByChannelResponseData().getMbusDeviceIdentification());
    assertThat(mbusDevice.getDeviceLifecycleStatus()).as(OPERATION + ", Checking deviceLifecycleStatus of device:").isEqualTo(DeviceLifecycleStatus.valueOf(settings.get(PlatformSmartmeteringKeys.KEY_DEVICE_LIFECYCLE_STATUS)));
}
Also used : SetDeviceLifecycleStatusByChannelResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.SetDeviceLifecycleStatusByChannelResponse) SetDeviceLifecycleStatusByChannelAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.SetDeviceLifecycleStatusByChannelAsyncRequest) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) Then(io.cucumber.java.en.Then)

Example 2 with SmartMeter

use of org.opensmartgridplatform.domain.core.entities.SmartMeter in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method theSmartMeterIsDecoupledFromGatewayDeviceInTheCoreDatabase.

@Then("^the smart meter is decoupled from gateway device in the core database$")
public void theSmartMeterIsDecoupledFromGatewayDeviceInTheCoreDatabase(final Map<String, String> settings) {
    final SmartMeter smartMeter = this.smartMeterRepository.findByDeviceIdentification(settings.get(PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION));
    assertThat(smartMeter).isNotNull();
    assertThat(smartMeter.getChannel()).isNull();
    assertThat(smartMeter.getGatewayDevice()).isNull();
    assertThat(smartMeter.getMbusPrimaryAddress()).isNull();
}
Also used : SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) Then(io.cucumber.java.en.Then)

Example 3 with SmartMeter

use of org.opensmartgridplatform.domain.core.entities.SmartMeter in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method theSmartMeterIsRegisteredInTheCoreDatabase.

@Then("^the smart meter is registered in the core database$")
public void theSmartMeterIsRegisteredInTheCoreDatabase(final Map<String, String> settings) {
    final SmartMeter smartMeter = this.smartMeterRepository.findByDeviceIdentification(settings.get(PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION));
    assertThat(smartMeter).isNotNull();
    assertThat(smartMeter.getSupplier()).isEqualTo(settings.get(PlatformSmartmeteringKeys.SUPPLIER));
    assertThat(smartMeter.getChannel()).isEqualTo(getShort(settings, PlatformSmartmeteringKeys.CHANNEL));
    assertThat(smartMeter.getMbusIdentificationNumber()).isEqualTo(settings.get(PlatformSmartmeteringKeys.MBUS_IDENTIFICATION_NUMBER));
    assertThat(smartMeter.getMbusManufacturerIdentification()).isEqualTo(settings.get(PlatformSmartmeteringKeys.MBUS_MANUFACTURER_IDENTIFICATION));
    assertThat(smartMeter.getMbusVersion()).isEqualTo(getShort(settings, PlatformSmartmeteringKeys.MBUS_VERSION, null));
    assertThat(smartMeter.getMbusDeviceTypeIdentification()).isEqualTo(getShort(settings, PlatformSmartmeteringKeys.MBUS_DEVICE_TYPE_IDENTIFICATION, null));
}
Also used : SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) Then(io.cucumber.java.en.Then)

Example 4 with SmartMeter

use of org.opensmartgridplatform.domain.core.entities.SmartMeter in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method createDeviceInCoreDatabase.

private Device createDeviceInCoreDatabase(final Map<String, String> inputSettings) {
    Device device;
    final ProtocolInfo protocolInfo = this.getProtocolInfo(inputSettings);
    final DeviceModel deviceModel = this.getDeviceModel(inputSettings);
    final boolean isSmartMeter = this.isSmartMeter(inputSettings);
    if (isSmartMeter) {
        final SmartMeter smartMeter = new SmartMeterBuilder().withSettings(inputSettings).setProtocolInfo(protocolInfo).setDeviceModel(deviceModel).build();
        device = this.smartMeterRepository.save(smartMeter);
    } else {
        device = new DeviceBuilder(this.deviceRepository).withSettings(inputSettings).setProtocolInfo(protocolInfo).setDeviceModel(deviceModel).build();
        device = this.deviceRepository.save(device);
    }
    final Map<FirmwareModule, String> firmwareModuleVersions = this.deviceFirmwareModuleSteps.getFirmwareModuleVersions(inputSettings, isSmartMeter);
    if (!firmwareModuleVersions.isEmpty()) {
        device.setFirmwareVersions(firmwareModuleVersions);
        device = this.deviceRepository.save(device);
    }
    if (inputSettings.containsKey(PlatformSmartmeteringKeys.GATEWAY_DEVICE_IDENTIFICATION)) {
        final Device gatewayDevice = this.deviceRepository.findByDeviceIdentification(inputSettings.get(PlatformSmartmeteringKeys.GATEWAY_DEVICE_IDENTIFICATION));
        device.updateGatewayDevice(gatewayDevice);
        device = this.deviceRepository.save(device);
    }
    return device;
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) DeviceBuilder(org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.DeviceBuilder) DlmsDeviceBuilder(org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.DlmsDeviceBuilder) Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) FirmwareModule(org.opensmartgridplatform.domain.core.entities.FirmwareModule) SmartMeterBuilder(org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.SmartMeterBuilder)

Example 5 with SmartMeter

use of org.opensmartgridplatform.domain.core.entities.SmartMeter in project open-smart-grid-platform by OSGP.

the class DeviceSteps method theGMeterIsDecoupledFromDevice.

@Then("^the G-meter \"([^\"]*)\" is Decoupled from device \"([^\"]*)\"$")
public void theGMeterIsDecoupledFromDevice(final String gMeter, final String eMeter) {
    Wait.until(() -> {
        final SmartMeter mbusDevice = this.smartMeterRepository.findByDeviceIdentification(gMeter);
        final Device gatewayDevice = this.deviceRepository.findByDeviceIdentification(eMeter);
        assertThat(gatewayDevice).as("No GatewayDevice found").isNotNull();
        assertThat(mbusDevice).as("No MbusDevice found").isNotNull();
        assertThat(mbusDevice.getGatewayDevice()).as("GatewayDevice must be empty").isNull();
    });
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) Then(io.cucumber.java.en.Then)

Aggregations

SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)75 Device (org.opensmartgridplatform.domain.core.entities.Device)18 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)12 Then (io.cucumber.java.en.Then)9 Test (org.junit.jupiter.api.Test)5 Address (org.opensmartgridplatform.domain.core.valueobjects.Address)4 GpsCoordinates (org.opensmartgridplatform.domain.core.valueobjects.GpsCoordinates)4 SmartMeteringDevice (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)4 GatewayDeviceNotSetForMbusDeviceException (org.opensmartgridplatform.domain.smartmetering.exceptions.GatewayDeviceNotSetForMbusDeviceException)3 ProtocolInfo (org.opensmartgridplatform.domain.core.entities.ProtocolInfo)2 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)2 DeviceModel (org.opensmartgridplatform.domain.core.valueobjects.DeviceModel)2 AddSmartMeterRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AddSmartMeterRequest)2 ActivityCalendarDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto)2 AdministrativeStatusTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AdministrativeStatusTypeDto)2 AlarmNotificationsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto)2 DefinableLoadProfileConfigurationDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DefinableLoadProfileConfigurationDto)2 GMeterInfoDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto)2 GetConfigurationObjectRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetConfigurationObjectRequestDto)2 GetFirmwareVersionQueryDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetFirmwareVersionQueryDto)2