Java tutorial
/* * TURNUS, the co-exploration framework * * Copyright (C) 2015 EPFL SCI STI MM * * This file is part of TURNUS. * * TURNUS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TURNUS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TURNUS. If not, see <http://www.gnu.org/licenses/>. * * Additional permission under GNU GPL version 3 section 7 * * If you modify this Program, or any covered work, by linking or combining it * with Eclipse (or a modified version of Eclipse or an Eclipse plugin or * an Eclipse library), containing parts covered by the terms of the * Eclipse Public License (EPL), the licensors of this Program grant you * additional permission to convey the resulting work. Corresponding Source * for a non-source form of such a combination shall include the source code * for the parts of Eclipse libraries used as well as that of the covered work. * */ package co.turnus.trace.scheduler.devs.util; import static co.turnus.trace.TraceOptions.SENS_STATEVAR; import static co.turnus.trace.TraceOptions.SENS_TOKENS; import static co.turnus.trace.scheduler.devs.DevsTraceSchedulerOptions.EXPORT_GANTT; import static co.turnus.gantt.GanttChartOptions.VCD_FILE; import static co.turnus.trace.scheduler.devs.DevsTraceSchedulerOptions.SIMULATION_ID; import java.io.File; import org.apache.commons.configuration.BaseConfiguration; import org.apache.commons.configuration.Configuration; import co.turnus.TurnusActivator; import co.turnus.profiling.ProfilingWeights; import co.turnus.profiling.io.XmlProfilingWeightsReader; import co.turnus.trace.TraceProject; import co.turnus.trace.scheduler.devs.DevsTraceScheduler; import co.turnus.trace.weighter.statistical.ActionWeightsDistribution; import co.turnus.trace.weighter.statistical.StatisticalTraceWeighter; import co.turnus.util.TurnusLogger; import co.turnus.util.TurnusLogger.TurnusLevel; public class SimpleTest { public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("usage: <trace-project-path> <weights-file-path> [gantt-chart-path]"); return; } TurnusActivator.init(); TurnusLogger.setLevel(TurnusLevel.ALL); Configuration config = parseArgs(args); File projectDir = new File(args[0]); File weightsFile = new File(args[1]); TraceProject project = TraceProject.load(projectDir); project.loadTrace(config); // load weights ProfilingWeights weights = new XmlProfilingWeightsReader().read(project.getNetwork(), weightsFile); // build the trace weighter StatisticalTraceWeighter tw = new StatisticalTraceWeighter(); tw.configure(weights, ActionWeightsDistribution.class); DevsTraceScheduler scheduler = new DevsTraceScheduler(project, null, tw); scheduler.setConfiguration(config); scheduler.run(); } private static Configuration parseArgs(String[] args) { Configuration config = new BaseConfiguration(); config.setProperty(SENS_STATEVAR, false); config.setProperty(SENS_TOKENS, true); config.setProperty(SIMULATION_ID, "SimpleTest"); if (args.length > 2) { config.setProperty(EXPORT_GANTT, true); config.setProperty(VCD_FILE, args[2]); } else { config.setProperty(EXPORT_GANTT, false); } return config; } }