swarm-support
[Top][All Lists]
Advanced

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

Drone: I made it work, here is how


From: Paul Johnson
Subject: Drone: I made it work, here is how
Date: Wed, 30 Jun 1999 16:17:43 -0500

I am sorry to bore you all with this business, but I have solved the
problems I had using Drone. I was desperate to get a "clean" solution
that I should show students and keep a straight face at the time.  I did
not want to resort to any wrappers or big distractions.  I found a
solution that takes a minimum of trouble and I'd like to share and hope
that future users find it convenient.  

My scheme is to use an Argument class object exactly as described in the
Swarm docs. It works exactly like the docs say.  My mistake was not
getting it "just right" to work and play well with Drone.  My
application is called "protest" and I only want to pass in a variable
parameter "numppl". However, to do that, I have to create "dead end"
methods that absorb the parameters -I, -R, and -S that drone probes for.
Note also I've changed the -D standard parameter option to --, so now
the longname swarm parameters are passed through.  

Without further ado, here are the vitals:

MyArguments.h:

#import <defobj/Arguments.h>

@interface MyArguments: Arguments_c
 {
   const char *numpplArg;
 }

- (int) getNumpplArg;

- sayHello;

@end


MyArguments.m:

#import "MyArguments.h"
#import <stdlib.h>

@implementation MyArguments

+ createBegin: aZone
 {
   static struct argp_option options[] = {
     {"numppl",'n',"N", 0, "Set numppl", 5},
     {"inputfile", 'I',"filename",0,"set fn",6},
     {"run",'R',"RunNumber",0,"Run is...",7},
     {"seed",'S',"SeedNumber",0,"Seed",8},
     { 0 }
   };
   
   MyArguments *obj = [super createBegin: aZone];

   [obj addOptions: options];
  
   return obj;
 }

- (int)parseKey: (int) key arg: (const char*) arg
 {
   if (key == 'n')
     {
       numpplArg = arg;
       return 0;
     }
   if (key == 'I')
     {
       printf("here is an I \n"); //note this does nothing but make
Drone think you are listening
       return 0;
     }
   if (key == 'S')
     {
       printf("here is an S \n"); //ditto
       return 0;
     }
   if (key == 'R')
     {
       printf("here is an R \n"); /ditto
       return 0;
     }
   else
     return [super parseKey: key arg: arg];
 }

- (int) getNumpplArg
 {
   int num=-1;
   if(numpplArg)
   num = atoi(numpplArg); 
        return num;  //elsewhere in the code, access this with [arguments
getNumpplArg]; (arguments is a global object)
  
 }

@end


Here is the relevant part of the.

protest.ctrl:

# This section sets Drone's parameters

# These parameters MUST be set up by the user

param rootDir = /swarm/test/trashdrone
param programDir = /swarm/ContagiousProtest/CP-990628
param programName = protest

# Frequently set parameters
param numRuns = 4
param emailAddr = address@hidden
param experimentSeed =
param useLocalHost = 1
param programVersion =

param getProgramVersion = 0
param versionOptions = -V
param makeInputFile = 1
param inputFileOption = --inputfile=
param runSeedOption = --seed=
param runNumOption = --run=
param runNumPrefix = run 
param setParamOption = --
param miscOptions = -s

After I get the code cleaned up, I'll be glad to give the whole program
to anybody that asks.

This version is a non batch program that makes screenshots every now and
then and, as promised, Drone correctly saves them to the experiment
directories.  It almost drove me crazy figuring it out, but it worked.

Hint to future users. If you get the syntax of your MyArguments.m parse
commands wrong, then the error message you get from the Drone process
is:

Reading control file...
Initializing...
Running...

DoLocalCmd: child process exited abnormally

This happens, for example, if you make a typographical error and put an
U in place of an I, for example, as i found out!

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

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