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 ; //nothing to be done here
22 int producer_fire(DOLProcess *p)
26 srand(0); //initialize random number generator
28 //generate input samples and display them
29 printf("producer: samples = { ");
31 for (index = 0; index < 10; index++) {
32 p->local->sample[index] = (float) getRandomNumber(-9, 9);
34 printf("%+3.1f, ", p->local->sample[index]);
37 printf("%+3.1f }\n", p->local->sample[index]);
41 //write samples to output port
42 for (index = 0; index < 10; index++) {
43 printf("%8s: Write sample[%02d]: %+6.4f\n",
44 "producer", index, p->local->sample[index]);
45 DOL_write((void*)PORT_OUT, &(p->local->sample[index]),