swarm-support
[Top][All Lists]
Advanced

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

Sub-swarm schedule activation/swarmContext question


From: glen e. p. ropella
Subject: Sub-swarm schedule activation/swarmContext question
Date: Mon, 23 Jun 1997 16:25:50 -0600

Ken Cline writes:
 > Schedule activation question for y'all:
 > 
 >    I was having a problem activating a sub-swarm's schedule
 > when the sub-swarm was created *after* my (top level) 
 > ModelObserver swarm has already been activated. I found a
 > way to make it work but I'm not sure I understand why it
 > works...
[...]
 > That is, 
 >    IF I create the sub-swarm after the ModelObserver has
 >       already been activated,
 >    AND IF the sub-swarm's displaySchedule is activated
 >       "in the context of" of the sub-swarm (as is typical of
 >       other swarms),
 >    THEN the displaySchedule is *not* executed.
 > 
 > However,
 >    IF I create the sub-swarm after the ModelObserver has
 >       already been activated (as before),
 >    AND IF the sub-swarm's displaySchedule is activated
 >       "in the context of" of the ModelObserver,
 >    THEN the displaySchedule *is* executed.
 > 
 > I suspect this has something to do with tying the
 > sub-swarm's displaySchedule to already active schedule but
 > I haven't found anything specific in either the
 > documentation or mailing list archives that clearly explains
 > (to me) exactly why this is so.
[...]

I could be wrong... but, this sounds like a bug we are already
aware of but haven't quite fixed, yet.  The bug goes as follows:
(again, correct me if I get it wrong, Roger)

The schedule data structure gets merged via activateIn.  When that
happens, a pointer to the next action is set.  If a new action is
added to the schedule *after* the activateIn is called for that 
schedule and that new action is placed in front of the next action
pointed to by the activity pointer, then the new action won't get 
executed.

This is due to the fact that the schedule mechanism doesn't 
automatically update itself any time a new action is added.  (This
bug doesn't show up if the new action is placed behind the next
action pointed to by the pointer.)

Now, the reason I think it might be the same bug is because the 
activateIn for the ModelObserver (indeed, the buildActions for 
the ModelObserver) occurs after the creation, buildActions, and
activateIn for the AgentObserver.  This means that when the pointer
for the ModelObserver's schedule gets set (initialized), the 
AgentObserver's schedule has already been set up, meaning that 
the actions associated with it are already merged into the 
master schedule.

It's possible that the reason swarmContext fixes this is that
the content of "swarmContext" in the AgentObserver should be 
the parent swarm (i.e. the modelObserver's activity), which 
means that the displaySchedule for the AgentObserver gets 
merged directly with the modelObserver's schedule without
first going through the indirection of the AgentObserver's
activity pointer.

You might be able to get around this by specifying several
actions in the displaySchedule such that some of the actions
get merged into the modelObserver's schedule before the next
modelObserver action and some get merged after the next
modelObserver action.  I think you should be able to do this
by specifying something like:

In AgentObserver.m
------------------
-buildActions {
   [ super buildActions ];

   displaySchedule = [ Schedule createBegin: [self getZone] ];
      [ displaySchedule setRepeatInterval: displayFrequency ];
   displaySchedule = [ displaySchedule createEnd ];
        
   displayActions = [ ActionGroup create: [self getZone] ];
      [ displayActions createActionTo: self message: M(grin1) ];

   [ displaySchedule at: 0 createAction: displayActions ];
   [ displaySchedule at: 1 createActionTo: self message: M(grin2) ];
   [ displaySchedule at: 2 createActionTo: self message: M(grin3) ];
   [ displaySchedule at: 3 createActionTo: self message: M(grin4) ];
   [ displaySchedule at: 4 createActionTo: self message: M(grin5) ];
      ...
}

// and change the activateIn pointer back to "self"

-activateIn: (id) swarmContext {
      ...
   [ super           activateIn: swarmContext ];
   [ displaySchedule activateIn: self ];
   return [ self getSwarmActivity ];
}

========================
Another, totally outoftheblue question... but I have to ask...
AgentObserver *is* a Swarm, right?

glen
p.s. You might benefit from Doug Donaldson's schedule browser
if any of this gets any more complex.  Doug?
-- 
{glen e. p. ropella <address@hidden> |  Send lawyers, guns, and money!  }
{Hive Drone, SFI Swarm Project         |            Hail Eris!            }
{http://www.trail.com/~gepr/home.html  |               =><=               }

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