[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Batch swarm problems
From: |
Marcus G. Daniels |
Subject: |
Re: Batch swarm problems |
Date: |
Fri, 15 Jun 2001 12:14:25 -0600 (MDT) |
KR> I'm trying to create a very simple batch swarm, no more complicated than
KR> that of the heatbugs one. However after in the main() function it has
KR> created the toplevelSwarm, it crashes - it doesn't even go into the
KR> buildObjects() method in the batchSwarm class. Is there a special
KR> convention for the naming of the .scm file, and what exactly should that
KR> file contain?
The file should have the same name as the first argument to initSwarm.
Here's an example. First, the batchDemo.scm parameters:
(list
(cons 'batchSwarm
(make-instance 'BatchDemo #:when 2 #:messageString "Hello World")))
("batchSwarm" is the parameter you give getObject or putObject.)
..and the program:
import swarm.objectbase.SwarmImpl;
import swarm.Globals;
import swarm.defobj.Zone;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;
import swarm.objectbase.Swarm;
import swarm.Selector;
public class BatchDemo extends SwarmImpl {
public int when;
public String messageString;
Schedule schedule;
BatchDemo (Zone aZone, int when, String messageString) {
super (aZone);
this.when = when;
this.messageString = messageString;
}
BatchDemo (Zone aZone) {
super (aZone);
}
public void frob (String val) {
System.out.println ("@" + Globals.env.getCurrentTime () + " " + val);
}
public Object buildActions () {
super.buildActions ();
schedule = new ScheduleImpl (getZone (), true);
try {
Selector sel = new Selector (getClass (), "frob", false);
schedule.at$createActionTo$message (when, this, sel,
(Object) messageString);
} 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 ();
}
static void main (String args[]) {
Globals.env.initSwarm ("batchDemo", "0.0", "address@hidden",
args);
BatchDemo batchDemo =
(BatchDemo) Globals.env.lispAppArchiver.getObject ("batchSwarm");
if (batchDemo == null)
{
Globals.env.verboseMessage ("Creating object");
batchDemo = new BatchDemo (Globals.env.globalZone,
1, "Hello World");
}
batchDemo.buildObjects ();
batchDemo.buildActions ();
batchDemo.activateIn (null).run ();
}
}
==================================
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.