7 * Returns a random integer in the range between lower_bound and
8 * upper_bound, where the bounding values are included in the interval.
10 int getRandomNumber(int lower_bound, int upper_bound)
12 return (rand() % (upper_bound - lower_bound + 1)) + lower_bound;
16 void producer_init(DOLProcess *p)
18 printf("init producer.\n");
22 int producer_fire(DOLProcess *p)
24 srand(0); //initialize random number generator
26 //generate input samples and display them
27 printf("producer: samples = { ");
29 for (p->local->index = 0; p->local->index < NUMBER_OF_SAMPLES; p->local->index++) {
30 p->local->sample[p->local->index] = (float) getRandomNumber(-9, 9);
31 if (p->local->index < NUMBER_OF_SAMPLES - 1) {
32 printf("%+3.1f, ", p->local->sample[p->local->index]);
35 printf("%+3.1f }\n", p->local->sample[p->local->index]);
39 //write samples to output port
40 for (p->local->index = 0; p->local->index < NUMBER_OF_SAMPLES; p->local->index++) {
41 printf("%8s: Write sample[%02d]: %+6.4f\n",
42 "producer", p->local->index, p->local->sample[p->local->index]);
43 DOL_write((void*)PORT_OUT, &(p->local->sample[p->local->index]),