Search in sources :

Example 1 with TcpServerBuilder

use of org.openmuc.jdlms.DlmsServer.TcpServerBuilder in project open-smart-grid-platform by OSGP.

the class DlmsServerConfig method dlmsServer.

@Bean
public DlmsServer dlmsServer(final OsgpServerConnectionListener osgpServerConnectionListener) throws IOException {
    final DlmsServer serverConnection;
    TcpServerBuilder serverBuilder = DlmsServer.tcpServerBuilder(this.port);
    if (this.useHdlc) {
        serverBuilder = serverBuilder.setSessionLayerFactory(ServerSessionLayerFactories.newHdlcSessionLayerFactory());
    }
    serverBuilder = serverBuilder.setConnectionListener(osgpServerConnectionListener);
    for (final Integer logicalDeviceId : LogicalDeviceIdsConverter.convert(this.logicalDeviceIds)) {
        LOGGER.info("preparing logical device {} on port {}", logicalDeviceId, this.port);
        final LogicalDevice logdev = this.buildDevice(logicalDeviceId).build();
        serverBuilder = serverBuilder.registerLogicalDevice(logdev).setReferencingMethod(ReferencingMethod.valueOf(this.referencingMethod.toUpperCase()));
    }
    serverConnection = serverBuilder.build();
    return serverConnection;
}
Also used : TcpServerBuilder(org.openmuc.jdlms.DlmsServer.TcpServerBuilder) DlmsServer(org.openmuc.jdlms.DlmsServer) LogicalDevice(org.openmuc.jdlms.LogicalDevice) Bean(org.springframework.context.annotation.Bean)

Aggregations

DlmsServer (org.openmuc.jdlms.DlmsServer)1 TcpServerBuilder (org.openmuc.jdlms.DlmsServer.TcpServerBuilder)1 LogicalDevice (org.openmuc.jdlms.LogicalDevice)1 Bean (org.springframework.context.annotation.Bean)1