/demos/tags/rel_1_21/servo/makefile |
File deleted |
|
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: rel_1_21/servo/servo.c |
=================================================================== |
--- rel_1_21/servo/servo.c (revision 1217) |
+++ rel_1_21/servo/servo.c (nonexistent) |
@@ -1,131 +0,0 @@ |
-#include "kernel/kern.h" |
- |
-#include "drivers/keyb.h" |
- |
-#include "servo.h" |
-#include "leg.h" |
- |
-int main () { |
- |
- int res; |
- char ch; |
-/* |
- servo_open(SERVO_COM2); |
- |
- cprintf("servo_set_RS232_baudrate\n"); |
- res = servo_set_RS232_baudrate(9600); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_get_RS232_baudrate\n"); |
- res = servo_get_RS232_baudrate(); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_store_RS232_baudrate\n"); |
- res = servo_store_RS232_baudrate(); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_set_period\n"); |
- res = servo_set_period(20000); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_get_period\n"); |
- res = servo_get_period(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_store_period\n"); |
- res = servo_store_period(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_get_setup_switch\n"); |
- res = servo_get_setup_switch(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_set_RC5_switch\n"); |
- res = servo_set_RC5_switch(1); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_off\n"); |
- res = servo_turn_off(1); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_on\n"); |
- res = servo_turn_on(1); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_off_all\n"); |
- res = servo_turn_off_all(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_on_all\n"); |
- res = servo_turn_on_all(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_set_levels\n"); |
- res = servo_set_levels(0x00,0x01); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_get_levels\n"); |
- res = servo_get_levels(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_store_levels\n"); |
- res = servo_store_levels(); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(0,ANGLE2SEC(45,0,0)); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(0); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_get_angle_sec\n"); |
- res = servo_get_angle_sec(0); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_get_analog\n"); |
- res = servo_get_analog(0); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- servo_close(); |
-*/ |
- set_leg_position(8.0,-5.0,0.0); |
- set_leg_position(8.0,0.0,0.0); |
- |
- return 0; |
- |
-} |
- |
Index: rel_1_21/servo/initfile.c |
=================================================================== |
--- rel_1_21/servo/initfile.c (revision 1217) |
+++ rel_1_21/servo/initfile.c (nonexistent) |
@@ -1,83 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- //CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- //KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
/rel_1_21/servo/initfile.c |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: rel_1_21/servo/leg.c |
=================================================================== |
--- rel_1_21/servo/leg.c (revision 1217) |
+++ rel_1_21/servo/leg.c (nonexistent) |
@@ -1,63 +0,0 @@ |
-#include <kernel/kern.h> |
-#include <math.h> |
- |
-#include "servo.h" |
- |
-#define LEG_A 10.0 |
-#define LEG_B 10.0 |
- |
-const double c0 = LEG_A * LEG_A; |
-const double c1 = LEG_A * LEG_A - LEG_B * LEG_B; |
-const double todeg = 180.0 / PI; |
- |
-int set_leg_position(double px, double py, double pz) |
-{ |
- |
- double px2 = px * px; |
- double py2 = py * py; |
- double pz2 = pz * pz; |
- |
- double pxz2 = pz2 + px2; |
- double gamma1 = asin(pz/sqrt(pxz2)) * todeg; |
- |
- double s = pxz2 + py2; |
- double k = c1 + s; |
- double k2 = k * k; |
- |
- double delta_xy = py2 * k2 - s * (k2 - 4.0 * pxz2 * c0); |
- double y1,dsqrt; |
- double alfa1,beta1,alfa2,beta2; |
- int alfa = 0, beta = 0, gamma = 0; |
- |
- if (delta_xy >= 0.0) { |
- dsqrt = sqrt(delta_xy); |
- y1 = (py * k + dsqrt) / (2.0 * s); |
- alfa1 = asin(y1/LEG_A) * todeg; |
- beta1 = asin((y1 - py)/LEG_B) * todeg + alfa1; |
- y1 = (py * k - dsqrt) / (2.0 * s); |
- alfa2 = asin(y1/LEG_A) * todeg; |
- beta2 = asin((y1 - py)/LEG_B) * todeg + alfa2; |
- cprintf("Alfa1 = %d Beta1 = %d\n",(int)alfa1,(int)beta1); |
- cprintf("Alfa2 = %d Beta2 = %d\n",(int)alfa2,(int)beta2); |
- if ((alfa1 >= -90.0 && alfa1 <= 90.0) && (beta1 >= 0.0 && beta1 <= 180.0)) { |
- alfa = (int)(alfa1 * 3600.0); |
- beta = (int)(beta1 * 3600.0); |
- gamma = (int)(gamma1 * 3600.0); |
- cprintf("Alfa Sec = %d Beta Sec = %d Gamma Sec = %d\n",alfa,beta,gamma); |
- return 0; |
- } else if ((alfa2 >= -90.0 && alfa2 <= 90.0) && (beta2 >= 0.0 && beta2 <= 180.0)) { |
- alfa = (int)(alfa2 * 3600.0); |
- beta = (int)(beta2 * 3600.0); |
- gamma = (int)(gamma1 * 3600.0); |
- cprintf("Alfa Sec = %d Beta Sec = %d Gamma Sec = %d\n",alfa,beta,gamma); |
- return 0; |
- } else { |
- cprintf("No possible !\n"); |
- return 1; |
- } |
- } else { |
- cprintf("No possible !\n"); |
- return 1; |
- } |
- |
-} |
Index: rel_1_21/telesco/makefile |
=================================================================== |
--- rel_1_21/telesco/makefile (revision 1217) |
+++ rel_1_21/telesco/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= tel |
- |
-include $(BASE)/config/example.mk |
- |
-tel: |
- make -f $(SUBMAKE) APP=tel INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: rel_1_21/telesco/moon.h |
=================================================================== |
--- rel_1_21/telesco/moon.h (revision 1217) |
+++ rel_1_21/telesco/moon.h (nonexistent) |
@@ -1,43 +0,0 @@ |
-// Immagine luna |
-BYTE luna[900]={ |
-0, 0 , 0, 0, 0, 0, 0, 0, 4, 57, 212, 228, 204, 214, 235, 237, 208, 190, 179, 197, 229, 89, 4, 0, |
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 208, 213, 178, 155, 139, 129, 123, 169, 170, 173, 157, |
-191, 209, 236, 215, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 36, 103, 146, 116, 93, 143, 119, 96, |
-134, 123, 117, 120, 113, 102, 93, 156, 210, 184, 66, 4, 0, 0, 0, 0, 0, 0, 0, 0, 2, 64, 83, 88, |
-72, 156, 144, 127, 99, 87, 91, 156, 158, 124, 144, 120, 109, 119, 175, 167, 180, 119, 3, 0, |
-0, 0, 0, 0, 0, 5, 56, 59, 63, 58, 138, 104, 71, 46, 55, 68, 79, 89, 172, 146, 141, 152, 110, 126, |
-134, 179, 148, 145, 134, 4, 0, 0, 0, 0, 4, 32, 58, 50, 49, 56, 105, 58, 38, 42, 45, 69, 64, 93, |
-144, 155, 157, 147, 95, 111, 122, 158, 162, 174, 171, 79, 4, 0, 0, 0, 4, 67, 49, 47, 54, 63, |
-51, 55, 43, 38, 48, 62, 55, 86, 89, 145, 92, 60, 99, 72, 97, 130, 184, 169, 195, 171, 3, 0, 0, |
-3, 77, 52, 37, 51, 72, 54, 63, 48, 46, 46, 48, 55, 54, 92, 95, 80, 55, 47, 47, 52, 56, 170, 187, |
-196, 190, 177, 190, 6, 0, 45, 84, 38, 40, 79, 73, 56, 43, 41, 46, 45, 51, 74, 98, 89, 68, 89, |
-46, 40, 48, 45, 38, 171, 176, 152, 165, 133, 157, 107, 3, 154, 42, 34, 42, 68, 66, 47, 52, 62, |
-55, 60, 50, 56, 50, 106, 127, 74, 38, 39, 58, 38, 42, 116, 87, 128, 148, 69, 59, 170, 2, 100, |
-41, 31, 38, 41, 53, 53, 62, 63, 64, 62, 65, 63, 58, 105, 71, 60, 57, 44, 43, 38, 36, 81, 58, 125, |
-205, 61, 43, 130, 37, 88, 39, 31, 33, 43, 52, 76, 66, 97, 116, 101, 96, 90, 56, 76, 47, 43, 135, |
-46, 87, 40, 30, 33, 37, 84, 152, 86, 43, 131, 81, 131, 36, 35, 33, 36, 53, 91, 73, 124, 145, |
-132, 95, 80, 50, 45, 45, 35, 49, 70, 59, 32, 30, 30, 30, 39, 75, 158, 92, 133, 138, 151, 41, |
-39, 38, 39, 82, 125, 59, 89, 98, 84, 64, 68, 40, 104, 107, 85, 78, 115, 75, 34, 43, 39, 36, 47, |
-78, 98, 142, 104, 122, 155, 49, 32, 36, 32, 57, 71, 58, 85, 97, 69, 49, 53, 40, 88, 124, 133, |
-169, 141, 94, 40, 40, 46, 53, 52, 81, 49, 77, 107, 122, 146, 79, 31, 38, 31, 37, 37, 51, 64, |
-59, 84, 72, 64, 96, 88, 132, 153, 158, 154, 149, 140, 109, 77, 125, 120, 54, 51, 59, 123, 86, |
-111, 122, 35, 44, 35, 34, 38, 63, 55, 55, 87, 76, 103, 133, 148, 146, 160, 151, 145, 163, 194, |
-92, 104, 136, 109, 54, 46, 65, 123, 53, 160, 144, 56, 46, 41, 39, 39, 91, 41, 47, 70, 75, 57, |
-112, 116, 140, 168, 179, 161, 164, 188, 123, 100, 145, 162, 87, 51, 111, 140, 5, 172, 148, |
-134, 86, 72, 75, 48, 50, 40, 45, 53, 106, 60, 108, 137, 135, 160, 157, 152, 169, 179, 191, |
-109, 70, 150, 122, 94, 104, 128, 4, 167, 144, 140, 103, 98, 116, 64, 56, 84, 62, 60, 59, 48, |
-80, 150, 143, 151, 187, 161, 147, 178, 219, 79, 69, 163, 132, 87, 108, 128, 0, 83, 195, 195, |
-125, 138, 67, 35, 106, 98, 90, 58, 44, 60, 131, 161, 152, 178, 157, 149, 164, 164, 177, 107, |
-119, 129, 119, 145, 133, 104, 0, 5, 181, 233, 190, 150, 78, 43, 62, 63, 87, 50, 53, 46, 81, |
-157, 187, 155, 181, 189, 145, 166, 211, 170, 137, 166, 189, 188, 164, 5, 0, 0, 5, 167, 175, |
-193, 193, 108, 114, 63, 118, 139, 125, 130, 202, 209, 221, 213, 180, 172, 201, 170, 175, |
-186, 177, 210, 236, 204, 14, 0, 0, 0, 3, 62, 166, 183, 166, 106, 139, 102, 129, 179, 206, 212, |
-240, 232, 224, 210, 208, 196, 173, 179, 177, 186, 191, 227, 185, 100, 2, 0, 0, 0, 0, 5, 125, |
-196, 143, 163, 169, 169, 152, 181, 212, 239, 241, 237, 234, 217, 180, 206, 188, 199, 188, |
-194, 202, 164, 120, 4, 0, 0, 0, 0, 0, 0, 5, 123, 180, 145, 147, 184, 184, 197, 223, 232, 224, |
-227, 227, 220, 190, 179, 192, 192, 197, 204, 165, 120, 4, 0, 0, 0, 0, 0, 0, 0, 0, 5, 74, 162, |
-135, 153, 176, 178, 204, 235, 232, 235, 231, 212, 201, 190, 189, 196, 202, 189, 70, 4, 0, |
-0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 182, 167, 170, 184, 208, 218, 215, 206, 209, 179, 205, 196, 188, |
-184, 193, 12, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 103, 202, 197, 201, 208, 235, 217, 203, |
-197, 188, 185, 217, 131, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 89, 130, 218, |
-195, 179, 165, 102, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
Index: rel_1_21/telesco/initfile.c |
=================================================================== |
--- rel_1_21/telesco/initfile.c (revision 1217) |
+++ rel_1_21/telesco/initfile.c (nonexistent) |
@@ -1,133 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: initfile.c,v 1.1 2003-06-04 09:41:01 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-04 09:41:01 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-int argc; |
-char *argv[100]; |
- |
-void read_cfg_file(int argc, char **argv); |
- |
-int main(int argc, char **argv); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- __compute_args__(mb, &argc, argv); |
- |
- read_cfg_file(argc, argv); |
- |
- //read_cfg_file(argc, argv); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- //__call_main__(mb); |
- return (void *)main(argc,argv); |
- //return (void *)0; |
-} |
- |
Index: rel_1_21/telesco/tel.c |
=================================================================== |
--- rel_1_21/telesco/tel.c (revision 1217) |
+++ rel_1_21/telesco/tel.c (nonexistent) |
@@ -1,709 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Bera Marco mbera@libero.it |
- * Varasio Gabriele varasio@odino.unipv.it |
- * |
- * Universita' degli studi di Pavia |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: tel.c,v 1.1 2003-06-04 09:41:01 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-04 09:41:01 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * 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 |
- * |
- */ |
- |
-/****************************************************************/ |
-/* PERIODIC PROCESS TEST */ |
-/****************************************************************/ |
- |
-#include <ll/i386/x-dos.h> |
-#include <kernel/kern.h> |
-#include <modules/cabs.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <math.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include "moon.h" |
- |
- |
-#define N_MAX_TELESCOPI 5 |
-#define X0 10 |
-#define pi 3.14 |
-#define ex 2.71 |
-#define NCAB N_MAX_TELESCOPI+1 |
-#define dim_msg 8 |
-#define dim_x 49 |
-#define dim_y 49 |
-#define radius 9 |
-#define Y_TELESCOPI 300 |
-/* task periods */ |
-#define PERIOD_T1 80000 |
-#define PERIOD_T4 100000 |
-#define PERIOD_T5 100000 |
-#define WCET_T 5000 |
-int period_t1=0; |
-#define SOGLIA 8 |
- |
-char *cname[NCAB] = {"cab1", "cab2", "cab3", "cab4","cab5","cab6"}; |
- |
-// posizioni dei telescopi e rispettivi poli |
- |
-int x[5] = {100, 200, 300, 400,500}; |
-//double poli[5]={-50,-30,-1, -20, -5}; |
-double poli[5]; |
-// guadagno proporzionale |
-double kp=0.0; |
-// flag per rilevare la pressione del tasto spazio |
-int numero_telescopi=0; |
-int flag=0; |
-KEY_EVT move_tasto; |
-// Immagini ausiliarie per il disegno della luna |
-BYTE lunabkg[900]; |
-BYTE lunadest[900]; |
- |
- |
-/* A semaphore used to access Video Cards in mutual exclusion */ |
-sem_t mutex; |
-sem_t mutex_tasto; |
- |
-/***************************************************************/ |
- |
-// cab necessari allo scambio delle coordinate dell'oggetto e delle |
-// immagini dei rispettivi telescopi |
- |
-CAB cid[NCAB]; |
- |
-// vettori per memorizzare le immagini |
-BYTE videobuf[dim_x*dim_y]; |
-BYTE videobuf1[dim_x*dim_y]; |
-BYTE videobuf2[dim_x*dim_y]; |
-BYTE videobuf3[dim_x*dim_y]; |
-BYTE videobuf4[dim_x*dim_y]; |
-BYTE videobuf5[dim_x*dim_y]; |
- |
- // Variabili per il disegno delle stelle sullo sfondo |
- int num_p; |
- int y_p[7]; |
- int x_p[7]; |
- int dim_p[7]; |
- int col_p[7]; |
- |
- |
- |
-TASK media(void *arg) |
-{ |
-char *p; |
- |
-int i=0; |
-int j=0; |
-while(1) |
-{ |
- p = cab_getmes(cid[1]); |
- memcpy(videobuf,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[1], p); |
- p = cab_getmes(cid[2]); |
- memcpy(videobuf1,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[2], p); |
- p = cab_getmes(cid[3]); |
- memcpy(videobuf2,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[3], p); |
- p = cab_getmes(cid[4]); |
- memcpy(videobuf4,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[4], p); |
- |
- p = cab_getmes(cid[5]); |
- memcpy(videobuf5,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[5], p); |
- |
- // calcolo media |
- |
- for (i=0;i<dim_x;i++) |
- |
- { |
- for(j=0;j<dim_y;j++) |
- { |
- videobuf3[i*dim_x+j]=(double)(videobuf[i*dim_x+j]+videobuf1[i*dim_x+j]+videobuf2[i*dim_x+j]+videobuf4[i*dim_x+j]+videobuf5[i*dim_x+j])/numero_telescopi; |
- } |
- } |
- |
- // visualizza immagine mediata |
- sem_wait(&mutex); |
- grx_putimage(570,10,570+dim_x-1,10+dim_y-1,videobuf3); |
- sem_post(&mutex); |
- task_endcycle(); |
- } |
-} |
- |
-TASK move(void *arg) |
-{ |
-//int i = (int)arg; |
-char *p; |
-int x_object=300; // posizione dell'oggetto da rilevare |
-int y_object=200; |
-// variabile contatore |
-int z=0; |
-char coord_x[dim_msg]; |
-p = cab_reserve(cid[0]); |
-sprintf(coord_x,"%d %d",x_object,y_object); |
-memcpy(p,coord_x,dim_msg*sizeof(char)); |
-cab_putmes(cid[0], p); |
- |
- //Normalizzazione |
- for(z=0;z<900;z++) |
- { |
- if (luna[z]>0) |
- { |
- luna[z]=((luna[z])*16.0/255.0)+16; |
- } |
- |
- } |
- |
- |
- task_endcycle(); |
- while (1) |
- { |
- |
- // Cancellazione Luna |
- sem_wait(&mutex); |
- grx_box(x_object-15,y_object-15,x_object+14,y_object+14,0); |
- sem_post(&mutex); |
- if (keyb_getcode(&move_tasto,NON_BLOCK)) |
- { |
- if (move_tasto.ascii=='4') |
- x_object=x_object-5; |
- if (move_tasto.ascii=='6') |
- x_object=x_object+5; |
- if (move_tasto.ascii=='2') |
- y_object=y_object+5; |
- if (move_tasto.ascii=='8') |
- y_object=y_object-5; |
- if (move_tasto.ascii=='9'){ |
- y_object=y_object-5; |
- x_object=x_object+5; } |
- if (move_tasto.ascii=='1'){ |
- y_object=y_object+5; |
- x_object=x_object-5; } |
- if (move_tasto.ascii=='7'){ |
- y_object=y_object-5; |
- x_object=x_object-5; } |
- if (move_tasto.ascii=='3'){ |
- y_object=y_object+5; |
- x_object=x_object+5;} |
- if (move_tasto.ascii==' '){ |
- sem_wait(&mutex_tasto); |
- flag=1; |
- if(numero_telescopi<N_MAX_TELESCOPI) |
- { |
- numero_telescopi++; |
- } |
- sem_post(&mutex_tasto); |
- } |
- //CONTROLLI SULLA POSIZIONE |
- if(y_object<(dim_y/2+70)) y_object=dim_y/2+70; |
- if(y_object>(240-dim_y/2)) y_object=(240-dim_y/2); |
- if(x_object<(dim_x/2+20 )) x_object=dim_x/2+20; |
- if(x_object>(630-dim_x/2-10)) x_object=(630-dim_x/2-10); |
- } |
- p = cab_reserve(cid[0]); |
- sprintf(coord_x,"%d %d",x_object,y_object); |
- memcpy(p,coord_x,dim_msg*sizeof(char)); |
- cab_putmes(cid[0], p); |
- |
- for(z=0;z<7;z++) |
- { |
- if (sqrt(pow((x_object-x_p[z]),2)+pow((y_object-y_p[z]),2))<20+dim_p[z]+radius) |
- grx_disc(x_p[z],y_p[z],dim_p[z],col_p[z]); |
- } |
- |
- |
- sem_wait(&mutex); |
- // Gestione sfondo |
- grx_getimage(x_object-15,y_object-15,x_object+14, y_object+14,lunabkg); |
- for(z=0;z<900;z++) |
- { |
- if( luna[z]==0 && lunabkg!=0 ) |
- { |
- lunadest[z]=lunabkg[z]; |
- } |
- else |
- { |
- lunadest[z]=luna[z]; |
- } |
- } |
- grx_putimage(x_object-15,y_object-15,x_object+14, y_object+14,lunadest); |
- sem_post(&mutex); |
- task_endcycle(); |
- } |
-} |
- |
- |
-TASK tele(void *arg) |
-{ |
-int i = (int)arg; |
-int passi; |
-char s[100]; |
-int x_object=300; // posizione dell'oggetto da rilevare |
-int y_object=200; |
-int x_start=500; // posizione iniziale dei telescopi |
-int y_start=190; |
-int x_current=x_start; // posizione corrente dei telescopi |
-int y_current=y_start; |
-int x_current_d[9]; |
-int y_current_d[9]; |
-int y= Y_TELESCOPI; // coordinata y dei telescopi |
-double alpha_new=atan((y-(double)y_current)/((x[i]-(double)x_current))); |
-double alpha=alpha_new; |
-double distance=0.0; |
-double alpha_target=0.0; |
-double tc=0.1; |
-double u=0.0; |
-double u_old=0.0; |
-double errore=0.0; |
-double delta_x=0; |
-double delta_y=0; |
- |
-char *p; |
-//int j=0; |
-// indice matrice per aggiunta di rumore |
-int k=0; |
-int q=0; |
-double polo=poli[i]; |
-int val=0; |
- |
- |
- |
-BYTE videobuf[dim_x*dim_y]; |
- |
- passi = 0; |
- //srand(i); |
- //srand(i+sys_gettime(NULL)); |
- alpha_target=atan((y-(double)y_object)/((double)x_object-x[i])); |
- |
- sem_wait(&mutex); |
- grx_text("targ",4,340,12,0); |
- sprintf(s,"%f",poli[i]); |
- grx_text(s,x[i],y+60,12,0); |
- grx_text("polo",4,y+60,12,0); |
- grx_text("new",4,y+50,12,0); |
- sprintf(s,"%1.6f",alpha_target); |
- grx_text(s, x[i]-25,y+50,12,0); |
- grx_rect(x[i]-40,y+25,x[i]+40,y+85,2); |
- grx_rect(x[i]-40,y+90,x[i]+40,y+150,2); |
- sem_post(&mutex); |
- |
- // Disegno telescopio |
- grx_disc(x[i],y,19,i+1); |
- grx_box( x[i]-19,y,x[i]+19,y+20,i+1); |
- |
- |
- task_endcycle(); |
- |
- while (1) { |
- // legge di controllo |
- passi++; |
- //sprintf(s,"%d",passi); |
- //grx_text(s, 50,110,12,0); |
- p = cab_getmes(cid[0]); |
- sscanf(p,"%d %d",&val,&y_object); |
- cab_unget(cid[0], p); |
- x_object=val; |
- alpha_target=atan((y-(double)y_object)/((double)x_object-x[i])); |
- if (alpha_target <0) |
- { |
- alpha_target=3.14+alpha_target; |
- } |
- |
- errore=alpha_target-alpha_new; |
- u=u_old+kp*tc*errore; |
- //alpha_new=0.13*alpha+0.87*u; |
- alpha_new=(exp(polo*tc))*alpha+(1-exp(polo*tc))*u; |
- u_old=u; |
- alpha=alpha_new; |
- |
- // implementazione dei limiti degli attuattori |
- if (alpha_new > 3.14) |
- alpha_new=3.14; |
- if (alpha_new <0) |
- alpha_new=0; |
- |
- distance=sqrt(((y-y_object)*(y-y_object))+((x_object-x[i])*(x_object-x[i]))); |
- |
- sem_wait(&mutex); |
- // Cancello braccio telescopio |
- if (passi>1) |
- { |
- for (k=0; k<9 ; k++) |
- { |
- grx_line(delta_x,delta_y,x_current_d[k],y_current_d[k],0); |
- } |
- } |
- x_current=x[i]+distance*cos(alpha_new); |
- y_current=300-distance*sin(alpha_new); |
- |
- // lettura immagine |
- |
- grx_getimage(x_current-(dim_x/2),y_current-(dim_y/2),x_current+(dim_x/2),y_current+(dim_y/2),videobuf); |
- |
- //aggiunta rumore |
- |
- sem_post(&mutex); |
- for (k=0;k<dim_x;k++) |
- { |
- for(q=0;q<dim_y;q++) |
- { |
- int num=0; |
- num=rand(); |
- num=(num%10)+1; |
- if (num>SOGLIA) |
- { |
- videobuf[k*dim_x+q]=videobuf[k*dim_x+q]+1; |
- } |
- } |
- } |
- sem_wait(&mutex); |
- |
- grx_putimage(x[i]-25,y+92,x[i]-25+dim_x-1,y+92+dim_y-1,videobuf); |
- |
- sprintf(s,"%3.4f",(180*(alpha_target/pi))); |
- grx_text(s, x[i]-25,y+40,12,0); |
- sprintf(s,"%3.4f",180*(alpha_new/pi)); |
- grx_text(s, x[i]-25,y+50,12,0); |
- |
- delta_x=x[i]+20*cos(alpha_new); |
- delta_y=y-20*sin(alpha_new); |
- |
- for ( k=0; k<9 ; k++) { |
- x_current_d[k]=x[i]+50*cos(alpha_new+(k-4)*0.01); |
- y_current_d[k]=300-50*sin(alpha_new+(k-4)*0.01); } |
- |
- // Disegno braccio telescopio |
- for(k=0 ; k<9 ; k++) |
- grx_line(delta_x,delta_y,x_current_d[k],y_current_d[k],i+1); |
- |
- sem_post(&mutex); |
- |
- // scrive immagine nel cab |
- p = cab_reserve(cid[i+1]); |
- memcpy(p,videobuf,dim_x*dim_y*sizeof(BYTE)); |
- cab_putmes(cid[i+1], p); |
- |
- task_endcycle(); |
- |
- } |
- |
-} |
- |
- |
-/****************************************************************/ |
- |
-/* This is the exception handler. It is called when an exception |
- is raised. |
- It exits from the graphical mode, then it prints a message and |
- shutdown the kernel using sys_abort() |
-*/ |
- |
-void demo_exc_handler(int signo, siginfo_t *info, void *extra) |
-{ |
- struct timespec t; |
- |
- grx_close(); |
- |
- /* Default action for an kern exception is */ |
- kern_cli(); |
- ll_gettime(TIME_EXACT, &t), |
- kern_printf("\nS.Ha.R.K. Exception raised!!!" |
- "\nTime (s:ns) :%ld:%ld" |
- "\nException number:%d (numbers in include/bits/errno.h)" |
- "\nPID :%d\n", |
- t.tv_sec, t.tv_nsec, info->si_value.sival_int, |
- info->si_task); |
- sys_abort(1); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
- It simply shutdown the system using sys_end. |
- Note that the byebye() function is called only if we exit from |
- the system using sys_end()!!!! |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
-void byebye(void *arg) |
-{ |
- grx_close(); |
- kern_printf("Bye Bye!\n"); |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- PID pid1, pid4,pid5; |
- KEY_EVT emerg; |
- int i=0; |
- int z=0; // contatore per disegno dei pianeti |
- HARD_TASK_MODEL m1, m4,m5; |
- //FILE *fp; |
- |
- struct sigaction action; |
- |
- cid[0] = cab_create(cname[0], dim_msg, 5); |
- cid[1] = cab_create(cname[1], dim_x*dim_y, 3); |
- cid[2] = cab_create(cname[2], dim_x*dim_y, 3); |
- cid[3] = cab_create(cname[3], dim_x*dim_y, 3); |
- cid[4] = cab_create(cname[4], dim_x*dim_y, 4); |
- cid[5] = cab_create(cname[5], dim_x*dim_y, 3); |
- cid[6] = cab_create(cname[6], dim_x*dim_y, 3); |
- |
- /*fp=fopen("file.txt","r"); |
- fscanf(fp,"%d",a); |
- fclose(fp); |
- */ |
- |
- /* Init the standard S.Ha.R.K. exception handler */ |
- action.sa_flags = SA_SIGINFO; /* Set the signal action */ |
- action.sa_sigaction = demo_exc_handler; |
- action.sa_handler = 0; |
- sigfillset(&action.sa_mask); /* we block all the other signals... */ |
- |
- if (sigaction(SIGHEXC, &action, NULL) == -1) { /* set the signal */ |
- perror("Error initializing signals..."); |
- sys_end(); |
- } |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT|NO_AT_ABORT); |
- |
- /* Initializes the semaphore */ |
- sem_init(&mutex,0,1); |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 8) < 0) { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- kern_printf("Video card ok!\n"); |
- |
- |
- |
- /* set the keyboard handler to exit correctly */ |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,my_end); |
- |
- srand(i+sys_gettime(NULL)); |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTR_BIT; |
- keyb_hook(emerg,my_end); |
- sem_wait(&mutex); |
- /* a small banner */ |
- grx_clear(0); |
- |
- grx_text("REALTIME TELESCOPES di Marco Bera e Gabriele Varasio",8,8,WHITE,0); |
- grx_text("Premere Spazio per creare un telescopio",8,22,WHITE,0); |
- grx_text("Premere Alt-X per uscire",8,32,WHITE,0); |
- grx_text("Usare il tastierino numerico per muovere l'oggetto",8,42,WHITE,0); |
- |
- // DISEGNARE BORDI |
- grx_rect(1,1,638,478,2); |
- grx_rect(558,1,638,61,2); |
- grx_rect(1,1,638,61,2); |
- |
- |
- // Disegno sfondo |
- for(z=0;z<7;z++) |
- { |
- num_p=rand(); |
- y_p[z]=100+((num_p%130)+1); |
- x_p[z]=50+((num_p%540)+1); |
- dim_p[z]=2+((num_p%5)+1); |
- col_p[z]=((num_p%10)+1); |
- grx_disc(x_p[z],y_p[z],dim_p[z],col_p[z]); |
- } |
- sem_post(&mutex); |
- |
- |
- hard_task_default_model(m4); |
- hard_task_def_ctrl_jet (m4); |
- hard_task_def_arg (m4, (void *)3); |
- hard_task_def_wcet (m4, 19000); |
- hard_task_def_mit (m4, PERIOD_T4); |
- hard_task_def_group (m4,1); |
- pid4 = task_create("move", move, &m4, NULL); |
- if (pid4 == NIL) { |
- grx_close(); |
- perror("Could not create task <move>"); |
- sys_abort(1); |
- } |
- task_activate(pid4); |
- hard_task_default_model(m5); |
- hard_task_def_ctrl_jet (m5); |
- hard_task_def_arg (m5, (void *)3); |
- hard_task_def_wcet (m5, 19000); |
- hard_task_def_mit (m5, PERIOD_T5); |
- hard_task_def_group (m5,1); |
- pid5 = task_create("media", media, &m5, NULL); |
- |
- if (pid5 == NIL) { |
- grx_close(); |
- perror("Could not create task <move>"); |
- sys_abort(1); |
- } |
- task_activate(pid5); |
- /* and finally we activate the three threads... */ |
- |
- |
- |
- do { |
- int val_flag=0; |
- sem_wait(&mutex_tasto); |
- val_flag=flag; |
- sem_post(&mutex_tasto); |
- |
- if ((val_flag==1) && (i < N_MAX_TELESCOPI)) |
- { |
- flag=0; |
- hard_task_default_model(m1); |
- hard_task_def_ctrl_jet (m1); |
- hard_task_def_arg (m1, (void *)i); |
- hard_task_def_wcet (m1, WCET_T); |
-// hard_task_def_mit (m1, PERIOD_T1); |
- hard_task_def_mit (m1, period_t1); |
- |
- hard_task_def_group (m1,1); |
- pid1 = task_create("tele1", tele, &m1, NULL); |
- if (pid1 == NIL) |
- { |
- grx_close(); |
- perror("Could not create task <tele1>"); |
- sys_abort(1); |
- } |
- task_activate(pid1); |
- i++; |
- } |
- } while (1); |
- |
- /* |
- now the task main ends, but the system does not shutdown because |
- there are others. |
- |
- The demo will finish if a Alt-X key is pressed. |
- */ |
- |
- return 0; |
-} |
-/*********** lettura da file ********************/ |
-void read_cfg_file(int argc, char **argv) |
-{ |
- int err; |
- DOS_FILE *fp; |
- char myfilebuf[1000]; |
- int myfilebuf_length; |
- |
- |
- |
- if (2) |
- { |
- fp = DOS_fopen("dati.cnf","r"); |
- |
- if (fp) |
- { |
- /* read up to 1000 chars */ |
- myfilebuf_length = DOS_fread(&myfilebuf,1,1000,fp); |
- |
- /* check for errors */ |
- err = DOS_error(); |
- |
- cprintf("Read %d bytes...\n", myfilebuf_length); |
- |
- if (err) |
- { |
- cprintf("Error %d reading file...Using default values\n", err); |
- } |
- else |
- { |
- //geti(myfilebuf, &pos, &NMouses); // Number of Mouses |
- sscanf(myfilebuf,"%lf %lf %lf %lf %lf %lf %d",&poli[0],&poli[1],&poli[2],&poli[3],&poli[4],&kp,&period_t1); |
- } |
- |
- DOS_fclose(fp); |
- return; |
- |
- } |
- else { |
- /* error!! */ |
- err = DOS_error(); |
- /* note that if you call DOS_error() here, it return 0!!! */ |
- cprintf("Error %d opening myfile.txt...Using default values\n", err); |
- } |
- |
- } |
- else { |
- cprintf("Wrong number of arguments...\n"); |
- l1_exit(0); |
- } |
-} |
- |
- |
-/****************************************************************/ |
Index: rel_1_21/telesco/dati.cnf |
=================================================================== |
--- rel_1_21/telesco/dati.cnf (revision 1217) |
+++ rel_1_21/telesco/dati.cnf (nonexistent) |
@@ -1,3 +0,0 @@ |
--1 -20 -30 -40 -50 0.5 100000 |
-# 5 poli kp(guadagno) periodo telescopio |
- |
Index: rel_1_21/autostr/autostr.c |
=================================================================== |
--- rel_1_21/autostr/autostr.c (revision 1217) |
+++ rel_1_21/autostr/autostr.c (nonexistent) |
@@ -1,1171 +0,0 @@ |
-/*************************************************************************** |
- ************************************************************************** |
- *** Universita' di Pavia *** |
- *** Corso : Informatoca Industriale *** |
- ************************************************************************** |
- *** Progetto : MONITORAGGIO AUTOSTRADA *** |
- ************************************************************************** |
- *** Realizzato da : Nino Verzellesi e Quadrubbi Giacomo *** |
- ************************************************************************** |
- ***************************************************************************/ |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include <math.h> |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/********************* DEFINIZIONE DELLE COSTANTI **************************/ |
- |
-#define ESC 27 /* codice ASCII del tasto ESCAPE */ |
-#define MAX_V 35 /* massimo numero di veicoli */ |
-#define GRUPPO 1 |
-#define LUNGCAMION 40 /* lunghezza del camion */ |
-#define LARGCAMION 10 /* larghezza del camion */ |
-#define LUNGLENTA 16 /* lunghezza della macchina lenta */ |
-#define LARGLENTA 8 /* larghezza della macchina lenta */ |
-#define LUNGVELOCE 20 /* lunghezza della macchina veloce */ |
-#define LARGVELOCE 8 /* larghezza della macchina veloce */ |
-#define DT 0.04 /* passo del campionamento */ |
-#define CENTROCORSIA1 477 /* coordinata del centro della corsia 1 */ |
-#define CENTROCORSIA2 459 /* coordinata del centro della corsia 2 */ |
-#define CENTROCARREGGIATA 469 /* coordinata del centro della carreggiata */ |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/****************** DEFINIZIONE DELLE VARIABILI GLOBALI ********************/ |
- |
-double tick = 1.0; /* system tick = 1 ms */ |
-int periodo = 40000; /* periodo */ |
-int wcet = 1000; /* deadline */ |
-PID pid; |
-sem_t mutex; /* semaforo per la grafica */ |
-sem_t strada; /* semaforo per le variabili corsia1 e corsia2 */ |
-int MAX_X; /* dimensione x della modalita' di visualizzazione dello schermo */ |
-int MAX_Y; /* dimensione y della modalita' di visualizzazione dello schermo */ |
-short corsia1[40000]; /* vettore della corsia1 */ |
-short corsia2[40000]; /* vettore della corsia2 */ |
-int xelic; /* cordinata dell'elicottero */ |
-char c; /* carattere da tastiera */ |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/****************** FUNZIONE CHE DISEGNA I VEICOLI *************************/ |
- |
-void draw_veicolo(int x, int y, int colore,int lunghezza,int larghezza) |
-{ |
- int u; /* indice di ciclo */ |
- int v; /* variabile ausiliaria per la ricostruzione della segnaletica */ |
- int xreal; /* coordinata di fine veicolo */ |
- |
- xreal=x-lunghezza; /* calcola la coordinata di fine veicolo */ |
- if (xreal<0) /* la pone a zero nel caso in cui sia minore di zero (veicolo non ancora interamente entrato in autostrada) */ |
- xreal=0; |
- |
- /* disegna il veicolo nella posizione indicata e con il colore indicato */ |
- sem_wait(&mutex); |
- grx_box(xreal,(int)(y-larghezza/2),x,(int)(y+larghezza/2),colore); |
- sem_post(&mutex); |
- |
- /* ricostruisce la segnaletica orrizzontale della strada nel caso in cui si sta' cancellando il veicolo dalla posizione precedente (ridisegna solo quella parte che e' stata cancellata) */ |
- if (colore==0) |
- for (u=xreal;u<x;u++) |
- { |
- v=u%8; |
- if ((v==0) || (v==1)) |
- { |
- sem_wait(&mutex); |
- grx_plot(u,CENTROCARREGGIATA,rgb16(255,255,255)); |
- sem_post(&mutex); |
- } |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA DAL VEICOLO CHE PRECEDE SULLA CORSIA **/ |
- |
-int dist_ant(int pos_x,int pos_y,int distsic) |
-{ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int distant; /* distanza dal veicolo che ci precede */ |
- int fine; /* variabile ausiliaria per capire se sto' arrivando alla fine della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distant=0; |
- |
- /* calcola la distanza da un eventuale veicolo che ci precede */ |
- sem_wait(&strada); |
- if (pos_y<CENTROCARREGGIATA) /* controlla se il veicolo e' nella prima corsia, altrimenti e' in seconda corsia */ |
- while (libero==0 && distant<distsic) /* il calcolo della distanza da un veicolo che ci precede termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distant; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distant=distsic; |
- else |
- if (corsia2[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distant++; |
- } |
- else /* il veicolo e' nella seconda corsia */ |
- while (libero==0 && distant<distsic) /* il calcolo della distanza da un veicolo che ci precede termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distant; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distant=distsic; |
- else |
- if (corsia1[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distant++; |
- } |
- sem_post(&strada); |
- |
- return(distant); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA ANTERIORE DESTRA DI UN VEICOLO CHE PRECEDE **/ |
- |
-int dist_ant_dx(int pos_x,int pos_y,int distsicdx) |
-{ |
- int distantdx; /* distanza dal veicolo che ci precede a destra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int fine; /* variabile ausiliaria per capire se sto' arrivando alla fine della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distantdx=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distantdx<distsicdx) /* il calcolo della distanza da un veicolo che ci precede a destra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distantdx; /* nel caso in cui il veicolo sia giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distantdx=distsicdx; |
- else |
- if (corsia1[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distantdx++; |
- } |
- sem_post(&strada); |
- |
- return(distantdx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA ANTERIORE SINISTRA DI UN VEICOLO CHE PRECEDE **/ |
- |
-int dist_ant_sx(int pos_x,int pos_y,int distsicsx) |
-{ |
- int distantsx; /* distanza dal veicolo che ci precede a sinistra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int fine; /* variabile ausiliaria per capire se sto' arrivando alla fine della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distantsx=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distantsx<distsicsx) /* il calcolo della distanza da un veicolo che ci precede a sinistra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distantsx; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distantsx=distsicsx; |
- else |
- if (corsia2[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distantsx++; |
- } |
- sem_post(&strada); |
- |
- return(distantsx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA POSTERIORE SINISTRA DI UN VEICOLO CHE INSEGUE **/ |
- |
-int dist_postsx (int pos_x,int pos_y,int distsorp) |
-{ |
- int distpostsx; /* distanza dal veicolo che ci insegue a sinistra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int inizio; /* variabile ausiliaria per capire se sono all'inizio della strada */ |
- |
- /* inizializzazione delle variabili */ |
- distpostsx=0; |
- libero=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distpostsx<distsorp) /* il calcolo della distanza da un veicolo che ci insegue a sinistra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- inizio=pos_x-distpostsx; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia insuguito da nessun veicolo */ |
- if (inizio<0) |
- distpostsx=distsorp; |
- else |
- if (corsia2[inizio]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distpostsx++; |
- } |
- sem_post(&strada); |
- |
- return(distpostsx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA POSTERIORE DESTRA DI UN VEICOLO CHE INSEGUE **/ |
- |
-int dist_postdx (int pos_x,int pos_y,int distrientro) |
-{ |
- int distpostdx; /* distanza dal veicolo che ci insegue a destra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int inizio; /* variabile ausiliaria per capire se sono all'inizio della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distpostdx=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distpostdx<distrientro) /* il calcolo della distanza da un veicolo che ci insegue a destra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- inizio=pos_x-distpostdx; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia inseguito da nessun veicolo */ |
- if (inizio<0) |
- distpostdx=distrientro; |
- else |
- if (corsia1[inizio]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distpostdx++; |
- } |
- sem_post(&strada); |
- |
- return(distpostdx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/**************************** TASK AUTO LENTA ******************************/ |
- |
-TASK auto_lenta(void *arg) |
-{ |
- int x; /* posizione x assunta dal veicolo */ |
- int y; /* posizione y assunta dal veicolo */ |
- int oxelic; /* posizione vecchia dell'elicottero */ |
- int ox; /* posizione vecchia x dall'auto lenta */ |
- int oy; /* posizione vecchia y dall'auto lenta */ |
- int k; /* indice di ciclo */ |
- int estremo; /* distanza massima a cui ci possiamo spostare dall'elicottero (sia a destra che a sinistra) */ |
- int sorpasso; /* indica se il veicolo e' in fase di sorpasso */ |
- int rientro; /* indica se il veicolo e' in fase di rientro */ |
- int precedentedritto; /* distanza anteriore da un veicolo */ |
- int od; /* vecchia distanza anteriore da un veicolo */ |
- int tot; /* distanza massima raggiungibile del sensore posteriore sinistro */ |
- int tot3; /* distanza massima raggiungibile del sensore anteriore destro */ |
- int tot2; /* distanza massima raggiungibile del sensore posteriore destro */ |
- int i = (int)arg; |
- int sensore_ant=200; /* distanza massima raggiungibile del sensore anteriore */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- float vcrociera; /* velocita' desiderata */ |
- float vmax2=35.0; /* velocita' massima raggiungibile in seconda corsia */ |
- float vmax1=25.0; /* velocita' massima raggiungibile in prima corsia */ |
- float frenata=-7.0; /* valore massimo della frenata */ |
- float amax=10.0; /* valore massimo dell'accellerazione */ |
- float v; /* velocita' attuale */ |
- float a; /* accellerazione attuale */ |
- float ov; /* velocita' precedente */ |
- float oa; /* accellerazione precedente */ |
- |
- /* inizializzazione delle variabili */ |
- v=5.0; |
- a=0.0; |
- x=LUNGLENTA; |
- y=CENTROCORSIA1; |
- sorpasso=0; |
- rientro=0; |
- tot=100; |
- tot2=150; |
- tot3=100; |
- vcrociera=vmax1; |
- oa=a; |
- ov=v; |
- od=0; |
- oxelic=xelic; |
- estremo=(int)((MAX_X/2)-1); |
- |
- while (1) |
- { |
- /* cancella il veicolo se era presente sull'autostrada vista dall'elicottero */ |
- if (abs(oxelic-ox)<estremo) |
- draw_veicolo(ox-oxelic+estremo, oy, 0,LUNGLENTA,LARGLENTA); |
- |
- /* salva le vecchie coordinate */ |
- ox = x; |
- oy = y; |
- |
- /* cancella il veicolo dalla vecchia posizione sulla corsia , andando a cancellarlo nel vettore della corsia in cui si trovava */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGLENTA;k++) |
- { |
- if ((oy<CENTROCORSIA1) && (oy>CENTROCORSIA2)) |
- { |
- corsia1[ox-k]=0; |
- corsia2[ox-k]=0; |
- } |
- else |
- if (oy==CENTROCORSIA1) |
- corsia1[ox-k]=0; |
- else |
- if (oy==CENTROCORSIA2) |
- corsia2[ox-k]=0; |
- } |
- sem_post(&strada); |
- |
- /* cancella tutte le vecchie informazioni che compaiono sullo schermo */ |
- sprintf(stri,"posizione %d",(int)(ox*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",oa); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",ov); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* legge la distanza dal sensore anteriore e nel caso in cui sia attaccato alla macchina che precede vengo eliminato */ |
- precedentedritto=dist_ant(x,y,sensore_ant); |
- if (precedentedritto==1) |
- task_abort(i); |
- |
- /* disegna il veicolo nella nuova posizione */ |
- if (abs(xelic-x)<estremo) |
- draw_veicolo(x-xelic+estremo, y, rgb16(255,0,0),LUNGLENTA,LARGLENTA); |
- |
- /* varia la massima distanza vista dal sensore posteriore sinistro a seconda della velocita' */ |
- tot=(int)(v*4); |
- if (tot<50) |
- tot=50; |
- |
- if (precedentedritto<100) /* ci siamo avvicinando troppo alla macchina che ci precede */ |
- if ((sorpasso==0) && (dist_postsx(x,y,200)>tot)&&(dist_ant_sx(x,y,50)>40)) |
- { |
- /* c'e' uno davanti e non sopraggiunge nessuno sulla corsia di sorpasso */ |
- sorpasso=1; |
- rientro=0; |
- vcrociera=vmax2; |
- } |
- else |
- a=frenata; /* c'e qualcuno davanti ,ma non possiamo sorpassare */ |
- else /* siamo lontani da un veicolo che ci precede o non ci precede nessuno */ |
- if (v<vcrociera) /* accelleriamo gradualmente fino a portarci alla velocita' di crociera desiderata */ |
- a=amax-(amax/vcrociera)*v; |
- else |
- if(v>vcrociera) /* freniamo per portarci al valore della velocita'di crociera */ |
- a=frenata/3; |
- else |
- a=0.0; /* siamo alla velocita' di crociera */ |
- |
- /* controlla se e' possibile la manovra di rientro dal sorpasso, aggiustando tutti i parametri nel modo corretto */ |
- if ((dist_postdx(x,y,200)>tot2) && (dist_ant_dx(x,y,200)>tot3) && (sorpasso==1)) |
- { |
- rientro=1; |
- sorpasso=0; |
- vcrociera=vmax1; |
- } |
- |
- /* aggiusta la cordinata y per far visualizzare il sorpasso o il rientro della macchina in modo graduale */ |
- if(y>CENTROCORSIA2 && sorpasso==1) |
- y=y-1; |
- |
- if(y<CENTROCORSIA1 && rientro==1) |
- y=y+1; |
- |
- /* calcola la velocita' e nel caso di v elocita' negative la pone a zero (non sono permesse le retromarcie) */ |
- v=v+a*DT; |
- if (v<0) |
- v=0.0; |
- |
- /* calcola la cordinata x a cui si trova la macchina */ |
- x=x+(int)((v*DT)/0.25); |
- |
- /* scrive a video i nuovi parametri appena calcolati */ |
- sprintf(stri,"posizione %d",(int)(x*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",v); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",a); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* quando il veicolo arriva alla fine dell'autostrada viene eliminato */ |
- if (x>=40000) |
- task_abort(i); |
- |
- /* salva la nuova posizione del veicolo */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGLENTA;k++) |
- { |
- if ((y<CENTROCORSIA1) && (y>CENTROCORSIA2)) |
- { |
- corsia2[x-k]=1; |
- corsia1[x-k]=1; |
- } |
- else |
- if (y==CENTROCORSIA1) |
- corsia1[x-k]=1; |
- else |
- if (y==CENTROCORSIA2) |
- corsia2[x-k]=1; |
- } |
- sem_post(&strada); |
- |
- /* salvo i parametri che occorrono per il prossimo ciclo */ |
- oxelic=xelic; |
- od=precedentedritto; |
- ov=v; |
- oa=a; |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/************************** TASK AUTO VELOCE *******************************/ |
- |
-TASK auto_veloce(void *arg) |
-{ |
- int x; /* posizione x assunta dal veicolo */ |
- int y; /* posizione y assunta dal veicolo */ |
- int oxelic; /* posizione vecchia dell'elicottero */ |
- int ox; /* posizione vecchia x dall'auto veloce */ |
- int oy; /* posizione vecchia y dall'auto veloce */ |
- int k; /* indice di ciclo */ |
- int estremo; /* distanza massima a cui ci possiamo spostare dall'elicottero (sia a destra che a sinistra) */ |
- int sorpasso; /* indica se il veicolo e' in fase di sorpasso */ |
- int rientro; /* indica se il veicolo e' in fase di rientro */ |
- int precedentedritto; /* distanza anteriore da un veicolo */ |
- int od; /* vecchia distanza anteriore da un veicolo */ |
- int tot; /* distanza massima raggiungibile del sensore posteriore sinistro */ |
- int tot3; /* distanza massima raggiungibile del sensore anteriore destro */ |
- int tot2; /* distanza massima raggiungibile del sensore posteriore destro */ |
- int i = (int)arg; |
- int sensore_ant=200; /* distanza massima raggiungibile del sensore anteriore */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- float vcrociera; /* velocita' desiderata */ |
- float vmax1=35.0; /* velocita' massima raggiungibile in prima corsia */ |
- float vmax2=40.0; /* velocita' massima raggiungibile in seconda corsia */ |
- float frenata=-7.0; /* valore massimo della frenata */ |
- float amax=15.0; /* valore massimo del'accellerazione */ |
- float v; /* velocita' attuale */ |
- float a; /* accellerazione attuale */ |
- float ov; /* velocita' precedente */ |
- float oa; /* accellerazione precedente */ |
- |
- /* inizializzazione delle variabili */ |
- v=5.0; |
- a=0.0; |
- x=LUNGVELOCE; |
- y=CENTROCORSIA1; |
- sorpasso=0; |
- rientro=0; |
- tot=100; |
- tot2=150; |
- tot3=100; |
- oa=a; |
- vcrociera=vmax1; |
- ov=v; |
- od=0; |
- oxelic=xelic; |
- estremo=(int)((MAX_X/2)-1); |
- |
- while (1) |
- { |
- /* cancella il veicolo se era presente sull'autostrada vista dall'elicottero */ |
- if (abs(oxelic-ox)<estremo) |
- draw_veicolo(ox-oxelic+estremo, oy, 0,LUNGVELOCE,LARGVELOCE); |
- |
- /* salva le vecchie coordinate */ |
- ox = x; |
- oy = y; |
- |
- /* cancella il veicolo dalla vecchia posizione sulla corsia , andando a cancellarlo nel vettore della corsia in cui si trovava */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGVELOCE;k++) |
- { |
- if ((oy<CENTROCORSIA1) && (oy>CENTROCORSIA2)) |
- { |
- corsia1[ox-k]=0; |
- corsia2[ox-k]=0; |
- } |
- else |
- if (oy==CENTROCORSIA1) |
- corsia1[ox-k]=0; |
- else |
- if (oy==CENTROCORSIA2) |
- corsia2[ox-k]=0; |
- } |
- sem_post(&strada); |
- |
- /* cancella tutte le vecchie informazioni che compaiono sullo schermo */ |
- sprintf(stri,"posizione %d",(int)(ox*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",ov); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",oa); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* legge la distanza dal sensore anteriore e nel caso in cui sia attaccato alla macchina che precede vengo eliminato */ |
- precedentedritto=dist_ant(x,y,sensore_ant); |
- if (precedentedritto==1) |
- task_abort(i); |
- |
- /* disegna il veicolo nella nuova posizione */ |
- if (abs(xelic-x)<estremo) |
- draw_veicolo(x-xelic+estremo, y, rgb16(0,255,0),LUNGVELOCE,LARGVELOCE); |
- |
- |
- /* varia la massima distanza vista dal sensore posteriore sinistro a seconda della velocita' */ |
- tot=(int)(v*4); |
- if (tot<50) |
- tot=50; |
- |
- if (precedentedritto<150) /* ci siamo avvicinando troppo alla macchina che ci precede */ |
- if ((sorpasso==0) && (dist_postsx(x,y,200)>tot)&&(dist_ant_sx(x,y,50)>40)) |
- { |
- /* c'e' uno davanti e non sopraggiunge nessuno sulla corsia di sorpasso */ |
- sorpasso=1; |
- rientro=0; |
- vcrociera=vmax2; |
- } |
- else /* c'e qualcuno davanti ,ma non possiamo sorpassare */ |
- a=frenata; |
- else /* siamo lontani da un veicolo che ci precede o non ci precede nessuno */ |
- if (v<vcrociera) /* accelleriamo gradualmente fino a portarci alla velocita' di crociera desiderata */ |
- a=amax-(amax/vcrociera)*v; |
- else |
- if(v>vcrociera) /* freniamo per portarci al valore della velocita'di crociera */ |
- a=frenata/3; |
- else |
- a=0.0; /* siamo alla velocita' di crociera */ |
- |
- /* controlla se e' possibile la manovra di rientro dal sorpasso, aggiustando tutti i parametri nel modo corretto */ |
- if ((dist_postdx(x,y,200)>tot2) && (dist_ant_dx(x,y,200)>tot3) && (sorpasso==1)) |
- { |
- rientro=1; |
- sorpasso=0; |
- vcrociera=vmax1; |
- } |
- |
- /* aggiusta la cordinata y per far visualizzare il sorpasso o il rientro della macchina in modo graduale */ |
- if(y>CENTROCORSIA2 && sorpasso==1) |
- y=y-1; |
- |
- if(y<CENTROCORSIA1 && rientro==1) |
- y=y+1; |
- |
- /* calcola la velocita' e nel caso di v elocita' negative la pone a zero (non sono permesse le retromarcie) */ |
- v=v+a*DT; |
- if (v<0) |
- v=0.0; |
- |
- /* calcola la cordinata x a cui si trova la macchina */ |
- x=x+(int)((v*DT)/0.25); |
- |
- /* scrive a video i nuovi parametri appena calcolati */ |
- sprintf(stri,"posizione %d",(int)(x*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",v); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",a); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* quando il veicolo arriva alla fine dell'autostrada viene eliminato */ |
- if (x>=40000) |
- task_abort(i); |
- |
- /* salva la nuova posizione del veicolo */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGVELOCE;k++) |
- { |
- if ((y<CENTROCORSIA1) && (y>CENTROCORSIA2)) |
- { |
- corsia2[x-k]=1; |
- corsia1[x-k]=1; |
- } |
- else |
- if (y==CENTROCORSIA1) |
- corsia1[x-k]=1; |
- else |
- if (y==CENTROCORSIA2) |
- corsia2[x-k]=1; |
- } |
- sem_post(&strada); |
- |
- /* salvo i parametri che occorrono per il prossimo ciclo */ |
- oxelic=xelic; |
- od=precedentedritto; |
- ov=v; |
- oa=a; |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/***************************** TASK AUTOCARRO ******************************/ |
- |
-TASK auto_carro(void *arg) |
-{ |
- int x; /* posizione x assunta dal veicolo */ |
- int y; /* posizione y assunta dal veicolo */ |
- int oxelic; /* posizione vecchia dell'elicottero */ |
- int ox; /* posizione vecchia x assunta dal camion */ |
- int oy; /* posizione vecchia y assunta dal camion */ |
- int k; /* indice di ciclo */ |
- int estremo; /* distanza massima a cui ci possiamo spostare dall'elicottero (sia a destra che a sinistra) */ |
- int sorpasso; /* indica se il veicolo e' in fase di sorpasso */ |
- int rientro; /* indica se il veicolo e' in fase di rientro */ |
- int precedentedritto; /* distanza anteriore da un veicolo */ |
- int od; /* vecchia distanza anteriore da un veicolo */ |
- int tot; /* distanza massima raggiungibile del sensore posteriore sinistro */ |
- int tot3; /* distanza massima raggiungibile del sensore anteriore destro */ |
- int tot2; /* distanza massima raggiungibile del sensore posteriore destro */ |
- int i = (int)arg; |
- int sensore_ant=200; /* distanza massima raggiungibile del sensore anteriore */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- float vcrociera; /* velocita' desiderata */ |
- float vmax1=15.0; /* velocita' massima raggiungibile in prima corsia */ |
- float vmax2=20.0; /* velocita' massima raggiungibile in seconda corsia */ |
- float frenata=-5.0; /* valore massimo della frenata */ |
- float amax=3.0; /* valore massimo del'accellerazione */ |
- float v; /* velocita' attuale */ |
- float a; /* accellerazione attuale */ |
- float ov; /* velocita' precedente */ |
- float oa; /* accellerazione precedente */ |
- |
- /* inizializzazione delle variabili */ |
- v=5.0; |
- a=0.0; |
- x=LUNGCAMION; |
- y=CENTROCORSIA1; |
- sorpasso=0; |
- rientro=0; |
- tot=100; |
- tot2=150; |
- tot3=100; |
- oa=a; |
- vcrociera=vmax1; |
- ov=v; |
- od=0; |
- oxelic=xelic; |
- estremo=(int)((MAX_X/2)-1); |
- |
- while (1) |
- { |
- /* cancella il veicolo se era presente sull'autostrada vista dall'elicottero */ |
- if (abs(oxelic-ox)<estremo) |
- draw_veicolo(ox-oxelic+estremo, oy, 0,LUNGCAMION,LARGCAMION); |
- |
- /* salva le vecchie coordinate */ |
- ox = x; |
- oy = y; |
- |
- /* cancella il veicolo dalla vecchia posizione sulla corsia , andando a cancellarlo nel vettore della corsia in cui si trovava */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGCAMION;k++) |
- { |
- if ((oy<CENTROCORSIA1) && (oy>CENTROCORSIA2)) |
- { |
- corsia1[ox-k]=0; |
- corsia2[ox-k]=0; |
- } |
- else |
- if (oy==CENTROCORSIA1) |
- corsia1[ox-k]=0; |
- else |
- if (oy==CENTROCORSIA2) |
- corsia2[ox-k]=0; |
- } |
- sem_post(&strada); |
- |
- /* cancella tutte le vecchie informazioni che compaiono sullo schermo */ |
- sprintf(stri,"posizione %d",(int)(ox*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",ov); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",oa); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* legge la distanza dal sensore anteriore e nel caso in cui sia attaccato alla macchina che precede vengo eliminato */ |
- precedentedritto=dist_ant(x,y,sensore_ant); |
- if (precedentedritto==1) |
- task_abort(i); |
- |
- /* disegna il veicolo nella nuova posizione */ |
- if (abs(xelic-x)<estremo) |
- draw_veicolo(x-xelic+estremo, y, rgb16(0,0,255),LUNGCAMION,LARGCAMION); |
- |
- /* varia la massima distanza vista dal sensore posteriore sinistro a seconda della velocita' */ |
- tot=(int)(v*4); |
- if (tot<50) |
- tot=50; |
- |
- if (precedentedritto<100) /* ci siamo avvicinando troppo alla macchina che ci precede */ |
- if ((sorpasso==0) && (dist_postsx(x,y,200)>tot)&&(dist_ant_sx(x,y,50)>40)) |
- { |
- /* c'e' uno davanti e non sopraggiunge nessuno sulla corsia di sorpasso */ |
- sorpasso=1; |
- rientro=0; |
- vcrociera=vmax2; |
- } |
- else /* c'e qualcuno davanti ,ma non possiamo sorpassare */ |
- a=frenata; |
- else /* siamo lontani da un veicolo che ci precede o non ci precede nessuno */ |
- if (v<vcrociera) /* accelleriamo gradualmente fino a portarci alla velocita' di crociera desiderata */ |
- a=amax-(amax/vcrociera)*v; |
- else |
- if(v>vcrociera) /* freniamo per portarci al valore della velocita'di crociera */ |
- a=frenata/3; |
- else |
- a=0.0; /* siamo alla velocita' di crociera */ |
- |
- /* controlla se e' possibile la manovra di rientro dal sorpasso, aggiustando tutti i parametri nel modo corretto */ |
- if ((dist_postdx(x,y,200)>tot2) && (dist_ant_dx(x,y,200)>tot3) && (sorpasso==1)) |
- { |
- rientro=1; |
- sorpasso=0; |
- vcrociera=vmax1; |
- } |
- |
- /* aggiusta la cordinata y per far visualizzare il sorpasso o il rientro della macchina in modo graduale */ |
- if(y>CENTROCORSIA2 && sorpasso==1) |
- y=y-1; |
- |
- if(y<CENTROCORSIA1 && rientro==1) |
- y=y+1; |
- |
- /* calcola la velocita' e nel caso di v elocita' negative la pone a zero (non sono permesse le retromarcie) */ |
- v=v+a*DT; |
- if (v<0) |
- v=0.0; |
- |
- /* calcola la cordinata x a cui si trova la macchina */ |
- x=x+(int)((v*DT)/0.25); |
- |
- /* scrive a video i nuovi parametri appena calcolati */ |
- sprintf(stri,"posizione %d",(int)(x*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",v); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",a); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* quando il veicolo arriva alla fine dell'autostrada viene eliminato */ |
- if (x>=40000) |
- task_abort(i); |
- |
- /* salva la nuova posizione del veicolo */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGCAMION;k++) |
- { |
- if ((y<CENTROCORSIA1) && (y>CENTROCORSIA2)) |
- { |
- corsia2[x-k]=1; |
- corsia1[x-k]=1; |
- } |
- else |
- if (y==CENTROCORSIA1) |
- corsia1[x-k]=1; |
- else |
- if (y==CENTROCORSIA2) |
- corsia2[x-k]=1; |
- } |
- sem_post(&strada); |
- |
- /* salvo i parametri che occorrono per il prossimo ciclo */ |
- oxelic=xelic; |
- od=precedentedritto; |
- ov=v; |
- oa=a; |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/***************************** TASK ELICOTTERO *****************************/ |
- |
-TASK eli_cottero(void *arg) |
-{ |
- int i = (int)arg; |
- int oxelic; /* vecchia posizione dell'elicottero */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- |
- /* disegna le scritte per l'indicatore a barra e finestra della posizione dell'elicottero */ |
- sprintf(stri,"0 Km"); |
- sem_wait(&mutex); |
- grx_text(stri,100,560,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(stri,"10 Km"); |
- sem_wait(&mutex); |
- grx_text(stri,700,560,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- while (1) |
- { |
- oxelic=xelic; /* salva la posizione precedente dell'elicottero */ |
- |
- if (c == '+') /* sposta l'elicottero a destra (verso la fine dell'autostrada */ |
- { |
- xelic=xelic+50; |
- if (xelic>40000-(int)((MAX_X/2)-1)) |
- xelic=40000-(int)((MAX_X/2)-1); |
- } |
- else |
- if (c =='-') /* sposta l'elicottero a sinistra (verso l'inizio dell'autostrada */ |
- { |
- xelic=xelic-30; |
- if (xelic<(int)((MAX_X/2)-1)) |
- xelic=(int)((MAX_X/2)-1); |
- } |
- |
- /* disegna le scritte innerenti all'elicottero e il valore della sua posizione (mediante scritta ed indicatore a barra con una finestra scorrevole) */ |
- sprintf(stri,"- <- xelic %d -> +",(int)(xelic*0.25)); |
- sprintf(ostri,"- <- xelic %d -> +",(int)(oxelic*0.25)); |
- |
- sem_wait(&mutex); |
- grx_text(ostri,MAX_X/2-50,500,rgb16(0,0,0),rgb16(0,0,0)); |
- grx_text(stri,MAX_X/2-50,500,rgb16(255,255,255),rgb16(0,0,0)); |
- grx_line(150,560,650,560,rgb16(255,255,255)); |
- grx_rect((int)((oxelic-(MAX_X/2))/80+150),540,(int)((oxelic+(MAX_X/2))/80+150) ,580 ,rgb16(0,0,0)); |
- grx_rect((int)((xelic-(MAX_X/2))/80+150),540,(int)((xelic+(MAX_X/2))/80+150) ,580 ,rgb16(255,255,255)); |
- sem_post(&mutex); |
- |
- c=' '; /* setta il carattere c */ |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* -----------------------------------------------------------------------------*/ |
- |
- |
-/************* FUNZIONE DI USCITA DAL SISTEMA ******************************/ |
- |
-void byebye(void *arg) |
-{ /* questa funzione e' chiamata quando il sistema esce */ |
- grx_close(); /* chiude la grafica */ |
- kern_printf("Ciao Ciao "); /* scrive il messaggio indicato sul terminale */ |
-} |
- |
- |
-/* -----------------------------------------------------------------------------*/ |
- |
- |
-/********************************* MAIN ************************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- int n_task = 0; /* numero di task creati */ |
- int u; |
- int v; |
- char introduzione[100]; /* vettore di caratteri */ |
- HARD_TASK_MODEL autolenta; /* task auto lenta */ |
- HARD_TASK_MODEL autoveloce; /* task auto veloce */ |
- HARD_TASK_MODEL autocarro; /* task camion */ |
- HARD_TASK_MODEL elicottero; /* task elicottero */ |
- |
- |
- /* inizializza le corsie dell'autostrada */ |
- sem_wait(&strada); |
- for (u=0;u<=40000;u++) |
- { |
- corsia1[u]=0; |
- corsia2[u]=0; |
- } |
- sem_post(&strada); |
- |
- /* Set the exception handler */ |
- //set_exchandler_grx(); |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* inizializzazione grafica */ |
- if (grx_init() < 1) |
- sys_abort(1); |
- |
- /* scelta automatica della risoluzione applicabile con quella scheda video (scegliendola tra 800*600 e 1024*768 ) */ |
- if(grx_getmode(1024,768,16)==-1) |
- { |
- if (grx_open(800, 600, 16) < 0) |
- { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- MAX_X=800; |
- MAX_Y=600; |
- } |
- else |
- { |
- if (grx_open(1024,768, 16) < 0) |
- { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- MAX_X=1024; |
- MAX_Y=768; |
- } |
- |
- kern_printf("La scheda video va'!!\n"); |
- |
- /* posizione iniziale elicottero */ |
- xelic=(int)((MAX_X/2)-1); |
- |
- /* disegna lo scenario della strada ed il menu */ |
- sprintf(introduzione,"Monitoraggio dei mezzi che transitano su una autostrada."); |
- sem_wait(&mutex); |
- grx_text(introduzione,50,10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"Sviluppato da: Verzellesi Quadrubbi"); |
- sem_wait(&mutex); |
- grx_text(introduzione,50,20,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"MENU"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,70,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"s = macchina sportiva"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,80,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"c = mezzo pesante"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,90,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"l = macchina lenta"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,100,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"+ = sposta l'elicottero verso destra"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,110,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"- = sposta l'elicottero verso sinistra"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,120,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"esc = uscita"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,130,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"NOTA"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,140,rgb16(255,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"Se i veicoli tamponano "); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,150,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione," vengono eliminati"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,160,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- grx_line(1,450,MAX_X,450,rgb16(255,255,255)); |
- grx_line(1,486,MAX_X,486,rgb16(255,255,255)); |
- |
- for (u=0;u<MAX_X;u++) |
- { |
- v=u%8; |
- if ((v==0) || (v==1)) |
- { |
- sem_wait(&mutex); |
- grx_plot(u,CENTROCARREGGIATA,rgb16(255,255,255)); |
- sem_post(&mutex); |
- } |
- } |
- |
- n_task=0; /* inizializzazione del numero dei task */ |
- |
- /* definisce e crea il task elicottero */ |
- kern_printf("elicottero"); |
- hard_task_default_model (elicottero); |
- hard_task_def_ctrl_jet (elicottero); |
- hard_task_def_arg (elicottero, (void *)n_task); |
- hard_task_def_wcet (elicottero,wcet); |
- hard_task_def_mit (elicottero, periodo); |
- hard_task_def_group (elicottero, GRUPPO); |
- hard_task_def_usemath (elicottero); |
- pid = task_create ("elicottero",eli_cottero, &elicottero, NULL); |
- if (pid == NIL) |
- { |
- grx_close(); |
- perror("Non si puo' creare il task"); |
- sys_abort(1); |
- } |
- task_activate(pid); |
- |
- n_task=1; /* incremente il numero dei task (ha creato l'elicottero */ |
- |
- /*Attesa di un carattere per creare un veicolo */ |
- c = keyb_getch(BLOCK); |
- do { |
- if (((c == 'c')||(c=='s')||(c=='l')) && (n_task < MAX_V)) /* in base al tasto premuto crea il task opportuno */ |
- { |
- if (c == 'l') /* definisce e crea il task autolenta */ |
- { |
- kern_printf("lenta"); |
- hard_task_default_model (autolenta); |
- hard_task_def_ctrl_jet (autolenta); |
- hard_task_def_arg (autolenta, (void *)n_task); |
- hard_task_def_wcet (autolenta, wcet); |
- hard_task_def_mit (autolenta, periodo); |
- hard_task_def_group (autolenta, GRUPPO); |
- hard_task_def_usemath (autolenta); |
- pid = task_create ("autolenta",auto_lenta, &autolenta, NULL); |
- } |
- else |
- if (c == 's') /* definisce e crea il task autoveloce */ |
- { |
- hard_task_default_model (autoveloce); |
- hard_task_def_ctrl_jet (autoveloce); |
- hard_task_def_arg (autoveloce, (void *)n_task); |
- hard_task_def_wcet (autoveloce, wcet); |
- hard_task_def_mit (autoveloce, periodo); |
- hard_task_def_group (autoveloce, GRUPPO); |
- hard_task_def_usemath (autoveloce); |
- pid = task_create ("autoveloce",auto_veloce, &autoveloce, NULL); |
- } |
- else |
- if (c == 'c') /* definisce e crea il task autocarro */ |
- { |
- hard_task_default_model (autocarro); |
- hard_task_def_ctrl_jet (autocarro); |
- hard_task_def_arg (autocarro, (void *)n_task); |
- hard_task_def_wcet (autocarro, wcet); |
- hard_task_def_mit (autocarro, periodo); |
- hard_task_def_group (autocarro, GRUPPO); |
- hard_task_def_usemath (autocarro); |
- pid = task_create ("camion",auto_carro, &autocarro, NULL); |
- } |
- |
- if (pid == NIL) /* nel caso in non si possano creare dei task chiude la grafica e con un messaggio segnala l'errore */ |
- { |
- grx_close(); |
- perror("Non si puo' creare il task"); |
- sys_abort(1); |
- } |
- |
- task_activate(pid); /* attiva i task */ |
- n_task++; /* incrementa il numero dei task creati */ |
- } |
- |
- c = keyb_getch(BLOCK); |
- |
- } while (c != ESC); /* termino il tutto solo quando e' stato premuto il tasto esc */ |
- |
- sys_end(); /* esco dal sistema */ |
- |
- return 0; |
-} |
Index: rel_1_21/autostr/initfile.c |
=================================================================== |
--- rel_1_21/autostr/initfile.c (revision 1217) |
+++ rel_1_21/autostr/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: initfile.c,v 1.1 2003-06-04 09:41:15 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-04 09:41:15 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: rel_1_21/autostr/makefile |
=================================================================== |
--- rel_1_21/autostr/makefile (revision 1217) |
+++ rel_1_21/autostr/makefile (nonexistent) |
@@ -1,17 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= autostr |
- |
-include $(BASE)/config/example.mk |
- |
-autostr: |
- make -f $(SUBMAKE) APP=autostr INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
- |
Index: rel_1_21/mesatex/initfile.c |
=================================================================== |
--- rel_1_21/mesatex/initfile.c (revision 1217) |
+++ rel_1_21/mesatex/initfile.c (nonexistent) |
@@ -1,119 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: initfile.c,v 1.2 2003-04-28 11:14:08 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-04-28 11:14:08 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: rel_1_21/mesatex/mesatex.c |
=================================================================== |
--- rel_1_21/mesatex/mesatex.c (revision 1217) |
+++ rel_1_21/mesatex/mesatex.c (nonexistent) |
@@ -1,407 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <drivers/vga.h> |
-#include <drivers/keyb.h> |
- |
-#include <GL/osmesa.h> |
-#include <GL/glut.h> |
- |
-#include <math.h> |
-#include <stdlib.h> |
-#include <assert.h> |
-#include <kernel/log.h> |
-#include <kernel/kern.h> |
- |
-#ifndef M_PI |
-#define M_PI 3.14159265 |
-#endif |
- |
-#define WIDTH 640 |
-#define HEIGHT 480 |
-#define BYTES_PP 2 //BytesPerPixel |
-#define INITSTR G640x480x64K //SVGAlib standard mode definitions |
-#define CARD VESA //Video driver |
- |
-OSMesaContext ctx; |
- |
-static GLuint TexObj[2]; |
-static GLfloat Angle = 0.0f; |
-static GLboolean UseObj = GL_FALSE; |
- |
-#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2) |
-# define TEXTURE_OBJECT 1 |
-#elif defined(GL_EXT_texture_object) |
-# define TEXTURE_OBJECT 1 |
-# define glBindTexture(A,B) glBindTextureEXT(A,B) |
-# define glGenTextures(A,B) glGenTexturesEXT(A,B) |
-# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B) |
-#endif |
- |
-unsigned char *rgb_565_buf = NULL; //RGB 16 bpp Buffer |
-unsigned char *video_buf = NULL; //Video Buffer |
- |
-unsigned long int VMEMLONG = WIDTH * HEIGHT * BYTES_PP / 4; // Used by copy_videomem_16to16 |
-unsigned long int RGB565MEM = WIDTH * HEIGHT * BYTES_PP; // Total video mem |
- |
-unsigned long int PERIOD_REFRESH = 60000; |
-unsigned long int PERIOD_DISEGNA = 60000; |
- |
-unsigned long int WCET_REFRESH, WCET_DISEGNA; |
- |
-TASK refesh(void); |
-TASK disegna(void); |
- |
-PID refresh_PID, disegna_PID; |
- |
-static void draw( void ) |
-{ |
- glDepthFunc(GL_EQUAL); |
- /* glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );*/ |
- glClear( GL_COLOR_BUFFER_BIT ); |
- |
- glColor3f( 1.0, 1.0, 1.0 ); |
- |
- /* draw first polygon */ |
- glPushMatrix(); |
- glTranslatef( -1.0, 0.0, 0.0 ); |
- glRotatef( Angle, 0.0, 0.0, 1.0 ); |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[0] ); |
-#endif |
- } |
- else { |
- glCallList( TexObj[0] ); |
- } |
- glBegin( GL_POLYGON ); |
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); |
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); |
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); |
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); |
- glEnd(); |
- glPopMatrix(); |
- |
- /* draw second polygon */ |
- glPushMatrix(); |
- glTranslatef( 1.0, 0.0, 0.0 ); |
- glRotatef( Angle-90.0, 0.0, 1.0, 0.0 ); |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[1] ); |
-#endif |
- } |
- else { |
- glCallList( TexObj[1] ); |
- } |
- glBegin( GL_POLYGON ); |
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); |
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); |
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); |
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); |
- glEnd(); |
- glPopMatrix(); |
- |
-} |
- |
- |
-static void gl_init() |
-{ |
- |
- static GLfloat h = (GLfloat) HEIGHT / (GLfloat) WIDTH; |
- static int twidth=8, theight=8; |
- static GLubyte tex1[] = { |
- 0, 0, 0, 0, 0, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 1, 1, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 1, 1, 1, 0, 0, |
- 0, 0, 0, 0, 0, 0, 0, 0 }; |
- |
- static GLubyte tex2[] = { |
- 0, 0, 0, 0, 0, 0, 0, 0, |
- 0, 0, 0, 2, 2, 0, 0, 0, |
- 0, 0, 2, 0, 0, 2, 0, 0, |
- 0, 0, 0, 0, 0, 2, 0, 0, |
- 0, 0, 0, 0, 2, 0, 0, 0, |
- 0, 0, 0, 2, 0, 0, 0, 0, |
- 0, 0, 2, 2, 2, 2, 0, 0, |
- 0, 0, 0, 0, 0, 0, 0, 0 }; |
- |
- GLubyte tex[64][3]; |
- GLint i, j; |
- |
- //Create the OSMesa Context |
- ctx = OSMesaCreateContext(OSMESA_RGB_565, NULL); |
- |
- //Make Current Context |
- OSMesaMakeCurrent(ctx, rgb_565_buf, GL_UNSIGNED_SHORT_5_6_5, WIDTH, HEIGHT); |
- |
- UseObj = GL_TRUE; |
- |
- glDisable( GL_DITHER ); |
- |
- /* Setup texturing */ |
- glEnable( GL_TEXTURE_2D ); |
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); |
- glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); |
- |
- /* generate texture object IDs */ |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glGenTextures( 2, TexObj ); |
-#endif |
- } |
- else { |
- TexObj[0] = glGenLists(2); |
- TexObj[1] = TexObj[0]+1; |
- } |
- |
- /* setup first texture object */ |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[0] ); |
- assert(glIsTexture(TexObj[0])); |
-#endif |
- } |
- else { |
- glNewList( TexObj[0], GL_COMPILE ); |
- } |
- /* red on white */ |
- for (i=0;i<theight;i++) { |
- for (j=0;j<twidth;j++) { |
- int p = i*twidth+j; |
- if (tex1[(theight-i-1)*twidth+j]) { |
- tex[p][0] = 255; tex[p][1] = 0; tex[p][2] = 0; |
- } |
- else { |
- tex[p][0] = 255; tex[p][1] = 255; tex[p][2] = 255; |
- } |
- } |
- } |
- |
- glTexImage2D( GL_TEXTURE_2D, 0, 3, twidth, theight, 0, |
- GL_RGB, GL_UNSIGNED_BYTE, tex ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); |
- if (!UseObj) { |
- glEndList(); |
- } |
- /* end of texture object */ |
- |
- /* setup second texture object */ |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[1] ); |
- assert(glIsTexture(TexObj[1])); |
-#endif |
- assert(!glIsTexture(TexObj[1] + 999)); |
- } |
- else { |
- glNewList( TexObj[1], GL_COMPILE ); |
- } |
- /* green on blue */ |
- for (i=0;i<theight;i++) { |
- for (j=0;j<twidth;j++) { |
- int p = i*twidth+j; |
- if (tex2[(theight-i-1)*twidth+j]) { |
- tex[p][0] = 0; tex[p][1] = 255; tex[p][2] = 0; |
- } |
- else { |
- tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 255; |
- } |
- } |
- } |
- glTexImage2D( GL_TEXTURE_2D, 0, 3, twidth, theight, 0, |
- GL_RGB, GL_UNSIGNED_BYTE, tex ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); |
- if (!UseObj) { |
- glEndList(); |
- } |
- /* end texture object */ |
- |
- glViewport(0, 0, (GLint)WIDTH, (GLint)HEIGHT); |
- glMatrixMode(GL_PROJECTION); |
- glLoadIdentity(); |
- /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ |
- glFrustum( -2.0, 2.0, 2.0, -2.0, 6.0, 20.0 ); |
- glMatrixMode(GL_MODELVIEW); |
- glLoadIdentity(); |
- glTranslatef( 0.0, 0.0, -8.0 ); |
- |
-} |
- |
-static int screen(int mode) |
-{ |
- |
- vga_modeinfo *minf; |
- |
- vga_setmode(mode,CARD); |
- minf = vga_getmodeinfo(mode); |
- if(! (minf->flags & CAPABLE_LINEAR)){ |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "The mode %d is not capable of linear\n",mode); |
- return 1; |
- } |
- vga_setpage(0); |
- if(vga_setlinearaddressing() == -1) { |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "Could not set linear addressing for mode %d\n",mode); |
- return 1; |
- } |
- |
- video_buf = vga_getgraphmem(); |
- |
- grx_setbuffer(rgb_565_buf, WIDTH, HEIGHT); //Init of RGB16 version of grx functions |
- //created to work with Mesa buffer |
- return 0; |
- |
-} |
- |
-void program_end(void *arg) |
-{ |
- |
- OSMesaDestroyContext(ctx); |
- free(rgb_565_buf); |
- |
- vga_setmode(TEXT,CARD); |
- |
- sys_end(); |
- |
-} |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-TASK refresh(void) |
-{ |
- |
- while(1) { |
- |
- copy_videomem_16to16(rgb_565_buf, video_buf, VMEMLONG); |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
- |
-TASK disegna(void) |
-{ |
- |
- char text[100]; |
- TIME disegna_TIME, refresh_TIME; |
- |
- while(1) { |
- |
- jet_gettable(refresh_PID, &refresh_TIME, 1); |
- jet_gettable(disegna_PID, &disegna_TIME, 1); |
- |
- Angle += 2.0; |
- |
- draw(); |
- |
- sprintf(text,"Hard Task Refresh PER:%6d us EX:%6d us",(int)PERIOD_REFRESH,(int)refresh_TIME); |
- grx_text(text,10,5,rgb16(0,0,255),0); |
- sprintf(text,"Hard Task Draw PER:%6d us EX:%6d us",(int)PERIOD_DISEGNA,(int)disegna_TIME); |
- grx_text(text,10,15,rgb16(0,0,255),0); |
- |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
-int main (int argc, char *argv[]) |
-{ |
- |
- HARD_TASK_MODEL ht_refresh, ht_disegna; |
- |
- sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- clear(); |
- |
- WCET_REFRESH =((long int) PERIOD_REFRESH * (0.45)); |
- WCET_DISEGNA =((long int) PERIOD_DISEGNA * (0.45)); |
- |
- hard_task_default_model(ht_refresh); |
- hard_task_def_wcet(ht_refresh,WCET_REFRESH); |
- hard_task_def_mit(ht_refresh,PERIOD_REFRESH); |
- hard_task_def_usemath(ht_refresh); |
- hard_task_def_group(ht_refresh,1); |
- hard_task_def_ctrl_jet(ht_refresh); |
- |
- refresh_PID = task_create("refresh", refresh, &ht_refresh, NULL); |
- if (refresh_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- hard_task_default_model(ht_disegna); |
- hard_task_def_mit(ht_disegna,PERIOD_DISEGNA); |
- hard_task_def_wcet(ht_disegna,WCET_DISEGNA); |
- hard_task_def_group(ht_disegna,1); |
- hard_task_def_ctrl_jet(ht_disegna); |
- hard_task_def_usemath(ht_disegna); |
- hard_task_def_stack(ht_disegna,30000); |
- |
- disegna_PID = task_create("disegna", disegna, &ht_disegna, NULL); |
- if (disegna_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- { |
- KEY_EVT k; |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,program_key_end); |
- } |
- |
- rgb_565_buf = malloc(RGB565MEM); |
- |
- gl_init(); |
- |
- if (screen(INITSTR)) { |
- printk(KERN_INFO "Graphical initialization failed !!\n"); |
- sys_end(); |
- } |
- |
- memset(rgb_565_buf, 0, RGB565MEM); |
- |
- group_activate(1); |
- |
- return 0; |
- |
-} |
Index: rel_1_21/mesatex/readme.txt |
=================================================================== |
--- rel_1_21/mesatex/readme.txt (revision 1217) |
+++ rel_1_21/mesatex/readme.txt (nonexistent) |
@@ -1,44 +0,0 @@ |
--------------------------------------- |
-MESA Demo (tex) |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 17/03/2003 |
--------------------------------------- |
- |
-This is a simple test demo for the MESA (5.0) |
-libraries, the low level graphic drivers is |
-the SVGA (from the SVGAlib) |
- |
-See drivers/svga/readme for supported cards |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-MESATEX.C The MESA Demo |
- |
--------------------------------------- |
- |
-- To specify your card change the line |
- |
-#define CARD <driver name> |
- |
-- The demo calls the grx and off-screen Mesa functions. |
-The resolution must be 16 bitsperpixel (64K colors) and |
-the graphic access mode must be linear. |
- |
-- There are two buffers |
- |
- The video buffer (video_buf) |
- The virtual buffer (rgb_565_buf) |
- |
- copy_videomem_16to16 links these buffers |
- |
- |
- |
Index: rel_1_21/mesatex/makefile |
=================================================================== |
--- rel_1_21/mesatex/makefile (revision 1217) |
+++ rel_1_21/mesatex/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = mesatex |
- |
-include $(BASE)/config/example.mk |
- |
-mesatex: |
- make -f $(SUBMAKE) APP=mesatex INIT= OTHEROBJS="initfile.o" SHARKOPT="__OSMESA__ __OLDCHAR__ __SVGA__" |
- |
Index: rel_1_21/auto/readme |
=================================================================== |
--- rel_1_21/auto/readme (revision 1217) |
+++ rel_1_21/auto/readme (nonexistent) |
@@ -1,51 +0,0 @@ |
-AUTO - Another Unuseful Track simulatOr |
---------------------------------------- |
- |
-by Marco Dallera and Marco Fiocca, 2001 |
- |
---------------------------------------- |
- |
-This project was done as a Lab assignment during the course of |
-"Informatica Industriale" at the University of Pavia, Italy. |
- |
-It simulates a race between cars under a set of 4 tracks. |
- |
-The authors provided also some pages that describes the application |
-(auto.ps, in italian, on the website). |
- |
-To run the application, just compile it and call "x auto th" where tn is |
-the track number (0 to 4). |
- |
-Since the control algorithm is quite complex, you need a quite powerful |
-machine. If you get an exception 8 (WCET violation), you need a faster PC. |
-You can anyway run the application making "auto2", that uses RR instead of |
-EDF or CBS, or "auto3", that uses the EDFACT Module (you need yo copy |
-the edfact.c and edfact.h files in the application directory to do that). |
- |
-To be run, the application needs to be compiled with the |
-#define MAX_CAB set to a number greater than 20 (see include/modules/cabs.h). |
- |
-The control algorithm of the cars is not yet perfect, and if you look to |
-the race for a long time, sometimes some cars go in the wrong direction. |
-If you find a better algorithm, send me a patch :-) |
- |
-The code you can find in this directory is the original code of the |
-students except for the MAX_CAB test into main(), and for the idle time |
-monitor (that I took from the jumpball example) that can be useful to know |
-when the system is overloaded. For example, on my PC there is idle time until |
-the system has 9 cars. The tenth make the PC overloaded until one of them |
-crashes :-). |
- |
-Finally note that the WCET and PERIODS specified by the authors are not so |
-correct, and with this setting you can run 8 cars maximum before crashing the |
-system. |
- |
-Have a nice race... |
- |
-Paolo |
-pj@sssup.it |
- |
-PS: Sometimes on my portable the demo crashes. I wonder why!... If someone |
-finds why, please tell me, I will patch it... |
- |
- |
Index: rel_1_21/auto/initfil1.c |
=================================================================== |
--- rel_1_21/auto/initfil1.c (revision 1217) |
+++ rel_1_21/auto/initfil1.c (nonexistent) |
@@ -1,108 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: initfil1.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-void read_track(int); |
-void read_sprites(); |
- |
-int argc; |
-char *argv[100]; |
- |
-int main(int argc, char **argv); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- __compute_args__(mb, &argc, argv); |
- |
- if (argc == 2) |
- read_track(strtoi(argv[1], 10, NULL)); |
- else |
- read_track(2); |
- |
- read_sprites(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- return (void *)main(argc,argv); |
-} |
Index: rel_1_21/auto/initfil2.c |
=================================================================== |
--- rel_1_21/auto/initfil2.c (revision 1217) |
+++ rel_1_21/auto/initfil2.c (nonexistent) |
@@ -1,108 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: initfil2.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-void read_track(int); |
-void read_sprites(); |
- |
-int argc; |
-char *argv[100]; |
-int main(int argc, char **argv); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- __compute_args__(mb, &argc, argv); |
- |
- if (argc == 2) |
- read_track(strtoi(argv[1], 10, NULL)); |
- else |
- read_track(0); |
- |
- read_sprites(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- return (void *)main(argc,argv); |
-} |
- |
- |
- |
- |
Index: rel_1_21/auto/control.c |
=================================================================== |
--- rel_1_21/auto/control.c (revision 1217) |
+++ rel_1_21/auto/control.c (nonexistent) |
@@ -1,701 +0,0 @@ |
-/* |
- * 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: control.c,v 1.2 2003-03-24 13:29:08 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-03-24 13:29:08 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------- */ |
-/* Car control */ |
-/* ------------- */ |
- |
-#include "include/auto.h" |
-#include "include/const.h" |
-#include "include/utils.h" |
- |
-#define TURN_QUANTUM 2 |
-#define KM 18.0 // pixel |
-#define HOUR 3600.0 // seconds |
-#define KPH (KM/HOUR) // 0.005 pixel/second |
-#define HIGHWAY_LIMIT 6 |
-#define MAZE_LIMIT 45 |
-#define CURVE_LIMIT 25 // il limite della curva per cui imposta la traiettoria |
-#define BORDER_LIMIT ((1.0 / params.rage) * 2.0) |
-#define STEERING_LIMIT 3 // limite di sterzata |
- |
-/* Road state */ |
-#define HIGHWAY 1 |
-#define MIXED 2 |
-#define MAZE 3 |
-#define CENTER 10 |
-#define TOO_LEFT 11 |
-#define TOO_RIGHT 12 |
- |
-/* Opponents relationship */ |
-#define ATTACK 20 |
-#define DEFENSE 21 |
-#define SUPERATTACK 22 |
- |
-/* Car parameters */ |
-#define MAX_SPEED (300 * KPH) |
-#define MIN_SPEED (10 * KPH) |
-#define MIN_ACC (-0.1) |
-#define MAX_ACC (0.02) |
- |
-extern sem_t grx_mutex; |
- |
-char track_img[TRACK_WIDTH*TRACK_HEIGHT]; |
-char sprite[18][CAR_WIDTH*CAR_HEIGHT]; |
- |
-/* Display functions */ |
-void put_transimage(int x1, int y1, int x2, int y2, BYTE *img,int car_color, int color); |
-void draw_car(point_f old_pos, car_status cs, int car_color, int fumo); |
-void put_trackbox(int x1, int y1, int x2, int y2); |
-void show_display(int, int, float, float, float, float); |
-void car_crash(PID sp, PID cp, point_f old_pos, int free); |
- |
-/* ------------------------------------------------------------------ */ |
- |
-TASK control(int index) { |
- int i = 0; // general purpose counter |
- car_status old_car_status; // the previous car state |
- car_status actual_car_status; // the actual car state |
- road_info actual_road_info; // the actual road informations |
- int road_state; // the state of the road: HIGHWAY, MIXED; MAZE |
- int car_align; // the car alignment with respect to road limits |
- int opps_state; // the relationship with other cars |
- float old_speed = 0; // the previous car speed value |
- float actual_speed = 0; // the actual car speed value |
- float old_acc = 0; // the previous acceleration value |
- float acc = 0; // the new acceleration |
- point polepos; |
- |
- // Variabili che dipendono dal tipo di macchina |
- float max_speed; // maximum car speed |
- float min_acc; // minimum acceleration |
- float max_acc; // maximum acceleration |
- |
- int killed = 0; // flag for killed cars |
- int crashed = 0; // flag for crashed cars |
- |
- /* Timing variables */ |
- float t = 0; |
- float dt = (float)CONTROL_PERIOD/100000.0; // time quantum |
- time ts = int2time(t); |
- float crash_t = 0; |
- time crash_ts = int2time(crash_t); |
- float bestlap = 999999999.9; |
- time bestlap_s = int2time(bestlap); |
- int bestlap_done = 0; |
- int laps = 0; |
- |
- /* Display vars */ |
- point spd_p, acc_p, time_p, drv_p; |
- char *txt; |
- |
- /* Car data */ |
- car_params params; // car data structure |
- |
- /* ----------------------------------------------------- */ |
- |
- txt = (char *)malloc(15*sizeof(char)); |
- |
- params = cars[index]; |
- |
- max_speed = params.max_speed * MAX_SPEED; // maximum car speed |
- min_acc = params.min_acc * MIN_ACC; // minimum acceleration |
- max_acc = params.max_acc * MAX_ACC; // maximum acceleration |
- |
- /* Get track data */ |
- while (track_list[i].selected == 0) |
- i++; |
- |
- /* Same pole for all */ |
- polepos.x = track_list[i].pole_pos.x; |
- polepos.y = track_list[i].pole_pos.y; |
- actual_car_status.pos.x = polepos.x; |
- actual_car_status.pos.y = polepos.y; |
- actual_car_status.orient = track_list[i].pole_orient; |
- set_car_status(actual_car_status, params.car_status_cab); |
- |
- /* Initialize old values */ |
- old_car_status = actual_car_status; |
- old_acc = acc; |
- old_speed = actual_speed; |
- |
- /* POWER IS NOTHING WITHOUT CONTROL */ |
- while(1) { |
- |
- if (crashed) { |
- crash_t += dt; |
- crash_ts = int2time(crash_t); |
- if (crash_ts.sec > 2) { |
- car_crash(params.sensor_pid,params.control_pid, |
- old_car_status.pos, 1); |
- killed=1; |
- } |
- } |
- |
- else { |
- |
- /* Reads road informations */ |
- actual_road_info = get_road_info(params.road_status_cab); |
- |
- /* Defines the state of the road */ |
- if (fabs(actual_road_info.curve) < HIGHWAY_LIMIT || |
- actual_road_info.distance > 0.9*TEL_HEIGHT) { |
- road_state = HIGHWAY; |
- } else if (fabs(actual_road_info.curve) > MAZE_LIMIT || |
- actual_road_info.distance < 0.1*TEL_HEIGHT) { |
- road_state = MAZE; |
- } else { |
- road_state = MIXED; |
- } |
- |
- /* Defines the car position whitin road borders */ |
- if (actual_road_info.left_border < BORDER_LIMIT) |
- car_align = TOO_LEFT; |
- else if (actual_road_info.right_border < BORDER_LIMIT) |
- car_align = TOO_RIGHT; |
- else car_align = CENTER; |
- |
- /* Sets the power percentage */ |
- switch (road_state) |
- { |
- case HIGHWAY: |
- acc = max_acc; // tarella!!!! |
- break; |
- case MIXED: |
- actual_speed = params.rage * (((float)actual_road_info.distance/(float)TEL_HEIGHT) / |
- (fabs(actual_road_info.curve)/90.0)) * max_speed; |
- acc = (actual_speed - old_speed) / dt; |
- break; |
- case MAZE: |
- actual_speed = params.rage * (1.0 - (fabs(actual_road_info.curve)/90.0)) * max_speed; |
- acc = (actual_speed - old_speed) / dt; |
- break; |
- default: |
- acc = 0.0; |
- } |
- |
- /* Can't go off road */ |
- /* When car is near a border, it steers to come in */ |
- switch (car_align) |
- { |
- case TOO_LEFT: |
- actual_car_status.orient -= TURN_QUANTUM; |
- break; |
- case TOO_RIGHT: |
- actual_car_status.orient += TURN_QUANTUM; |
- break; |
- } |
- |
- if (road_state != HIGHWAY) { |
- // C'e' una curva vicina. |
- // Se la curva e' a destra si tiene vicino al bordo di sinistra |
- // per impostare la traiettoria migliore e viceversa |
- if (actual_road_info.curve < 0 && actual_road_info.left_border > BORDER_LIMIT |
- && fabs(actual_road_info.curve) > CURVE_LIMIT) |
- actual_car_status.orient += TURN_QUANTUM; |
- else if (actual_road_info.curve > 0 && actual_road_info.right_border > BORDER_LIMIT |
- && fabs(actual_road_info.curve) > CURVE_LIMIT) |
- actual_car_status.orient -= TURN_QUANTUM; |
- |
- // Fa la curva dolcemente |
- if (actual_road_info.distance < ((1.0/params.rage) * (TEL_HEIGHT * 0.25))) { |
- actual_car_status.orient += actual_road_info.curve * (params.rage/8.0); |
- //actual_car_status.orient += actual_road_info.curve / 4.0; |
- } |
- } |
- |
- /* Defines the state of interactions with other cars */ |
- if (actual_road_info.opps_number > 0) |
- { |
- if (road_state == HIGHWAY && actual_road_info.opps_list[0].y > (TEL_HEIGHT/3.0)) |
- opps_state = ATTACK; |
- else if (road_state == MAZE && actual_road_info.opps_list[0].y < (TEL_HEIGHT/3.0)) |
- opps_state = DEFENSE; |
- else if (actual_road_info.opps_list[0].y < (TEL_HEIGHT/6.0) && |
- actual_road_info.opps_list[0].x != 0 && |
- (abs(actual_road_info.opps_list[0].x) < CAR_W/2)) { |
- // Defends and steers to avoid opponents |
- opps_state = DEFENSE; |
- acc *= -((TEL_HEIGHT/6.0) / (actual_road_info.opps_list[0].y)); |
- actual_car_status.orient -= ((actual_road_info.opps_list[0].x) / |
- abs(actual_road_info.opps_list[0].x)) * TURN_QUANTUM/2; |
- } |
- else if (actual_road_info.opps_list[0].y < (TEL_HEIGHT/3.0) && |
- actual_road_info.opps_list[0].x != 0 && |
- abs(actual_road_info.opps_list[0].x) < CAR_W/2) { |
- // Attacks and steers to override the opponent |
- opps_state = ATTACK; |
- actual_car_status.orient -= ((actual_road_info.opps_list[0].x) / |
- abs(actual_road_info.opps_list[0].x)) * TURN_QUANTUM; |
- } |
- else |
- opps_state = DEFENSE; |
- |
- // Response to opponents positions |
- if (opps_state == ATTACK) |
- acc = max_acc; |
- else if (opps_state == DEFENSE) |
- acc *= 0.5; |
- } |
- |
- |
- /* Checking car position: road/offroad */ |
- if (actual_road_info.left_border * actual_road_info.right_border < 0) |
- acc = 0.5 * min_acc; |
- |
- if (actual_road_info.flag != ROAD_OK) { |
- switch (actual_road_info.flag) { |
- case LEFT_ONLY: |
- if (actual_road_info.left_border < 0) |
- actual_car_status.orient -= TURN_QUANTUM; |
- acc = 0.5 * max_acc; |
- break; |
- case RIGHT_ONLY: |
- if (actual_road_info.right_border < 0) |
- actual_car_status.orient += TURN_QUANTUM; |
- acc = 0.5 * max_acc; |
- break; |
- case NO_ROAD: |
- crashed = 1; |
- car_crash(params.sensor_pid,params.control_pid, |
- old_car_status.pos, 0); |
- break; |
- } |
- } |
- |
- /* Checking collisions... */ |
- if (actual_road_info.collision != NO_COLL) { |
- switch(actual_road_info.collision) { |
- case COLLISION_LEFT: |
- actual_car_status.orient -= TURN_QUANTUM; |
- acc *= (0.5 * params.rage); |
- break; |
- case COLLISION_RIGHT: |
- actual_car_status.orient += TURN_QUANTUM; |
- acc *= (0.5 * params.rage); |
- break; |
- } |
- } |
- |
- /* Checking acceleration range... */ |
- acc = max(min(max_acc,acc),min_acc); |
- actual_speed = old_speed + acc*dt; |
- |
- /* Checking speed range... */ |
- actual_speed = min(max(actual_speed,MIN_SPEED),max_speed); |
- |
- /* Checking steering angle ... */ |
- if (fabs(actual_car_status.orient - old_car_status.orient) > |
- STEERING_LIMIT) { |
- if ((actual_car_status.orient - old_car_status.orient) > 0) |
- actual_car_status.orient = old_car_status.orient + STEERING_LIMIT; |
- else |
- actual_car_status.orient = old_car_status.orient - STEERING_LIMIT; |
- } |
- |
- /* Setting new car position... */ |
- actual_car_status.pos.x += actual_speed * cos(degree_to_rad(actual_car_status.orient)); |
- actual_car_status.pos.y -= actual_speed * sin(degree_to_rad(actual_car_status.orient)); |
- |
- /* Checking track limits... */ |
- if (actual_car_status.pos.x < MIN_CAR_X) |
- actual_car_status.pos.x = MIN_CAR_X; |
- if (actual_car_status.pos.x > MAX_CAR_X) |
- actual_car_status.pos.x = MAX_CAR_X; |
- if (actual_car_status.pos.y < MIN_CAR_Y) |
- actual_car_status.pos.y = MIN_CAR_Y; |
- if (actual_car_status.pos.y > MAX_CAR_Y) |
- actual_car_status.pos.y = MAX_CAR_Y; |
- |
- /* Sends new status to car_status_cab */ |
- set_car_status(actual_car_status, params.car_status_cab); |
- |
- if (!crashed) { |
- /* Updates car */ |
- if (acc == min_acc) |
- draw_car(old_car_status.pos,actual_car_status, params.color, 1); |
- else |
- draw_car(old_car_status.pos,actual_car_status, params.color, 0); |
- } |
- |
- /* Sets display points */ |
- spd_p.x = TRACK_X1 + TRACK_WIDTH + TEL_HEIGHT + TEL_WIDTH + 9; |
- spd_p.y = TEL_HEIGHT*index + 1 + index + 1; |
- bar_display(spd_p, 70, 4, GREEN, actual_speed, max_speed, LIGHTGRAY, "Spd"); |
- |
- acc_p.x = spd_p.x; |
- acc_p.y = spd_p.y + 24; |
- bidir_bar_display(acc_p, 70, 4, GREEN, acc, max(fabs(min_acc), max_acc), LIGHTGRAY, "Acc"); |
- |
- sem_wait(&grx_mutex); |
- |
- /* Displays driver's name */ |
- drv_p.x = spd_p.x + 80; |
- drv_p.y = spd_p.y; |
- grx_text(params.driver, drv_p.x, drv_p.y, params.color, BLACK); |
- |
- /* Displays timer */ |
- time_p.x = spd_p.x + 80; |
- time_p.y = spd_p.y + 8; |
- if( (!bestlap_done) || (bestlap_done && t > 50)) |
- { |
- /* Mins */ |
- txt = itoa(ts.min, txt); |
- grx_text(txt, time_p.x, time_p.y, WHITE, BLACK); |
- grx_text(":", time_p.x + 8, time_p.y, WHITE, BLACK); |
- /* Secs */ |
- txt = itoa(ts.sec, txt); |
- if (ts.sec < 10) { |
- grx_text("0", time_p.x+16, time_p.y, WHITE, BLACK); |
- grx_text(txt, time_p.x+24, time_p.y, WHITE, BLACK); |
- } |
- else |
- grx_text(txt, time_p.x+16, time_p.y, WHITE, BLACK); |
- /* Decs */ |
- grx_text(":", time_p.x+32, time_p.y, WHITE, BLACK); |
- txt = itoa(ts.dec, txt); |
- grx_text(txt, time_p.x+40, time_p.y, WHITE, BLACK); |
- } |
- |
- /* Displays the best lap */ |
- if(bestlap_done == 1) |
- { |
- time_p.x = spd_p.x + 80; |
- time_p.y = spd_p.y + 16; |
- /* Mins */ |
- txt = itoa(bestlap_s.min, txt); |
- grx_text(txt, time_p.x, time_p.y, YELLOW, BLACK); |
- grx_text(":", time_p.x + 8, time_p.y, YELLOW, BLACK); |
- /* Secs */ |
- txt = itoa(bestlap_s.sec, txt); |
- if (bestlap_s.sec < 10) { |
- grx_text("0", time_p.x+16, time_p.y, YELLOW, BLACK); |
- grx_text(txt, time_p.x+24, time_p.y, YELLOW, BLACK); |
- } |
- else |
- grx_text(txt, time_p.x+16, time_p.y, YELLOW, BLACK); |
- /* Decs */ |
- grx_text(":", time_p.x+32, time_p.y, YELLOW, BLACK); |
- txt = itoa(bestlap_s.dec, txt); |
- grx_text(txt, time_p.x+40, time_p.y, YELLOW, BLACK); |
- } |
- |
- /* Displays lap number */ |
- time_p.x = spd_p.x + 80; |
- time_p.y = spd_p.y + 24; |
- grx_text("Lap ", time_p.x, time_p.y, LIGHTGRAY, BLACK); |
- txt = itoa(laps, txt); |
- grx_text(txt, time_p.x+32, time_p.y, LIGHTGRAY, BLACK); |
- |
- sem_post(&grx_mutex); |
- |
- /* Control the best lap */ |
- t += dt; |
- ts = int2time(t); |
- |
- /* Finish line */ |
- if ((track_list[i].lap == CLOCK && |
- (actual_car_status.pos.x >= polepos.x) && (old_car_status.pos.x < polepos.x) |
- && (actual_car_status.pos.y > polepos.y-20) && (actual_car_status.pos.y < polepos.y+20)) || |
- (track_list[i].lap == ANTICLOCK && |
- (actual_car_status.pos.x <= polepos.x) && (old_car_status.pos.x > polepos.x) |
- && (actual_car_status.pos.y > polepos.y-20) && (actual_car_status.pos.y < polepos.y+20))) { |
- laps++; // increases lap number |
- |
- bestlap = min(bestlap,t); |
- bestlap_s = int2time(bestlap); |
- bestlap_done = 1; |
- t = 0; |
- ts = int2time(t); |
- } |
- |
- /* Updates old values */ |
- old_car_status = actual_car_status; |
- old_acc = acc; |
- old_speed = actual_speed; |
- |
- } // end crashed |
- |
- task_endcycle(); |
- |
- // Esce se e' morto |
- if (killed) return 0; |
- } |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void car_crash(PID sp, PID cp, point_f old_pos, int free) |
-{ |
- point p1, p2; |
- p1.x = round(old_pos.x) - CAR_WIDTH/2 - 1; |
- p1.y = round(old_pos.y) - CAR_HEIGHT/2 - 1; |
- p2.x = p1.x + CAR_WIDTH + 1; |
- p2.y = p1.y + CAR_HEIGHT + 1; |
- |
- sem_wait(&grx_mutex); |
- /* Find the track box to redraw */ |
- put_trackbox(p1.x,p1.y,p2.x,p2.y); |
- |
- if (free == 0) { |
- // Draw the explosion |
- put_transimage(p1.x+1,p1.y+1,p2.x-1,p2.y-1,&sprite[16][0],0,0); |
- } |
- else if (free == 1) { |
- // Delete the explosion |
- put_trackbox(p1.x,p1.y,p2.x,p2.y); |
- task_kill(sp); |
- task_kill(cp); |
- } |
- sem_post(&grx_mutex); |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void draw_car(point_f old_pos, car_status cs, int car_color, int fumo) |
-{ |
- int index; |
- point p1, p2; |
- p1.x = round(old_pos.x) - CAR_WIDTH/2 - 1; |
- p1.y = round(old_pos.y) - CAR_HEIGHT/2 - 1; |
- p2.x = p1.x + CAR_WIDTH + 1; |
- p2.y = p1.y + CAR_HEIGHT + 1; |
- |
- sem_wait(&grx_mutex); |
- /* Find the track box to redraw */ |
- put_trackbox(p1.x,p1.y,p2.x,p2.y); |
- |
- |
- p1.x = round(cs.pos.x) + (CAR_WIDTH/2 * cos(degree_to_rad(cs.orient))); |
- p1.y = round(cs.pos.y) - (CAR_HEIGHT/2 * sin(degree_to_rad(cs.orient))); |
- p2.x = round(cs.pos.x) - (CAR_WIDTH/2 * cos(degree_to_rad(cs.orient))); |
- p2.y = round(cs.pos.y) + (CAR_HEIGHT/2 * sin(degree_to_rad(cs.orient))); |
- |
- index = ((((int)cs.orient%360)+360)%360); |
- index = (int)(index + 11.25)%360; |
- index /= 22.5; |
- |
- put_transimage(round(cs.pos.x) - CAR_WIDTH/2 + 1,round(cs.pos.y) - CAR_HEIGHT/2 + 1, |
- round(cs.pos.x) + CAR_WIDTH/2 ,round(cs.pos.y) + CAR_HEIGHT/2, |
- &sprite[index][0], car_color, 0); |
- if (fumo) |
- put_transimage(round(cs.pos.x) - CAR_WIDTH/2 + 1,round(cs.pos.y) - CAR_HEIGHT/2 + 1, |
- round(cs.pos.x) + CAR_WIDTH/2 ,round(cs.pos.y) + CAR_HEIGHT/2, |
- &sprite[17][0], car_color, 0); |
- sem_post(&grx_mutex); |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-/* Copy a box of track_image to screen */ |
-void put_trackbox(int x1, int y1, int x2, int y2) |
-{ |
- int y; |
- int tx1,ty1,tx2,ty2; |
- BYTE *addr; |
- |
- tx1 = x1-TRACK_X1+1; |
- ty1 = y1-TRACK_Y1; |
- tx2 = x2-TRACK_X1+1; |
- ty2 = y2-TRACK_Y1; |
- |
- if (tx1 < 0) tx1 = 0; |
- if (ty1 < 0) ty1 = 0; |
- if (tx2 > TRACK_WIDTH-1) tx2 = TRACK_WIDTH-1; |
- if (ty2 > TRACK_HEIGHT-1) ty2 = TRACK_HEIGHT-1; |
- |
- tx1 = max(tx1,0); |
- ty1 = max(ty1,0); |
- tx2 = min(tx2,TRACK_WIDTH-1); |
- ty2 = min(ty2,TRACK_HEIGHT-1); |
- |
- addr = &track_img[0] + tx1 + TRACK_WIDTH * ty1; |
- |
- x1 = max(0,x1); |
- y1 = max(0,y1); |
- |
- for (y = y1; y <= y2; y++) { |
- grx_putimage(x1+1, y, x2, y, addr); |
- addr += TRACK_WIDTH; |
- } |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void put_transimage(int x1, int y1, int x2, int y2, BYTE *img, int car_color, |
- int color) |
-{ |
- int x,y; |
- BYTE *addr; |
- addr = img; |
- |
- |
- for (y = y1; y < y2; y++) { |
- for ( x = x1; x < x2; x++, addr++) { |
- if (*addr != color) { |
- if (*addr == 26) |
- grx_plot(x,y,car_color); |
- else |
- grx_plot(x,y,*addr); |
- |
- } |
- } |
- addr++; |
- } |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void show_display(int rs, int ca, float speed, float max_speed, |
- float acc, float max_acc) |
-{ |
- point hw, mx, mz; // three road states |
- point tl, ct, tr; // three car alignments |
- point sp1, sp2; // speed display coordinates |
- point ap1, ap2; // acceleration display coordinates |
- int s_amp = 0; |
- int a_amp = 0; |
- |
- /* Leds coordinates */ |
- hw.x = 10; |
- hw.y = SCREEN_HEIGHT-50; |
- mx.x = 25; |
- mx.y = SCREEN_HEIGHT-50; |
- mz.x = 40; |
- mz.y = SCREEN_HEIGHT-50; |
- tl.x = 10; |
- tl.y = SCREEN_HEIGHT-35; |
- ct.x = 25; |
- ct.y = SCREEN_HEIGHT-35; |
- tr.x = 40; |
- tr.y = SCREEN_HEIGHT-35; |
- sp1.x = 10; |
- sp1.y = SCREEN_HEIGHT-75; |
- sp2.x = 110; |
- sp2.y = SCREEN_HEIGHT-65; |
- ap1.x = 10; |
- ap1.y = SCREEN_HEIGHT-90; |
- ap2.x = 110; |
- ap2.y = SCREEN_HEIGHT-80; |
- |
- sem_wait(&grx_mutex); |
- |
- /* Writes out controller titles */ |
- grx_text("Road", mz.x+15, mz.y, YELLOW, BLACK); |
- grx_text("Curve", tr.x+15, tr.y, YELLOW, BLACK); |
- switch (rs) |
- { |
- case HIGHWAY: |
- grx_box(hw.x, hw.y, hw.x+10, hw.y+10, GREEN); |
- grx_box(mx.x, mx.y, mx.x+10, mx.y+10, BLACK); |
- grx_box(mz.x, mz.y, mz.x+10, mz.y+10, BLACK); |
- break; |
- case MIXED: |
- grx_box(hw.x, hw.y, hw.x+10, hw.y+10, BLACK); |
- grx_box(mx.x, mx.y, mx.x+10, mx.y+10, YELLOW); |
- grx_box(mz.x, mz.y, mz.x+10, mz.y+10, BLACK); |
- break; |
- case MAZE: |
- grx_box(hw.x, hw.y, hw.x+10, hw.y+10, BLACK); |
- grx_box(mx.x, mx.y, mx.x+10, mx.y+10, BLACK); |
- grx_box(mz.x, mz.y, mz.x+10, mz.y+10, RED); |
- break; |
- } |
- |
- switch (ca) |
- { |
- case TOO_LEFT: |
- grx_box(tl.x, tl.y, tl.x+10, tl.y+10, RED); |
- grx_box(ct.x, ct.y, ct.x+10, ct.y+10, BLACK); |
- grx_box(tr.x, tr.y, tr.x+10, tr.y+10, BLACK); |
- break; |
- case TOO_RIGHT: |
- grx_box(tl.x, tl.y, tl.x+10, tl.y+10, BLACK); |
- grx_box(ct.x, ct.y, ct.x+10, ct.y+10, BLACK); |
- grx_box(tr.x, tr.y, tr.x+10, tr.y+10, BLUE); |
- break; |
- default: |
- grx_box(tl.x, tl.y, tl.x+10, tl.y+10, BLACK); |
- grx_box(ct.x, ct.y, ct.x+10, ct.y+10, WHITE); |
- grx_box(tr.x, tr.y, tr.x+10, tr.y+10, BLACK); |
- } |
- |
- /* Draws speed display */ |
- grx_text("Speed", sp1.x+120, sp1.y, YELLOW, BLACK); |
- grx_rect(sp1.x-1, sp1.y-1, sp2.x+1, sp2.y+1, GREEN); |
- /* Updates speed display */ |
- grx_box(sp1.x, sp1.y, sp2.x, sp2.y, BLACK); |
- s_amp = round( (speed * (float)(sp2.x-sp1.x)) / max_speed ); |
- grx_box(sp1.x, sp1.y, sp1.x+s_amp, sp2.y, LIGHTGRAY); |
- |
- /* Draws acceleration display */ |
- grx_text("Acceleration", ap1.x+120, ap1.y, YELLOW, BLACK); |
- grx_rect(ap1.x-1, ap1.y-1, ap2.x+1, ap2.y+1, GREEN); |
- /* Updates acceleration display */ |
- grx_box(ap1.x, ap1.y, ap2.x, ap2.y, BLACK); |
- a_amp = round( (float)acc * (float)((ap2.x-ap1.x)/2) / (float)max_acc ); |
- if (a_amp >= 0) |
- grx_box((ap1.x+ap2.x)/2, ap1.y, ((ap1.x+ap2.x)/2)+a_amp, ap2.y, LIGHTGRAY); |
- else |
- grx_box((ap1.x+ap2.x)/2+a_amp, ap1.y, ((ap1.x+ap2.x)/2), ap2.y, LIGHTGRAY); |
- grx_line((ap1.x+ap2.x)/2, ap1.y-2, (ap1.x+ap2.x)/2, ap2.y+2, WHITE); |
- sem_post(&grx_mutex); |
-} |
- |
Index: rel_1_21/auto/initfil3.c |
=================================================================== |
--- rel_1_21/auto/initfil3.c (revision 1217) |
+++ rel_1_21/auto/initfil3.c (nonexistent) |
@@ -1,107 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: initfil3.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "edfact.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-void read_track(int); |
-void read_sprites(); |
- |
-int argc; |
-char *argv[100]; |
-int main(int argc, char **argv); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDFACT_register_level(0); |
- CBS_register_level(0, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- __compute_args__(mb, &argc, argv); |
- |
- if (argc == 2) |
- read_track(strtoi(argv[1], 10, NULL)); |
- else |
- read_track(2); |
- |
- read_sprites(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- return (void *) main(argc,argv); |
-} |
Index: rel_1_21/auto/edfact.c |
=================================================================== |
--- rel_1_21/auto/edfact.c (revision 1217) |
+++ rel_1_21/auto/edfact.c (nonexistent) |
@@ -1,567 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@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: edfact.c,v 1.4 2003-01-07 17:10:15 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2003-01-07 17:10:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2001 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
-#include "edfact.h" |
-#include <ll/stdio.h> |
-#include <ll/string.h> |
-#include <kernel/model.h> |
-#include <kernel/descr.h> |
-#include <kernel/var.h> |
-#include <kernel/func.h> |
-#include <kernel/trace.h> |
- |
-//#define edfact_printf kern_printf |
-#define edfact_printf printk |
- |
-/*+ Status used in the level +*/ |
-#define EDFACT_READY MODULE_STATUS_BASE /*+ - Ready status +*/ |
-#define EDFACT_IDLE MODULE_STATUS_BASE+4 /*+ to wait the deadline +*/ |
- |
-/*+ flags +*/ |
-#define EDFACT_FLAG_NORAISEEXC 2 |
- |
-/*+ the level redefinition for the Earliest Deadline First level +*/ |
-typedef struct { |
- level_des l; /*+ the standard level descriptor +*/ |
- |
- TIME period[MAX_PROC]; /*+ The task periods; the deadlines are |
- stored in the priority field +*/ |
- int deadline_timer[MAX_PROC]; |
- /*+ The task deadline timers +*/ |
- |
- struct timespec deadline_timespec[MAX_PROC]; |
- |
- int dline_miss[MAX_PROC]; /*+ Deadline miss counter +*/ |
- int wcet_miss[MAX_PROC]; /*+ Wcet miss counter +*/ |
- |
- int nact[MAX_PROC]; /*+ Wcet miss counter +*/ |
- |
- int flag[MAX_PROC]; |
- /*+ used to manage the JOB_TASK_MODEL and the |
- periodicity +*/ |
- |
- IQUEUE ready; /*+ the ready queue +*/ |
- |
- int flags; /*+ the init flags... +*/ |
- |
- bandwidth_t U; /*+ the used bandwidth +*/ |
- |
-} EDFACT_level_des; |
- |
- |
-static void EDFACT_timer_deadline(void *par); |
- |
-static void EDFACT_internal_activate(EDFACT_level_des *lev, PID p, |
- struct timespec *t) |
-{ |
- struct timespec *temp; |
- |
- temp = iq_query_timespec(p, &lev->ready); |
- |
- TIMESPEC_ASSIGN(temp,t); |
- ADDUSEC2TIMESPEC(lev->period[p], temp); |
- |
- TIMESPEC_ASSIGN(&lev->deadline_timespec[p], |
- temp); |
- |
- /* Insert task in the correct position */ |
- proc_table[p].status = EDFACT_READY; |
- iq_timespec_insert(p,&lev->ready); |
- |
- /* needed because when there is a wcet miss I disable CONTROL_CAP */ |
- proc_table[p].control |= CONTROL_CAP; |
-} |
- |
-static void EDFACT_timer_deadline(void *par) |
-{ |
- PID p = (PID) par; |
- EDFACT_level_des *lev; |
- |
- lev = (EDFACT_level_des *)level_table[proc_table[p].task_level]; |
- |
- switch (proc_table[p].status) { |
- case EDFACT_IDLE: |
- edfact_printf("I%d",p); |
- |
- EDFACT_internal_activate(lev,p, &lev->deadline_timespec[p]); |
- |
- event_need_reschedule(); |
- break; |
- |
- default: |
- edfact_printf("D%d",p); |
- /* else, a deadline miss occurred!!! */ |
- lev->dline_miss[p]++; |
- |
- /* the task is into another state */ |
- lev->nact[p]++; |
- |
- /* Set the deadline timer */ |
- ADDUSEC2TIMESPEC(lev->period[p], &lev->deadline_timespec[p]); |
- } |
- |
- /* Set the deadline timer */ |
- lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
- EDFACT_timer_deadline, |
- (void *)p); |
- |
-} |
- |
-static void EDFACT_timer_guest_deadline(void *par) |
-{ |
- PID p = (PID) par; |
- |
- edfact_printf("AAARRRGGGHHH!!!"); |
- kern_raise(XDEADLINE_MISS,p); |
-} |
- |
- |
-/* The scheduler only gets the first task in the queue */ |
-static PID EDFACT_public_scheduler(LEVEL l) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- return iq_query_first(&lev->ready); |
-} |
- |
-/* The on-line guarantee is enabled only if the appropriate flag is set... */ |
-static int EDFACT_public_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- if (lev->flags & EDFACT_FAILED_GUARANTEE) { |
- *freebandwidth = 0; |
- return 0; |
- } |
- else |
- if (*freebandwidth >= lev->U) { |
- *freebandwidth -= lev->U; |
- return 1; |
- } |
- else |
- return 0; |
- |
-} |
- |
-static int EDFACT_public_create(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- HARD_TASK_MODEL *h; |
- |
- if (m->pclass != HARD_PCLASS) return -1; |
- if (m->level != 0 && m->level != l) return -1; |
- h = (HARD_TASK_MODEL *)m; |
- if (!h->wcet || !h->mit || h->periodicity != PERIODIC) return -1; |
- /* now we know that m is a valid model */ |
- |
- lev->period[p] = h->mit; |
- |
- lev->flag[p] = 0; |
- lev->deadline_timer[p] = -1; |
- lev->dline_miss[p] = 0; |
- lev->wcet_miss[p] = 0; |
- lev->nact[p] = 0; |
- |
- /* Enable wcet check */ |
- proc_table[p].avail_time = h->wcet; |
- proc_table[p].wcet = h->wcet; |
- proc_table[p].control |= CONTROL_CAP; |
- |
- /* update the bandwidth... */ |
- if (lev->flags & EDFACT_ENABLE_GUARANTEE) { |
- bandwidth_t b; |
- b = (MAX_BANDWIDTH / h->mit) * h->wcet; |
- |
- /* really update lev->U, checking an overflow... */ |
- if (MAX_BANDWIDTH - lev->U > b) |
- lev->U += b; |
- else |
- /* The task can NOT be guaranteed (U>MAX_BANDWIDTH)... |
- in this case, we don't raise an exception... in fact, after the |
- EDFACT_task_create the task_create will call level_guarantee that return |
- -1... return -1 in EDFACT_task_create isn't correct, because: |
- . generally, the guarantee must be done when also the resources |
- are registered |
- . returning -1 will cause the task_create to return with an errno |
- ETASK_CREATE instead of ENO_GUARANTEE!!! |
- |
- Why I use the flag??? because if the lev->U overflows, if i.e. I set |
- it to MAX_BANDWIDTH, I lose the correct allocated bandwidth... |
- */ |
- lev->flags |= EDFACT_FAILED_GUARANTEE; |
- } |
- |
- return 0; /* OK, also if the task cannot be guaranteed... */ |
-} |
- |
-static void EDFACT_public_detach(LEVEL l, PID p) |
-{ |
- /* the EDFACT level doesn't introduce any dinamic allocated new field. |
- we have only to reset the NO_GUARANTEE FIELD and decrement the allocated |
- bandwidth */ |
- |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- if (lev->flags & EDFACT_FAILED_GUARANTEE) |
- lev->flags &= ~EDFACT_FAILED_GUARANTEE; |
- else |
- lev->U -= (MAX_BANDWIDTH / lev->period[p]) * proc_table[p].wcet; |
-} |
- |
-static void EDFACT_public_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- /* the task state is set EXE by the scheduler() |
- we extract the task from the ready queue |
- NB: we can't assume that p is the first task in the queue!!! */ |
- iq_extract(p, &lev->ready); |
-} |
- |
-static void EDFACT_public_epilogue(LEVEL l, PID p) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- /* check if the wcet is finished... */ |
- if (proc_table[p].avail_time <= 0 && proc_table[p].control&CONTROL_CAP) { |
- /* wcet finished: disable wcet event and count wcet miss */ |
- edfact_printf("W%d",p); |
- proc_table[p].control &= ~CONTROL_CAP; |
- lev->wcet_miss[p]++; |
- } |
- |
- /* the task it returns into the ready queue... */ |
- iq_timespec_insert(p,&lev->ready); |
- proc_table[p].status = EDFACT_READY; |
-} |
- |
-static void EDFACT_public_activate(LEVEL l, PID p) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- struct timespec t; |
- |
- /* Test if we are trying to activate a non sleeping task */ |
- /* save activation (only if needed... */ |
- if (proc_table[p].status != SLEEP) { |
- /* a periodic task cannot be activated when it is already active */ |
- kern_raise(XACTIVATION,p); |
- return; |
- } |
- |
- kern_gettime(&t); |
- EDFACT_internal_activate(lev,p, &t); |
- |
- /* Set the deadline timer */ |
- lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
- EDFACT_timer_deadline, |
- (void *)p); |
- |
-} |
- |
-static void EDFACT_public_unblock(LEVEL l, PID p) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- /* Insert task in the coEDFect position */ |
- proc_table[p].status = EDFACT_READY; |
- iq_timespec_insert(p,&lev->ready); |
-} |
- |
-static void EDFACT_public_block(LEVEL l, PID p) |
-{ |
-} |
- |
-static int EDFACT_public_message(LEVEL l, PID p, void *m) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- struct timespec t; |
- |
- /* we reset the capacity counters... */ |
- proc_table[p].avail_time = proc_table[p].wcet; |
- |
- if (lev->nact[p] > 0) { |
- edfact_printf("E%d",p); |
- |
- /* Pending activation: reactivate the thread!!! */ |
- lev->nact[p]--; |
- |
- /* see also EDFACT_timer_deadline */ |
- kern_gettime(&t); |
- EDFACT_internal_activate(lev,p, &t); |
- |
- /* check if the deadline has already expired */ |
- if (TIMESPEC_A_LT_B(iq_query_timespec(p, &lev->ready), &schedule_time)) { |
- /* count the deadline miss */ |
- lev->dline_miss[p]++; |
- kern_event_delete(lev->deadline_timer[p]); |
- } |
- |
- } |
- else { |
- edfact_printf("e%d",p); |
- |
- /* the task has terminated his job before it consume the wcet. All OK! */ |
- proc_table[p].status = EDFACT_IDLE; |
- |
- /* when the deadline timer fire, it recognize the situation and set |
- correctly all the stuffs (like reactivation, etc... ) */ |
- } |
- |
- jet_update_endcycle(); /* Update the Jet data... */ |
- trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */ |
- |
- return 0; |
-} |
- |
-static void EDFACT_public_end(LEVEL l, PID p) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- edfact_printf("Û%d",p); |
- |
- /* we finally put the task in the ready queue */ |
- proc_table[p].status = FREE; |
- iq_insertfirst(p,&freedesc); |
- /* and free the allocated bandwidth */ |
- lev->U -= (MAX_BANDWIDTH/lev->period[p]) * proc_table[p].wcet; |
- |
- if (lev->deadline_timer[p] != -1) { |
- edfact_printf("²%d",p); |
- kern_event_delete(lev->deadline_timer[p]); |
- } |
-} |
- |
- |
-/* Guest Functions |
- These functions manages a JOB_TASK_MODEL, that is used to put |
- a guest task in the EDFACT ready queue. */ |
- |
-static void EDFACT_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- JOB_TASK_MODEL *job; |
- |
- if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) { |
- kern_raise(XINVALID_TASK, p); |
- return; |
- } |
- |
- job = (JOB_TASK_MODEL *)m; |
- |
- TIMESPEC_ASSIGN(iq_query_timespec(p, &lev->ready), &job->deadline); |
- |
- lev->deadline_timer[p] = -1; |
- lev->dline_miss[p] = 0; |
- lev->wcet_miss[p] = 0; |
- lev->nact[p] = 0; |
- |
- if (job->noraiseexc) |
- lev->flag[p] = EDFACT_FLAG_NORAISEEXC; |
- else { |
- lev->flag[p] = 0; |
- lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
- EDFACT_timer_guest_deadline, |
- (void *)p); |
- } |
- |
- lev->period[p] = job->period; |
- |
- /* Insert task in the correct position */ |
- iq_timespec_insert(p,&lev->ready); |
- proc_table[p].status = EDFACT_READY; |
- |
- /* there is no bandwidth guarantee at this level, it is performed |
- by the level that inserts guest tasks... */ |
-} |
- |
-static void EDFACT_private_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- /* the task state is set to EXE by the scheduler() |
- we extract the task from the ready queue |
- NB: we can't assume that p is the first task in the queue!!! */ |
- iq_extract(p, &lev->ready); |
-} |
- |
-static void EDFACT_private_epilogue(LEVEL l, PID p) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- /* the task has been preempted. it returns into the ready queue... */ |
- iq_timespec_insert(p,&lev->ready); |
- proc_table[p].status = EDFACT_READY; |
-} |
- |
-static void EDFACT_private_extract(LEVEL l, PID p) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- //kern_printf("EDFACT_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
- if (proc_table[p].status == EDFACT_READY) |
- { |
- iq_extract(p, &lev->ready); |
- //kern_printf("(g_end rdy extr)"); |
- } |
- |
- /* we remove the deadline timer, because the slice is finished */ |
- if (lev->deadline_timer[p] != NIL) { |
-// kern_printf("EDFACT_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
- kern_event_delete(lev->deadline_timer[p]); |
- lev->deadline_timer[p] = NIL; |
- } |
- |
-} |
- |
-/* Registration functions */ |
- |
-/*+ Registration function: |
- int flags the init flags ... see EDFACT.h +*/ |
-LEVEL EDFACT_register_level(int flags) |
-{ |
- LEVEL l; /* the level that we register */ |
- EDFACT_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- |
- printk("EDFACT_register_level\n"); |
- |
- /* request an entry in the level_table */ |
- l = level_alloc_descriptor(sizeof(EDFACT_level_des)); |
- |
- lev = (EDFACT_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- lev->l.private_insert = EDFACT_private_insert; |
- lev->l.private_extract = EDFACT_private_extract; |
- lev->l.private_dispatch = EDFACT_private_dispatch; |
- lev->l.private_epilogue = EDFACT_private_epilogue; |
- |
- lev->l.public_scheduler = EDFACT_public_scheduler; |
- if (flags & EDFACT_ENABLE_GUARANTEE) |
- lev->l.public_guarantee = EDFACT_public_guarantee; |
- else |
- lev->l.public_guarantee = NULL; |
- lev->l.public_create = EDFACT_public_create; |
- lev->l.public_detach = EDFACT_public_detach; |
- lev->l.public_end = EDFACT_public_end; |
- lev->l.public_dispatch = EDFACT_public_dispatch; |
- lev->l.public_epilogue = EDFACT_public_epilogue; |
- lev->l.public_activate = EDFACT_public_activate; |
- lev->l.public_unblock = EDFACT_public_unblock; |
- lev->l.public_block = EDFACT_public_block; |
- lev->l.public_message = EDFACT_public_message; |
- |
- /* fill the EDFACT descriptor part */ |
- for(i=0; i<MAX_PROC; i++) { |
- lev->period[i] = 0; |
- lev->deadline_timer[i] = -1; |
- lev->flag[i] = 0; |
- lev->dline_miss[i] = 0; |
- lev->wcet_miss[i] = 0; |
- lev->nact[i] = 0; |
- } |
- |
- iq_init(&lev->ready,&freedesc, 0); |
- lev->flags = flags & 0x07; |
- lev->U = 0; |
- |
- return l; |
-} |
- |
-bandwidth_t EDFACT_usedbandwidth(LEVEL l) |
-{ |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- return lev->U; |
-} |
- |
-int EDFACT_get_dline_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- return lev->dline_miss[p]; |
-} |
- |
-int EDFACT_get_wcet_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- return lev->wcet_miss[p]; |
-} |
- |
-int EDFACT_get_nact(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- return lev->nact[p]; |
-} |
- |
-int EDFACT_reset_dline_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- lev->dline_miss[p] = 0; |
- return 0; |
-} |
- |
-int EDFACT_reset_wcet_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]); |
- |
- lev->wcet_miss[p] = 0; |
- return 0; |
-} |
- |
Index: rel_1_21/auto/tracks.c |
=================================================================== |
--- rel_1_21/auto/tracks.c (revision 1217) |
+++ rel_1_21/auto/tracks.c (nonexistent) |
@@ -1,111 +0,0 @@ |
-/* |
- * 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: tracks.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* -------------- */ |
-/* Track loader */ |
-/* -------------- */ |
- |
-#include "include/auto.h" |
-#include "include/const.h" |
- |
-track track_list[TRACK_NUMBER]; |
- |
-int track_init() |
-{ |
- track demo1; |
- track demo2; |
- track brazil; |
- track monaco; |
- |
- strcpy(demo1.name, "demo1.raw"); |
- demo1.pole_pos.x = 150; |
- demo1.pole_pos.y = 35; |
- demo1.pole_orient = 0.0; |
- demo1.lap = CLOCK; |
- demo1.selected = 0; |
- |
- strcpy(demo2.name, "demo2.raw"); |
- demo2.pole_pos.x = 150; |
- demo2.pole_pos.y = 30; |
- demo2.pole_orient = 0.0; |
- demo2.lap = CLOCK; |
- demo2.selected = 0; |
- |
- strcpy(brazil.name, "brazil.raw"); |
- brazil.pole_pos.x = 140; |
- brazil.pole_pos.y = 185; |
- brazil.pole_orient = 225.0; |
- brazil.lap = ANTICLOCK; |
- brazil.selected = 0; |
- |
- strcpy(monaco.name, "monaco.raw"); |
- monaco.pole_pos.x = 35; |
- monaco.pole_pos.y = 315; |
- monaco.pole_orient = 85.0; |
- monaco.lap = CLOCK; |
- monaco.selected = 0; |
- |
- track_list[0] = demo1; |
- track_list[1] = demo2; |
- track_list[2] = brazil; |
- track_list[3] = monaco; |
- |
- return 0; |
-} |
Index: rel_1_21/auto/keyb.c |
=================================================================== |
--- rel_1_21/auto/keyb.c (revision 1217) |
+++ rel_1_21/auto/keyb.c (nonexistent) |
@@ -1,105 +0,0 @@ |
-/* |
- * 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: keyb.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------------ */ |
-/* Keyboard handler */ |
-/* ------------------ */ |
- |
-#include "include/auto.h" |
-#include "include/const.h" |
- |
- |
-void keyb_handler() { |
- KEY_EVT k; |
- keyb_set_map(itaMap); |
- |
- /* Exit keys: ENTER */ |
- k.flag = 0; |
- k.scan = KEY_ENT; |
- k.ascii = 13; |
- keyb_hook(k, endfun); |
- |
- /* Creates a new HARD car */ |
- k.flag = 0; |
- k.scan = KEY_H; |
- k.ascii = 'h'; |
- keyb_hook(k, hard_car_create); |
- |
- /* Creates a new SOFT car */ |
- k.flag = 0; |
- k.scan = KEY_S; |
- k.ascii = 's'; |
- keyb_hook(k, soft_car_create); |
-} |
- |
- |
-void endfun(KEY_EVT *k) |
-{ |
- grx_close(); |
- cprintf("Ctrl-Brk pressed! Ending...\n"); |
- sys_end(); |
-} |
- |
- |
-void my_close(void *arg) |
-{ |
- kern_printf("my_close\n"); |
-} |
- |
Index: rel_1_21/auto/edfact.h |
=================================================================== |
--- rel_1_21/auto/edfact.h (revision 1217) |
+++ rel_1_21/auto/edfact.h (nonexistent) |
@@ -1,152 +0,0 @@ |
-/* |
- * 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: edfact.h,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:15 $ |
- ------------ |
- |
- This file contains the server EDFACT (EDF with pending activations) |
- |
- Title: |
- EDFACT |
- |
- Task Models Accepted: |
- HARD_TASK_MODEL - Hard Tasks (only Periodic) |
- wcet field and mit field must be != 0. They are used to set the wcet |
- and period of the tasks. |
- periodicity field can be only PERIODIC |
- drel field is ignored |
- |
- Guest Models Accepted: |
- JOB_TASK_MODEL - a single guest task activation |
- Identified by an absolute deadline and a period. |
- period field is ignored |
- |
- Description: |
- This module schedule his tasks following the classic EDF scheme. |
- The task guarantee is based on the factor utilization approach. |
- The tasks scheduled are only periodic. |
- All the task are put in a queue and the scheduling is based on the |
- deadline value. |
- NO GUARANTEE is performed on guest tasks. The guarantee must be performed |
- by the level that inserts guest tasks in the EDF level. |
- If a task miss a deadline a counter is incremented. |
- If a task exausts the wcet a counter is incremented |
- No ZOMBIE support!!!!!! |
- |
- Exceptions raised: |
- XUNVALID_GUEST XUNVALID_TASK |
- some primitives are not implemented: |
- task_sleep, task_delay, guest_endcycle, guest_sleep, guest_delay |
- |
- XACTIVATION |
- If a task is actiated through task_activate or guest_activate more than |
- one time |
- |
- Restrictions & special features: |
- - This level doesn't manage the main task. |
- - At init time we have to specify: |
- . guarantee check |
- (when all task are created the system will check that the task_set |
- will not use more than the available bandwidth) |
- - A function to return the used bandwidth of the level is provided. |
- - Functions to return and reset the nact, wcet and dline miss counters |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2001 Paolo Gai |
- * |
- * 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 |
- * |
- */ |
- |
- |
-#ifndef __EDFACT_H__ |
-#define __EDFACT_H__ |
- |
-#include <ll/ll.h> |
-#include <kernel/config.h> |
-#include <sys/types.h> |
-#include <kernel/types.h> |
- |
- |
- |
- |
- |
- |
- |
- |
-/*+ flags... +*/ |
-#define EDFACT_ENABLE_GUARANTEE 1 /*+ Task Guarantee enabled +*/ |
-#define EDFACT_ENABLE_ALL 1 |
- |
-#define EDFACT_FAILED_GUARANTEE 8 /*+ used in the module, unsettabl |
- in EDF_register_level... +*/ |
- |
- |
- |
- |
- |
-#define ELASTIC_HARD_PCLASS 0x0600 |
- |
-#define EDFACT_LEVELNAME "EDFACT base" |
-#define EDFACT_LEVEL_CODE 166 |
-#define EDFACT_LEVEL_VERSION 1 |
- |
- |
-/*+ Registration function: |
- int flags Options to be used in this level instance... |
- |
- returns the level number at which the module has been registered. |
-+*/ |
-LEVEL EDFACT_register_level(int flags); |
- |
-/*+ Returns the used bandwidth of a level +*/ |
-bandwidth_t EDFACT_usedbandwidth(LEVEL l); |
- |
-/*+ returns respectively the number of dline, wcet or nact; -1 if error +*/ |
-int EDFACT_get_dline_miss(PID p); |
-int EDFACT_get_wcet_miss(PID p); |
-int EDFACT_get_nact(PID p); |
- |
-/*+ resets respectively the number of dline, wcet miss; -1 if error +*/ |
-int EDFACT_reset_dline_miss(PID p); |
-int EDFACT_reset_wcet_miss(PID p); |
- |
-#endif |
- |
Index: rel_1_21/auto/info.c |
=================================================================== |
--- rel_1_21/auto/info.c (revision 1217) |
+++ rel_1_21/auto/info.c (nonexistent) |
@@ -1,154 +0,0 @@ |
-/* |
- * 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: info.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------------- */ |
-/* Information panel */ |
-/* ------------------- */ |
- |
-#include "include/auto.h" |
-#include "include/const.h" |
-#include "include/utils.h" |
- |
-extern sem_t grx_mutex; |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name) |
-{ |
- int background = BLACK; |
- int amp = 0; |
- point p2; |
- |
- p2.x = p1.x + width; |
- p2.y = p1.y + height; |
- |
- sem_wait(&grx_mutex); |
- |
- grx_text(name, p1.x, p1.y + height + 3, color, background); |
- grx_rect(p1.x - 1, p1.y - 1, p2.x + 1, p2.y + 1, border); |
- |
- grx_box(p1.x, p1.y, p2.x, p2.y, BLACK); |
- amp = abs(round( var * (float)(p2.x - p1.x) / max )); |
- grx_box(p1.x, p1.y, p1.x + amp, p2.y, color); |
- |
- sem_post(&grx_mutex); |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void bidir_bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name) |
-{ |
- int background = BLACK; |
- int amp = 0; |
- point p2; |
- |
- p2.x = p1.x + width; |
- p2.y = p1.y + height; |
- |
- sem_wait(&grx_mutex); |
- |
- grx_text(name, p1.x, p1.y + height + 3, color, background); |
- grx_rect(p1.x - 1, p1.y - 1, p2.x + 1, p2.y + 1, border); |
- |
- grx_box(p1.x, p1.y, p2.x, p2.y, BLACK); |
- amp = round( var * (float)((p2.x - p1.x)/2) / max ); |
- if (amp >= 0) |
- grx_box((p1.x+p2.x)/2, p1.y, ((p1.x+p2.x)/2)+amp, p2.y, color); |
- else |
- grx_box((p1.x+p2.x)/2+amp, p1.y, ((p1.x+p2.x)/2), p2.y, color); |
- grx_line((p1.x+p2.x)/2, p1.y-2, (p1.x+p2.x)/2, p2.y+2, border); |
- |
- sem_post(&grx_mutex); |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
-void cmd_display() |
-{ |
- point p1; |
- |
- p1.x = TRACK_X1; |
- p1.y = TRACK_Y2+3; |
- |
- sem_wait(&grx_mutex); |
- grx_rect(p1.x, p1.y, p1.x+CMD_WIDTH, p1.y+CMD_HEIGHT, BLUE); |
- grx_rect(p1.x+1, p1.y+1, p1.x+CMD_WIDTH-1, p1.y+CMD_HEIGHT-1, CYAN); |
- grx_rect(p1.x+2, p1.y+2, p1.x+CMD_WIDTH-2, p1.y+CMD_HEIGHT-2, LIGHTBLUE); |
- grx_text("## Another Unuseful Track simulatOr ##", |
- p1.x+8, p1.y+8, YELLOW, BLACK); |
- grx_text("## -------------------------------- ##", |
- p1.x+8, p1.y+16, YELLOW, BLACK); |
- grx_text("Marco Dallera", p1.x+8, p1.y+24, GREEN, BLACK); |
- grx_text("marchicchio@libero.it", p1.x+120, p1.y+24, GREEN, BLACK); |
- grx_text("Marco Fiocca", p1.x+8, p1.y+32, GREEN, BLACK); |
- grx_text("marqinho@tiscalinet.it", p1.x+120, p1.y+32, GREEN, BLACK); |
- |
- grx_text("Command keys ", p1.x+8, p1.y+48, LIGHTBLUE, BLACK); |
- grx_text("------------------------", p1.x+8, p1.y+56, LIGHTBLUE, BLACK); |
- grx_text("h create a HARD car", p1.x+8, p1.y+64, CYAN, BLACK); |
- grx_text("s create a SOFT car", p1.x+8, p1.y+72, CYAN, BLACK); |
- grx_text("ENTER exit to DOS", p1.x+8, p1.y+80, CYAN, BLACK); |
- |
- sem_post(&grx_mutex); |
- |
-} |
- |
-/* ------------------------------------------------------------------ */ |
- |
Index: rel_1_21/auto/makefile |
=================================================================== |
--- rel_1_21/auto/makefile (revision 1217) |
+++ rel_1_21/auto/makefile (nonexistent) |
@@ -1,22 +0,0 @@ |
-# |
-# Auto Makefile |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= auto auto2 auto3 |
- |
-include $(BASE)/config/example.mk |
- |
-auto: |
- make -f $(SUBMAKE) APP=auto INIT= OTHEROBJS="initfil1.o sensor.o control.o keyb.o info.o utils.o tracks.o jetctrl.o" SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-auto2: |
- make -f $(SUBMAKE) APP=auto INIT= OTHEROBJS="initfil2.o sensor.o control.o keyb.o info.o utils.o tracks.o jetctrl.o" SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-auto3: |
- make -f $(SUBMAKE) APP=auto INIT= OTHEROBJS="initfil3.o sensor.o control.o keyb.o info.o utils.o tracks.o edfact.o jetctrl.o" SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: rel_1_21/auto/utils.c |
=================================================================== |
--- rel_1_21/auto/utils.c (revision 1217) |
+++ rel_1_21/auto/utils.c (nonexistent) |
@@ -1,131 +0,0 @@ |
-/* |
- * 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: utils.c,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-#include "include/auto.h" |
-#include "include/utils.h" |
-#include <string.h> |
-#include <stdlib.h> |
- |
-float rand_01() |
-{ |
- return (((float)(rand()%20) / 100.0) + 0.8); |
-} |
- |
-int rand_color() |
-{ |
- return (rand()%16); |
-} |
- |
-int round(float value) |
-{ |
- return ((int)(value + 0.5)); |
-} |
- |
-void reverse(char s[]) { |
- int c, i, j; |
- |
- for (i = 0, j = strlen(s)-1; i<j; i++, j--) { |
- c = s[i]; |
- s[i] = s[j]; |
- s[j] = c; |
- } |
-} |
- |
-char * itoa(int n, char *s) { |
- int i, sign; |
- |
- if ((sign = n) < 0) |
- n = -n; |
- i = 0; |
- |
- do { |
- s[i++] = n % 10 + '0'; |
- } while ((n /= 10) > 0); |
- |
- if (sign < 0) |
- s[i++] = '-'; |
- s[i] = 0; |
- |
- reverse(s); |
- |
- return s; |
-} |
- |
-time int2time(int t) |
-{ |
- time ts; |
- |
- ts.dec = t % 10; |
- ts.sec = (t/10) % 60; |
- ts.min = (int)(t / 600); |
- |
- return ts; |
-} |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
Index: rel_1_21/auto/include/utils.h |
=================================================================== |
--- rel_1_21/auto/include/utils.h (revision 1217) |
+++ rel_1_21/auto/include/utils.h (nonexistent) |
@@ -1,76 +0,0 @@ |
-/* |
- * 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: utils.h,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------------ */ |
-/* Useful functions */ |
-/* ------------------ */ |
- |
-#ifndef __UTILS_H_ |
- |
-#define __UTILS_H_ |
- |
-float rand_01(); |
-int rand_color(); |
-int round(float value); |
-char * itoa(int n, char *s); |
-void reverse(char s[]); |
-time int2time(int t); |
- |
-#endif |
Index: rel_1_21/auto/include/const.h |
=================================================================== |
--- rel_1_21/auto/include/const.h (revision 1217) |
+++ rel_1_21/auto/include/const.h (nonexistent) |
@@ -1,141 +0,0 @@ |
-/* |
- * 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: const.h,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------------ */ |
-/* Useful constants */ |
-/* ------------------ */ |
- |
-#ifndef __CONST_H_ |
- |
-#define __CONST_H_ |
- |
-/* Screen dimensions */ |
-#define SCREEN_WIDTH 800 |
-#define SCREEN_HEIGHT 600 |
-#define SCREEN_BIT_COLORS 8 |
- |
-/* Visible area */ |
-#define TEL_WIDTH 50 |
-#define TEL_HEIGHT 50 |
- |
-/* Car dimensions */ |
-#define CAR_WIDTH 12 |
-#define CAR_HEIGHT 12 |
-#define CAR_W 8 |
-#define CAR_H 10 |
- |
-/* Track dimensions */ |
-#define TRACK_WIDTH 500 |
-#define TRACK_HEIGHT 500 |
- |
-/* Track position */ |
-#define TRACK_X1 0 |
-#define TRACK_Y1 0 |
-#define TRACK_X2 TRACK_X1+TRACK_WIDTH-1 |
-#define TRACK_Y2 TRACK_Y1+TRACK_HEIGHT-1 |
- |
-/* Max number of car on track */ |
-#define MAX_CAR_NUMBER 10 |
-#define DRIVERS_NUMBER 20 |
-#define MAX_DRIVER_NAME_LENGTH 20 |
-#define MAX_TRACK_NAME_LENGTH 20 |
-#define TRACK_NUMBER 4 |
- |
-/* Lap direction */ |
-#define CLOCK 0 |
-#define ANTICLOCK 1 |
- |
-/* Information display coords */ |
-#define CMD_WIDTH TRACK_WIDTH |
-#define CMD_HEIGHT (SCREEN_HEIGHT-TRACK_HEIGHT-3) |
- |
-/* Car position limits */ |
-#define MIN_CAR_X (TRACK_X1 + CAR_WIDTH/2 + 4) |
-#define MIN_CAR_Y (TRACK_Y1 + CAR_HEIGHT/2 + 4) |
-#define MAX_CAR_X (TRACK_X2 - CAR_WIDTH/2 - 4) |
-#define MAX_CAR_Y (TRACK_Y2 - CAR_HEIGHT/2 - 4) |
- |
-/* Road constants */ |
-#define LEFT_ONLY 10 |
-#define RIGHT_ONLY 11 |
-#define ROAD_OK 12 |
-#define NO_ROAD 13 |
- |
-/* Collision constants */ |
-#define COLLISION_LEFT 20 |
-#define COLLISION_RIGHT 21 |
-#define COLLISION_BACK 22 |
-#define NO_COLL 0 |
- |
-/* CAB constants */ |
-#define ROAD_MSG_DIM sizeof(road_info) |
-#define ROAD_MSG_READER 4 |
- |
-#define CAR_MSG_DIM sizeof(car_status) |
-#define CAR_MSG_READER 5 |
- |
-/* Tasks parameters */ |
-#define SENSOR_WCET 3000 |
-#define SENSOR_PERIOD 40000 |
-#define CONTROL_WCET 1000 |
-#define CONTROL_PERIOD 40000 |
- |
-#endif |
- |
Index: rel_1_21/auto/include/auto.h |
=================================================================== |
--- rel_1_21/auto/include/auto.h (revision 1217) |
+++ rel_1_21/auto/include/auto.h (nonexistent) |
@@ -1,188 +0,0 @@ |
-/* |
- * 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: auto.h,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:42 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------------- */ |
-/* Useful structures */ |
-/* ------------------- */ |
- |
-#ifndef __CAR_H_ |
- |
-#define __CAR_H_ |
- |
-#include <modules/cabs.h> |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
-#include <kernel/types.h> |
-#include <drivers/keyb.h> |
-#include <drivers/glib.h> |
-#include <semaphore.h> |
-#include <math.h> |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <string.h> |
-#include "const.h" |
- |
-#define degree_to_rad(a) ((M_PI/180.0)*(a)) |
-#define rad_to_degree(a) ((180.0/M_PI)*(a)) |
- |
-typedef struct { |
- int x; |
- int y; |
-} point; |
- |
-typedef struct { |
- float x,y; |
-} point_f; |
- |
-typedef struct { |
- float mod; |
- float phase; |
-} vector; |
- |
-typedef struct { |
- point_f pos; |
- float orient; |
-} car_status; |
- |
-typedef struct { |
- int left_border; |
- int right_border; |
- int distance; |
- float curve; |
- point opps_list[MAX_CAR_NUMBER]; |
- int opps_number; |
- int collision; |
- int flag; |
-} road_info; |
- |
-typedef struct { |
- int left,center,right; |
-} road_strip; |
- |
-typedef struct { |
- PID sensor_pid,control_pid; |
- int number; |
- char driver[MAX_DRIVER_NAME_LENGTH]; |
- float max_speed, min_acc, max_acc; |
- float rage; |
- CAB road_status_cab; |
- CAB car_status_cab; |
- int color; |
-} car_params; |
- |
-typedef struct { |
- char name[MAX_TRACK_NAME_LENGTH]; // il nome del file |
- point pole_pos; // la posizione di partenza |
- float pole_orient; // la direzione di partenza |
- int lap; // il senso di marcia: CLOCK, ANTICLOCK |
- int selected; // it's a flag marking the actually selected track |
-} track; |
- |
-typedef struct { |
- int min; |
- int sec; |
- int dec; |
-} time; |
- |
-extern car_params cars[MAX_CAR_NUMBER]; |
-extern char track_img[TRACK_WIDTH*TRACK_HEIGHT]; |
-extern track track_list[TRACK_NUMBER]; |
- |
-/* ---------------------------------------- */ |
-/* Functions definition */ |
-/* ---------------------------------------- */ |
- |
-/* CABs R/W functions */ |
-int set_car_status(car_status, CAB); // sends the new status according to the control law |
-car_status get_car_status(CAB); // reads car status from a CAB |
-int set_road_info(road_info, CAB); // sends the new road informations |
-road_info get_road_info(CAB); // reads road status values from a CAB |
- |
-/* Keyboard functions */ |
-void keyb_handler(); |
-void endfun(KEY_EVT *); |
-void my_close(void *); |
- |
-/* Display functions */ |
-void bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name); |
-void bidir_bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name); |
-void cmd_display(); |
- |
-/* Closing function */ |
-void byebye(); |
-void error_msg(); |
- |
-/* Tasks */ |
-TASK sensor(); // Camera car task |
-TASK control(); // Car controller task |
-TASK manual(); // Manual driving task |
-TASK actuator(); // Graphic drawing task |
-TASK info(); // Car informations display task |
- |
-/* Tasks management */ |
-void hard_car_create(); |
-void soft_car_create(); |
-void killcar(); |
- |
-/* Tracks management */ |
-int track_init(); |
- |
-#endif |
- |
Index: rel_1_21/auto/tracks/monaco.raw |
=================================================================== |
--- rel_1_21/auto/tracks/monaco.raw (revision 1217) |
+++ rel_1_21/auto/tracks/monaco.raw (nonexistent) |
@@ -1 +0,0 @@ |
- |
\ No newline at end of file |
Index: rel_1_21/auto/tracks/brazil.raw |
=================================================================== |
--- rel_1_21/auto/tracks/brazil.raw (revision 1217) |
+++ rel_1_21/auto/tracks/brazil.raw (nonexistent) |
@@ -1,2 +0,0 @@ |
-
- ! " |
---|