HP VXI 75000 C Series User's And Scpi Programming Manual page 398

Algorithmic closed loop controller
Table of Contents

Advertisement

/* Print usage information */
void usage(char *prog_name)
{
(void) fprintf(stderr, "usage: %s algorithm_file...\n", prog_name);
}
/* Get an algorithm from a filename */
static char *get_algorithm(char *file_name)
{
FILE
int32
int
char
f = fopen(file_name, "r");
if (! f) {
(void) fprintf(stderr, "Error: can't open algorithm file '%s'\n",
exit(1);
}
a_size = 0;
while (getc(f) != EOF) {
a_size++;
}
rewind(f);
algorithm = malloc(a_size + 1);
a_size = 0;
while ((c = getc(f)) != EOF) {
algorithm[a_size] = c;
a_size++;
}
algorithm[a_size] = 0;
(void) fclose(f);
return algorithm;
}
/* Main program */
/*ARGSUSED*/
int main(int argc, char *argv[])
{
/* Main program local variable declarations */
char
int
char
int32
#if 1
/* Check pass parameters */
if ((argc < 2) || (argc > 33)) {
usage(argv[0]);
exit(1);
}
398 Example Program Listings
*f;
/* Algorithm file pointer */
a_size;
/* Algorithm size */
c;
/* Character read from input */
*algorithm;
/* Points to algorithm string */
file_name);
/* Count length of algorithm */
/* Use as array index */
/* Read the algorithm */
/* Null terminate */
/* Return algorithm string */
/* Keeps lint happy */
*algorithm;
/* Algorithm string */
alg_num;
/* Algorithm number being loaded */
string[333];
/* Holds error information */
error;
/* Holds error number */
/* Set to 1 if reading algorithm files */
/* Must have 1 to 32 algorithms */
/* Storage for algorithm */
Appendix G

Advertisement

Table of Contents
loading

This manual is also suitable for:

Vxi e1415a

Table of Contents