#include #define LEN 256 int main () { FILE * fp; int i,j,k; /* open the file for writing*/ fp = fopen ("scalerWaveformDIRC.db","w"); /* write text into the file stream*/ fprintf (fp, "# \n"); fprintf (fp, "# DIRC waveforms to be filled by state codes \n"); fprintf (fp, "# \n"); fprintf (fp, " \n"); fprintf (fp, "grecord(bi,\"$(PREF)DIRC:SCALER:FILL_FLAG\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Fill flag for DIRC WV\")\n"); fprintf (fp, " field(ONAM, \"FILL\")\n"); fprintf (fp, " field(ZNAM, \"STOP\")\n"); fprintf (fp, " field(VAL , \"1\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:SCALER:INTERVAL\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Update time for DIRC WV\")\n"); fprintf (fp, " field(VAL , \"1.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(stringin,\"$(PREF)DIRC:n:c1:scaler:SNL:TEXT\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"STATUS from DIRC SNL\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(stringin,\"$(PREF)DIRC:n:c2:scaler:SNL:TEXT\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"STATUS from DIRC SNL\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(stringin,\"$(PREF)DIRC:s:c1:scaler:SNL:TEXT\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"STATUS from DIRC SNL\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(stringin,\"$(PREF)DIRC:s:c2:scaler:SNL:TEXT\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"STATUS from DIRC SNL\")\n"); fprintf (fp, "} \n"); /* --------------- NORTH Total c1, c2, c1+c2 -------------------------*/ fprintf (fp, " \n"); fprintf (fp, "######################## NORTH, Total C1, C2, C1+C2 ########################\n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:n:c1:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Total value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:n:c2:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Total value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(calc,\"$(PREF)DIRC:n:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(INPA, \"$(PREF)DIRC:n:c1:scaler_sum\")\n"); fprintf (fp, " field(INPB, \"$(PREF)DIRC:n:c2:scaler_sum\")\n"); fprintf (fp, " field(SCAN, \".2 second\")\n"); fprintf (fp, " field(CALC, \"A+B\")\n"); fprintf (fp, "} \n"); /* --------------- SOUTH Total c1, c2, c1+c2 -------------------------*/ fprintf (fp, " \n"); fprintf (fp, "######################## SOUTH, Total C1, C2, C1+C2 ########################\n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:s:c1:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Total value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:s:c2:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Total value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(calc,\"$(PREF)DIRC:s:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(INPA, \"$(PREF)DIRC:s:c1:scaler_sum\")\n"); fprintf (fp, " field(INPB, \"$(PREF)DIRC:s:c2:scaler_sum\")\n"); fprintf (fp, " \n"); fprintf (fp, " field(SCAN, \".2 second\")\n"); fprintf (fp, " field(CALC, \"A+B\")\n"); fprintf (fp, "} \n"); /* --------------- Total NORTH + SOUTH -------------------------*/ fprintf (fp, "######################## Total SOUTH+NORTH ########################\n"); fprintf (fp, "grecord(calc,\"$(PREF)DIRC:ns:scaler_sum\")\n"); fprintf (fp, "{ \n"); fprintf (fp, " field(INPA, \"$(PREF)DIRC:s:scaler_sum\")\n"); fprintf (fp, " field(INPB, \"$(PREF)DIRC:n:scaler_sum\")\n"); fprintf (fp, " field(SCAN, \".2 second\")\n"); fprintf (fp, " field(CALC, \"A+B\")\n"); fprintf (fp, "} \n"); /* --------------- NORTH -------------------------*/ for(i = 1; i < 3;i++){ for(j = 1; j < 19;j++){ for(k = 1; k < 4;k++){ fprintf (fp, " \n"); fprintf (fp, "######################## NORTH, COLUMN %1d ROW %1d:%1d ########################\n",i,j,k); fprintf (fp, " \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:n:c%1d:r%1d:%1d:scaler_sum\")\n",i,j,k); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Total value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:n:c%1d:r%1d:%1d:scaler_avg\")\n",i,j,k); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Average value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PREC , \"1\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); } } } /* --------------- SOUTH -------------------------*/ for(i = 1; i < 3;i++){ for(j = 1; j < 19;j++){ for(k = 1; k < 4;k++){ fprintf (fp, "######################## SOUTH, COLUMN %1d ROW %1d:%1d ########################\n",i,j,k); fprintf (fp, " \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:s:c%1d:r%1d:%1d:scaler_sum\")\n",i,j,k); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Total value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); fprintf (fp, "grecord(ai,\"$(PREF)DIRC:s:c%1d:r%1d:%1d:scaler_avg\")\n",i,j,k); fprintf (fp, "{ \n"); fprintf (fp, " field(DESC, \"Average value of DIRC WV\")\n"); fprintf (fp, " field(VAL , \"0.0\")\n"); fprintf (fp, " field(PREC , \"1\")\n"); fprintf (fp, " field(PINI, \"YES\")\n"); fprintf (fp, "} \n"); } } } /* close the file*/ fclose (fp); return 0; }