[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EZGraph
From: |
Marcus G. Daniels |
Subject: |
Re: EZGraph |
Date: |
07 Jul 2000 10:28:01 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "DA" == David Aliaga <address@hidden> writes:
DA> I just want to graph the value of a variable every time a trial finish.
[..]
DA> Should I create another level with diferent schedule
If you want to have the trial independent from the mechanics of the
trial, I think what you want is at:createAction: (or a similiar
activate-in-nil idiom). Below is an example of at:createAction:.
Also take a look at simpleExperBug in swarmapps for another an example of a
separation of observeration timescale from the actual trial.
#import <simtools.h> // initSwarm
#import <activity.h> // Schedule
#import <objectbase/Swarm.h> // Swarm
@interface Trial: Swarm
{
unsigned trialNumber;
id <Schedule> trialSchedule;
}
- buildActions;
- step;
- (id <Activity>)activateIn: (id <Swarm>)swarmContext;
@end
@implementation Trial
- buildActions
{
trialSchedule = [Schedule create: self];
[trialSchedule at: 0 createActionTo: self message: M(step)];
[trialSchedule at: 10 createActionTo: self message: M(step)];
return self;
}
- step
{
printf ("trial# %u step @ %lu\n", trialNumber, getCurrentTime ());
return self;
}
- (id <Activity>)activateIn: swarmContext
{
trialNumber++;
[super activateIn: swarmContext];
[trialSchedule activateIn: self];
return [self getActivity];
}
@end
@interface Controller: Swarm
{
id <Schedule> experimentSchedule;
}
- buildActions;
- activateIn: swarmContext;
@end
@implementation Controller
- buildActions
{
id <Swarm> trialSwarm = [Trial create: self];
[trialSwarm buildActions];
experimentSchedule = [Schedule create: self];
[experimentSchedule at: 0 createAction: trialSwarm];
[experimentSchedule at: 1 createAction: trialSwarm];
return self;
}
- activateIn: swarmContext
{
[super activateIn: swarmContext];
[experimentSchedule activateIn: self];
return [self getActivity];
}
@end
int
main (int argc, const char **argv)
{
initSwarmBatch (argc, argv);
[[[[Controller create: globalZone] buildActions] activateIn: nil] run];
return 0;
}
/*
Local Variables:
compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -o createAction
-Wall -Werror -g -Wno-import -I$SWARMHOME/include -L$SWARMHOME/lib
createAction.m -lswarm -lobjc"
End:
*/
==================================
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.
- EZGraph, David Aliaga, 2000/07/07
- Re: EZGraph, Norberto Eiji Nawa, 2000/07/07
- Re: EZGraph,
Marcus G. Daniels <=