#include #include #include #include #define PAC_HOST_MAX_FILENAME_LENGTH (100) #define PI (22./7.) #define WAVEFORM_SIZE (2048) #define INTEGER_SCALAR (16384) /* 2^14 */ #define DEBUG (0) int main(int argc, char *argv[]) { int ii; int wfType; FILE *fi; FILE *fq; char iFilename[PAC_HOST_MAX_FILENAME_LENGTH]; char qFilename[PAC_HOST_MAX_FILENAME_LENGTH]; double I_cal; double Q_cal; double theta; /* angle in degrees [0,360] */ printf("argc: %d\n", argc); if (argc!=4) { fprintf(stderr,"Usage: pacCreateWaveforms [0:1] [Ifilename Qfilename] where 0 is for normal and 1 is for calibration waveforms\n"); } /* argv[0] is the program name */ /* argv[1] specifies normal(0) vs calibration(1) waveform creation */ wfType = atoi(argv[1]); strcpy(iFilename, argv[2]); strcpy(qFilename, argv[3]); /* display parsed args */ printf("wfType is %d\n", wfType); printf("pacCreateWaveforms: iFilename: '%s'\n", iFilename); printf("pacCreateWaveforms: qFilename: '%s'\n", qFilename); /* set up place to write I waveform */ fi = fopen(iFilename,"w"); if (fi==NULL) { fprintf(stderr, "pacCreateWaveforms: unable to open '%s' for write. Exiting.\n", iFilename); return(-1); } /* set up place to write Q waveform */ fq = fopen(qFilename,"w"); if (fq==NULL) { fprintf(stderr,"pacCreateWaveforms: unable to open '%s' for write. Exiting.\n", qFilename); return(-1); } switch (wfType) { case 0: /* normal */ for (ii=0; ii<2048; ii++) { /* I is a ramp from 0 to 356*45 + 16384 first 357 points, then 0 for the rest */ if (ii == 0) { fprintf(fi,"0\n"); } else { /* CONSTANT for 400 pts, then 0 */ if (ii < 400) { fprintf(fi,"32000\n"); } else { fprintf(fi,"0\n"); if (DEBUG) { printf("I(%d):0\n", ii); } } } /* CONSTANT for 400 pts, then 0 */ if (ii == 0) { fprintf(fq,"0\n"); } else { if (ii < 400) { fprintf(fq,"32000\n"); } else { fprintf(fq,"0\n"); /* Q is 0 after that */ } } } break; case 1: /* calibration */ for (ii=0; ii