swarm-support
[Top][All Lists]
Advanced

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

Re: none


From: Marcus G. Daniels
Subject: Re: none
Date: 24 Feb 2001 22:49:51 -0800
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "RL" == Rob Leclerc <Rob> writes:

RL> can only drop a top-level activity or a terminated activity that is not
RL> currently running 

Call `terminate' before dropping the agent Swarm, then fall out of the
`run' call and do the drop.  Here's an example...

import swarm.Globals;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.Swarm;
import swarm.Selector;
import swarm.activity.Activity;
import swarm.activity.ScheduleImpl;
import swarm.activity.Schedule;
import swarm.defobj.Zone;

public class DropSwarm extends SwarmImpl {
    Schedule schedule;

    DropSwarm (Zone aZone) {
        super (aZone);
    }

    static void main (String args[]) {
        Globals.env.initSwarm ("DropSwarm", "0.0", "address@hidden",
                               args);
        
        Swarm swarm = new DropSwarm (Globals.env.globalZone);

        swarm.buildObjects ();
        swarm.buildActions ();
        swarm.activateIn (null).run ();
        swarm.drop ();
    }

    public void stepAgent () {
        System.out.println ("stepAgent " + Globals.env.getCurrentTime ());
        getActivity ().terminate ();
    }
    
    public Object buildActions () {
        schedule = new ScheduleImpl (getZone ());

        try {
            Selector sel = new Selector (getClass (), "stepAgent", false);
            
            schedule.at$createActionTo$message (0, this, sel);
            schedule.at$createActionTo$message (1, this, sel);
        } catch (Exception e) {
            e.printStackTrace (System.err);
            System.exit (1);
        }
        return this;
    }
    
    public Activity activateIn (Swarm swarmContext) {
        super.activateIn (swarmContext);

        schedule.activateIn (this);
        return getActivity ();
    }
}

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