Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

Building a Graphical Observer Swarm

4.6. Building a Graphical Observer Swarm

With the model swarm defined, arranging for a graphical observer Swarm is the next step. For Heatbugs, the code is in HeatbugObserverSwarm. The structure of an observer swarm is almost exactly like building a model swarm.

@interface HeatbugObserverSwarm : GUISwarm {
  int displayFrequency; // one parameter: update freq

  id displayActions; // schedule data structs
  id displaySchedule;
  
  HeatbugModelSwarm * heatbugModelSwarm; // the Swarm we're observing
  
  // Lots of display objects. First, widgets
  XColormap * colormap; // allocate colours
  ZoomRaster * worldRaster; // 2d display widget
  EZGraph * unhappyGraph; // graphing widget
  
  // Now, higher order display and data objects
  Value2dDisplay * heatDisplay; // display the heat
  Object2dDisplay * heatbugDisplay; // display the heatbugs
}
    

Again we have input parameters (display frequency), schedule data structures, and resident objects (model swarm, display widgets). The important exception is that HeatbugObserverSwarm is a subclass not just of the generic Swarm class, but specifically a GUISwarm. That implies that the HeatbugObserverSwarm will contain a control panel to allow the user to stop execution, and will also have a special go method to set everything running.