swarm-support
[Top][All Lists]
Advanced

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

Re: FunctionGraph


From: Marcus G. Daniels
Subject: Re: FunctionGraph
Date: 30 Jan 2001 15:19:01 -0800
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "PT" == Pietro Terna <address@hidden> writes:

PT>     I'm looking for an example (in Java or ObjC) about the use of
PT> FunctionGraph.

In Java, it isn't usable in Java because GraphElement is hidden.
I've since taken FunctionGraph out of the Java API as well.

#import <simtools.h>
#import <objectbase/SwarmObject.h>
#import <analysis.h>
#include <misc.h>

@interface Agent: SwarmObject
- compute: xPtr: yPtr;
@end

@implementation Agent
- compute: xPtr: yPtr
{
  double x = *(double *)xPtr;
  double y = sin (x);

  *(double *)yPtr = y;
  return (id)YES;
}
@end

@interface Controller: SwarmObject
{
  id <FunctionGraph> fg;
  id <GraphElement> fe;
  id <Graph> graph;
  id agent;
  id panel;
}
- createEnd;
- graph;
- exit;
@end

@implementation Controller

- createEnd
{
  id fgd;

  agent = [Agent create: [self getZone]];

  fgd = [Frame create: [self getZone]];
  
  graph = [Graph createParent: fgd];
  [graph setWindowTitle: "FunctionGraph"];

  [graph pack];

  fe = [graph createElement];
  [fe setLabel: "myLabel"];
  [fe setColor: "red"];
  [fe setWidth: 1];    
  
  fg = [FunctionGraph createBegin: [self getZone]];
  [fg setElement: fe];
  [fg setDataFeed: agent];
  [fg setFunctionSelector: M(compute::)];
  [fg setXMin: 0.0 Max: 2.0 * M_PI Resolution: 100];
  [fg setResetFrequency: 0];
  fg = [fg createEnd]; 

  panel = [ButtonPanel createBegin: [self getZone]];
  [panel setButtonTarget: self];
  panel = [panel createEnd];
  [panel setWindowTitle: "ControlPanel"];
  [panel addButtonName: "Exit" method: @selector (exit)];

  return self;
}

- exit
{
  exit (0);
}

- graph
{
  [fg graph];

  return self;
}
@end

int
main (int argc, const char **argv)
{ 
  id controller;

  initSwarm (argc, argv);

  controller = [Controller create: globalZone];
  
  [controller graph];
  
  while (1)
    {
      while (GUI_EVENT_ASYNC ()) {}
    }  
}

/*
Local Variables:
compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -DDLL -o 
funcgraph -g -Wno-import -I$SWARMHOME/include -L$SWARMHOME/lib funcgraph.m 
-lswarmdll -lobjcdll"
compile-command-linux: "$SWARMHOME/bin/libtool-swarm --mode=link gcc 
-D_GNU_SOURCE -o  funcgraph -Wall -Werror -g -Wno-import 
-I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm funcgraph.m -lswarm -lobjc"
compile-command-solaris: "/opt/SDGswarm/2.1.1/bin/libtool-swarm --mode=link 
/opt/SDGgcc/2.95.2/bin/gcc -o deleteAll -Wall -Werror -g -Wno-import 
-I/opt/SDGswarm/2.1.1/include -L/opt/SDGswarm/2.1.1/lib deleteAll.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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]