swarm-support
[Top][All Lists]
Advanced

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

Selectors and Probes


From: Charles Staelin
Subject: Selectors and Probes
Date: Mon, 27 Mar 2000 10:30:52 -0500

I wonder if someone could help me with two questions, both
using the Java layer of Swarm.

The first is in the construction of a Selector.  The third
argument is theObjectiveCFlag.  I assume that it should be
true when the message is to the ObjectiveC layer of Swarm
and false when the message is to the Java layer.  Is it safe
to assume that the flag should be false when creating a
selector for any method I've defined in my Java code, and
true otherwise (i.e., for methods defined in the Swarm
layer)?

The second involves setting a probe.  The following code
results in the runtime errors which follow it. I've played
around with it in many ways, to no effect.  I've also tried
using getProbeForVariable$InClass, but that just hangs
everything. I.e.:

Globals.env.probeLibrary.getProbeForVariable$inClass("dislay
Frequency", ObserverSwarm.this.getClass());

I'm sure it's something simple, but I'm stumped.

Thanks for any help.

Charles


// ObserverSwarm.java The observer swarm is collection of
objects that
// are used to run and observe the ModelSwarm that actually
comprises
// the simulation.

import swarm.Globals;
import swarm.Selector;

import swarm.defobj.Zone;
import swarm.defobj.ZoneImpl;

import swarm.gui.Colormap;
import swarm.gui.ColormapImpl;
import swarm.gui.ZoomRaster;
import swarm.gui.ZoomRasterImpl;

import swarm.space.Value2dDisplay;
import swarm.space.Value2dDisplayImpl;
import swarm.space.Object2dDisplay;
import swarm.space.Object2dDisplay;
import swarm.space.Object2dDisplayImpl;

import swarm.simtoolsgui.GUISwarm;
import swarm.simtoolsgui.GUISwarmImpl;

import swarm.activity.ActionGroup;
import swarm.activity.ActionGroupImpl;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;

import swarm.objectbase.Swarm;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.EmptyProbeMap;
import swarm.objectbase.EmptyProbeMapImpl;
import swarm.objectbase.VarProbe;
import swarm.objectbase.VarProbeImpl;

import swarm.collections.ListImpl;


public class ObserverSwarm extends GUISwarmImpl
{
    // Declare the display parameters and their default
values.
    public int displayFrequency = 1;

    // Declare other variables local to ObserverSwarm.
    ModelSwarm modelSwarm;
    ZoomRaster worldRaster;
    Value2dDisplay foodDisplay;
    Object2dDisplay bugDisplay;
    ScheduleImpl displaySchedule;
    EmptyProbeMapImpl probeMap;
    VarProbe vProbe;

    // This is the constructor for a new ObserverSwarm.
    public ObserverSwarm(Zone azone)
    {
        // Use the parent class to create an observer swarm.
        super(azone);

        // Build a custom probe map.  Without a probe map, the
default
        // is to show all variables and messages.  Here we choose
to
        // customize the appearance of the probe, giving a nicer
        // interface.

        // Create the probe map and give it the ObserverSwarm
class.
        probeMap = new EmptyProbeMapImpl(azone, getClass());

        System.out.println("before");
        // Now add probes for the variables we wish to probe.
        vProbe = getProbeForVariable("displayFrequency");
        System.out.println("next");
        probeMap.addProbe(vProbe);
        System.out.println("after");

        // And finaly install our probe into the probeLibrary.
Note
        // that this library object was automatically created by
        // initSwarm.
        Globals.env.probeLibrary.setProbeMap$For(probeMap,
getClass());

    }

cd c:/usr/home/java/tutorial/simpleObserverBug2/
C:\Swarm-2.1\libexec\Kaffe -classpath
.;C:\Swarm-2.1\share\swarm\swarm.jar;C:\Swarm-2.1\share\kaff
e\Klasses.jar StartSimplebug

before *** event raised for warning: WarningMessage
*** function: _i_ProbeMap__getProbeForVariable_(), file:
/src/Swarm/swarm/src/objectbase/ProbeMap.m, line: 583
The variable displayFrequency was not found
*** execution continuing...
next *** event raised for error: InvalidArgument
*** function: nil_method(), file:
/src/Swarm/swarm/src/defobj/internal.m, line: 1349
The message `isKindOf:' was sent to nil.
*** execution terminating due to error
/src/Swarm/swarm/src/defobj/Symbol.m:173 -[Error(c)
_raiseEvent:]

Process StartSimplebug exited abnormally with code -1

--------------------------------------------------------
Charles Staelin                email: address@hidden
Department of Economics
Smith College                  phone: (413) 585-3621
Northampton, MA 01063            fax: (413) 585-3393
--------------------------------------------------------


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