Skip to content

Commit

Permalink
feat(sumo): support SUMO 1.21.0
Browse files Browse the repository at this point in the history
Added hint, that SUMO_HOME/bin must be present in the PATH variable. Pre-loading some libraries is not required anymore (and also did not work with 1.21.0 anymore).
  • Loading branch information
kschrab committed Oct 11, 2024
1 parent 9362a6c commit 66eb001
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class LibSumoAmbassador extends SumoAmbassador {

private static final String VALID_LIBSUMO_VERSIONS = "1\\.(19|20)\\.";
private static final String VALID_LIBSUMO_VERSIONS = "1\\.(19|20|21)\\.";

public LibSumoAmbassador(AmbassadorParameter ambassadorParameter) {
super(ambassadorParameter);
Expand Down Expand Up @@ -71,34 +71,30 @@ protected void initSumoConnection() throws InternalFederateException {
}

if (new File(libsumoLibrary).exists()) {
// Workaround based on suggestions made in https://github.com/eclipse/sumo/issues/12605
if (operatingSystem == CLocalHost.OperatingSystem.WINDOWS) {
loadQuiet(getFromSumoHome("iconv-2.dll"));
loadQuiet(getFromSumoHome("intl-8.dll"));
loadQuiet(getFromSumoHome("proj_9_0.dll"));
try {
System.load(libsumoLibrary);
} catch (UnsatisfiedLinkError e) {
throw new InternalFederateException("""
The required libsumojni library could be found, but not loaded due to missing dependencies.
Make sure your PATH variable contains the entry "$SUMO_HOME/bin".
""");
}

System.load(libsumoLibrary);

if (incorrectLibSumoVersion()) {
throw new InternalFederateException(
"The loaded Libsumo library at " + libsumoLibrary + " is not compatible with this ambassador. "
+ "Valid versions are: " + VALID_LIBSUMO_VERSIONS);
throw new InternalFederateException("""
The loaded libsumojni library at %s is not compatible with this ambassador. Valid versions are: %s
""".formatted(libsumoLibrary, VALID_LIBSUMO_VERSIONS));
}
} else {
try {
// Workaround based on suggestions made in https://github.com/eclipse/sumo/issues/12605
if (operatingSystem == CLocalHost.OperatingSystem.WINDOWS) {
loadLibraryQuiet("iconv-2");
loadLibraryQuiet("intl-8");
loadLibraryQuiet("proj_9_0");
}

// if no file found, try to load libsumo it directly from java.library.path
System.loadLibrary("libsumojni");
} catch (Throwable e) {
throw new InternalFederateException("The required libsumojni library could not be found in " + libsumoLibrary + ". "
+ "Make sure SUMO_HOME is set properly and that your SUMO installation contains the libsumojni library.");
throw new InternalFederateException("""
The required libsumojni library could not be found in %s.
Make sure SUMO_HOME is set properly and that your SUMO installation contains the libsumojni library.
Furthermore, your PATH variable should contain the entry $SUMO_HOME/bin.
""".formatted(libsumoLibrary));
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<version.slf4j>2.0.12</version.slf4j><!-- 2.0.12 is approved #13344 -->
<version.sqlite-jdbc>3.42.0.0</version.sqlite-jdbc><!-- 3.42.0.0 is approved in #9089 -->
<!-- note, when upgrading, the field LibSumoAmbassador#VALID_LIBSUMO_VERSIONS needs to be changed too -->
<version.libsumo>1.20.0</version.libsumo>
<version.libsumo>1.21.0</version.libsumo>
</properties>

<dependencies>
Expand Down

0 comments on commit 66eb001

Please sign in to comment.