Subversion Repositories shark

Rev

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