Search in sources :

Example 6 with DlmsDevice

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();
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Then(io.cucumber.java.en.Then)

Example 7 with DlmsDevice

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;
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)

Example 8 with 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();
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Then(io.cucumber.java.en.Then)

Example 9 with DlmsDevice

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();
    }
}
Also used : DeviceKeyProcessAlreadyRunningException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.DeviceKeyProcessAlreadyRunningException) Instant(java.time.Instant) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 10 with DlmsDevice

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);
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)

Aggregations

DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)103 Test (org.junit.jupiter.api.Test)58 DlmsDeviceBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder)24 DlmsMessageListener (org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener)17 InvocationCountingDlmsMessageListener (org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener)17 AttributeAddress (org.openmuc.jdlms.AttributeAddress)15 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)13 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)10 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)10 Then (io.cucumber.java.en.Then)9 DataObject (org.openmuc.jdlms.datatypes.DataObject)7 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)7 AccessResultCode (org.openmuc.jdlms.AccessResultCode)6 Instant (java.time.Instant)5 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)5 IOException (java.io.IOException)4 Date (java.util.Date)4 List (java.util.List)4 ThrowableAssert.catchThrowable (org.assertj.core.api.ThrowableAssert.catchThrowable)4 SetParameter (org.openmuc.jdlms.SetParameter)4