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