2

For some reason my method doesn’t get called when I use @ScheduledMethod. Have no idea what is wrong as I used it before and everything was fine.

Here is the code:

import repast.simphony.engine.schedule.ScheduledMethod;

public class WindGen {

private double power;

@ScheduledMethod(start = 1, interval = 1, priority = 2)
private void generatePower() {

    int t = SystemOperator.getT();

    power = 20 * Math.sin(Math.toRadians(t * 360 / 48) + 30);

}

public double getPower() {
    return power;
}
}

Thanks in advance, Dina.

2 Answers2

2

because your method is private. You need to change it to public to get it work.

user2925516
  • 65
  • 1
  • 10
0

I had a simiar issue with @ScheduledMethod: it simply did not execute my method.

However, I did get it running by scheduling the method in a different way, which could look for you as follows:

ISchedule schedule = RunEnvironment.getInstance().getCurrentSchedule();
ScheduleParameters  generate = ScheduleParameters.createRepeating(start = 1, interval = 1, priority = 2);
schedule.schedule(generate , this ,"generatePower");

I suggest you try executing this code snippet once, at the very beginning and (perhaps) in the same class.

You will find further information on scheduling in the Repast Simphony FAQ.

Hope it helps, Thorben