Subversion Repositories shark

Rev

Rev 1590 | Go to most recent revision | Details | 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
 
21
/* CVS :        $Id: control.c,v 1.1 2002-10-01 10:25:00 pj Exp $ */
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
 
42
//**************************
43
//* file:        control.c *
44
//* included by: bca.c     *
45
//**************************
46
 
47
PID crea_soft_control()
48
{
49
  SOFT_TASK_MODEL m;
50
  PID pid;
51
 
52
  soft_task_default_model(m);
53
  soft_task_def_periodic(m);
54
  soft_task_def_period(m,CONTROL_PERIOD);
55
  soft_task_def_wcet(m,CONTROL_WCET);
56
  soft_task_def_met(m,CONTROL_MET);
57
 
58
  pid = task_create("control", control, &m, NULL);
59
  return pid;
60
}
61
 
62
TASK control(void *argv)
63
{
64
    int i, x0, y0;
65
    int rect1_x0, rect1_y0, rect1_x1, rect1_y1;
66
    int rect2_x0, rect2_y0, rect2_x1, rect2_y1;
67
    char * str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
68
 
69
   x0=frame_control->x0;
70
   y0=frame_control->y0;
71
   rect1_x0=674;
72
   rect1_y0=y0+19;
73
   rect1_x1=758;
74
   rect1_y1=y0+24;
75
   rect2_x0=690;
76
   rect2_y0=frame_control->y1-81+3;
77
   rect2_x1=758;
78
   rect2_y1=frame_control->y1-81+2+6;
79
 
80
  while(1){
81
 
82
   sprintf(str,"AEREI:           %02d",aereo_count);
83
   grx_text(str,x0+2,y0+18,FAB_white,FAB_blue);
84
   grx_box(rect1_x0,rect1_y0,rect1_x1,rect1_y1,FRAME_CONTROL_BACK_COLOR);
85
   grx_box(rect1_x0,rect1_y0,
86
           rect1_x0+(rect1_x1-rect1_x0)*aereo_count/AEREO_N_MAX,rect1_y1,
87
           FAB_yellow);
88
   for (i=0; i<AEREO_N_MAX; i++){
89
     if (aereo_table[i].status)
90
         if (i==0) {
91
           sprintf(str,"HARD  vel=%04.1fkm/h",aereo_table[i].vel);
92
           grx_text(str,
93
                  x0+2,y0+28+8*i,
94
                  FAB_white,FRAME_CONTROL_BACK_COLOR);
95
           grx_box(x0+36,y0+29+8*i,
96
                 x0+45,y0+26+8*(i+1),
97
                 aereo_table[i].color);
98
           }
99
         else {
100
           sprintf(str,"Soft  vel=%04.1fkm/h",aereo_table[i].vel);
101
           grx_text(str,
102
                  x0+2,y0+28+8*i,
103
                  FAB_white,FRAME_CONTROL_BACK_COLOR);
104
           grx_box(x0+36,y0+29+8*i,
105
                 x0+45,y0+26+8*(i+1),
106
                 aereo_table[i].color);
107
           }
108
     else grx_text("                   ",
109
                  x0+2,y0+28+8*i,
110
                  FAB_white,FRAME_CONTROL_BACK_COLOR);
111
     }
112
 
113
   sprintf(str,"CANNONI:         %02d",cannone_count);
114
   grx_text(str,x0+2,frame_control->y1-81+2,FAB_white,FAB_blue);
115
   grx_box(rect2_x0,rect2_y0,rect2_x1,rect2_y1,FRAME_CONTROL_BACK_COLOR);
116
   grx_box(rect2_x0,rect2_y0,
117
           rect2_x0+(rect2_x1-rect2_x0)*cannone_count/CANNONE_N_MAX,rect2_y1,
118
           FAB_yellow);
119
 
120
   for (i=0; i<CANNONE_N_MAX; i++)
121
     if (cannone_table[i].status)  {
122
       if (cannone_table[i].fire) {
123
           if (i==0) {
124
             grx_text("                   ",x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
125
             sprintf(str,"HARD vel=%-5.1fkm/h",cannone_table[i].missile_vel);
126
             grx_text(str,x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
127
             }
128
           else {
129
             grx_text("                   ",x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
130
             sprintf(str,"Soft vel=%-5.1fkm/h",cannone_table[i].missile_vel);
131
             grx_text(str,x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
132
             }
133
           }
134
       else  {
135
           if (i==0) grx_text("HARD               ",x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
136
           else      grx_text("Soft               ",x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
137
           }
138
       }
139
     else grx_text("                   ",x0+2,frame_control->y1-81+12+8*i,FAB_white,FRAME_CONTROL_BACK_COLOR);
140
 
141
  task_endcycle();
142
  }
143
}