[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Drone is making me really mad
From: |
Sven N. Thommesen |
Subject: |
Re: Drone is making me really mad |
Date: |
Wed, 30 Jun 1999 14:14:26 -0500 |
Yes, Paul, the code I sent you earlier *did* involve a 'parameter file form
hell'. It has about 180 parameters in it!
However, for purposes of what you need, look at what I also once sent you,
namely a subclass to Arguments that picks up any command line arguments of
type "-D arg=value" and puts them into an array of strings which your
program is free to access and parse as it wishes. It can pass those
arguments to the relevant swarms/agents directly; there's no need to use my
global super-parameter-struct.
I recall that it took a while to figure out the correct combination of
Drone parameter prefix and subclass to Arguments to get the command line
correctly parsed.
You need to tell Drone 'param setParamOption = " -D "' for this to work;
other command line options must also be of the sort "-D <arg>=<value>".
I've appended the code for the Arguments subclass.
I'll be happy to send you a drone.params file that works, if you need it.
Sven
At 05:28 PM 6/29/1999 -0500, you wrote:
>I have a program that runs using the Swarm command line features of
>Argument protocol. It can respond to -n33, say, to set the number of
>agents to 33.
>
>I have drone, it works on their examples, but I can't figure how to make
>drone run my simulation.
>
>I don't want to run in batch mode, so my Observer swarm is setup to
>start itself running, take screenshots, and quit after 50 time steps. I
>can comment out the Drone misc options -batchmode line to stop that
>option from taking place.
>
>There is some discussion/debate/puzzlement over drone in the email
>archive. I can't find any definitive statement on how to just pass in
>one or two simple little arguments to a Swarm program.
>
>Sven T posted some examples that propose changing the set
>
>param setParamOption = -D
>
>to
>
>param setParamOption =" -D"
>
>but these settings will note even parse with Redhat6, drone 1.03:
>
>ReadControlFile: Error parsing control file line: param setParamOption
>=" -D"
>
>Plus Sven's treatment is tied up an entity which might be called "the
>parameter file from hell" in some monster application he is working on.
>I don't want to have the monster app, I just want to pass in, say, one
>or two parameters.
>
>In the program I'm currently working on , and it works from the command
>line with
>
>./protest -n33
>
>or
>
>./protest --numppl=33
>
>
>Drone seems to want to pass all program parameters with -D in front of
>them, as in -Dn=33.
>
>--
>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.
// "MySwarmDroneArguments.m"
// Subclass of Arguments, to accommodate Drone command line arguments
// Sven Thommesen <address@hidden> 1998-08-27
// This implementation assumes that you already have code in your app to
// parse Drone's command line arguments; you just need for Swarm's
// Argument to leave them alone and not croak.
// In Drone's drone.params, you need to do
// param setParamOption = " -D "
// to work with this file.
// Other arguments must also be of the sort "-D <arg>=<value>"
// (notice the SPACE after -D).
#import <strings.h>
#import "MySwarmDroneArguments.h"
@implementation MySwarmDroneArguments
+ createBegin: aZone
{
static struct argp_option options[] = {
{"protocol", 'p', "PROTOCOL", 0, "Set protocol", 5},
{"drone-param", 'D', "PARAM", 0, "Parameter from Drone", 6},
{ 0 }
};
MySwarmDroneArguments *obj = [super createBegin: aZone];
[obj addOptions: options];
obj->numDroneArgs = 0;
return obj;
}
- (int)parseKey: (int)key arg: (const char *)arg
{
const char *delim = "=";
char *token1, *token2;
if (key == 'p')
{
protocolArg = arg;
return 0;
}
else if (key == 'D')
{
droneArg = arg;
// printf("MSAA: droneArg = %s\n", droneArg);
if (numDroneArgs >= MAXDRONEARGS)
[InvalidCombination raiseEvent:
"Too many drone command line arguments!\n"];
strcpy(myArgString, droneArg);
// printf("MSAA: myArgString = %s\n", myArgString);
strcpy(myArgStringArr[numDroneArgs], myArgString);
// printf("MSAA: myArgStringArr[%02d] = %s\n",
// numDroneArgs, myArgStringArr[numDroneArgs]);
// -----
// Splitting the drone arguments using strtok:
if (strlen(myArgString) > 0)
{
token1 = strtok(myArgString,delim);
token2 = strtok(NULL,delim);
// printf("MSAA: String : token-1 = %s token-2 = %s\n", token1, token2);
strcpy(myArgNameArr[numDroneArgs], token1);
strcpy(myArgValueArr[numDroneArgs], token2);
} else {
// printf("MSAA: String was empty ???\n");
}
// -----
numDroneArgs++;
return 0;
}
else
return [super parseKey: key arg: arg];
}
- (const char *)getProtocolArg
{
return protocolArg;
}
- (const char *)getDroneArg
{
return droneArg;
}
- (int)getNumDroneArgs
{
return numDroneArgs;
}
- (char *)getMyArgString
{
return myArgString;
}
- (ArgString *)getMyArgStringArr
{
return &(myArgStringArr[0]);
}
- (TokenString *) getMyArgNameArr
{
return &(myArgNameArr[0]);
}
- (TokenString *) getMyArgValueArr
{
return &(myArgValueArr[0]);
}
@end
// "MySwarmAppArguments.h"
// Subclass of Arguments, to accommodate Drone command line parameters
// Sven Thommesen <address@hidden> 1998-08-27
// #import <objectbase/Arguments.h> // 1.3.1
#import <defobj.h> // for 1.4
#import <defobj/Arguments.h> // for 1.4
#define MAXDRONEARGS 20
#define MAXDRONESTRING 81
#define MAXARGSTRING 81
typedef char ArgString [MAXDRONESTRING];
typedef ArgString ArgStringArr [MAXDRONEARGS];
typedef char TokenString [MAXARGSTRING];
typedef TokenString TokenStringArr [MAXDRONEARGS];
@interface MySwarmDroneArguments: Arguments_c // for 1.4
// @interface MySwarmDroneArguments: Arguments // 1.3.1
{
const char *protocolArg;
const char *droneArg;
int numDroneArgs;
ArgString myArgString;
ArgStringArr myArgStringArr;
TokenStringArr myArgNameArr, myArgValueArr;
}
- (const char *) getProtocolArg;
- (const char *) getDroneArg;
- (int) getNumDroneArgs;
- (char *) getMyArgString;
- (ArgString *) getMyArgStringArr;
- (TokenString *) getMyArgNameArr;
- (TokenString *) getMyArgValueArr;
@end