use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method theDlmsDeviceWithIdentificationDoesNotExist.
@Then("^the dlms device with identification \"([^\"]*)\" does not exist$")
public void theDlmsDeviceWithIdentificationDoesNotExist(final String deviceIdentification) {
final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
assertThat(dlmsDevice).as("DLMS device with identification " + deviceIdentification + " in protocol database").isNull();
final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
assertThat(device).as("DLMS device with identification " + deviceIdentification + " in core database").isNull();
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method findExistingDlmsDevice.
private DlmsDevice findExistingDlmsDevice(final String deviceIdentification) {
final String deviceDescription = "DLMS device with identification " + deviceIdentification;
final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
assertThat(dlmsDevice).as(deviceDescription + " must be in the protocol database").isNotNull();
return dlmsDevice;
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method theInvocationCounterForTheEncryptionKeyOfShouldBeGreaterThan.
@Then("^the invocation counter for the encryption key of \"([^\"]*)\" should be greater than (\\d++)$")
public void theInvocationCounterForTheEncryptionKeyOfShouldBeGreaterThan(final String deviceIdentification, final Integer invocationCounterLowerBound) {
final DlmsDevice dlmsDevice = this.findExistingDlmsDevice(deviceIdentification);
this.findExistingSecurityKey(dlmsDevice, E_METER_ENCRYPTION_KEY_UNICAST, "Encryption key");
final Long invocationCounter = dlmsDevice.getInvocationCounter();
assertThat(invocationCounter).as("The invocation counter for the encryption key of DLMS device with identification " + dlmsDevice.getDeviceIdentification() + " must not be null").isNotNull();
assertThat(invocationCounter > invocationCounterLowerBound).as("The invocation counter for the encryption key of DLMS device with identification " + dlmsDevice.getDeviceIdentification() + " (which is " + invocationCounter + ") must be greater than " + invocationCounterLowerBound).isTrue();
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DeviceKeyProcessingService method startProcessing.
public void startProcessing(final String deviceIdentification) throws DeviceKeyProcessAlreadyRunningException, FunctionalException {
final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
if (dlmsDevice == null) {
throw new FunctionalException(FunctionalExceptionType.UNKNOWN_DEVICE, ComponentType.PROTOCOL_DLMS, new ProtocolAdapterException("Unable to start key changing process with unknown device: " + deviceIdentification));
}
final Instant oldestStartTimeNotConsiderTimedOut = Instant.now().minus(this.deviceKeyProcessingTimeout);
final int updatedRecords = this.dlmsDeviceRepository.setProcessingStartTime(dlmsDevice.getDeviceIdentification(), oldestStartTimeNotConsiderTimedOut);
if (updatedRecords == 0) {
throw new DeviceKeyProcessAlreadyRunningException();
}
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DeviceKeyProcessingService method stopProcessing.
public void stopProcessing(final String deviceIdentification) {
final DlmsDevice dlmsDevice = this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification);
dlmsDevice.setKeyProcessingStartTime(null);
this.dlmsDeviceRepository.saveAndFlush(dlmsDevice);
}
Aggregations