swarm-support
[Top][All Lists]
Advanced

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

Re: a counter


From: Nelson Minar
Subject: Re: a counter
Date: Mon, 17 Jun 96 18:25:15 MDT

>I would like create a simple agent which keeps track of the 
>number of iterations in the simulation and stops the simulation 
>after a specific number, say 40 or 50 or 200 etc. 

nice use of the word "agent"! :-)

simtools/GUISwarm.m and heatbugs/HeatbugBatchSwarm.m have examples of
this. The basic idea is you want to send a message to the top level
running activity.

If you aren't worried about keeping the control panel and GUI in a
consistent state, then executing
  [getTopLevelActivity() terminate]
will stop the system. HeatbugBatchSwarm does this in the "stopRunning"
method, which it schedules on itself. Because the BatchSwarm doesn't
have any graphics, this is enough.

GUISwarms also maintain an extra state, the state of the control panel
they own. Look in GUISwarm.m's "go" method and the code for
ControlPanel to see how the logic works. Basically, plain old
  [getTopLevelActivity() terminate]
is good enough if you want to quit entirely. But if you want to stop
and wait for the user to hit go, it's more complicated. I believe
the right combination is to do
  [getTopLevelActivity() stop];
  [controlPanel setState: ControlStateStopped];
where controlPanel is the controlPanel for the GUISwarm.


reply via email to

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