Marcus Daniels 05/20/2000 >>>>> "RLR" == Rick Riolo writes: RLR> I'd like to start a model schedule at a time > 0, but then have RLR> it repeat forever Use setRelativeTime: on the Schedule that you want to repeat and activate it from another Schedule, like below. This one has an additional schedule to shut down the run, but never mind that... #import #import #import #import @interface Market: SwarmObject - (void)stepMarket; @end @implementation Market - (void)stepMarket { printf ("[market] step (%lu)\n", getCurrentTime ()); } @end @interface AgentSwarm: Swarm { id updateSchedule; } + createBegin: aZone; - createEnd; - activateIn: swarmContext; - (void)update; @end @implementation AgentSwarm + createBegin: aZone { AgentSwarm *obj = [super createBegin: aZone]; obj->updateSchedule = [[[[Schedule createBegin: aZone] setRepeatInterval: 5] setRelativeTime: YES] createEnd]; return obj; } - createEnd { [super createEnd]; [updateSchedule at: 2 createActionTo: self message: M(update)]; return self; } - activateIn: swarmContext { [super activateIn: swarmContext]; [updateSchedule activateIn: self]; return [self getActivity]; } - (void)update { printf ("[agents] update (%lu)\n", getCurrentTime ()); } @end @interface Controller: Swarm { id marketSchedule; id startUpdateSchedule; id stopSchedule; } + createBegin: aZone; - createEnd; - activateIn: swarmContext; - startUpdates; - (void)quit; @end @implementation Controller + createBegin: aZone { Controller *obj = [super createBegin: aZone]; { id market = [Market create: aZone]; id s = [Schedule createBegin: aZone]; [s setRepeatInterval: 1]; s = [s createEnd]; [s at: 0 createActionTo: market message: M(stepMarket)]; obj->marketSchedule = s; } obj->startUpdateSchedule = [Schedule create: aZone]; obj->stopSchedule = [Schedule create: aZone]; return obj; } - createEnd { [super createEnd]; [startUpdateSchedule at: 2 createActionTo: self message: M(startUpdates)]; [stopSchedule at: 10 createActionTo: self message: M(quit)]; return self; } - startUpdates { id agentSwarm = [AgentSwarm create: self]; printf ("[controller] startUpdates (%lu)\n", getCurrentTime ()); [agentSwarm activateIn: self]; return self; } - activateIn: swarmContext { [super activateIn: swarmContext]; [startUpdateSchedule activateIn: self]; [marketSchedule activateIn: self]; [stopSchedule activateIn: self]; return [self getActivity]; } - run { [self activateIn: nil]; [[self getActivity] run]; return self; } - (void)quit { [[self getActivity] terminate]; } @end int main (int argc, const char **argv) { initSwarmBatch (argc, argv); [[Controller create: globalZone] run]; return 0; } /* Local Variables: compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -o startLateThenRepeat -Wall -Werror -g -Wno-import -I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm startLateThenRepeat.m -lswarm -lobjc" End: */