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

* copyright (c) 2004-2019 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 KillFederation { /** * constructs a new CreateFederation. */ private KillFederation() { super(); } /** * executes a fedeation * @param args */ public static void main(String[] args) { try { String fedURL = CreateFederation.DEFAULT_FED; if (args.length != 1) { System.out.println("Usage: KillFederation "); System.out.println("Now using default instead: " + fedURL); } else { fedURL = args[0]; } RTIambassador rtiAmbassador = RTI.getRTIambassador("localhost", 8989); rtiAmbassador.destroyFederationExecution(parseFederationName(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; } }