swarm-support
[Top][All Lists]
Advanced

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

Re: Problem with Object2dDisplay


From: Konrad Lang
Subject: Re: Problem with Object2dDisplay
Date: Wed, 29 Sep 1999 10:57:53 +0200 (MET DST)

>>>>> "KL" == Konrad Lang <address@hidden> writes:
>>>>> "MG" == Marcus G. Daniels <address@hidden> writes:
 
KL> but if I try
KL> destroying and recreating the ZoomRaster and the Object2dDisplay
KL> as an Activity within the global schedule , the Object2dDisplay
KL> seems to point to some different objects when it gets the display
KL> message.

MG> The objects that Object2dDisplay points to live in the Grid2d that
MG> you provide.  Shouldn't something happen to the Grid2d during this
MG> recreation cycle?  Perhaps it is destroyed as part of dropping the
MG> ModelSwarm?

The Grid2d is destroyed but recreated and reassigned to a new
Object2dDisplay within the ActivityGroup.
 
KL> function: _i_Object_s__doesNotRecognize_(), file: DefObject.m,
KL> line: 635 ObjectX does not recognize drawX:Y:*** execution
KL> terminating due to error
 
MG> What is an "ObjectX"?  Does it belong in the lattice? 
MG> Does it make sense to send drawX:Y: to it?

ObjectX normaly points to some agent that implements a drawX:Y: method,
but after the first ciycle this points to some other object out of the
model swarm that does not implement the drawX:Y: method.

I provide some sample code:
This is the Schedule of the Observer Swarm:

// Creation of the ActionGroup & Schedule:
experActions = [ActionGroup create: self];
// The model is built ( with all the objects created)
[experActions createActionTo: self    message: M(buildModel)];
// The worldRaster & Object2dDisplay are created
[experActions createActionTo: self message: M(build2DModelOutput)];
// Run the model
[experActions createActionTo: self    message: M(runModel)];
// Do the Tk Events
[experActions createActionTo: actionCache message: M(doTkEvents)];
// Drop the worldRaster & Object2dDisplay
[experActions createActionTo: self    message: M(drop2DModelOutput)];
// Drop the model
[experActions createActionTo: self    message: M(dropModel)];

// And the schedule for the whole thing
 experSchedule = [Schedule createBegin: self];
  [experSchedule setRepeatInterval: 1];
  experSchedule = [experSchedule createEnd];
  [experSchedule at: 0 createAction: experActions];

The significant methods are:
- build2DModelOutput
{
 ...
  worldRaster = [ZoomRaster createBegin: self];
  SET_WINDOW_GEOMETRY_RECORD_NAME (worldRaster);
  worldRaster = [worldRaster createEnd];
  [worldRaster enableDestroyNotification: self
               notificationMethod: @selector (_worldRasterDeath_:)];
  [worldRaster setColormap: colormap];
  [worldRaster setZoomFactor: 4];
  [worldRaster setWidth: [[theModel getWorld] getSizeX]
                 Height: [[theModel getWorld] getSizeY]];
  [worldRaster setWindowTitle: "Agent World"];
  [worldRaster pack];                             // draw the window.

  agentDisplay = [Object2dDisplay createBegin: self];
  [agentDisplay setDisplayWidget: worldRaster];
  [agentDisplay setDiscrete2dToDisplay: [theModel getWorld]];
  [agentDisplay setObjectCollection: [theModel getAgentList]];
  [agentDisplay setDisplayMessage: M(drawSelfOn:)];
  agentDisplay = [agentDisplay createEnd];

  return self;
}

- display2dModelOutput
{

  [agentDisplay display];   
  [worldRaster drawSelf];

  return self;
}

- drop2DModelOutput
{  
  [worldRaster drop];
  worldRaster = nil;
  [agentDisplay drop];
  agentDisplay = nil;
  return self;
}

And from the ModelSwarm Object some of the methods in the observer swarm
are called:

  modelActions = [ActionGroup create: self];
  [modelActions createActionForEach: agentList    message: M(step)];
  [modelActions createActionTo:      self       message: M(checkToStop)];

  // XXX Only for update of 2dObjectDisplay
  [modelActions createActionTo:  TkSuperObject message: 
M(display2dModelOutput)];
  [modelActions createActionTo:  TkActionCache message: M(doTkEvents)];
  }
 
  // TkSuperObject is the id of the ObserverSwarm
  // TkActionCache is the id of the ObserverSwarm actionCache
  // So that TkEvents are triggerd within the ModelSwarm

  modelSchedule = [Schedule createBegin: self];
  [modelSchedule setRepeatInterval: 1];
  modelSchedule = [modelSchedule createEnd];
  [modelSchedule at: 0 createAction: modelActions];A

 
I hope this was some useful information about my problem ...

 konrad lang

-------
  ICQ#: 23489351
  Lang Konrad               Student of Computer Science in Salzburg, Austria
-------
At the source of every error which is blamed on the computer you will find
at least two human errors, including the error of blaming it on the computer.


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