Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
326 | f9daq | 1 | #include <stdlib.h> |
2 | #include <stdio.h> |
||
3 | #include <time.h> |
||
4 | #include <sys/time.h> |
||
5 | #include "dataio.h" |
||
6 | |||
7 | #define PEDESTAL 255 |
||
8 | |||
9 | int main(int argc, char **argv) { |
||
10 | |||
11 | char fname[200]= {"tmp.out"}; |
||
12 | int type; |
||
13 | time_t t; |
||
14 | |||
15 | if(argc<2) { |
||
16 | printf("Not enough arguments!\n"); |
||
17 | return -1; |
||
18 | } else { |
||
19 | sprintf(fname,"%s",argv[1]); |
||
20 | type=atoi(argv[2]); |
||
21 | } |
||
22 | |||
23 | FILE *fp= fopen(fname,"ab"); |
||
24 | |||
25 | switch(type) { |
||
26 | case RUNREC_ID: |
||
27 | if(argc<9) { |
||
28 | printf("Not enough arguments!\n"); |
||
29 | } else { |
||
30 | RUNREC runrec; // start header: appears once at the start of the file |
||
31 | runrec.id = RUNREC_ID; |
||
32 | runrec.len = sizeof(runrec); |
||
33 | runrec.fver = 0x10000; |
||
34 | time(&t); |
||
35 | runrec.time=t; |
||
36 | runrec.nev = atoi(argv[3]); |
||
37 | runrec.ped = PEDESTAL; |
||
38 | runrec.nx = atoi(argv[4]); |
||
39 | runrec.x0 = atoi(argv[5]); |
||
40 | runrec.dx = atoi(argv[6]); |
||
41 | runrec.ny = atoi(argv[7]); |
||
42 | runrec.y0 = atoi(argv[8]); |
||
43 | runrec.dy = atoi(argv[9]); |
||
44 | printf("Writing header to file %s\n",fname); |
||
45 | printf("RECID = %u\n",runrec.id); |
||
46 | printf("Length = %u\n",runrec.len); |
||
47 | printf("File version = %u\n",runrec.fver); |
||
48 | printf("Time = %u\n",runrec.time); |
||
49 | printf("Number of events per step = %u\n",runrec.nev); |
||
50 | printf("Pedestal = %u\n",runrec.ped); |
||
51 | printf("Number of steps in X = %d\n",runrec.nx); |
||
52 | printf("Start position X = %d\n",runrec.x0); |
||
53 | printf("Step size direction X = %d\n",runrec.dx); |
||
54 | printf("Number of steps in Y = %d\n",runrec.ny); |
||
55 | printf("Start position Y = %d\n",runrec.y0); |
||
56 | printf("Step size direction Y = %d\n",runrec.dy); |
||
57 | if (fp) fwrite(&runrec, runrec.len,1,fp); |
||
58 | } |
||
59 | break; |
||
60 | case ENDREC_ID: |
||
61 | ENDREC endrec; // end header: appears once at the end of the file |
||
62 | endrec.id = ENDREC_ID; |
||
63 | endrec.len = sizeof(endrec); |
||
64 | time(&t); |
||
65 | endrec.time=t; |
||
66 | printf("Writing header to file %s\n",fname); |
||
67 | printf("RECID = %u\n",endrec.id); |
||
68 | printf("Length = %u\n",endrec.len); |
||
69 | printf("Time = %u\n",endrec.time); |
||
70 | if (fp) fwrite(&endrec, endrec.len,1,fp); |
||
71 | break; |
||
72 | case POSREC_ID: |
||
73 | if(argc<8) { |
||
74 | printf("Not enough arguments!\n"); |
||
75 | } else { |
||
76 | POSREC posrec; // position header: appears at every change of position |
||
77 | posrec.id = POSREC_ID; |
||
78 | posrec.len = sizeof(posrec); |
||
79 | time(&t); |
||
80 | posrec.time=t; |
||
81 | posrec.ix = atoi(argv[3]); |
||
82 | posrec.x = atoi(argv[4]); |
||
83 | posrec.xset = atoi(argv[5]); |
||
84 | posrec.iy = atoi(argv[6]); |
||
85 | posrec.y = atoi(argv[7]); |
||
86 | posrec.yset = atoi(argv[8]); |
||
87 | printf("Writing header to file %s\n",fname); |
||
88 | printf("RECID = %u\n",posrec.id); |
||
89 | printf("Length = %u\n",posrec.len); |
||
90 | printf("Time = %u\n",posrec.time); |
||
91 | printf("Iteration X = %d\n",posrec.ix); |
||
92 | printf("MIKRO Position X = %d\n",posrec.x); |
||
93 | printf("Set position X = %d\n",posrec.xset); |
||
94 | printf("Iteration Y = %d\n",posrec.iy); |
||
95 | printf("MIKRO Position Y = %d\n",posrec.y); |
||
96 | printf("Set position Y = %d\n",posrec.yset); |
||
97 | if (fp) fwrite(&posrec, posrec.len,1,fp); |
||
98 | } |
||
99 | break; |
||
100 | } |
||
101 | fclose(fp); |
||
102 | return 0; |
||
103 | } |