Search in sources :

Example 1 with SclParseException

use of org.openmuc.openiec61850.SclParseException in project Protocol-Adapter-IEC61850 by OSGP.

the class RtuSimulatorConfig method rtuSimulator.

@Bean
public RtuSimulator rtuSimulator(@Value("${rtu.icd:Pampus_v0.4.5.icd}") final String icdFilename, @Value("${rtu.port:60102}") final Integer port, @Value("${rtu.serverName:WAGO61850Server}") final String serverName, @Value("${rtu.stopGeneratingValues:false}") final Boolean stopGeneratingValues) throws IOException {
    final InputStream icdFile = resourceLoader.getResource("classpath:" + icdFilename).getInputStream();
    try {
        final RtuSimulator rtuSimulator = new RtuSimulator(port, icdFile, serverName);
        if (stopGeneratingValues) {
            rtuSimulator.ensurePeriodicDataGenerationIsStopped();
        }
        rtuSimulator.start();
        return rtuSimulator;
    } catch (final SclParseException e) {
        LOGGER.warn("Error parsing SCL/ICD file {}", e);
    } finally {
        icdFile.close();
    }
    return null;
}
Also used : InputStream(java.io.InputStream) SclParseException(org.openmuc.openiec61850.SclParseException) Bean(org.springframework.context.annotation.Bean)

Aggregations

InputStream (java.io.InputStream)1 SclParseException (org.openmuc.openiec61850.SclParseException)1 Bean (org.springframework.context.annotation.Bean)1