Created
October 23, 2012 15:53
-
-
Save 573/3939611 to your computer and use it in GitHub Desktop.
The simple/extra/RepastUtils.java file (JPF)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simple.extra; | |
import static org.apache.log4j.Logger.getLogger; | |
import org.apache.log4j.Logger; | |
import repast.simphony.engine.environment.RunEnvironment; | |
import repast.simphony.engine.environment.RunState; | |
import repast.simphony.engine.environment.ScheduleRegistry; | |
import repast.simphony.engine.schedule.ISchedule; | |
/** un-optimized */ | |
public class RepastUtils { | |
private final static Logger log = getLogger(RepastUtils.class); | |
public static double getCurrentSimulationTick() { | |
return getModelSchedule().getTickCount(); | |
} | |
public static ISchedule getModelSchedule() { | |
ISchedule iSchedule = null; | |
ScheduleRegistry scheduleRegistry = null; | |
RunState runstate = RunState.getInstance(); | |
try { | |
runstate.getClass(); | |
try { | |
runstate.getScheduleRegistry().getClass(); | |
scheduleRegistry = runstate.getScheduleRegistry(); | |
try { | |
scheduleRegistry.getModelSchedule().getClass(); | |
iSchedule = scheduleRegistry.getModelSchedule(); | |
} catch (Throwable no_ischedule) { | |
log.error("ISchedule not found. ", no_ischedule); | |
// System.exit(EXIT); | |
} | |
} catch (Throwable no_scheduleregistry) { | |
log.error("ScheduleRegistry not found. ", no_scheduleregistry); | |
// System.exit(EXIT); | |
} | |
} catch (Throwable no_runstate) { | |
log.error("RunState not initialized. ", no_runstate); | |
// System.exit(EXIT); | |
} | |
if (iSchedule == null) { | |
RunEnvironment runenv = RunEnvironment.getInstance(); | |
try { | |
runenv.getClass(); | |
try { | |
runenv.getCurrentSchedule().getClass(); | |
iSchedule = runenv.getCurrentSchedule(); | |
} catch (Throwable no_ischedule) { | |
log.error("ISchedule not found. ", no_ischedule); | |
// System.exit(EXIT); | |
} | |
} catch (Throwable no_runenvironment) { | |
log.error("No RunEnvironment initialized. ", no_runenvironment); | |
// System.exit(EXIT); | |
} | |
} | |
return iSchedule; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment