swarm-support
[Top][All Lists]
Advanced

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

Re: Probes


From: Paul E Johnson
Subject: Re: Probes
Date: Sat, 10 Mar 2001 10:12:28 -0600

Fred Wan wrote:
> 
> Hi,
> 
> In the Swarm user guide by Paul Johnson the following passage can be found:
> 
> There are two main uses for probes: they can be fed into data-collection
> objects and serve as interfaces to the
> objects about which data is being collected (thus keeping the
> data-collection objects as general as possible) -
> the Averager class, for example, directly subclasses MessageProbe. Or, they
> can be used in order to
> generate a GUI to the individual objects in the simulation (the more common
> usage).

Nothing like seeing your name pop up to perk up the old attention.  To
grab specific values out of an object, sometimes I've used the getDouble
and getInt functions that Marcus put together some time ago. I don't
know if there is a java equivalent, but I think there could be.

id
makeProbe (id obj, const char *ivarName)
{
  id probe = [VarProbe createBegin: [obj getZone]];
  [probe setProbedClass: [obj getClass]];
  [probe setProbedVariable: ivarName];
  return [probe createEnd];
}
double
getDouble (id obj, const char *ivarName)
{
  id probe = makeProbe (obj, ivarName);
  double ret = [probe probeAsDouble: obj];
  [probe drop];
  return ret;
}
int
getInt (id obj, const char *ivarName)
{
  id probe = makeProbe (obj, ivarName);
  int ret = [probe probeAsInt: obj];
  [probe drop];
  return ret;
}

The usage of these is featured in my tutorial addon: 

http://lark.cc.ukans.edu/~pauljohn/ps909/simpleObserverBug3-5.tar.gz

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

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