Subversion Repositories shark

Rev

Rev 1090 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1090 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
1590 tullio 21
/* CVS :        $Id: dummy.c,v 1.2 2006-07-03 15:10:15 tullio Exp $ */
1090 pj 22
 
23
/*
24
 * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
25
 *
26
 * This program is free software; you can redistribute it and/or modify
27
 * it under the terms of the GNU General Public License as published by
28
 * the Free Software Foundation; either version 2 of the License, or
29
 * (at your option) any later version.
30
 *
31
 * This program is distributed in the hope that it will be useful,
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
 * GNU General Public License for more details.
35
 *
36
 * You should have received a copy of the GNU General Public License
37
 * along with this program; if not, write to the Free Software
38
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
39
 *
40
 */
41
 
1590 tullio 42
#include "bca.h"
1090 pj 43
 
44
PID crea_soft_dummy_radar()
45
{
46
  SOFT_TASK_MODEL m;
47
  PID pid;
48
 
49
  soft_task_default_model(m);
50
  soft_task_def_level(m,0);
51
  soft_task_def_periodic(m);
52
  soft_task_def_period(m,DUMMY_RADAR_PERIOD);
53
  soft_task_def_wcet(m,DUMMY_RADAR_WCET);
54
  soft_task_def_met(m,DUMMY_RADAR_MET);
55
 
56
  pid = task_create("dummy_radar", dummy_radar, &m, NULL);
57
  return pid;
58
}
59
 
60
TASK dummy_radar(void *argv)
61
{
62
  WORD i,r,r_max,pos;
63
  BYTE red[3]={250, 150,50};
64
  int  d[3]=  {+10,+10,+10};
65
 
66
  r =     0;
67
  r_max = ballframe_radar->r+1;
68
 
69
  while(1){
70
    for(i=0; i<3; i++) {
71
      if (red[i]<50)  d[i]=+10;
72
      if (red[i]>250) d[i]=-50;
73
      red[i] += d[i];
74
      grx_disc(ballframe_lucerossa[i]->cx,
75
               ballframe_lucerossa[i]->cy,
76
               ballframe_lucerossa[i]->r,
77
               FAB_rgb(red[i],50,50));
78
      }
79
    grx_disc(ballframe_radar->cx,
80
             ballframe_radar->cy,
81
             r_max, FAB_blue);
82
    grx_circle(ballframe_radar->cx,
83
               ballframe_radar->cy,
84
               (r+9)%r_max, FAB_white);
85
    grx_circle(ballframe_radar->cx,
86
               ballframe_radar->cy,
87
               (r+5)%r_max, FAB_rgb(200,200,255));
88
    grx_circle(ballframe_radar->cx,
89
               ballframe_radar->cy,
90
               r%r_max, FAB_rgb(100,100,255));
91
    for (i=0; i<AEREO_N_MAX; i++) {
92
      if (aereo_table[i].status
93
         &&aereo_table[i].x>X0
94
         &&aereo_table[i].y>Y0) {
95
            pos = ballframe_radar->cx - ballframe_radar->r
96
                + (aereo_table[i].x-X0)*2*ballframe_radar->r/500;
97
            grx_plot(pos,ballframe_radar->cy,FAB_yellow);
98
            }
99
      }
100
    r++;
101
 
102
  task_endcycle();
103
  }
104
}