Search in sources :

Example 1 with SmartMeterBuilder

use of org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.SmartMeterBuilder 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)

Aggregations

DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 DeviceBuilder (org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.DeviceBuilder)1 DlmsDeviceBuilder (org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.DlmsDeviceBuilder)1 SmartMeterBuilder (org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.SmartMeterBuilder)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)1 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)1 ProtocolInfo (org.opensmartgridplatform.domain.core.entities.ProtocolInfo)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1