swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scheduling and re-scheduling problems


From: Marcus G. Daniels
Subject: Re: scheduling and re-scheduling problems
Date: 31 Aug 1999 20:56:35 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "WS" == William S Shu <address@hidden> writes:

WS> I implemented the above -- excluding startSchedule, for the time
WS> being -- and when I call it with: [self scheduleFrom: 10 To: 20
WS> Behaviour: M(breed)];

FWIW, here's how I'd do it:

#import <simtools.h>
#import <objectbase/Swarm.h>

@interface PeriodSwarm: Swarm
{
  id <Schedule> controlSchedule;
  id <Schedule> periodSchedule;
  id <Schedule> anotherSchedule;
  id <Activity> periodActivity;
}
- setStartTime: (timeval_t)start;
- setStopTime: (timeval_t)stop;
- start;
- stop;
- activateIn: swarmContext;
- click;
- run;
@end

@implementation PeriodSwarm
+ createBegin: aZone
{
  PeriodSwarm *obj = [super createBegin: aZone];

  obj->controlSchedule = [Schedule create: aZone];
  return obj;
}

- setStartTime: (timeval_t)start
{
  [controlSchedule at: start
                   createActionTo: self
                   message: M(start)];
  return self;
}

- setStopTime: (timeval_t)stop
{
  [controlSchedule at: stop
                   createActionTo: self
                   message: M(stop)];
  return self;
}

- start
{
  printf ("Starting: %lu\n", getCurrentTime ());
  periodSchedule = [[[[Schedule createBegin: [self getZone]]
                       setRepeatInterval: 1]
                      setRelativeTime: YES]
                     createEnd];
  [periodSchedule createActionTo: self message: M(click)];
  periodActivity = [periodSchedule activateIn: self];
  return self;
}

- stop
{
  printf ("Stopping: %lu\n", getCurrentTime ());
  [periodActivity terminate];
  return self;
}

- activateIn: swarmContext
{
  [super activateIn: swarmContext];
  [controlSchedule activateIn: self];
  return [self getActivity];
}

- click
{
  printf ("click %lu\n", getCurrentTime ());
  return self;
}

- run
{
  [self activateIn: nil];
  [[self getActivity] run];
  return self;
}

@end

int
main (int argc, const char **argv)
{
  initSwarm (argc, argv);
  
  [[[[[PeriodSwarm createBegin: globalZone]
       setStartTime: 10]
      setStopTime: 20]
     createEnd]
    run];
    
  return 0;
}

/*
Local Variables:
compile-command: "${SWARMHOME}/bin/libtool-swarm --mode=link gcc -DDLL -o 
periodswarm -g -Wno-import -I${SWARMHOME}/include -L${SWARMHOME}/lib 
periodswarm.m -lswarmdll -lobjcdll"
End:
*/

WS>    I want reschedule all the future actions of a given
WS> schedule/activity or whatever (and its subActivities or whatever) by
WS> scaling (up or down) its repeat cycle and the start times of all its
WS> actions (be they individual or in action groups). 

One way is to have a template copy of the time pattern,
(say, in a C array) that is transformed by a multiplier before it is
put into a schedule.  If you use a repeat interval, don't expect
to have a backdoor scaling to that; scale everything ahead of time.  
If that isn't possible, it's got to be dynamic scheduling all the way.

                  ==================================
   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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]