Rev 1123 |
Rev 1589 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* Massimiliano Giorgi <massy@gandalf.sssup.it>
* Luca Abeni <luca@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
/* CVS : $Id: bca.c,v 1.5 2004-05-23 08:59:27 giacomo Exp $ */
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/****************************************************
* *
* file: bca.c *
* header file: bca.h *
* data: 15/09/2002 *
* creato da: Fabio CALABRESE *
* *
******************************************************
* *
* descrizione: e' il file in cui è descritto il task*
* main del programma S.Ha.R.K. *
* "(B)ase(C)ontr(A)rea". *
* Il codice del programma comprende *
* anche l'implementazione di altri task*
* distribuiti nei seguenti file che *
* quindi sono inclusi: *
* dummy.c *
* control.c *
* aereo.c *
* cannone.c *
* missile.c *
* esplo.c *
* Inoltre è incluso anche il file: *
* scenario.c *
* che descrive come disegnare lo *
* scenario grafico iniziale *
* *
******************************************************/
// *** Librerie S.Ha.R.K ***
#include <kernel/kern.h>
#include <ll/i386/cons.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_keyb26.h>
// *** Librerie Standard C ***
#include <stdlib.h>
// *** Librerie FAB ***
#include "fab_lib/fab_msg.h"
#include "fab_lib/fab_show.h"
#include "fab_lib/fab_tool.h"
#include "fab_lib/fab_grx.h"
// *** Librerie BCA ***
#include "bca.h"
char * titolo
[10];
void scenario
();
void info
();
#include"scenario.c"
PID crea_soft_dummy_radar
();
TASK dummy_radar
(void *);
#include"dummy.c"
PID crea_soft_control
();
TASK control
(void *);
#include"control.c"
PID crea_soft_aereo_creator
();
TASK aereo_creator
();
PID crea_hard_aereo
(int index
);
PID crea_soft_aereo
(int index
);
TASK aereo
(void * index
);
#include"aereo.c"
PID crea_soft_cannone_creator
();
TASK cannone_creator
();
PID crea_hard_cannone
(int index
);
PID crea_soft_cannone
(int index
);
TASK cannone
(void * index
);
#include"cannone.c"
PID crea_hard_missile
();
PID crea_soft_missile
();
TASK missile
();
#include"missile.c"
PID crea_soft_esplo
();
TASK esplo
(void *);
#include"esplo.c"
void end_fun
(KEY_EVT
* k
)
{ sys_shutdown_message
("Ending...\n");
sys_end
();
}
void incrementa_aerei_fun
(KEY_EVT
* k
)
{ if (aereo_count
<AEREO_N_MAX
) aereo_count
++;
}
void decrementa_aerei_fun
(KEY_EVT
* k
)
{ if (aereo_count
>AEREO_N_MIN
) aereo_count
--;
}
void incrementa_cannoni_fun
(KEY_EVT
* k
)
{ if (cannone_count
<CANNONE_N_MAX
) cannone_count
++;
}
void decrementa_cannoni_fun
(KEY_EVT
* k
)
{ if (cannone_count
>CANNONE_N_MIN
) cannone_count
--;
}
int main
(int argc
, char **argv
)
{
PID pid
;
KEY_EVT k
;
k.
flag = 0;
k.
scan = KEY_ENT
;
k.
ascii = 13;
k.
status = KEY_PRESSED
;
keyb_hook
(k
,end_fun
,FALSE
);
k.
flag = 0;
k.
scan = KEY_1
;
k.
ascii = '1';
k.
status = KEY_PRESSED
;
keyb_hook
(k
,incrementa_aerei_fun
,FALSE
);
k.
flag = 0;
k.
scan = KEY_2
;
k.
ascii = '2';
k.
status = KEY_PRESSED
;
keyb_hook
(k
,decrementa_aerei_fun
,FALSE
);
k.
flag = 0;
k.
scan = KEY_3
;
k.
ascii = '3';
k.
status = KEY_PRESSED
;
keyb_hook
(k
,incrementa_cannoni_fun
,FALSE
);
k.
flag = 0;
k.
scan = KEY_4
;
k.
ascii = '4';
k.
status = KEY_PRESSED
;
keyb_hook
(k
,decrementa_cannoni_fun
,FALSE
);
/* inizializza il mutex grafico */
app_mutex_init
(&grx_mutex
);
scenario
();
//---init---
srand(sys_gettime
(NULL
));
aereo_count
= AEREO_N_MIN
;
cannone_count
= CANNONE_N_MIN
;
pid
=crea_soft_dummy_radar
();
task_activate
(pid
);
pid
=crea_soft_aereo_creator
();
task_activate
(pid
);
pid
=crea_soft_cannone_creator
();
task_activate
(pid
);
pid
=crea_soft_control
();
task_activate
(pid
);
//----------
return 0;
}