Search in sources :

Example 1 with DeviceServer

use of org.opensmartgridplatform.simulator.protocol.dlms.server.DeviceServer in project open-smart-grid-platform by OSGP.

the class SimulatorThread method run.

/**
 * Start running a thread that starts a device simulator, waits for three minutes and then closes
 * that simulator.
 */
@Override
public void run() {
    final String[] arguments = this.configureSimulatorArguments(this.port, this.logicalId);
    final DlmsServer dlmsServer = new DeviceServer().getDlmsServer(arguments);
    try {
        this.checkStartUp(this.port);
        Thread.sleep(SIMULATOR_DELAY);
    } catch (final InterruptedException e) {
        LOGGER.warn("SimulatorThread was interrupted.", e);
    }
    try {
        dlmsServer.close();
        if (this.unregisterPort(this.port)) {
            LOGGER.info("Successfully closed DlmsServer, port {} is free for future use.", this.port);
        }
    } catch (final IOException e) {
        LOGGER.warn("Failed to close DlmsServer on port {}", this.port, e);
    }
}
Also used : DlmsServer(org.openmuc.jdlms.DlmsServer) IOException(java.io.IOException) DeviceServer(org.opensmartgridplatform.simulator.protocol.dlms.server.DeviceServer)

Aggregations

IOException (java.io.IOException)1 DlmsServer (org.openmuc.jdlms.DlmsServer)1 DeviceServer (org.opensmartgridplatform.simulator.protocol.dlms.server.DeviceServer)1