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