[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
questions regarding activity and getCurrentTime()...
From: |
Rick Riolo |
Subject: |
questions regarding activity and getCurrentTime()... |
Date: |
Sat, 21 Feb 1998 14:09:55 -0500 (EST) |
I have a couple of questions, based on some behavior in the
heatbugs demo. What I did was write this method in HeatSpace.m:
-updateLattice {
[super updateLattice];
printf("--> at %lu heat at 20,20 is now %d.\n",
getCurrentTime(), [self getValueAtX: 20 Y: 20] );
return self;
}
The addition of the above is the only change from the heatbugs
as it comes out of swarmapps-1.0.2 (all this with swarm-1.0.5).
That is, I am trying to override updateLattice and
have it do what it does usually, then have it print
a little message. But when I then Start heatbugs, I get a
crash with this old familiar message:
badger-rlr)./heatbugs
*** event raised for error: InvalidOperation
*** function: _activity_context_error(), file: XActivity.m, line: 622
> getCurrentTime(): there is no currently running activity from which
> to obtain requested activity context information.
> The context query macros are available only within a> compiled action being
> executed under a running activity.
> They are not available when the activity is stopped
> or otherwise inactive.
> This includes any external probe request.
So...one thing I don't understand is why it says there is no
currently running activity. As far as I know, the only place
updateLattice gets sent to the heatbugs HeatSpace is in the model
activity group:
modelActions = [ActionGroup create: [self getZone]];
[modelActions createActionTo: heat message: M(stepRule)];
[modelActions createActionForEach: heatbugList message: M(step)];
[modelActions createActionTo: heat message: M(updateLattice)];
Note that in another version of heatbugs, in which I have added
a stepReport method for the ModelSwarm object, I do this:
modelActions = [ActionGroup create: [self getZone]];
[modelActions createActionTo: heat message: M(stepRule)];
[modelActions createActionForEach: heatbugList message: M(step)];
[modelActions createActionTo: heat message: M(updateLattice)];
[modelActions createActionTo: self message: M(stepReport)];
What is strange is that in this case, the stepReport method
calls getCurrentTime(), and that works fine!!
In this version, if I add the -updateLattice override as above,
and change nothing else, it also crashes with the message above.
So....I don't understand what's going on here.
Am I missing some sending of the updateLattice message to HeatSpace
that happens before the schedule starts?
I don't find it if I do a grep in the heatbugs directory.
---------
Now a related question:
If I take that reference to getCurrentTime() out of my overriding
updateLattice, I have:
-updateLattice {
[super updateLattice];
printf("--> heat at 20,20 is now %d.\n",
[self getValueAtX: 20 Y: 20] );
return self;
}
When I do this it runs fine, but what puzzles me is why it prints
messages like this:
--> heat at 20,20 is now 145.
--> heat at 20,20 is now 145.
--> heat at 20,20 is now 305.
--> heat at 20,20 is now 305.
--> heat at 20,20 is now 458.
--> heat at 20,20 is now 458.
That is, it seems to be printing my little message twice each step.
(Each of those pairs comes from pressing <STEP> once in this case.)
Why does it do that? Is it really doing updateLattice twice each time step?
Or is something funny happening because of my use of [super
updateLattice]? I know sometimes un-intuitive things can happen,
as in the example on pages 71-73 or so of the ObjectiveC ref manual.
But I don't quite see how it would happen in this case.
Am I missing something obvious in all this?
thanks.
- r
Rick Riolo address@hidden
Program for Study of Complex Systems (PSCS)
4068 Randall Lab
University of Michigan Ann Arbor MI 48109-1120
Phone: 313 763 3323 Fax: 313 763 9267
http://www.pscs.umich.edu/PEOPLE/rlr-home.html
==================================
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.
==================================
- questions regarding activity and getCurrentTime()...,
Rick Riolo <=