Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
Add Comment
Please, Sign In to add comment