package nl.tudelft.simulation.dsol.hla; import hla.rti.RTIambassador; import nl.tudelft.simulation.language.io.URLResource; import nl.tudelft.simulation.logger.CategoryLogger; import se.pitch.prti.RTI; /** * The specifies *

* copyright (c) 2004-2018 Delft University of Technology , the * Netherlands.
* See for project information www.simulation.tudelft.nl/dsol
* License of use: General Public License (GPL) , no warranty
* @author Peter Jacobs * @since 1.2 */ public class CreateFederation { public final static String DEFAULT_FED = "https://simulation.tudelft.nl/dsol-hla/fed/RPCFederation.fed"; /** * constructs a new CreateFederation. */ private CreateFederation() { super(); } /** * executes a fedeation * @param args */ public static void main(String[] args) { try { String fedURL = DEFAULT_FED; if (args.length != 1) { System.out.println("Usage: CreateFederation "); System.out.println("Now using default instead: " + fedURL); } else { fedURL = args[0]; } RTIambassador rtiAmbassador = RTI.getRTIambassador("localhost", 8989); rtiAmbassador.createFederationExecution(parseFederationName(fedURL), URLResource.getResource(fedURL)); } catch (Exception exception) { CategoryLogger.always().error(exception); } } protected static String parseFederationName(String fedURL) { // Assume name is between final '/' and '.' String result = fedURL; result = result.substring(result.lastIndexOf('/') + 1); result = result.substring(0, result.indexOf('.')); System.out.println("Parsed FED name: " + result); return result; } }