swarm-support
[Top][All Lists]
Advanced

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

Re: adding another probe display


From: Marcus G. Daniels
Subject: Re: adding another probe display
Date: 19 Dec 1998 18:35:01 -0800

>>>>> "AO" == Akiko Ogawa <- RS/GIS lab <address@hidden>> writes:

AO> Could you please advise exactly what kind of codes and
AO> where should I insert in order to create 2 probe maps in
AO> TemplateModelSwarm.[hm]? 

I guess what you want is to have alternate ProbeDisplays for different
views of the same object?  Here's one way to do that.  In this 
example, two probe displays are created (one for `increment', and the
other for `spazFactor', each that uses its' own single-entry ProbeMap.
The main thing to note is that the ModelSwarm provides it's own getProbeMap.

diff -c -r1.4 TemplateModelSwarm.h
*** TemplateModelSwarm.h        1998/02/04 23:40:20     1.4
--- TemplateModelSwarm.h        1998/12/20 02:29:20
***************
*** 13,24 ****
--- 13,28 ----
  {
    // MODIFY: add your own simulation parameters
    int increment;
+   double spazFactor;
  
    id modelActions;
    id modelSchedule;
  
    // MODIFY: add your own model objects.  
    Counter *counter;
+ 
+   BOOL secondaryProbeMapFlag;
+   id <ProbeMap> secondaryProbeMap;
  }
  
  // MODIFY: add access methods for what agents are visible.
***************
*** 30,33 ****
--- 34,38 ----
  - buildActions;
  - activateIn: swarmContext;
  
+ - setSecondaryProbeMapFlag: (BOOL)secondaryProbeMapFlag;
  @end
Index: TemplateModelSwarm.m
===================================================================
RCS file: /opt/src/hive/cvs/Swarm/template/TemplateModelSwarm.m,v
retrieving revision 1.4
diff -c -r1.4 TemplateModelSwarm.m
*** TemplateModelSwarm.m        1998/06/24 01:34:23     1.4
--- TemplateModelSwarm.m        1998/12/20 02:29:20
***************
*** 9,36 ****
  
  @implementation TemplateModelSwarm
  
! -(Counter *) getCounter {
    return counter;
  }
  
! +createBegin: (id) aZone {
!   TemplateModelSwarm * obj;
    id <ProbeMap> probeMap;
! 
!   obj = [super createBegin: aZone];
! 
    // MODIFY: add in defaults for your simulation parameters.
    obj->increment = 1;
  
    probeMap = [EmptyProbeMap createBegin: aZone];
!   [probeMap setProbedClass: [self class]];
    probeMap = [probeMap createEnd];
  
    // MODIFY: add your own probes for your parameters.
!   [probeMap addProbe: [probeLibrary getProbeForVariable: "increment"
!                                   inClass: [self class]]];
!   [probeLibrary setProbeMap: probeMap For: [self class]];
!   
    return obj;
  }
  
--- 9,44 ----
  
  @implementation TemplateModelSwarm
  
! - (Counter *)getCounter
! {
    return counter;
  }
  
! + createBegin: aZone
! {
!   TemplateModelSwarm *obj = [super createBegin: aZone];
!   Class class = [obj class];
    id <ProbeMap> probeMap;
!   id incrementProbe = 
!     [probeLibrary getProbeForVariable: "increment" inClass: class];
!   id spazFactorProbe = 
!     [probeLibrary getProbeForVariable: "spazFactor" inClass: class];
!   
    // MODIFY: add in defaults for your simulation parameters.
    obj->increment = 1;
+   obj->spazFactor = 2;
  
    probeMap = [EmptyProbeMap createBegin: aZone];
!   [probeMap setProbedClass: class];
    probeMap = [probeMap createEnd];
+   [probeMap addProbe: incrementProbe];
+   [probeLibrary setProbeMap: probeMap For: class];
  
    // MODIFY: add your own probes for your parameters.
!   obj->secondaryProbeMap = [[[[EmptyProbeMap createBegin: aZone]
!                                setProbedClass: class]
!                               createEnd]
!                              addProbe: spazFactorProbe];
    return obj;
  }
  
***************
*** 75,80 ****
--- 83,99 ----
    [modelSchedule activateIn: self];
  
    return [self getSwarmActivity];
+ }
+ 
+ - setSecondaryProbeMapFlag: (BOOL)flag
+ {
+   secondaryProbeMapFlag = flag;
+   return self;
+ }
+ 
+ - getProbeMap
+ {
+   return secondaryProbeMapFlag ? secondaryProbeMap : [super getProbeMap];
  }
  
  @end
Index: TemplateObserverSwarm.m
===================================================================
RCS file: /opt/src/hive/cvs/Swarm/template/TemplateObserverSwarm.m,v
retrieving revision 1.8
diff -c -r1.8 TemplateObserverSwarm.m
*** TemplateObserverSwarm.m     1998/06/24 01:34:23     1.8
--- TemplateObserverSwarm.m     1998/12/20 02:29:20
***************
*** 43,50 ****
    [super buildObjects];
    
    templateModelSwarm = [TemplateModelSwarm create: self];
!   
    CREATE_PROBE_DISPLAY (templateModelSwarm);
    CREATE_PROBE_DISPLAY (self);
  
    [actionCache waitForControlEvent];
--- 43,54 ----
    [super buildObjects];
    
    templateModelSwarm = [TemplateModelSwarm create: self];
! 
!   [templateModelSwarm setSecondaryProbeMapFlag: NO];
    CREATE_PROBE_DISPLAY (templateModelSwarm);
+   [templateModelSwarm setSecondaryProbeMapFlag: YES];
+   CREATE_PROBE_DISPLAY (templateModelSwarm);
+ 
    CREATE_PROBE_DISPLAY (self);
  
    [actionCache waitForControlEvent];



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