[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Combining an autorepeat schedule and a autodrop schedule
From: |
Marcus G. Daniels |
Subject: |
Re: Combining an autorepeat schedule and a autodrop schedule |
Date: |
09 Oct 2000 13:18:48 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "PdV" == P deVries <address@hidden> writes:
PdV> In a swarm I have created two schedules:
PdV> - one repeating schedule
PdV> - one non-repeating, autodrop schedule
PdV> If I activate each schedule separately there is no
PdV> problem. However, if I activate both schedules at the same time,
PdV> I get the following error (after more timesteps than the
PdV> repeatschedules length):
*** event raised for error: InvalidOperation
*** function: _update_mergeSchedules(), file:
/src/Swarm/swarm/src/activity/Schedule.m, line: 268
What you describe should work, and it does work for me using the program
below and the current 2.1.1-fixes DLLs. What is different about
your code? Or maybe it gets fixed for you with new DLLs?
import swarm.Globals;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.Swarm;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;
import swarm.defobj.Zone;
import swarm.Selector;
public class MixedSchedules extends SwarmImpl {
Schedule autodropSchedule;
Schedule repeatingSchedule;
Selector autodropSelector;
public void autodropMethod () {
System.out.println ("method called by autodrop schedule @ " +
Globals.env.getCurrentTime ());
}
public void repeatingMethod () {
int t = Globals.env.getCurrentTime ();
int next = t + Globals.env.uniformIntRand.getIntegerWithMin$withMax (0, 10);
System.out.println ("method called by repeating schedule @ " + t + " next:
" + next);
autodropSchedule.at$createActionTo$message (next, this, autodropSelector);
}
MixedSchedules (Zone aZone) {
super (aZone);
autodropSchedule = new ScheduleImpl (aZone, true);
repeatingSchedule = new ScheduleImpl (aZone, 10);
try {
autodropSelector = new Selector (getClass (), "autodropMethod", false);
Selector repeatingSelector = new Selector (getClass (),
"repeatingMethod", false);
repeatingSchedule.at$createActionTo$message (0, this, repeatingSelector);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
}
public Activity activateIn (Swarm swarmContext) {
super.activateIn (swarmContext);
autodropSchedule.activateIn (this);
repeatingSchedule.activateIn (this);
return getActivity ();
}
static void main (String []args) {
Globals.env.initSwarm ("MixedSchedules", "0.0", "address@hidden", args);
MixedSchedules mixedSchedules = new MixedSchedules (Globals.env.globalZone);
mixedSchedules.activateIn (null).run ();
}
}
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.