/*Marcus Daniels December 28, 1999 Here's something new with the current snapshot from: ftp://ftp.santafe.edu/pub/swarm/testing A similar example for Java was posted the other day. Objective C users would need to build and install the snapshot in order to get the new headers and libraries in place (a DLL upgrade in not sufficient). */ #import // initSwarm #import // Swarm #import // Schedule @interface Controller: Swarm { id schedule; id stopSchedule; } @end @implementation Controller - (void)stepX: (double)x Y: (double)y { printf ("stepX: %lf Y: %lf @ %lu\n", x, y, getCurrentTime ()); } - stop { [getTopLevelActivity () terminate]; return self; } - buildActions { [super buildActions]; schedule = [Schedule create: self setRepeatInterval: 1]; [schedule at: 0 createFAction: [FCall create: self target: self selector: M(stepX:Y:) arguments: [[[[[FArguments createBegin: self] setSelector: M(stepX:Y:)] addDouble: 10.0] addDouble: 20.0] createEnd]]]; stopSchedule = [Schedule create: self setAutoDrop: YES]; [stopSchedule at: 10 createActionTo: self message: M(stop)]; return self; } - activateIn: swarmContext { [super activateIn: swarmContext]; [schedule activateIn: self]; [stopSchedule activateIn: self]; return [self getActivity]; } @end int main (int argc, const char **argv) { initSwarmBatch (argc, argv); { id controller = [Controller create: globalZone]; [controller buildObjects]; [controller buildActions]; [[controller activateIn: nil] run]; } } /* Local Variables: compile-command: "gcc -DDLL -o testFAction -g -Wno-import -I$SWARMHOME/include -L$SWARMHOME/lib testFAction.m -lswarmdll -lobjcdll" End: */