Search in sources :

Example 1 with CommunicationMethod

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod in project open-smart-grid-platform by OSGP.

the class DlmsObjectConfigService method getDlmsObjectForCommunicationMethod.

public DlmsObject getDlmsObjectForCommunicationMethod(final DlmsDevice device, final DlmsObjectType type) throws ProtocolAdapterException {
    final Protocol protocol = Protocol.forDevice(device);
    final CommunicationMethod method = CommunicationMethod.getCommunicationMethod(device.getCommunicationMethod());
    return this.dlmsObjectConfigs.stream().filter(config -> config.contains(protocol)).findAny().flatMap(dlmsObjectConfig -> dlmsObjectConfig.findObjectForCommunicationMethod(type, method)).orElseThrow(() -> new ProtocolAdapterException("Did not find " + type.name() + " object with communication method " + method.getMethodName() + " for device " + device.getDeviceId()));
}
Also used : CommunicationMethod(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) Arrays(java.util.Arrays) DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DateTime(org.joda.time.DateTime) DataObject(org.openmuc.jdlms.datatypes.DataObject) Autowired(org.springframework.beans.factory.annotation.Autowired) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) ArrayList(java.util.ArrayList) AttributeAddress(org.openmuc.jdlms.AttributeAddress) List(java.util.List) DlmsRegister(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister) ObisCode(org.openmuc.jdlms.ObisCode) CommunicationMethod(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 DateTime (org.joda.time.DateTime)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 ObisCode (org.openmuc.jdlms.ObisCode)1 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 CommunicationMethod (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod)1 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)1 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)1 DlmsRegister (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister)1 Medium (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium)1 DlmsHelper (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper)1 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1