aesa: make "make clean" also remove output.txt
[jump.git] / aesa / src / Consumer.c
1 #include "Consumer.h"
2
3 /************************************************************************************/
4
5 void Consumer_init(DOLProcess * p)
6 {
7         int i,j,k;
8
9         p->local->channel_cntr = 0;
10         p->local->pulse_cntr = 0;
11         p->local->bin_cntr = 0;
12         p->local->n_iterations = 0;
13
14         p->local->excount = 0;
15
16         
17         for (i=0; i<NUMBER_OF_DOPPLER_CHANNELS; i++) 
18         {
19                 for (j=0; j<NUMBER_OF_PULSES; j++) 
20                 {
21                         for (k=0; k<NUMBER_OF_RANGE_BINS; k++) 
22                         {
23                                 (p->local->Channels[i][j][k]).real = 0.0;
24                                 (p->local->Channels[i][j][k]).imag = 0.0;
25                                 (p->local->Channels_Delayed[i][j][k]).real = 0.0;
26                                 (p->local->Channels_Delayed[i][j][k]).imag = 0.0;
27                         }
28                 }
29         }
30 #ifdef PRINT_CONSUMER
31   p->local->out = fopen( "output.txt", "w" );
32 #endif
33 }
34
35 /************************************************************************************/
36
37 int Consumer_fire(DOLProcess * p)
38 {
39         CREATEPORTVAR(input_port);
40         CREATEPORTVAR(input_port_delayed);
41         int chan_index;
42
43         p->local->excount++;
44
45
46         for (chan_index = 0; chan_index < NUMBER_OF_DOPPLER_CHANNELS; chan_index++) 
47         {
48
49
50                 CREATEPORT(input_port, PORT_IN, 1, chan_index, NUMBER_OF_BEAMS);
51                 // DOL_read((void*)input_port, &(p->local->Channels[chan_index][p->local->pulse_cntr][p->local->bin_cntr]), sizeof(ComplexNumber), p);
52                 DOL_read((void*)input_port, &(p->local->Channels[chan_index][p->local->pulse_cntr][0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
53
54                 CREATEPORT(input_port_delayed, PORT_IN_DELAYED, 1, chan_index, NUMBER_OF_BEAMS);
55                 // DOL_read((void*)input_port_delayed, &(p->local->Channels_Delayed[chan_index][p->local->pulse_cntr][p->local->bin_cntr]), sizeof(ComplexNumber), p);
56                 DOL_read((void*)input_port_delayed, &(p->local->Channels_Delayed[chan_index][p->local->pulse_cntr][0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
57         }
58         
59         // p->local->bin_cntr = p->local->bin_cntr + 1;
60         // if (p->local->bin_cntr == NUMBER_OF_RANGE_BINS) 
61         // {
62         //      p->local->bin_cntr = 0;
63                 p->local->pulse_cntr = p->local->pulse_cntr + 1;
64                 if (p->local->pulse_cntr == NUMBER_OF_PULSES)
65                 {
66                         p->local->pulse_cntr = 0;
67                         p->local->n_iterations = p->local->n_iterations + 1;
68                 }
69         // }
70         
71         if (p->local->n_iterations == NUMBER_OF_ITERATIONS) {
72     int i,j,k;
73     char c;             
74     printf("\n\n:: Consumer process finished :\n\n");
75     // printf("\ttotal number of executions:  %d",p->local->excount);   
76     
77
78 #ifdef PRINT_CONSUMER  
79           for (i=0; i<NUMBER_OF_DOPPLER_CHANNELS; i++) 
80           {
81       fprintf(p->local->out, "\n------------------------\n", i);
82       fprintf(p->local->out, ":: Doppler channel %d ::\n", i);
83       fprintf(p->local->out, "------------------------\n", i);
84                   for (j=0; j<NUMBER_OF_PULSES; j++) 
85                   {
86         fprintf(p->local->out, "\n:: Pulse %d, Range Bin 1 to %d ::\n", j, NUMBER_OF_RANGE_BINS);
87                           for (k=0; k<NUMBER_OF_RANGE_BINS; k++) 
88                           {
89           fprintf(p->local->out, "[%f, %f] ", p->local->Channels[i][j][k].real, p->local->Channels[i][j][k].imag);
90                           }
91         fprintf(p->local->out, "\n");
92                   }
93           }
94     
95     for (i=0; i<NUMBER_OF_DOPPLER_CHANNELS; i++) 
96           {
97       fprintf(p->local->out, "\n--------------------------------\n", i);
98       fprintf(p->local->out, ":: Doppler channel delayed %d ::\n", i);
99       fprintf(p->local->out, "--------------------------------\n", i);
100                   for (j=0; j<NUMBER_OF_PULSES; j++) 
101                   {
102         fprintf(p->local->out, "\n:: Pulse slot%d, Range Bin 0 to %d ::\n", j, NUMBER_OF_RANGE_BINS);
103                           for (k=0; k<NUMBER_OF_RANGE_BINS; k++) 
104                           {
105           fprintf(p->local->out, "[%f, %f] ", p->local->Channels_Delayed[i][j][k].real, p->local->Channels_Delayed[i][j][k].imag);
106                           }
107         fprintf(p->local->out, "\n");
108                   }
109     }
110 #endif  
111
112                 DOL_detach(p);
113         }
114         
115         return 0;
116 }