/unsupported/trunk/joy/joy_test.c |
File deleted |
|
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: joy/joy_grx.c |
=================================================================== |
--- joy/joy_grx.c (revision 1656) |
+++ joy/joy_grx.c (nonexistent) |
@@ -1,177 +0,0 @@ |
- |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * Authors : Paolo Gai <pj@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * 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 <kernel/func.h> |
-#include <stdlib.h> |
-#include <drivers/keyb.h> |
-#include <drivers/glib.h> |
-#include <semaphore.h> |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include <math.h> |
- |
-#include "joy.h" |
- |
-#define RGB_BLACK rgb16( 0, 0, 0) |
-#define RGB_GRAY rgb16(127,127,127) |
-#define RGB_WHITE rgb16(255,255,255) |
-#define RGB_RED rgb16(255, 0, 0) |
-#define RGB_GREEN rgb16( 0,255, 0) |
-#define RGB_BLUE rgb16( 0, 0,255) |
-#define RGB_YELLOW rgb16(255,255, 0) |
-#define RGB_MAGENTA rgb16(255, 0,255) |
-#define RGB_CYAN rgb16( 0,255,255) |
-#define RGB_D_RED rgb16(127, 0, 0) |
-#define RGB_D_GREEN rgb16( 0,127, 0) |
-#define RGB_D_BLUE rgb16( 0, 0,127) |
-#define RGB_D_YELLOW rgb16(127,127, 0) |
-#define RGB_D_MAGENTA rgb16(127, 0,127) |
-#define RGB_D_CYAN rgb16( 0,127,127) |
- |
-sem_t mx_mat, mx_grf; /* mutex semaphores */ |
-PID pid; |
-JOY_BOUND jb; |
- |
- |
-TASK write() |
-{ |
- int x = 319, y = 239; |
- float dx, dy; |
- JOY_STATE jsa; |
- |
- clear(); |
- |
- dx = 640 / (jb.x_max - jb.x_min); |
- dy = 480 / (jb.y_max - jb.y_min); |
- |
- while (1) { |
- sem_wait(&mx_grf); |
- grx_circle(10 + x, 10 + y, 9, RGB_BLACK); |
- sem_post(&mx_grf); |
- |
- get_joystick_A(&jsa); |
- |
- x = (jsa.x - jb.x_min) * dx; |
- y = (jsa.y - jb.y_min) * dy; |
- |
- sem_wait(&mx_grf); |
- if (jsa.b1==1) |
- grx_circle(10 + dx * x, 10 + dy * y, 9, RGB_RED); |
- else |
- grx_circle(10 + dx * x, 10 + dy * y, 9, RGB_YELLOW); |
- sem_post(&mx_grf); |
- |
- task_endcycle(); |
- } |
- return 0; |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("Ctrl-Brk pressed! Ending...\n"); |
- sys_end(); |
-} |
- |
-void my_close(void *arg) |
-{ |
- int i; |
- TIME tmp; |
- |
- grx_close(); |
- kern_printf("Taskset Execution Time\n\n"); |
- for (i=3; i<MAX_PROC; i++){ |
- if (!jet_getstat(i, NULL, &tmp, NULL, NULL)) |
- kern_printf("Task Name : %s - Max Time : %d\n", proc_table[i].name, (int)tmp); |
- } |
-} |
- |
-void init_graph() { |
- grx_box( 0, 0,639,479,RGB_BLACK); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- SOFT_TASK_MODEL ms; |
- KEY_EVT k; |
- TIME seme; |
- int modenum; |
- |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- sem_init(&mx_mat,0,1); |
- sem_init(&mx_grf,0,1); |
- |
- seme = sys_gettime(NULL); |
- srand(seme); |
- |
- sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- if (get_joystick_bound_A(&jb)) { |
- perror("Could not find Joystick."); |
- sys_end(); |
- } |
- |
- grx_init(); |
- modenum = grx_getmode(640, 480, 16); |
- grx_setmode(modenum); |
- init_graph(); |
- |
- soft_task_default_model(ms); |
- soft_task_def_level(ms,1); |
- soft_task_def_ctrl_jet(ms); |
- soft_task_def_met(ms,100); |
- soft_task_def_period(ms,10000); |
- soft_task_def_usemath(ms); |
- pid = task_create("Write", write, &ms, NULL); |
- if (pid == NIL) { |
- grx_close(); |
- perror("Could not create task <Write>"); |
- sys_end(); |
- } else { |
- task_activate(pid); |
- } |
- |
- return 0; |
-} |
/joy/joy_grx.c |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: joy/initfile.c |
=================================================================== |
--- joy/initfile.c (revision 1656) |
+++ joy/initfile.c (nonexistent) |
@@ -1,84 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Paolo Gai <pj@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.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 <kernel/func.h> |
-#include <stdlib.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 //300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 300 |
- |
-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(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_set_map(itaMap); |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
/joy/initfile.c |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: joy/README |
=================================================================== |
--- joy/README (revision 1656) |
+++ joy/README (nonexistent) |
@@ -1,2 +0,0 @@ |
-TODO |
- |
Index: joy/makefile |
=================================================================== |
--- joy/makefile (revision 1656) |
+++ joy/makefile (nonexistent) |
@@ -1,18 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= joy_hex joy_test joy_grx |
- |
-include $(BASE)/config/example.mk |
- |
-joy_grx: |
- make -f $(SUBMAKE) APP=joy_grx INIT= OTHEROBJS="initfile.o" SHARKOPT="__OLDCHAR__ __GRX__ __JOY__" |
- |
-joy_test: |
- make -f $(SUBMAKE) APP=joy_test INIT= OTHEROBJS="initfile.o" SHARKOPT="__OLDCHAR__ __JOY__" |
/joy/makefile |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: base_cpp/readme |
=================================================================== |
--- base_cpp/readme (revision 1656) |
+++ base_cpp/readme (nonexistent) |
@@ -1,8 +0,0 @@ |
-This directory contains a few C++ demos: |
- |
-- hello.cpp - this is a simple hello world written in C++, similar to that in demos/base |
- |
- |
-Initialization files: |
- |
-- ihello.c - same as in demos/base |
Index: base_cpp/ihello.c |
=================================================================== |
--- base_cpp/ihello.c (revision 1656) |
+++ base_cpp/ihello.c (nonexistent) |
@@ -1,95 +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: ihello.c,v 1.1.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:47 $ |
- ------------ |
- |
- The simplest initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- NRT_TASK_MODEL at level 0 |
- |
-**/ |
- |
-/* |
- * 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/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: base_cpp/makefile |
=================================================================== |
--- base_cpp/makefile (revision 1656) |
+++ base_cpp/makefile (nonexistent) |
@@ -1,13 +0,0 @@ |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = hello |
- |
-include $(BASE)/config/example.mk |
- |
- |
-# Text applications |
-hello: |
- make -f $(SUBMAKE) APP=hello INIT= OTHEROBJS="ihello.o" OTHERINCL= |
Index: base_cpp/hello.cpp |
=================================================================== |
--- base_cpp/hello.cpp (revision 1656) |
+++ base_cpp/hello.cpp (nonexistent) |
@@ -1,72 +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 |
- */ |
- |
-/* |
- * Copyright (C) 2003 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 |
- */ |
- |
-/* |
- CVS : $Id: hello.cpp,v 1.1.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- hello.c: |
- |
- This test is a simple hello world function. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-class myHello { |
- int i; |
-public: |
- |
- myHello(int anumber) |
- { |
- i = anumber; |
- } |
- |
- void myprint(void) |
- { |
- cprintf("myHello objecy prints %d.", i); |
- } |
-}; |
- |
-int main(int argc, char **argv) |
-{ |
- cprintf("Hello, world!\n"); |
- |
- myHello h(1234); |
- |
- h.myprint(); |
- |
- return 0; |
-} |
Index: oldexamples/stdio/test0.c |
=================================================================== |
--- oldexamples/stdio/test0.c (revision 1656) |
+++ oldexamples/stdio/test0.c (nonexistent) |
@@ -1,72 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <stdio.h> |
-#include <string.h> |
- |
-int main(int argc,char *argv[]) |
-{ |
- char buffer[256]; |
- FILE *fin; |
- int res; |
- int c; |
- |
- /* |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- return -1; |
- } |
- |
- res=mount(temp_device,FS_MSDOS,"/TEMP",NULL); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- sys_end(); |
- return -1; |
- } |
- */ |
- |
- /* |
- * |
- */ |
- |
- fin=NULL; |
- |
- cprintf("opening...\n"); |
- fin=fopen("/TEMP/ALFA1.TXT","r"); |
- cprintf("opened!\n"); |
- |
- cprintf("res=%p\n",fin); |
- |
- if (fin!=NULL) { |
- |
- while (!feof(fin)) { |
- |
- memset(buffer,'@',sizeof(buffer)); |
- |
- cprintf("reading...\n"); |
- res=fread(buffer,1,sizeof(buffer)-1,fin); |
- cprintf("read!\n"); |
- |
- cprintf("res=%i\n",res); |
- buffer[res<sizeof(buffer)-1?res:sizeof(buffer)-1]='\0'; |
- cprintf("'%s'\n",buffer); |
- |
- } |
- |
- cprintf("closing...\n"); |
- fclose(fin); |
- cprintf("closed!\n"); |
- } |
- |
- cprintf("[press 'x' to exit]\n"); |
- while ((c = keyb_getch(BLOCK)) != 'x') ; |
- |
- return 0; |
-} |
Index: oldexamples/stdio/test1.c |
=================================================================== |
--- oldexamples/stdio/test1.c (revision 1656) |
+++ oldexamples/stdio/test1.c (nonexistent) |
@@ -1,67 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <stdio.h> |
-#include <string.h> |
- |
-int main(int argc,char *argv[]) |
-{ |
- char buffer[256]; |
- FILE *fin; |
- char *s; |
- // int res; |
- int c; |
- |
- /* |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- return -1; |
- } |
- |
- res=mount(temp_device,FS_MSDOS,"/TEMP",NULL); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- sys_end(); |
- return -1; |
- } |
- */ |
- |
- /* |
- * |
- */ |
- |
- cprintf("opening...\n"); |
- fin=fopen("/TEMP/ALFA2.TXT","r"); |
- cprintf("opened!\n"); |
- |
- if (fin!=NULL) { |
- |
- while (!feof(fin)) { |
- cprintf("getting line...\n"); |
- s=fgets(buffer,sizeof(buffer),fin); |
- cprintf("got!\n"); |
- if (s==NULL) { |
- if (ferror(fin)) |
- cprintf("error while using fgets()!\n"); |
- break; |
- } |
- cprintf("'%s'\n",buffer); |
- } |
- |
- cprintf("closing...\n"); |
- fclose(fin); |
- cprintf("closed!\n"); |
- } |
- |
- cprintf("[press 'x' to exit]\n"); |
- while ((c = keyb_getchar()) != 'x') ; |
- |
- return 0; |
-} |
Index: oldexamples/stdio/test2.c |
=================================================================== |
--- oldexamples/stdio/test2.c (revision 1656) |
+++ oldexamples/stdio/test2.c (nonexistent) |
@@ -1,91 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <string.h> |
- |
-int main(int argc,char *argv[]) |
-{ |
- char buffer[256]; |
- FILE *fin; |
- char *s; |
- int res; |
- int c,n; |
- char ch; |
- |
- /* |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- return -1; |
- } |
- |
- res=mount(temp_device,FS_MSDOS,"/TEMP",NULL); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- sys_end(); |
- return -1; |
- } |
- */ |
- |
- /* |
- * |
- */ |
- |
- cprintf("opening...\n"); |
- fin=fopen("/TEMP/ALFA2.TXT","r"); |
- cprintf("opened!\n"); |
- |
- if (fin!=NULL) { |
- |
- n=-1; |
- cprintf("fscanf()ing...\n"); |
- res=fscanf(fin,"number %i",&n); |
- cprintf("fscanf()ed...\n"); |
- if (res!=1) { |
- cprintf("error on 1st fscanf() res=%i\n",res); |
- return 0; |
- } |
- cprintf("scanned number %i (exact 103)\n",n); |
- |
- s=fgets(buffer,sizeof(buffer),fin); |
- if (s==NULL) { |
- cprintf("error on 1st fgets()\n"); |
- return 0; |
- } |
- s=fgets(buffer,sizeof(buffer),fin); |
- if (s==NULL) { |
- cprintf("error on 2nd fgets()\n"); |
- return 0; |
- } |
- s=fgets(buffer,sizeof(buffer),fin); |
- if (s==NULL) { |
- cprintf("error on 3rd fgets()\n"); |
- return 0; |
- } |
- |
- cprintf("fscanf()ing...\n"); |
- res=fscanf(fin,"line %i error letter '%c'",&n,&ch); |
- cprintf("fscanf()ed...\n"); |
- if (res!=2) { |
- cprintf("error on 2nd fscanf() res=%i\n",res); |
- return 0; |
- } |
- cprintf("scanned number %i (exact 205) characer '%c' (exact 'c')\n",n,ch); |
- |
- cprintf("closing...\n"); |
- fclose(fin); |
- cprintf("closed!\n"); |
- } |
- |
- cprintf("[press 'x' to exit]\n"); |
- while ((c = keyb_getchar()) != 'x') ; |
- |
- return 0; |
-} |
Index: oldexamples/stdio/test3.c |
=================================================================== |
--- oldexamples/stdio/test3.c (revision 1656) |
+++ oldexamples/stdio/test3.c (nonexistent) |
@@ -1,55 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <string.h> |
- |
-int main(int argc,char *argv[]) |
-{ |
- char buffer[256]; |
- char *s; |
- // int res; |
- int c; |
- |
- /* |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- return -1; |
- } |
- |
- res=mount(temp_device,FS_MSDOS,"/TEMP",NULL); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- sys_end(); |
- return -1; |
- } |
- */ |
- |
- /* |
- * |
- */ |
- |
- printf("try using printf() to write on console!\n"); |
- printf("second line of the test\n"); |
- fprintf(stdout,"using fprintf() to write on stdout\n"); |
- fprintf(stderr,"try using fprintf() to write on stderr!\n"); |
- fprintf(stderr,"all this %i message are using ?printf() functions\n",4); |
- |
- printf("now try to write a phrase and press [Enter] to finish\n"); |
- s=fgets(buffer,sizeof(buffer),stdin); |
- if (s!=NULL) printf("you have typed: '%s'\n",s); |
- |
- cprintf("[press 'x' to exit]\n"); |
- |
- while ((c = keyb_getchar()) != 'x') ; |
- |
- return 0; |
-} |
Index: oldexamples/stdio/test4.c |
=================================================================== |
--- oldexamples/stdio/test4.c (revision 1656) |
+++ oldexamples/stdio/test4.c (nonexistent) |
@@ -1,60 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <stdio.h> |
-#include <string.h> |
- |
-int main(int argc,char *argv[]) |
-{ |
- char buffer[256]; |
- FILE *fin; |
- int res; |
- int c; |
- int flag=1; |
- |
- /* prova di rewind() */ |
- |
- cprintf("opening...\n"); |
- fin=fopen("/TEMP/ALFA1.TXT","r"); |
- cprintf("opened!\n"); |
- |
- cprintf("res=%p\n",fin); |
- |
- if (fin!=NULL) { |
- |
- REDO: |
- |
- while (!feof(fin)) { |
- cprintf("reading...\n"); |
- res=fread(buffer,1,sizeof(buffer)-2,fin); |
- cprintf("read!\n"); |
- |
- cprintf("res=%i\n",res); |
- buffer[res<sizeof(buffer)-1?res:sizeof(buffer)-1]='\0'; |
- cprintf("'%s'\n",buffer); |
- } |
- |
- if (flag) { |
- flag=0; |
- cprintf("rewinding...\n"); |
- rewind(fin); |
- cprintf("rewinded!\n"); |
- goto REDO; |
- } |
- |
- cprintf("closing...\n"); |
- fclose(fin); |
- cprintf("closed!\n"); |
- } |
- |
- cprintf("[press 'x' to exit]\n"); |
- while ((c = keyb_getch(BLOCK)) != 'x') ; |
- |
- return 0; |
-} |
Index: oldexamples/stdio/common.c |
=================================================================== |
--- oldexamples/stdio/common.c (revision 1656) |
+++ oldexamples/stdio/common.c (nonexistent) |
@@ -1,117 +0,0 @@ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
- |
-/* -- */ |
- |
-int __register_sub_init_prologue(void) |
-{ |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-/* -- */ |
- |
-__dev_t root_device; |
-__dev_t temp_device; |
- |
-int choose_root_callback(__dev_t dev,__uint8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs) |
-{ |
- static int flag=0; |
- if (fs==FS_MSDOS) { |
- if (flag) return dev; |
- flag=1; |
- } |
- return -1; |
-} |
- |
-/* -- */ |
- |
-//extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t)); |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,TRUE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- } |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
-extern int libc_initialize(void); |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- struct mount_opts opts; |
- int res; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,TRUE); |
- filesystem_init(&fs); |
- |
- libc_initialize(); |
- |
- if (temp_device>=0) { |
- memset(&opts,0,sizeof(struct mount_opts)); |
- opts.flags=MOUNT_FLAG_RW; |
- res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- } |
- } |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
- |
-/* -- */ |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
- //dump_sem_table(); |
- //dump_nop_table(); |
- cprintf("CTRL-C pressed!\n"); |
- sys_end(); |
-} |
Index: oldexamples/stdio/initfs.c |
=================================================================== |
--- oldexamples/stdio/initfs.c (revision 1656) |
+++ oldexamples/stdio/initfs.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 |
- */ |
- |
-/* |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfs.c,v 1.1.1.1 2004-05-24 18:03:39 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:39 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.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; |
- extern int __register_sub_init_prologue(void); |
- extern int __register_sub_init(void); |
- |
- __register_sub_init_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- __register_sub_init(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern int __bdev_sub_init(void); |
- extern int __fs_sub_init(void); |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- __bdev_sub_init(); |
- __fs_sub_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: oldexamples/stdio/makefile |
=================================================================== |
--- oldexamples/stdio/makefile (revision 1656) |
+++ oldexamples/stdio/makefile (nonexistent) |
@@ -1,28 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS=test0 test1 test2 test3 test4 |
-OBJS=common.o |
- |
-include $(BASE)/config/example.mk |
- |
-test0: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test0 INIT=initfs.o OTHEROBJS=common.o |
- |
-test1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test1 INIT=initfs.o OTHEROBJS=common.o |
- |
-test2: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test2 INIT=initfs.o OTHEROBJS=common.o |
- |
-test3: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test3 INIT=initfs.o OTHEROBJS=common.o |
- |
-test4: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test4 INIT=initfs.o OTHEROBJS=common.o |
Index: oldexamples/fs/initfs.c |
=================================================================== |
--- oldexamples/fs/initfs.c (revision 1656) |
+++ oldexamples/fs/initfs.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 |
- */ |
- |
-/* |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfs.c,v 1.1.1.1 2004-05-24 18:03:39 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:39 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.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; |
- extern int __register_sub_init_prologue(void); |
- extern int __register_sub_init(void); |
- |
- __register_sub_init_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- __register_sub_init(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern int __bdev_sub_init(void); |
- extern int __fs_sub_init(void); |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- __bdev_sub_init(); |
- __fs_sub_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: oldexamples/fs/makefile |
=================================================================== |
--- oldexamples/fs/makefile (revision 1656) |
+++ oldexamples/fs/makefile (nonexistent) |
@@ -1,45 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS=hello |
-PROGS+=test0 test1 |
-PROGS+=testw0 testw1 |
-PROGS+=tree1 tree2 |
-PROGS+=testu |
-OBJS=common.o |
- |
-include $(BASE)/config/example.mk |
- |
-# |
-# |
-# |
- |
-hello: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=hello INIT=initfs.o OTHEROBJS=common.o |
- |
-test0: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test0 INIT=initfs.o OTHEROBJS=common.o |
- |
-test1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test1 INIT=initfs.o OTHEROBJS=common.o |
- |
-testu: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=testu INIT=initfs.o OTHEROBJS=common.o |
- |
-testw0: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=testw0 INIT=initfs.o OTHEROBJS=common.o |
- |
-testw1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=testw1 INIT=initfs.o OTHEROBJS=common.o |
- |
-tree1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=tree1 INIT=initfs.o OTHEROBJS=common.o |
- |
-tree2: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=tree2 INIT=initfs.o OTHEROBJS=common.o |
Index: oldexamples/fs/common.h |
=================================================================== |
--- oldexamples/fs/common.h (revision 1656) |
+++ oldexamples/fs/common.h (nonexistent) |
@@ -1,15 +0,0 @@ |
- |
-#ifndef _COMMON_H |
-#define _COMMON_H |
- |
-#include <sys/types.h> |
- |
-extern __dev_t root_device; |
-extern __dev_t temp_device; |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs); |
- |
-void showmessage(char *s); |
-void waitend(void); |
- |
-#endif |
Index: oldexamples/fs/test0.c |
=================================================================== |
--- oldexamples/fs/test0.c (revision 1656) |
+++ oldexamples/fs/test0.c (nonexistent) |
@@ -1,63 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define FILENAME "/TEMP/ALFA1.TXT" |
- |
-int main(int argc,char *argv[]) |
-{ |
- int c; |
- int h; |
- // int res; |
- |
- cprintf("OPENING %s\n",FILENAME); |
- h=open(FILENAME,O_RDONLY); |
- if (h>=0) { |
- char buffer[128]; |
- int len; |
- cprintf("OPENED!\n"); |
- |
- cprintf("READING...\n"); |
- len=read(h,buffer,sizeof(buffer)); |
- cprintf("READ %i bytes\n",len); |
- memset(buffer,'\0',sizeof(buffer)); |
- cprintf("buffer='%s'\n",buffer); |
- |
- cprintf("READING...\n"); |
- len=read(h,buffer,sizeof(buffer)); |
- cprintf("READ %i bytes\n",len); |
- memset(buffer,'\0',sizeof(buffer)); |
- cprintf("buffer='%s'\n",buffer); |
- |
- //close(h); |
- |
- } else |
- cprintf("FAILED!\n"); |
- |
- cprintf("Press [x] to exit\n"); |
- |
- while ((c = keyb_getchar()) != 'x') ; |
- |
- //bdev_dump_status(); |
- |
- return 0; |
-} |
Index: oldexamples/fs/tree1.c |
=================================================================== |
--- oldexamples/fs/tree1.c (revision 1656) |
+++ oldexamples/fs/tree1.c (nonexistent) |
@@ -1,154 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
- |
-#include <sys/types.h> |
-#include <sys/stat.h> |
-#include <sys/mount.h> |
-#include <dirent.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
-#include <stdlib.h> |
-#include <semaphore.h> |
-#include <stdio.h> |
- |
-#include "common.h" |
- |
-#define FROMDIR "/TEMP" |
- |
-char pathname[8192]; |
- |
-int noscroll=1; |
- |
-static int counter=0; |
- |
-void viewdir(int prof) |
-{ |
- struct dirent *den; |
- struct stat st; |
- char *str; |
- DIR *d; |
- int res; |
- int x; |
- //int i; |
- //static int flag=0; |
- |
- str=pathname+(x=strlen(pathname)); |
- d=opendir(pathname); |
- |
- if (d==NULL) { |
- cprintf("ERR: can't open dir %s (errno: %i)\n",pathname,errno); |
- return; |
- } |
- |
- while ((den=readdir(d))!=NULL) { |
- |
- { |
- //int c='p'; |
- //c = keyb_getchar(); |
- //if (c=='z') inode_stats(); |
- } |
- |
- if (x==1&&*pathname=='/') |
- strcat(pathname,den->d_name); |
- else |
- strcat(strcat(pathname,"/"),den->d_name); |
- |
- /* |
- if (!strcmp(den->d_name,"eport.ror")) { |
- if (flag==0) debug_info_show(1); |
- flag++; |
- // inode_stats(); |
- } |
- */ |
- |
- if (counter==22100) noscroll=0; |
- |
- if (noscroll) { |
- place(0,10); |
- cprintf(" "); |
- place(0,10); |
- } |
- cprintf("%05i %s\n",++counter,pathname); |
- //dcache_stats(); |
- |
- if (!strcmp(den->d_name,".")) goto SKIP; |
- if (!strcmp(den->d_name,"..")) goto SKIP; |
- |
- //goto SKIP; |
- |
- /* |
- if (!strcmp("MSINH.C",den->d_name)) { |
- //if (!strcmp("WDIN32.OBJ",den->d_name)) { |
- cprintf(">>>START SHOWING DEBUG INFO<<<\n"); |
- noscroll=0; |
- //inode_stats(); |
- debug_info_show(1); |
- } |
- */ |
- |
- res=stat(pathname,&st); |
- if (res!=0) { |
- cprintf("can't stat %s\n",pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sys_end(); |
- l1_exit(0); |
- } else { |
- if (S_ISDIR(st.st_mode)) { |
- viewdir(prof+1); |
- } |
- |
- } |
- |
- SKIP: |
- *str='\0'; |
- } |
- |
- closedir(d); |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- // int res; |
- |
- //if (noscroll) clear(); |
- |
- //strcpy(pathname,"/"); |
- //viewdir(0); |
- |
- showmessage("Try to show all filenames from a directory recursively\n" |
- "using one NRT task.\n"); |
- |
- noscroll=0; |
- strcpy(pathname,FROMDIR); |
- viewdir(0); |
- |
- //dump_dentry_tree(); |
- |
- /* |
- * |
- */ |
- |
- /* |
- res=umount(temp_device); |
- //dump_dentry_tree(); |
- if (res!=0) { |
- cprintf("can't unmount XXX on /TEMP\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- //sys_end(); |
- return -1; |
- } |
- */ |
- |
- //bdev_dump_status(); |
- |
- sys_end(); |
- return 0; |
-} |
Index: oldexamples/fs/test1.c |
=================================================================== |
--- oldexamples/fs/test1.c (revision 1656) |
+++ oldexamples/fs/test1.c (nonexistent) |
@@ -1,74 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-//#define FILENAME "/temp/ALFA1.TXT" |
- |
-#define FILENAME "/pippo.c" |
- |
-int leggi(int h) |
-{ |
- char buffer[124]; |
- int len; |
- |
- memset(buffer,'\0',sizeof(buffer)); |
- cprintf("READING...\n"); |
- len=read(h,buffer,sizeof(buffer)-1); |
- cprintf("READ %i bytes\n",len); |
- cprintf("buffer='%s'\n",buffer); |
- |
- return len; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- int h; |
- |
- showmessage("Try lseek() using a file for reading."); |
- |
- cprintf("OPENING %s\n",FILENAME); |
- h=open(FILENAME,O_RDONLY); |
- |
- if (h>=0) { |
- cprintf("OPENED!\n"); |
- |
- leggi(h); |
- leggi(h); |
- leggi(h); |
- |
- cprintf("SEEK to 16\n"); |
- lseek(h,16,SEEK_SET); |
- |
- leggi(h); |
- |
- cprintf("SEEK to %i\n",123*3+1); |
- lseek(h,123*3+1,SEEK_SET); |
- |
- leggi(h); |
- |
- } else |
- cprintf("FAILED!\n"); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: oldexamples/fs/test2.c |
=================================================================== |
--- oldexamples/fs/test2.c (revision 1656) |
+++ oldexamples/fs/test2.c (nonexistent) |
@@ -1,57 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <string.h> |
-#include "common.c" |
- |
-int main(int argc,char *argv[]) |
-{ |
- int res; |
- int c; |
- int h; |
- |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- return -1; |
- } |
- |
- /* mounting 2nd msdos partition on /TEMP */ |
- res=mount(temp_device,FS_MSDOS,"/TEMP",NULL); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- //sys_end(); |
- return -1; |
- } |
- |
- /* |
- * |
- */ |
- |
- cprintf("OPENING %s\n",FILENAME); |
- h=open(FILENAME,O_RDONLY); |
- if (h>=0) { |
- char buffer[128]; |
- int len; |
- cprintf("OPENED!\n"); |
- cprintf("READING...\n"); |
- len=read(h,buffer,sizeof(buffer)); |
- cprintf("READ %i bytes\n",len); |
- memset(buffer,'\0',sizeof(buffer)); |
- cprintf("buffer='%s'\n",buffer); |
- } else |
- cprintf("FAILED!\n"); |
- |
- cprintf("Press [x] to exit\n"); |
- |
- while ((c = keyb_getchar()) != 'x'); |
- |
- bdev_dump_status(); |
- |
- sys_end(); |
- return 0; |
-} |
Index: oldexamples/fs/tree2.c |
=================================================================== |
--- oldexamples/fs/tree2.c (revision 1656) |
+++ oldexamples/fs/tree2.c (nonexistent) |
@@ -1,275 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
- |
-#include <sys/types.h> |
-#include <sys/stat.h> |
-#include <sys/mount.h> |
-#include <dirent.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
-#include <stdlib.h> |
-#include <semaphore.h> |
-#include <stdio.h> |
- |
-#include "common.h" |
- |
-#define NOSHOW |
-#undef NOSHOW |
- |
-#define sem_signal sem_post |
- |
-int noscroll=0; |
-sem_t console; |
- |
-#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
-//#define MWCET 1000l |
-//#define MPERIOD (MWCET*(MPROC+10)) |
- |
-TASK viewdir(void *prof); |
-sem_t actmutex,actsync; |
-char *globpathname; |
-PID globpid; |
-int counter=0,actcounter=0; |
- |
-void activate_task(int prof, char *pathname) |
-{ |
- char tname[32]; |
- NRT_TASK_MODEL m; |
- PID pid; |
- |
-REPEAT: |
- sem_wait(&actmutex); |
- |
- if (actcounter>=MPROC) { |
- sem_signal(&actmutex); |
- task_delay(10000); |
- goto REPEAT; |
- } |
- |
- globpathname=pathname; |
- counter++; |
- sprintf(tname,"tsk%i",counter); |
- |
- /* |
- printd("Û"); |
- sem_wait(&console); |
- printd("Ü"); |
- cprintf("%03i has called for ##%s##\n",prof,pathname); |
- sem_signal(&console); |
- */ |
- |
- nrt_task_default_model(m); |
- //soft_task_def_met(m,MWCET); |
- //soft_task_def_wcet(m,MWCET); |
- //soft_task_def_periodic(m); |
- nrt_task_def_arg(m,(void*)counter); |
- //soft_task_def_period(m,MPERIOD); |
- |
- globpid=pid=task_create(tname,viewdir,&m,NULL); |
- if (pid==-1) { |
- sem_wait(&console); |
- cprintf("can't create '%s'\n",tname); |
- perror("can't create task"); |
- sem_signal(&console); |
- sys_end(); |
- return; |
- } |
- task_activate(pid); |
- sem_wait(&actsync); |
- actcounter++; |
- |
- /* |
- printd("Û"); |
- sem_wait(&console); |
- printd("Ü"); |
- if (noscroll) place(0,9); |
- cprintf("task running: %5i/%5i --- task started: %5i\n", |
- actcounter,MAX_PROC,counter); |
- sem_signal(&console); |
- */ |
- |
- sem_signal(&actmutex); |
-} |
- |
-/* |
- * |
- */ |
- |
-int filecounter=0; |
- |
-TASK viewdir(void *pointer) |
-{ |
- struct dirent *den; |
- struct stat st; |
- char *str; |
- DIR *d; |
- int res; |
- int x; |
- char pathname[1024]; |
- PID mypid; |
- int prof=(int)pointer; |
- |
- strcpy(pathname,globpathname); |
- mypid=globpid; |
- sem_signal(&actsync); |
- |
- //sem_wait(&console); |
- //cprintf("%03i on <%s>\n",prof,pathname); |
- //sem_signal(&console); |
- |
- str=pathname+(x=strlen(pathname)); |
- d=opendir(pathname); |
- |
- if (d==NULL) { |
- sem_wait(&console); |
- cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- goto END; |
- } |
- |
- while ((den=readdir(d))!=NULL) { |
- |
- if (x==1&&*pathname=='/') |
- strcat(pathname,den->d_name); |
- else |
- strcat(strcat(pathname,"/"),den->d_name); |
- |
- sem_wait(&console); |
-#ifndef NOSHOW |
- if (noscroll) { |
- place(0,10); |
- cprintf(" "); |
- place(0,10); |
- } |
- //cprintf("%03i(0_%03i) %s\n",prof,(int)mypid,pathname); |
- cprintf("t%03i %s\n",prof,pathname); |
-#endif |
- filecounter++; |
- sem_signal(&console); |
- |
- //if (*den->d_name=='.') { |
- // sem_wait(console,BLOCK); |
- // cprintf("%03i HAS FOUND <%s>\n",prof,den->d_name); |
- // sem_signal(console); |
- //} |
- |
- if (!strcmp(den->d_name,".")) { |
- //sem_wait(console,BLOCK); |
- //cprintf("%03i skip for .\n",prof); |
- //sem_signal(console); |
- goto SKIP; |
- } |
- if (!strcmp(den->d_name,"..")) { |
- //sem_wait(console,BLOCK); |
- //cprintf("%03i skip for ..\n",prof); |
- //sem_signal(console); |
- goto SKIP; |
- } |
- |
- res=stat(pathname,&st); |
- if (res!=0) { |
- sem_wait(&console); |
- cprintf("t%03i can't stat %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- closedir(d); |
- goto END; |
- } else { |
- if (S_ISDIR(st.st_mode)) { |
- sem_wait(&console); |
- //if (den->d_name[0]=='.') |
- // cprintf("%03i called for <%s>\n",prof,den->d_name); |
- sem_signal(&console); |
- activate_task(prof,pathname); |
- } |
- |
- } |
- |
- SKIP: |
- *str='\0'; |
- } |
- |
- closedir(d); |
- |
-END: |
- sem_wait(&actmutex); |
- actcounter--; |
- sem_signal(&actmutex); |
- |
- return 0; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- extern void dump_sem_table(void); |
- TIME stime,etime; |
- // int res; |
- |
- /* |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- return -1; |
- } |
- */ |
- |
- /* mounting 2nd msdos partition on /TEMP */ |
- /* |
- res=mount(temp_device,FS_MSDOS,"/TEMP",NULL); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- return -1; |
- } |
- */ |
- |
- /* clear screen */ |
- //clear(); |
- |
- showmessage("This test show all filenames of a directory of an hardisk\n" |
- "recursively using a soft task for every directory.\n"); |
- |
- stime=sys_gettime(NULL); |
- |
- sem_init(&console,0,1); |
- sem_init(&actmutex,0,1); |
- sem_init(&actsync,0,0); |
- |
- //dump_sem_table(); |
- |
- //keyb_getchar(); |
- |
- activate_task(-1,"/TEMP"); |
- |
- for(;;) { |
- sem_wait(&actmutex); |
- if (actcounter==0) break; |
- sem_signal(&actmutex); |
- } |
- |
- etime=sys_gettime(NULL); |
- |
- cprintf("\nfiles: %i\n",filecounter); |
- cprintf("time : %li\n",etime-stime); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: oldexamples/fs/hello.c |
=================================================================== |
--- oldexamples/fs/hello.c (revision 1656) |
+++ oldexamples/fs/hello.c (nonexistent) |
@@ -1,13 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
- |
-int main(int argc,char *argv[]) |
-{ |
- cprintf("\nHello, world!\n\n"); |
- return 0; |
-} |
Index: oldexamples/fs/testu.c |
=================================================================== |
--- oldexamples/fs/testu.c (revision 1656) |
+++ oldexamples/fs/testu.c (nonexistent) |
@@ -1,47 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
-#include <sys/types.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define FILENAME "/TEMP/TESTW1.TXT" |
- |
-//#define FILENAME "/TEMP/CIR2" |
- |
-extern dev_t temp_device; |
- |
-int main(int argc,char *argv[]) |
-{ |
- int res; |
- |
- showmessage("Try to unlink (ie. delete) a file.\n"); |
- |
- cprintf("UNLINKING %s\n",FILENAME); |
- res=unlink(FILENAME); |
- if (res!=0) { |
- cprintf("FAILED!\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- } else cprintf("OK!\n"); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: oldexamples/fs/testw0.c |
=================================================================== |
--- oldexamples/fs/testw0.c (revision 1656) |
+++ oldexamples/fs/testw0.c (nonexistent) |
@@ -1,54 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
-#include <sys/types.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define FILENAME "/TEMP/TESTW0.TXT" |
- |
-extern dev_t temp_device; |
- |
-int main(int argc,char *argv[]) |
-{ |
- int res; |
- // int c; |
- int h; |
- |
- showmessage("Try to create and truncate a file.\n"); |
- |
- cprintf("OPENING %s\n",FILENAME); |
- h=open(FILENAME,O_CREAT|O_WRONLY|O_TRUNC); |
- if (h!=-1) { |
- cprintf("CLOSING %s\n",FILENAME); |
- res=close(h); |
- if (res!=0) { |
- cprintf("CLOSE FAILED!\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- } |
- } else { |
- cprintf("FAILED!\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- } |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: oldexamples/fs/testw1.c |
=================================================================== |
--- oldexamples/fs/testw1.c (revision 1656) |
+++ oldexamples/fs/testw1.c (nonexistent) |
@@ -1,71 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
-#include <sys/types.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define FILENAME "/TEMP/TESTW1.TXT" |
- |
-int scrivi(int h,char *buffer,int len) |
-{ |
- int res; |
- cprintf("WRITING...\n"); |
- res=write(h,buffer,len); |
- cprintf("WRITTEN %i bytes\n",res); |
- if (res>0) { |
- buffer[res]='\0'; |
- cprintf("(%s)\n",buffer); |
- } else cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- return res; |
-} |
- |
-extern dev_t temp_device; |
- |
-int main(int argc,char *argv[]) |
-{ |
- int res; |
- int h; |
- |
- showmessage("Try to create and overwriting a file.\n"); |
- |
- cprintf("OPENING %s\n",FILENAME); |
- h=open(FILENAME,O_CREAT|O_WRONLY|O_TRUNC); |
- |
- if (h>=0) { |
- cprintf("OPENED fd=%i!\n",h); |
- |
- scrivi(h,"ABC ",3); |
- |
- scrivi(h,"abcdefghilmnopqrstuvz ",21); |
- |
- res=close(h); |
- if (res!=0) { |
- cprintf("CLOSE FAILED!\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- } |
- } else { |
- cprintf("FAILED!\n"); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- } |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: oldexamples/fs/common.c |
=================================================================== |
--- oldexamples/fs/common.c (revision 1656) |
+++ oldexamples/fs/common.c (nonexistent) |
@@ -1,135 +0,0 @@ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
- |
-/* -- */ |
- |
-int __register_sub_init_prologue(void) |
-{ |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-/* -- */ |
- |
-__dev_t root_device; |
-__dev_t temp_device; |
- |
-int choose_root_callback(__dev_t dev,__uint8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs) |
-{ |
- static int flag=0; |
- if (fs==FS_MSDOS) { |
- if (flag) return dev; |
- flag=1; |
- } |
- return -1; |
-} |
- |
-/* -- */ |
- |
-//extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t)); |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,TRUE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- } |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
-extern int libc_initialize(void); |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- struct mount_opts opts; |
- int res; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,TRUE); |
- filesystem_init(&fs); |
- |
- libc_initialize(); |
- |
- if (temp_device>=0) { |
- memset(&opts,0,sizeof(struct mount_opts)); |
- opts.flags=MOUNT_FLAG_RW; |
- res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- } |
- } |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
- |
-/* -- */ |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
- //dump_sem_table(); |
- //dump_nop_table(); |
- cprintf("CTRL-C pressed!\n"); |
- sys_end(); |
-} |
- |
-/* -- */ |
- |
-void showmessage(char *s) |
-{ |
- cputs(s); |
- cprintf("Press [x] to begin..."); |
- while (keyb_getchar()!='x'); |
- cprintf("\n"); |
-} |
- |
-void waitend(void) |
-{ |
- int c; |
- cprintf("Press [x] to exit..."); |
- while ((c=keyb_getchar())!='x'); |
- cprintf("\n"); |
-} |
Index: oldexamples/mpeg/mplay.c |
=================================================================== |
--- oldexamples/mpeg/mplay.c (revision 1656) |
+++ oldexamples/mpeg/mplay.c (nonexistent) |
@@ -1,512 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Luca Abeni <luca@hartik.sssup.it> |
- * Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: mplay.c,v 1.1.1.1 2004-05-24 18:03:39 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:39 $ |
- */ |
- |
-#include <ll/sys/types.h> |
- |
-#include <kernel/func.h> |
-#include <kernel/const.h> |
- |
-//#include <hartik.h> |
-#include <drivers/keyb.h> |
- |
-#include <stdlib.h> |
-#include <stdio.h> |
- |
-//#include <xdos.h> |
-#include <drivers/glib.h> |
- |
-#include "mpeg/video.h" |
-/*#include "proto.h"*/ |
-#include "mpeg/util.h" |
-#include "mpeg/dither.h" |
-#include "mpeg/mpeg.h" |
- |
- |
- |
- |
- |
- |
-#include <drivers/keyb.h> |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
- grx_close(); |
- cprintf("CTRL-C pressed!\n"); |
- grx_modeinfo(); |
- sys_end(); |
-} |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <sys/types.h> |
-#include <sys/mount.h> |
- |
-int __register_sub_init_prologue(void) |
-{ |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-dev_t root_device; |
- |
-int choose_root_callback(dev_t dev,u_int8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,TRUE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- return 0; |
-} |
- |
-extern int libc_initialize(void); |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- //struct mount_opts opts; |
- |
- //memset(&opts,0,sizeof(struct mount_opts)); |
- //opts.flags=MOUNT_FLAG_RW; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,TRUE); |
- filesystem_init(&fs); |
- |
- libc_initialize(); |
- |
- return 0; |
-} |
- |
- |
- |
- |
- |
-int x_fseek(FILE *file, long where, int from) |
-{ |
- return fseek(file,where,from); |
-} |
- |
-size_t x_fread(void *buffer, size_t size, size_t n, FILE *file) |
-{ |
- return fread(buffer,size,n,file); |
-} |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
-TIME ttt; |
- |
-DWORD n; |
- |
-///* #define GPHBDIM 4097152 */ |
-//#define GPHBDIM 1000000 |
- |
-//BYTE gphb[GPHBDIM]; /* Std Dim: 2M */ |
-//BYTE *nextphbyte = gphb; |
- |
-struct streamdescr { |
- FILE *f; |
- ImageDesc *i; |
- int x1, y1; |
-} sd[10]; |
- |
-#define SCREENX 800 |
-#define SCREENY 600 |
- |
-void txtreset(void *dummy) |
-{ |
- grx_close(); |
- grx_modeinfo(); |
- /* cprintf("Total frames: %ld\n", i); |
- cprintf("Total time: %lu\n", t);*/ |
- //cprintf("Frame rate: %lu\n", (n * 1000) / ttt); |
- /* cprintf("Max frame time: %lu\n", mft);*/ |
-} |
- |
-#define MAINSLEEP 20000 |
- |
-void drawload(TIME l) |
-{ |
- #define LLPWINSIZE 20 |
- int actl; |
-// struct load l; |
- #define LOADX 500 |
- #define LOADY 300 |
- #define LOADYDIM 50 |
- #define LOADXDIM 100 |
- static int th = 0; |
- static int x = 0; |
- static int hy[LLPWINSIZE]; |
- static int somma = 0; |
- int i; |
- |
-/* for (i = 0; i < LLPWINSIZE; i++) hy[i] = 0; */ |
- |
-// load_actual(&l); |
-// actl = (LOADYDIM * l.actual) / l.rif + 1; |
-// { |
-// char str[80]; |
-// sprintf(str,"%d",actl); |
-// /*grx_text("Ciao", 200, 200, color16(31, 63, 31), 0);*/ |
-// grx_text(" ", 100, 400, 100, 0); |
-// grx_text(str, 100, 400, 100,0); |
-// } |
-/* LowPass Filter */ |
- |
- |
- actl=((long)l*LOADYDIM)/MAINSLEEP+1; |
- |
- somma += actl - hy[th]; |
- hy[th] = actl; |
- th = (th + 1) % LLPWINSIZE; |
- actl = somma / LLPWINSIZE; |
- grx_line(LOADX+x,LOADY,LOADX+x,(LOADY+LOADYDIM),0); |
- if (actl > LOADYDIM) actl = LOADYDIM; |
- grx_line(LOADX+x,(LOADY + actl),LOADX+x,(LOADY+LOADYDIM),255); |
- |
- x = (x + 1) % LOADXDIM; |
- |
-} |
- |
- |
- |
-TASK play(void *arg) |
-{ |
- int i=(int)arg; |
- int loop = TRUE; |
- BYTE *pixels; |
- int moreframes = TRUE; |
- FILE *mpeg = sd[i].f; |
- ImageDesc *img = sd[i].i; |
- int x1, y1, x2, y2; |
- |
- /*printf ("Task %d: Movie is %d x %d pixels\n", i, img->Width, img->Height); |
- printf ("Required picture rate = %d, required bit rate = %d\n", |
- img->PictureRate, img->BitRate);*/ |
- |
- pixels = (BYTE *) malloc(img->Size * sizeof(BYTE)); |
- x1 = sd[i].x1; |
- y1 = sd[i].y1; |
- x2 = x1 + img->Width-1; |
- y2 = y1 + img->Height-1; |
- while (loop) { /* play the whole movie forever */ |
- loop = 1; |
- n = 0; |
- ttt = sys_gettime(NULL); |
- while (moreframes) { |
- //cprintf("°"); |
- moreframes = GetMPEGFrame (img, pixels); |
- grx_putimage(x1, y1, x2, y2, pixels); |
- n++; |
- task_endcycle(); |
- } |
- ttt = sys_gettime(NULL) - ttt; |
- RewindMPEG (mpeg, img); |
- SetMPEGOption (img, MPEG_DITHER, GRAY_DITHER); |
- moreframes = TRUE; |
- } |
- |
- return 0; |
-} |
- |
- |
- |
-int main(int argc, char *argv[]) |
-{ |
- // SYS_PARMS sp = BASE_SYS; |
- KEY_EVT k; |
- // MODEL m = BASE_MODEL; |
- PID pid; |
- |
- // DOS_FILE *Infile; |
-// BYTE *mpegbuff[10], *p; |
-// WORD res; |
-// DWORD cnt[10]; |
- |
- |
-TIME sum; |
- |
- SOFT_TASK_MODEL model; |
- |
- FILE *mpeg; |
- ImageDesc img[10]; |
- int full_color = FALSE; |
- |
- int mode; |
- int esc; |
- int i; |
- int actx = 10, acty = 10; |
- ColormapEntry *cp; |
- |
- //cprintf("file '%s'\n",argv[1]); |
- |
- if (argc < 2) { |
- fprintf (stderr, "Usage: %s mpegfile\n", argv[0]); |
- sys_abort(301); |
- } |
- |
- /* |
- for (i = 0; i < argc - 1; i++) { |
- Infile = DOS_fopen(argv[i + 1], "r"); |
- if (!Infile) { |
- cprintf("%s not found!!!\n", argv[i + 1]); |
- sys_abort(300); |
- } |
- cprintf("\n %s Opened!!!\n\n", argv[i + 1]); |
- |
- mpegbuff[i] = nextphbyte; |
- p = mpegbuff[i]; cnt[i] = 0; |
- res = 0x1000; |
- while (res > 0) { |
- res = DOS_fread(p, 0x1000, 1, Infile); |
- cnt[i] += res; |
- p += res; |
- } |
- p += res; |
- nextphbyte = p; |
- } |
- */ |
- |
- /* OK, Now we can start the system!!! */ |
- //sys_init(&sp); |
- //keyb_init(SOFT, 100); |
- // keyb_init(NULL); |
- // k.flag = CNTR_BIT; |
- // k.scan = KEY_C; |
- // k.ascii = 'c'; |
- //keyb_excset(k,endfun); |
- |
- //vfs_init(); |
- /* |
- for (i = 0; i < argc - 1; i++) { |
- vfs_assign(argv[i + 1], mpegbuff[i], cnt[i]); |
- } |
- */ |
- |
- |
- |
- |
- |
- |
- /* Init the graph... */ |
- if (grx_init() == -1) { |
- cprintf("No init!!!\n"); |
- sys_abort(255); |
- } |
- |
- mode = grx_getmode(SCREENX, SCREENY, 8); |
- cprintf("Mode num: %x\n", mode); |
- grx_cardinfo(); |
- cprintf("[hit enter to continue]\n"); |
- esc = FALSE; |
- while (!esc) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii == 13) esc = TRUE; |
- } |
- |
- |
- if (mode == -1) { |
- cprintf("Mode not present!!!\n"); |
- sys_abort(255); |
- } |
- |
- if (grx_setmode(mode) == -1) { |
- cprintf("No SetMode!!!\n"); |
- sys_abort(255); |
- } |
- |
- //sys_atexit(txtreset,NULL,AFTER_EXIT); |
- |
- |
- //cprintf("Û0Û"); |
- |
- for (i = 0; i < argc - 1; i++) { |
- mpeg = fopen(argv[i + 1], "r"); |
- |
- if (!mpeg) { |
- perror (argv[1]); |
- sys_abort(301); |
- } |
- |
- |
- setvbuf(mpeg,NULL,_IOFBF,BUFSIZ*100); |
- |
- |
- //cprintf("Û0.5Û"); |
- |
- /* !!! */ |
- img[i].vid_stream=NULL; |
- img[i].Colormap=NULL; |
- |
- if (!OpenMPEG(mpeg, &(img[i]))) { |
- fprintf (stderr, "OpenMPEG on %s failed\n", argv[i + 1]); |
- sys_abort(301); |
- } |
- |
- |
- //cprintf("Û1Û"); |
- |
- |
- |
- SetMPEGOption (&(img[i]), MPEG_DITHER, GRAY_DITHER); |
- //SetMPEGOption (&(img[i]), MPEG_DITHER, FS4_DITHER); |
- |
- |
- /* SetMPEGOption(MPEG_DITHER, GRAY_DITHER); */ |
- |
- /* printf ("Movie is %d x %d pixels\n", img[i].Width, img[i].Height); |
- printf ("Required picture rate = %d, required bit rate = %d\n", |
- img[i].PictureRate, img[i].BitRate); */ |
- |
- //cprintf("Û2Û"); |
- |
- if (i == 0) { |
- cp = img[i].Colormap; |
- |
- if (!full_color) { |
- int ii; |
- |
- for (ii = 0; ii < img[i].ColormapSize; ii++) { |
- |
- |
- grx_setcolor (ii, img[i].Colormap[ii].red / 4, |
- img[i].Colormap[ii].green / 4, |
- img[i].Colormap[ii].blue / 4); |
- |
- |
- } |
- |
- /*NO!!! Colormap is an array of short, setpalette wants an array of BYTE!!!*/ |
- /* grx_setpalette(0, 255, img.Colormap);*/ |
- } |
- } |
- if (actx + img[i].Width > SCREENX) { |
- actx = 10; |
- acty += 200; |
- } |
- sd[i].x1 = actx; |
- sd[i].y1 = acty; |
- sd[i].f = mpeg; |
- sd[i].i = &(img[i]); |
- |
- //cprintf("Û3Û"); |
- |
- soft_task_default_model(model); |
- ////soft_task_def_system(model); |
- //soft_task_def_met(model,9000); |
- //soft_task_def_wcet(model,9000); |
- //soft_task_def_period(model,50000); |
- |
- soft_task_def_met(model,5000); |
- soft_task_def_wcet(model,15000); |
- soft_task_def_period(model,40000); |
- soft_task_def_periodic(model); |
- soft_task_def_arg(model,(void*)i); |
- soft_task_def_ctrl_jet(model); |
- |
- //task_def_arg(m, i); |
- //task_def_wcet(m, 9000); |
- pid = task_create("video", play, &model, NULL); |
- if (pid == -1) { |
- cprintf(" task --> Not Guaranteed!!!\n"); |
- sys_abort(20000); |
- } |
- task_activate(pid); |
- |
- //cprintf("Û4Û"); |
- |
- actx += img[i].Width + 10; |
- } |
- |
- /* play(0);*/ |
- esc = FALSE; |
- //jet_delstat(pid); |
- while (!esc) { |
- if (keyb_getcode(&k,NON_BLOCK) && (k.ascii == 13)) esc = TRUE; |
- task_delay(MAINSLEEP); |
- //jet_getstat(pid,&sum,NULL,NULL,NULL); |
- //jet_delstat(pid); |
- //drawload(sum); |
- } |
- |
- sys_abort(59000); |
- |
- return 0; |
-} |
Index: oldexamples/mpeg/mplay2.c |
=================================================================== |
--- oldexamples/mpeg/mplay2.c (revision 1656) |
+++ oldexamples/mpeg/mplay2.c (nonexistent) |
@@ -1,590 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Luca Abeni <luca@hartik.sssup.it> |
- * Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: mplay2.c,v 1.1.1.1 2004-05-24 18:03:39 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:39 $ |
- */ |
- |
-#include <ll/sys/types.h> |
- |
-#include <kernel/func.h> |
-#include <kernel/const.h> |
- |
-//#include <hartik.h> |
-#include <drivers/keyb.h> |
- |
- |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
- |
- |
-#include <stdlib.h> |
-#include <stdio.h> |
- |
-//#include <xdos.h> |
-#include <drivers/glib.h> |
- |
-#include "mpeg/video.h" |
-/*#include "proto.h"*/ |
-#include "mpeg/util.h" |
-#include "mpeg/dither.h" |
-#include "mpeg/mpeg.h" |
- |
- |
- |
- |
- |
- |
- |
- |
-//#define NOSHOW 1 |
- |
- |
- |
- |
-#include <drivers/keyb.h> |
- |
- |
-int mustdied=0; |
- |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
- mustdied=1; |
-#ifndef NOSHOW |
- grx_close(); |
-#endif |
- cprintf("CTRL-C pressed!\n"); |
-#ifndef NOSHOW |
- grx_modeinfo(); |
-#endif |
- sys_end(); |
-} |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <sys/types.h> |
-#include <sys/mount.h> |
- |
-int __register_sub_init_prologue(void) |
-{ |
- int id; |
- TRC_init_phase1(NULL); |
- trc_register_fixed_queue(); |
- id=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
- trc_trace_class(TRC_CLASS_USER); |
- trc_assign_class_to_queue(TRC_CLASS_USER,id); |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-dev_t root_device; |
-dev_t temp_device; |
- |
-int choose_root_callback(dev_t dev,u_int8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs) |
-{ |
- static int flag=0; |
- if (fs==FS_MSDOS) { |
- if (flag) return dev; |
- flag=1; |
- } |
- return -1; |
-} |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,FALSE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- } |
- |
- return 0; |
-} |
- |
-extern int libc_initialize(void); |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- struct mount_opts opts; |
- int res; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,FALSE); |
- filesystem_init(&fs); |
- |
- if (temp_device>=0) { |
- memset(&opts,0,sizeof(struct mount_opts)); |
- opts.flags=MOUNT_FLAG_RW; |
- res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- } else |
- cprintf("mounted /TEMP rw\n"); |
- |
- } |
- |
- libc_initialize(); |
- |
- TRC_init_phase2(); |
- |
- return 0; |
-} |
- |
-int x_fseek(FILE *file, long where, int from) |
-{ |
- return fseek(file,where,from); |
-} |
- |
-size_t x_fread(void *buffer, size_t size, size_t n, FILE *file) |
-{ |
- return fread(buffer,size,n,file); |
-} |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
-TIME ttt; |
- |
-DWORD n[10]; |
- |
-///* #define GPHBDIM 4097152 */ |
-//#define GPHBDIM 1000000 |
- |
-//BYTE gphb[GPHBDIM]; /* Std Dim: 2M */ |
-//BYTE *nextphbyte = gphb; |
- |
-struct streamdescr { |
- FILE *f; |
- ImageDesc *i; |
- int x1, y1; |
-} sd[10]; |
- |
-#define SCREENX 800 |
-#define SCREENY 600 |
- |
-void txtreset(void *dummy) |
-{ |
-#ifndef NOSHOW |
- grx_close(); |
- grx_modeinfo(); |
- /* cprintf("Total frames: %ld\n", i); |
- cprintf("Total time: %lu\n", t);*/ |
- //cprintf("Frame rate: %lu\n", (n * 1000) / ttt); |
- /* cprintf("Max frame time: %lu\n", mft);*/ |
- /* |
- sys_status(READY_RT_STATUS | READY_NRT_STATUS | BLOCKED_STATUS | |
- IDLE_STATUS | SLEEP_STATUS | EXEC_STATUS); |
- */ |
-#endif |
-} |
- |
-#define MAINSLEEP 20000 |
- |
-void drawload(TIME l) |
-{ |
- #define LLPWINSIZE 20 |
- int actl; |
-// struct load l; |
- #define LOADX 500 |
- #define LOADY 300 |
- #define LOADYDIM 50 |
- #define LOADXDIM 100 |
- static int th = 0; |
- static int x = 0; |
- static int hy[LLPWINSIZE]; |
- static int somma = 0; |
- int i; |
- |
-/* for (i = 0; i < LLPWINSIZE; i++) hy[i] = 0; */ |
- |
-// load_actual(&l); |
-// actl = (LOADYDIM * l.actual) / l.rif + 1; |
-// { |
-// char str[80]; |
-// sprintf(str,"%d",actl); |
-// /*grx_text("Ciao", 200, 200, color16(31, 63, 31), 0);*/ |
-// grx_text(" ", 100, 400, 100, 0); |
-// grx_text(str, 100, 400, 100,0); |
-// } |
-/* LowPass Filter */ |
- |
- |
- actl=((long)l*LOADYDIM)/MAINSLEEP+1; |
- |
- somma += actl - hy[th]; |
- hy[th] = actl; |
- th = (th + 1) % LLPWINSIZE; |
- actl = somma / LLPWINSIZE; |
-#ifndef NOSHOW |
- grx_line(LOADX+x,LOADY,LOADX+x,(LOADY+LOADYDIM),0); |
- if (actl > LOADYDIM) actl = LOADYDIM; |
- grx_line(LOADX+x,(LOADY + actl),LOADX+x,(LOADY+LOADYDIM),255); |
-#endif |
- x = (x + 1) % LOADXDIM; |
- |
-} |
- |
- |
- |
-TASK play(void *arg) |
-{ |
- int i=(int)arg; |
- int loop = TRUE; |
- BYTE *pixels; |
- int moreframes = TRUE; |
- FILE *mpeg = sd[i].f; |
- ImageDesc *img = sd[i].i; |
- int x1, y1, x2, y2; |
- |
- /*printf ("Task %d: Movie is %d x %d pixels\n", i, img->Width, img->Height); |
- printf ("Required picture rate = %d, required bit rate = %d\n", |
- img->PictureRate, img->BitRate);*/ |
- |
- pixels = (BYTE *) malloc(img->Size * sizeof(BYTE)); |
- x1 = sd[i].x1; |
- y1 = sd[i].y1; |
- x2 = x1 + img->Width-1; |
- y2 = y1 + img->Height-1; |
- while (loop) { /* play the whole movie forever */ |
- loop = 0; |
- n[i] = 0; |
- ttt = sys_gettime(NULL); |
- while (moreframes && n[i]<250) { |
- |
- if (mustdied) break; |
- |
-#ifdef NOSHOW |
- cprintf("%c",'°'+i); |
-#endif |
- |
- moreframes = GetMPEGFrame (img, pixels); |
-#ifndef NOSHOW |
- grx_putimage(x1, y1, x2, y2, pixels); |
-#endif |
- n[i]++; |
- task_endcycle(); |
- } |
- ttt = sys_gettime(NULL) - ttt; |
- if (!loop) break; |
- RewindMPEG (mpeg, img); |
- SetMPEGOption (img, MPEG_DITHER, GRAY_DITHER); |
- moreframes = TRUE; |
- } |
- |
- return 0; |
-} |
- |
- |
- |
-int main(int argc, char *argv[]) |
-{ |
- // SYS_PARMS sp = BASE_SYS; |
- KEY_EVT k; |
- // MODEL m = BASE_MODEL; |
- PID pid; |
- |
- // DOS_FILE *Infile; |
-// BYTE *mpegbuff[10], *p; |
-// WORD res; |
-// DWORD cnt[10]; |
- |
- |
-TIME sum; |
- |
- SOFT_TASK_MODEL model; |
- |
- FILE *mpeg; |
- ImageDesc img[10]; |
- int full_color = FALSE; |
- |
- int mode; |
- int esc; |
- int i; |
- int actx = 10, acty = 10; |
- ColormapEntry *cp; |
- |
- //cprintf("file '%s'\n",argv[1]); |
- |
- if (argc < 2) { |
- fprintf (stderr, "Usage: %s mpegfile\n", argv[0]); |
- sys_abort(301); |
- } |
- |
- /* |
- for (i = 0; i < argc - 1; i++) { |
- Infile = DOS_fopen(argv[i + 1], "r"); |
- if (!Infile) { |
- cprintf("%s not found!!!\n", argv[i + 1]); |
- sys_abort(300); |
- } |
- cprintf("\n %s Opened!!!\n\n", argv[i + 1]); |
- |
- mpegbuff[i] = nextphbyte; |
- p = mpegbuff[i]; cnt[i] = 0; |
- res = 0x1000; |
- while (res > 0) { |
- res = DOS_fread(p, 0x1000, 1, Infile); |
- cnt[i] += res; |
- p += res; |
- } |
- p += res; |
- nextphbyte = p; |
- } |
- */ |
- |
- /* OK, Now we can start the system!!! */ |
- //sys_init(&sp); |
- //keyb_init(SOFT, 100); |
- // keyb_init(NULL); |
- // k.flag = CNTR_BIT; |
- // k.scan = KEY_C; |
- // k.ascii = 'c'; |
- //keyb_excset(k,endfun); |
- |
- //vfs_init(); |
- /* |
- for (i = 0; i < argc - 1; i++) { |
- vfs_assign(argv[i + 1], mpegbuff[i], cnt[i]); |
- } |
- */ |
- |
- |
- |
- |
- |
- |
- /* Init the graph... */ |
-#ifndef NOSHOW |
- |
- if (grx_init() == -1) { |
- cprintf("No init!!!\n"); |
- sys_abort(255); |
- } |
- |
- mode = grx_getmode(SCREENX, SCREENY, 8); |
- cprintf("Mode num: %x\n", mode); |
- grx_cardinfo(); |
-#endif |
- |
- cprintf("[hit enter to continue]\n"); |
- esc = FALSE; |
- while (!esc) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii == 13) esc = TRUE; |
- } |
- |
- |
- if (mode == -1) { |
- cprintf("Mode not present!!!\n"); |
- sys_abort(255); |
- } |
- |
-#ifndef NOSHOW |
- if (grx_setmode(mode) == -1) { |
- cprintf("No SetMode!!!\n"); |
- sys_abort(255); |
- } |
-#endif |
- |
- //sys_atexit(txtreset,NULL,AFTER_EXIT); |
- |
- |
- //cprintf("Û0Û"); |
- |
- for (i = 0; i < argc - 1; i++) { |
- mpeg = fopen(argv[i + 1], "r"); |
- |
- if (!mpeg) { |
- perror (argv[1]); |
- sys_abort(301); |
- } |
- |
- //cprintf("Û0.5Û"); |
- |
- /* !!! */ |
- img[i].vid_stream=NULL; |
- img[i].Colormap=NULL; |
- |
- if (!OpenMPEG(mpeg, &(img[i]))) { |
- fprintf (stderr, "OpenMPEG on %s failed\n", argv[i + 1]); |
- sys_abort(301); |
- } |
- |
- |
- //cprintf("Û1Û"); |
- |
- |
- |
- SetMPEGOption (&(img[i]), MPEG_DITHER, GRAY_DITHER); |
- //SetMPEGOption (&(img[i]), MPEG_DITHER, FS4_DITHER); |
- |
- |
- /* SetMPEGOption(MPEG_DITHER, GRAY_DITHER); */ |
- |
- /* printf ("Movie is %d x %d pixels\n", img[i].Width, img[i].Height); |
- printf ("Required picture rate = %d, required bit rate = %d\n", |
- img[i].PictureRate, img[i].BitRate); */ |
- |
- //cprintf("Û2Û"); |
- |
- if (i == 0) { |
- cp = img[i].Colormap; |
- |
- if (!full_color) { |
- int ii; |
- |
- for (ii = 0; ii < img[i].ColormapSize; ii++) { |
- |
-#ifndef NOSHOW |
- |
- grx_setcolor (ii, img[i].Colormap[ii].red / 4, |
- img[i].Colormap[ii].green / 4, |
- img[i].Colormap[ii].blue / 4); |
- |
-#endif |
- |
- } |
- |
- /*NO!!! Colormap is an array of short, setpalette wants an array of BYTE!!!*/ |
- /* grx_setpalette(0, 255, img.Colormap);*/ |
- } |
- } |
- if (actx + img[i].Width > SCREENX) { |
- actx = 10; |
- acty += 200; |
- } |
- sd[i].x1 = actx; |
- sd[i].y1 = acty; |
- sd[i].f = mpeg; |
- sd[i].i = &(img[i]); |
- |
- //cprintf("Û3Û"); |
- |
- soft_task_default_model(model); |
- ////soft_task_def_system(model); |
- //soft_task_def_met(model,9000); |
- //soft_task_def_wcet(model,9000); |
- //soft_task_def_period(model,50000); |
- |
- soft_task_def_met(model,5000); |
- soft_task_def_wcet(model,5000); |
- soft_task_def_period(model,40000); |
- soft_task_def_periodic(model); |
- soft_task_def_arg(model,(void*)i); |
- soft_task_def_ctrl_jet(model); |
- |
- //task_def_arg(m, i); |
- //task_def_wcet(m, 9000); |
- pid = task_create("Shower", play, &model, NULL); |
- if (pid == -1) { |
- cprintf(" task --> Not Guaranteed!!!\n"); |
- sys_abort(20000); |
- } |
- task_activate(pid); |
- |
- //cprintf("Û4Û"); |
- |
- actx += img[i].Width + 10; |
- } |
- |
- /* play(0);*/ |
- esc = FALSE; |
- //jet_delstat(pid); |
- while (!esc) { |
- if (keyb_getcode(&k,NON_BLOCK) && (k.ascii == 13)) esc = TRUE; |
- task_delay(MAINSLEEP); |
- //jet_getstat(pid,&sum,NULL,NULL,NULL); |
- //jet_delstat(pid); |
- //drawload(sum); |
- } |
- |
- sys_abort(59000); |
- |
- return 0; |
-} |
Index: oldexamples/mpeg/common.c |
=================================================================== |
--- oldexamples/mpeg/common.c (revision 1656) |
+++ oldexamples/mpeg/common.c (nonexistent) |
@@ -1,74 +0,0 @@ |
-#include <drivers/keyb.h> |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
- grx_close(); |
- cprintf("CTRL-C pressed!\n"); |
- grx_modeinfo(); |
- sys_end(); |
-} |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <sys/types.h> |
-#include <sys/mount.h> |
- |
-int __register_sub_init_prologue(void) |
-{ |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-dev_t root_device; |
- |
-int choose_root_callback(dev_t dev,u_int8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,TRUE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- return 0; |
-} |
- |
-extern int libc_initialize(void); |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- //struct mount_opts opts; |
- |
- //memset(&opts,0,sizeof(struct mount_opts)); |
- //opts.flags=MOUNT_FLAG_RW; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,TRUE); |
- filesystem_init(&fs); |
- |
- libc_initialize(); |
- |
- return 0; |
-} |
- |
Index: oldexamples/mpeg/mpg123.c |
=================================================================== |
--- oldexamples/mpeg/mpg123.c (revision 1656) |
+++ oldexamples/mpeg/mpg123.c (nonexistent) |
@@ -1,219 +0,0 @@ |
- |
-#include "mpg123/mpg123.h" |
-#include <stdlib.h> |
- |
-/* stub */ |
-FILE *http_open (char *url) |
-{ |
- return NULL; |
-} |
- |
- |
- |
-static long rates[3][3] = { |
- { 32000,44100,48000 } , |
- { 16000,22050,24000 } , |
- { 8000,11025,12000 } |
-}; |
- |
-int supported_rates = 0; |
- |
-int outmode = DECODE_AUDIO; |
- |
-char *listname = NULL; |
-long outscale = 32768; |
-int checkrange = FALSE; |
-int tryresync = TRUE; |
-int quiet = FALSE; |
-int verbose = 0; |
-int doublespeed= 0; |
-int halfspeed = 0; |
-int shuffle = 0; |
-int change_always = 1; |
-int force_8bit = 0; |
-int force_frequency = -1; |
-long numframes = -1; |
-long startFrame= 0; |
-int usebuffer = 0; |
-int frontend_type = 0; |
-int remote = 0; |
-int buffer_fd[2]; |
-int buffer_pid; |
- |
- |
-static int intflag = FALSE; |
-static int remflag = FALSE; |
- |
- |
-static char remote_buffer[1024]; |
-static struct frame fr; |
-static struct audio_info_struct ai; |
-txfermem *buffermem; |
-#define FRAMEBUFUNIT (18 * 64 * 4) |
- |
-void init_output(void) |
-{ |
- static int init_done = FALSE; |
- |
- if (init_done) |
- return; |
- init_done = TRUE; |
- |
- if (!(pcm_sample = (unsigned char *) malloc(audiobufsize * 2))) { |
- perror ("malloc()"); |
- l1_exit (1); |
- |
- } |
- |
- if(outmode==DECODE_AUDIO) { |
- //if(audio_open(&ai) < 0) { |
- // perror("audio"); |
- // exit(1); |
- // } |
- /* audio_set_rate (&ai); should already be done in audio_open() [OF] */ |
- } |
-} |
- |
-static void reset_audio_samplerate(void) |
-{ |
- |
- //if (outmode == DECODE_AUDIO) { |
- /* audio_reset_parameters(&ai); */ |
- /* close and re-open in order to flush |
- * the device's internal buffer before |
- * changing the sample rate. [OF] |
- */ |
- //audio_close (&ai); |
- //if (audio_open(&ai) < 0) { |
- // perror("audio"); |
- // exit(1); |
- // } |
- // } |
-} |
- |
-void play_frame(int init,struct frame *fr) |
-{ |
- int clip; |
- |
- if((fr->header_change && change_always) || init) { |
- int reset_audio = 0; |
- |
- if(remote) |
- print_rheader(fr); |
- |
- if (!quiet && init) { |
- if (verbose) |
- print_header(fr); |
- else |
- print_header_compact(fr); |
- } |
- |
- if(force_frequency < 0) { |
- if(ai.rate != freqs[fr->sampling_frequency]>>(fr->down_sample)) { |
- ai.rate = freqs[fr->sampling_frequency]>>(fr->down_sample); |
- reset_audio = 1; |
- } |
- } |
- else if(ai.rate != force_frequency) { |
- ai.rate = force_frequency; |
- reset_audio = 1; |
- } |
- |
- init_output(); |
- |
- if(reset_audio) { |
- reset_audio_samplerate(); |
- if (intflag) |
- return; |
- } |
- } |
- |
- if (fr->error_protection) { |
- getbits(16); /* crc */ |
- } |
- |
- clip = (fr->do_layer)(fr,outmode,&ai); |
- |
- /* |
- if(clip > 0 && checkrange) |
- fprintf(stderr,"%d samples clipped\n", clip); |
- */ |
-} |
- |
-void audio_info_struct_init(struct audio_info_struct *ai) |
-{ |
- ai->rate = -1; |
- ai->gain = -1; |
- ai->output = -1; |
- ai->device = NULL; |
- ai->channels = -1; |
- ai->format = -1; |
-} |
- |
-int audio_play_samples(struct audio_info_struct *ai, unsigned char *buf, int n) |
-{ |
- return 0; |
-} |
- |
- |
-int main(int argc,char *argv[]) |
-{ |
- static char *fname="/MOSSE.MP3"; |
- int result; |
- unsigned long frameNum = 0; |
- //struct timeval start_time, now; |
- unsigned long secdiff; |
- int init; |
- |
- |
- quiet=0; |
- verbose=1; |
- |
- // DECODE_STDOUT stampa to 1 |
- // DECODE_AUDIO chiama la audio_play_samples |
- // DECODE_BUFFER scrive su buffer_fd[1] |
- outmode = DECODE_AUDIO; |
- |
- audio_info_struct_init(&ai); |
- |
- fr.single = -1; /* both channels */ |
- fr.synth = synth_1to1; |
- fr.down_sample = 0; |
- |
- make_decode_tables(outscale); |
- init_layer2(); |
- init_layer3(fr.down_sample); |
- |
- open_stream(fname,-1); |
- |
- //gettimeofday (&start_time, NULL); |
- read_frame_init(); |
- |
- init = 1; |
- for(frameNum=0;read_frame(&fr) && numframes && !intflag;frameNum++) { |
- if(frameNum < startFrame || (doublespeed && (frameNum % doublespeed))) { |
- if(fr.lay == 3) |
- set_pointer(512); |
- continue; |
- } |
- numframes--; |
- play_frame(init,&fr); |
- init = 0; |
- if (!(frameNum & 0xf)) |
- fprintf(stderr, "\r{%4lu} ",frameNum); |
- } |
- |
- close_stream(); |
- |
- { |
- /* This formula seems to work at least for |
- * MPEG 1.0/2.0 layer 3 streams. |
- */ |
- int sfd = freqs[fr.sampling_frequency] * (fr.lsf + 1); |
- int secs = (frameNum * (fr.lay==1 ? 384 : 1152) + sfd / 2) / sfd; |
- fprintf(stderr,"[%d:%02d] Decoding of %s finished.\n", secs / 60, |
- secs % 60, fname); |
- } |
- |
-} |
- |
Index: oldexamples/mpeg/initfs.c |
=================================================================== |
--- oldexamples/mpeg/initfs.c (revision 1656) |
+++ oldexamples/mpeg/initfs.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 |
- */ |
- |
-/* |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfs.c,v 1.1.1.1 2004-05-24 18:03:39 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:39 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.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; |
- extern int __register_sub_init_prologue(void); |
- extern int __register_sub_init(void); |
- |
- __register_sub_init_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- __register_sub_init(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern int __bdev_sub_init(void); |
- extern int __fs_sub_init(void); |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- __bdev_sub_init(); |
- __fs_sub_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: oldexamples/mpeg/makefile |
=================================================================== |
--- oldexamples/mpeg/makefile (revision 1656) |
+++ oldexamples/mpeg/makefile (nonexistent) |
@@ -1,42 +0,0 @@ |
-# |
-# |
-# |
-# TO REMAKE BETTER |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
-include $(BASE)/config/config.mk |
-include $(BASE)/config/libdep.mk |
- |
-.PHONY: test all install depend clean cleanall |
- |
-C_INC+= -I$(BASE)/ports |
-LINK_LIB+= -lmpeg -lmp3 |
-LINK_DEP+= $(LIB_PATH)/libmpeg.a $(LIB_PATH)/libmp3.a |
- |
-test:: mplay mplay2 mpg123 |
- |
-clean:: |
- rm -f *.o |
- rm -f mplay |
- rm -f mplay2 |
- rm -f mpg123 |
- |
-mplay:mplay.o $(LIB_PATH)/initfs.o $(LIB_DEP) |
- $(LD) $(LINK_OPT) $(LINK_STARTUP) mplay.o $(LIB_PATH)/initfs.o \ |
- --start-group $(LINK_LIB) --end-group \ |
- -o mplay |
- |
-mplay2:mplay2.o $(LIB_PATH)/initfs.o $(LIB_DEP) |
- $(LD) $(LINK_OPT) $(LINK_STARTUP) mplay2.o $(LIB_PATH)/initfs.o \ |
- --start-group $(LINK_LIB) --end-group \ |
- -o mplay2 |
- |
-mpg123:mpg123.o common.o $(LIB_PATH)/initfs.o $(LIB_DEP) |
- $(LD) $(LINK_OPT) $(LINK_STARTUP) \ |
- mpg123.o common.o $(LIB_PATH)/initfs.o \ |
- --start-group $(LINK_LIB) --end-group \ |
- -o mpg123 |
Index: oldexamples/makefile |
=================================================================== |
--- oldexamples/makefile (revision 1656) |
+++ oldexamples/makefile (nonexistent) |
@@ -1,5 +0,0 @@ |
-# fake makefile ;-) |
- |
-all: |
- |
-clean: |
Index: fsdemo/xread.h |
=================================================================== |
--- fsdemo/xread.h (revision 1656) |
+++ fsdemo/xread.h (nonexistent) |
@@ -1,46 +0,0 @@ |
- |
-#ifndef XREAD_H_ |
-#define XREAD_H_ |
- |
-#include <stdio.h> |
- |
-#define BUFFERMAXSIZE (128*1024l) |
- |
-struct xbuffer { |
- int handle; |
- char buffer[BUFFERMAXSIZE+8]; |
- int readptr; |
- int writeptr; |
-}; |
-extern struct xbuffer *table[OPEN_MAX]; |
- |
-void x_init(void); |
- |
-/* rate in bit/sec */ |
-/* band in percentuale */ |
-int x_initbuffer(int group, FILE *f, int rate, int band); |
- |
-#define XUNUSEDPID 5821 |
- |
-/* |
- * |
- */ |
- |
-static __inline__ int filledspace(struct xbuffer *ptr) |
-{ |
- int size; |
- |
- if (ptr->writeptr==ptr->readptr) return 0; |
- |
- size=ptr->writeptr-ptr->readptr; |
- if (size<0) size+=BUFFERMAXSIZE; |
- |
- return size; |
-} |
- |
-static __inline__ int freespace(struct xbuffer *ptr) |
-{ |
- return BUFFERMAXSIZE-filledspace(ptr); |
-} |
- |
-#endif |
Index: fsdemo/config.h |
=================================================================== |
--- fsdemo/config.h (revision 1656) |
+++ fsdemo/config.h (nonexistent) |
@@ -1,44 +0,0 @@ |
- |
-/* |
- * |
- */ |
- |
-/* if def: does not use graphics */ |
-#define NOGRX 1 |
-#undef NOGRX |
- |
-/* if def: use a mutex for all graphics operations */ |
-#define GRXMUTEX 1 |
-#undef GRXMUTEX |
- |
-/* if def: use full color (16bits.. sigh) else use 8 bits/pixel grayscale */ |
-#define FULLCOLOR 1 |
-#undef FULLCOLOR |
- |
-/* |
- * |
- */ |
- |
-/* if def: does not trace events (does not work) */ |
-#define NOTRACE 1 |
-//#undef NOTRACE |
- |
-/* |
- * |
- */ |
- |
-/* if def: activate task buffering */ |
-#define ACTIVATE 1 |
-//#undef ACTIVATE |
- |
-/* |
- * |
- */ |
- |
-/* if def: use bd_edf resource for I/O tasks */ |
-#define EDFSCHED 1 |
-#undef EDFSCHED |
- |
-/* if def: use bd_pscan resources for I/O tasks */ |
-#define PSCANSCHED 1 |
-#undef PSCANSCHED |
Index: fsdemo/readme |
=================================================================== |
--- fsdemo/readme (revision 1656) |
+++ fsdemo/readme (nonexistent) |
@@ -1,21 +0,0 @@ |
-S.Ha.R.K. FSDEMO |
- |
-This demo has been made as a thesis demo by Massimiliano Giorgi |
-(massy@gandalf.sssup.it). The following is the translations of some itailan |
-notes left my Massy. For any problems, please contact us |
-shark-help@gandalf.sssup.it... |
- |
-bye |
- |
-Paolo |
- |
----------------------------------------------------------------------------- |
- |
-mplay is the demo I used during my thesis presentation. |
- |
-To use the demo you need a few mpeg files (those listed into mplay.c) into the directory /temp/m/ and some BMP photos into the directory /temp/b/ |
- |
-Note that only BMP 24bpp images are supported. They MUST have a DIB header, |
-with a line length mujltiple of 4 pixels!!! |
- |
-Massy |
Index: fsdemo/gvideo.c |
=================================================================== |
--- fsdemo/gvideo.c (revision 1656) |
+++ fsdemo/gvideo.c (nonexistent) |
@@ -1,292 +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 |
- */ |
- |
-/* |
- * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: gvideo.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:44 $ |
- */ |
- |
-#include "config.h" |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
-#include <kernel/const.h> |
- |
-#include <drivers/glib.h> |
- |
-#include <stdlib.h> |
- |
-#include "mpeg/video.h" |
-#include "mpeg/util.h" |
-#include "mpeg/dither.h" |
-#include "mpeg/mpeg.h" |
- |
-#include "mutex.h" |
-#include "gvideo.h" |
-#include "gbuffer.h" |
-#include "xread.h" |
- |
-#define STARTGROUP 513 |
- |
-#define VIDEORATE 70 |
-#define READRATE 30 |
- |
-/* |
- * colors |
- */ |
- |
-#ifdef FULLCOLOR |
- |
-#define COLORFG rgb16(255,255,255) |
-#define COLORBG rgb16(0,0,0) |
- |
-#define SP rgb16(0,128,0) |
-#define FG rgb16(255,255,255) |
-#define BG rgb16(0,0,0) |
- |
-#else |
- |
-/* for writing */ |
-#define COLORFG 255 |
-#define COLORBG 0 |
- |
-/* for box */ |
-#define SP 128 |
-#define FG 255 |
-#define BG 0 |
- |
-#endif |
- |
-/* border size (pixels) */ |
-#define BO 4 |
- |
-/* |
- * |
- */ |
- |
-#ifdef FULLCOLOR |
-/* 16bits format 5:6:5 */ |
-/* 32bits format 8:8:8:0 */ |
-void down32to16(WORD *dst, BYTE *src, int size) |
-{ |
- int i; |
- return; |
- for (i=0;i<size;i+=4,dst++,src+=4) |
- /* blue green red */ |
- *dst=((src[2]&0xf8)>>3)|((src[1]&0xfc)<<3)|((src[0]&0xf8)<<8); |
-} |
-#endif |
- |
-/* |
- * |
- */ |
- |
-void draw_frame(int x, int y, int dx, int dy) |
-{ |
-#ifndef NOGRX |
- grxlock(); |
- grx_box(x-1-BO,y-1-BO,x+dx+BO,y+dy+BO,SP); |
- grx_rect(x-1-BO,y-1-BO,x+dx+BO,y+dy+BO,FG); |
- grx_box(x,y,x+dx-1,y+dy-1,BG); |
- grx_rect(x-1,y-1,x+dx,y+dy,FG); |
- grxunlock(); |
-#endif |
-} |
- |
-struct info { |
- int x,y; |
- ImageDesc *img; |
-}; |
- |
-static TASK play(void *arg) |
-{ |
- struct info *ptr=(struct info*)arg; |
- int x1,y1,x2,y2; |
- BYTE *pixels; //,*image; |
- int moreframes; |
- |
- pixels=(BYTE*)malloc(ptr->img->Size*sizeof(BYTE)); |
-#ifdef FULLCOLOR |
- image=(BYTE*)malloc(ptr->img->Size/2*sizeof(BYTE)); |
-#endif |
- x1=ptr->x; |
- y1=ptr->y; |
- x2=x1+ptr->img->Width-1; |
- y2=y1+ptr->img->Height-1; |
- |
- moreframes=1; |
- for (;;) { |
- while (moreframes) { |
- moreframes=GetMPEGFrame(ptr->img,pixels); |
-#ifndef NOGRX |
-#ifdef FULLCOLOR |
- down32to16((WORD*)image,pixels,ptr->img->Size); |
- grxlock(); |
- grx_putimage(x1, y1, x2, y2, pixels); |
- grxunlock(); |
-#else |
- grxlock(); |
- grx_putimage(x1, y1, x2, y2, pixels); |
- grxunlock(); |
-#endif |
-#else |
- cprintf("%c",'0'); |
-#endif |
- task_endcycle(); |
- } |
- break; |
- |
- //if (!loop) break; |
- //RewindMPEG (mpeg, img); |
- //SetMPEGOption (img, MPEG_DITHER, GRAY_DITHER); |
- //moreframes = TRUE; |
- } |
- |
- return NULL; |
-} |
- |
-int gvideo_init(char *title, struct gvideoinfo *ptr) |
-{ |
- // static int groupcounter=0; |
- struct info *info; |
- SOFT_TASK_MODEL model; |
- FILE *fin; |
- PID pid,pid2; |
- ImageDesc *img; |
- int res; |
- int i; |
- int period,wcet; |
- int group; |
- |
- img=(ImageDesc*)malloc(sizeof(ImageDesc)); |
- if (img==NULL) return -3; |
- img->vid_stream=NULL; |
- img->Colormap=NULL; |
- |
- info=(struct info*)malloc(sizeof(struct info)); |
- if (info==NULL) return -11; |
- info->img=img; |
- info->x=ptr->x; |
- info->y=ptr->y; |
- |
- fin=fopen(ptr->pathname, "r"); |
- if (!fin) return -1; |
- |
- //group=STARTGROUP+groupcounter++; |
- group=STARTGROUP; |
- pid2=x_initbuffer(group,fin,ptr->bitrate,ptr->band*READRATE); |
- if (pid2<0) return -2; |
- |
-#ifdef ACTIVATE |
- gbuffer_init(table[fileno(fin)],group,20+12,450); |
-#else |
- gbuffer_init(NULL,group,20+12,450); |
-#endif |
- |
- res=OpenMPEG(fin,img); |
- if (!res) return -4; |
- |
-#ifdef FULLCOLOR |
- SetMPEGOption(img,MPEG_DITHER,HALF_COLOR_DITHER); |
-#else |
- SetMPEGOption(img,MPEG_DITHER,GRAY_DITHER); |
-#endif |
- |
- //cprintf("colrmap size=%8i\n",img->ColormapSize); |
- //cprintf("picture rate=%8i\n",img->PictureRate); |
- //cprintf("bit rate =%8i\n",img->BitRate); |
- |
-#ifndef FULLCOLOR |
- if (group==STARTGROUP) { |
- ColormapEntry *cp; |
- cp=img->Colormap; |
- for (i=0;i<img->ColormapSize;i++) { |
-#ifndef NOGRX |
- grxlock(); |
- grx_setcolor (i,img->Colormap[i].red/4, |
- img->Colormap[i].green/4, |
- img->Colormap[i].blue/4); |
- grxunlock(); |
-#endif |
- } |
- } |
-#endif |
- |
- draw_frame(info->x,info->y,img->Width,img->Height); |
- ptr->w=img->Width; |
- ptr->h=img->Height; |
- |
- { |
- char buffer[256]; |
- |
-#ifndef NOGRX |
- grxlock(); |
- grx_text(title,ptr->x,ptr->y-14,COLORFG,COLORBG); |
- grxunlock(); |
- sprintf(buffer,"Average bit rate: %i.%03i Mb/s", |
- ptr->bitrate/1024/1024,(ptr->bitrate%(1024*1024))*1000/1024/1000); |
- grxlock(); |
- grx_text(buffer,ptr->x,ptr->y+ptr->h+BO*2+2,COLORFG,COLORBG); |
- grxunlock(); |
- sprintf(buffer,"Frame rate : %02.3f frame/sec", |
- (double)ptr->framerate/100.0); |
- grxlock(); |
- grx_text(buffer,ptr->x,ptr->y+ptr->h+BO*2+2+9,COLORFG,COLORBG); |
- grxunlock(); |
-#endif |
- } |
- |
- period=100000000/ptr->framerate; |
- wcet=period*ptr->band*VIDEORATE/10000; |
- |
- soft_task_default_model(model); |
- soft_task_def_met(model,wcet); |
- soft_task_def_wcet(model,wcet); |
- soft_task_def_period(model,period); |
- soft_task_def_periodic(model); |
- soft_task_def_arg(model,(void*)info); |
- soft_task_def_group(model,group); |
- soft_task_def_ctrl_jet(model); |
- |
- pid=task_create("Video",play,&model,NULL); |
- if (pid==-1) return -6; |
- |
- return group; |
-} |
Index: fsdemo/gbuffer.c |
=================================================================== |
--- fsdemo/gbuffer.c (revision 1656) |
+++ fsdemo/gbuffer.c (nonexistent) |
@@ -1,129 +0,0 @@ |
-/* |
- * |
- * |
- */ |
- |
-#include "config.h" |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
-#include <kernel/const.h> |
- |
-#include <drivers/glib.h> |
- |
-#include <stdlib.h> |
-#include <assert.h> |
- |
-#include "mutex.h" |
-#include "xread.h" |
- |
-#define PERIOD 250000 |
-#define WCET 1000 |
- |
-#ifdef FULLCOLOR |
- |
-#define BARCOLOR rgb16(255,0,0) |
-#define BARBG rgb16(0,0,0) |
- |
-#define TEXTCOLOR rgb16(255,255,255) |
-#define TEXTBG rgb16(0,0,0) |
- |
-#else |
- |
-#define BARCOLOR 128 |
-#define BARBG 0 |
- |
-#define TEXTCOLOR 255 |
-#define TEXTBG 0 |
- |
-#endif |
- |
-//#define XC 700 |
-//#define YC 400 |
-#define LEN 100 |
-#define BORDER 8 |
- |
-extern void draw_frame(int x, int y, int dx, int dy); |
- |
-struct taskinfo{ |
- int XC,YC; |
- struct xbuffer *ptr; |
-}; |
- |
-static TASK monitorbuffer(void *arg) |
-{ |
- struct taskinfo *p=(struct taskinfo *)arg; |
- int XC,YC; |
- int oy,y; |
- struct xbuffer *ptr; |
- int sum,old; |
- |
- ptr=p->ptr; |
- XC=p->XC; |
- YC=p->YC; |
- |
- oy=YC+LEN-1; |
- for (;;) { |
- sum=freespace(ptr); |
-#ifndef NOGRX |
- y=YC+LEN*sum/BUFFERMAXSIZE-1; |
- if (y!=oy) { |
- grxlock(); |
- if (y<oy) grx_box(XC,y,XC+BORDER-1,oy,BARCOLOR); |
- else grx_box(XC,oy,XC+BORDER-1,y,BARBG); |
- grxunlock(); |
- oy=y; |
- } |
-#else |
- cprintf("@%i@",sum); |
-#endif |
- old=sum; |
- task_endcycle(); |
- } |
- return 0; |
-} |
- |
-int gbuffer_init(struct xbuffer *ptr, int group, int XC, int YC) |
-{ |
- struct taskinfo *info; |
- SOFT_TASK_MODEL model; |
- PID pid; |
- |
-#ifdef ACTIVATE |
- info=(struct taskinfo *)malloc(sizeof(struct taskinfo)); |
- if (info==NULL) sys_abort(912); |
- info->XC=XC; |
- info->YC=YC; |
- info->ptr=ptr; |
- |
- soft_task_default_model(model); |
- soft_task_def_met(model,WCET); |
- soft_task_def_wcet(model,WCET); |
- soft_task_def_period(model,PERIOD); |
- soft_task_def_periodic(model); |
- soft_task_def_group(model,group); |
- soft_task_def_arg(model,(void*)info); |
- /*soft_task_def_group(model,group);*/ |
- |
- pid=task_create("bufferload",monitorbuffer,&model,NULL); |
- if (pid==-1) return -6; |
- |
-#else |
- pid=-1; |
-#endif |
- |
-#ifndef NOGRX |
- draw_frame(XC,YC,BORDER,LEN); |
- grxlock(); |
- grx_text("Buffer",XC-18,YC+LEN+BORDER*2,TEXTCOLOR,TEXTBG); |
- grx_text("100%",XC+BORDER*2+1,YC-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 75%",XC+BORDER*2+1,YC+LEN/4-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 50%",XC+BORDER*2+1,YC+LEN/4*2-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 25%",XC+BORDER*2+1,YC+LEN/4*3-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 0%",XC+BORDER*2+1,YC+LEN-4,TEXTCOLOR,TEXTBG); |
- grxunlock(); |
-#endif |
- |
- return pid; |
-} |
- |
Index: fsdemo/gvideo.h |
=================================================================== |
--- fsdemo/gvideo.h (revision 1656) |
+++ fsdemo/gvideo.h (nonexistent) |
@@ -1,22 +0,0 @@ |
-/* |
- * |
- * |
- */ |
- |
-#ifndef __GVIDEO_H |
-#define __GVIDEO_H |
- |
-struct gvideoinfo { |
- int x,y; |
- int h,w; /* no fill */ |
- |
- char *pathname; |
- |
- int bitrate; /* bytes/sec */ |
- int framerate; /* frames/sec */ |
- int band; /* CPU band in percent */ |
-}; |
- |
-int gvideo_init(char *title, struct gvideoinfo *info); |
- |
-#endif |
Index: fsdemo/mplay.c |
=================================================================== |
--- fsdemo/mplay.c (revision 1656) |
+++ fsdemo/mplay.c (nonexistent) |
@@ -1,393 +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 |
- */ |
- |
-/* |
- * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: mplay.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:44 $ |
- */ |
- |
-#include "config.h" |
- |
-//#include <ll/sys/types.h> |
- |
-#include <kernel/func.h> |
-#include <kernel/const.h> |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
-#include <drivers/glib.h> |
-#include <drivers/gd.h> |
-#include <drivers/keyb.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <sys/types.h> |
-#include <sys/mount.h> |
- |
-#include <stdlib.h> |
-#include <stdio.h> |
-#include <time.h> |
- |
-#include "gclock.h" |
-#include "gvideo.h" |
-#include "gload.h" |
-#include "gbuffer.h" |
-#include "gphoto.h" |
-#include "mutex.h" |
-#include "xread.h" |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
-#ifndef NOGRX |
- grx_close(); |
-#endif |
- cprintf("CTRL-C pressed!\n"); |
- sys_end(); |
-} |
- |
-/* |
- * |
- * |
- * |
- */ |
- |
-int __register_sub_init_prologue(void) |
-{ |
- // int id; |
-#ifndef NOTRACE |
- TRC_init_phase1(NULL); |
- trc_register_fixed_queue(); |
- id=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
- trc_trace_class(TRC_CLASS_USER); |
- trc_assign_class_to_queue(TRC_CLASS_USER,id); |
-#endif |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
-#if defined(EDFSCHED) |
- extern void BD_EDF_register_module(void); |
- BD_EDF_register_module(); |
-#elif defined(PSCANSCHED) |
- extern void BD_PSCAN_register_module(void); |
- BD_PSCAN_register_module(); |
-#endif |
- return 0; |
-} |
- |
-dev_t root_device=-1; |
-dev_t temp_device=-1; |
- |
-int choose_root_callback(dev_t dev,u_int8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs) |
-{ |
- static int flag=0; |
- if (fs==FS_MSDOS) { |
- if (flag) return dev; |
- flag=1; |
- } |
- return -1; |
-} |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,FALSE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- sys_shutdown_message("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- /* |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- } |
- */ |
- |
- return 0; |
-} |
- |
-int __fs_sub_init(void) |
-{ |
- extern int libc_initialize(void); |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- // struct mount_opts opts; |
- // int res; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,FALSE); |
- filesystem_init(&fs); |
- |
- /* |
- if (temp_device>=0) { |
- memset(&opts,0,sizeof(struct mount_opts)); |
- opts.flags=MOUNT_FLAG_RW; |
- res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- } else |
- cprintf("mounted /TEMP rw\n"); |
- } |
- */ |
- |
- libc_initialize(); |
- |
-#ifndef NOTRACE |
- TRC_init_phase2(); |
-#endif |
- |
- return 0; |
-} |
- |
-/* |
- * |
- * |
- * |
- */ |
- |
-struct { |
- char *filename; |
- int bitrate; |
- int framerate; |
-} mpegs[16]={ |
- /* 0 */ |
- {"/temp/m/2jaeger.mpg", 573225, 3000}, /* 3.27 bad*/ |
- {"/temp/m/alien.mpg", 289000, 2500}, /* 10.12 I */ |
- {"/temp/m/b0.mpg", 1725251, 3000}, /* 3.33 IBBPBBPBBPBB */ |
- {"/temp/m/canyon.mpg", 237194, 3000}, /* 58.60 IBBPBB */ |
- /* 4 */ |
- {"/temp/m/earth-ci.mpg", 974900, 2500}, /* 28.80 IBBPBB */ |
- {"/temp/m/flower.mpg", 1147101, 2997}, /* 5.01 bad */ |
- {"/temp/m/frisco.mpg", 397262, 3000}, /* 1.70 bad */ |
- {"/temp/m/hulahoop.mpg", 684126, 3000}, /* 1.33 bad */ |
- /* 8 */ |
- {"/temp/m/iicm.mpg", 527308, 3000}, /* 26.70 bad */ |
- {"/temp/m/micky.mpg", 711240, 3000}, /* 0.66 bad */ |
- {"/temp/m/mobile.mpg", 114622, 2997}, /* 5.01 bad */ |
- {"/temp/m/redsnigh.mpg", 597776, 2500}, /* 48.40 IBBBBBBBBBPBBBBBBBBB*/ |
- /* 12 */ |
- {"/temp/m/son.mpg", 1134335, 2500}, /* 6.92 IBBPBBPBBPBB */ |
- {"/temp/m/stoelend.mpg", 2248942, 3000}, /* 0.53 IBBPBB */ |
- {"/temp/m/sukhoi.mpg", 481521, 3000}, /* 25.47 I */ |
- {"/temp/m/us.mpg", 681599, 3000} /* 24.37 IBBPBB */ |
-}; |
- |
-#define DEFINDEX 3 |
- |
-char *getfilename(int index) |
-{ |
- return mpegs[index%16].filename; |
-} |
- |
-int getbitrate(int index) |
-{ |
- return mpegs[index%16].bitrate; |
-} |
- |
-int getframerate(int index) |
-{ |
- return mpegs[index%16].framerate; |
-} |
- |
-/* |
- * |
- * |
- * |
- */ |
- |
-#ifdef FULLCOLOR |
- |
-#define TEXTCOLOR rgb16(0,255,0) |
-#define TEXTCOLOR2 rgb16(255,255,255) |
-#define TEXTBG rgb16(0,0,0) |
- |
-#else |
- |
-#define TEXTCOLOR 255 |
-#define TEXTCOLOR2 255 |
-#define TEXTBG 0 |
- |
-#endif |
- |
-#define SCREENX 800 |
-#define SCREENY 600 |
- |
-#define MAINSLEEP 20000 |
- |
-g_sem_t grxsem; |
- |
-int main(int argc, char *argv[]) |
-{ |
- struct gvideoinfo info; |
- KEY_EVT k; |
- int index; |
- int mode; |
- int esc; |
- int pid,grp; |
- // int i; |
- int sx=20; |
- PID ph1,ph2,ph3; |
- |
- g_sem_init(&grxsem,1); |
- |
- /* |
- if (argc<2) { |
- cprintf("Usage: %s mpegfileordinal\n",argv[0]); |
- sys_abort(301); |
- } |
- */ |
- |
- /* init the "file reader tasks" module */ |
- x_init(); |
- |
- /* Init the graph... */ |
-#ifndef NOGRX |
- if (grx_init()==-1) { |
- cprintf("No init!!!\n"); |
- sys_abort(255); |
- } |
-#ifdef FULLCOLOR |
- mode=grx_getmode(SCREENX,SCREENY,16); |
-#else |
- mode=grx_getmode(SCREENX,SCREENY,8); |
-#endif |
- if (mode==-1) { |
- cprintf("Mode not present!!!\n"); |
- sys_abort(255); |
- } |
-#endif |
- |
- cprintf("[hit enter to continue]\n"); |
- esc=FALSE; |
- while (!esc) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii==13) esc=TRUE; |
- } |
- |
-#ifndef NOGRX |
- if (grx_setmode(mode) == -1) { |
- cprintf("No SetMode!!!\n"); |
- sys_abort(255); |
- } |
-#endif |
- |
-#ifndef NOGRX |
- grx_text("HARTIK 4.0 (Lego)",12*2,22,TEXTCOLOR,TEXTBG); |
- grx_text("[Filesystem demo]",12*2,22+10,TEXTCOLOR,TEXTBG); |
- |
- grx_text("Video : 8bit/pixel",250,450,TEXTCOLOR2,TEXTBG); |
- grx_text("Double buffer: YES",250,450+10,TEXTCOLOR2,TEXTBG); |
- grx_text("Algorithm : FCFS",250,450+20,TEXTCOLOR2,TEXTBG); |
-#endif |
- |
- pid=gclock_init(32+64+64,540); |
- task_activate(pid); |
- |
- //for (i=0;i<argc-1;i++) { |
- |
- //index=atoi(argv[i+1]); |
- index=4; |
- |
- info.x=sx+30; |
- info.y=80; |
- info.pathname=getfilename(index); |
- info.bitrate=getbitrate(index); |
- info.framerate=getframerate(index); |
- info.band=25; |
- |
- grp=gvideo_init("Video: earth.mpg", &info); |
- //if (grp>0) group_activate(grp); |
- |
- sx+=info.w+15; |
- //} |
- |
- pid=gload_init(1); |
- task_activate(pid); |
- |
- ph1=gphoto_show("Photo: galaxy","/temp/b/ph2a.bmp",500,25); |
- ph2=gphoto_show("Photo: canyon","/temp/b/ph3a.bmp",500,225); |
- ph3=gphoto_show("Photo: nicole","/temp/b/ph7a.bmp",500,425); |
- |
- if (grp>0) group_activate(grp); |
- |
- esc=0; |
- |
- { |
- struct timespec delay; |
- |
- delay.tv_sec = MAINSLEEP/1000000; |
- delay.tv_nsec = (MAINSLEEP%1000000)*1000; |
- |
- while (!esc) { |
- if (keyb_getcode(&k,NON_BLOCK)) { |
- if(k.ascii==13) esc=1; |
- else if (k.ascii=='a') task_activate(ph1); |
- else if (k.ascii=='s') task_activate(ph2); |
- else if (k.ascii=='d') task_activate(ph3); |
- } |
- nanosleep(&delay, NULL); |
- } |
- } |
- |
-#ifndef NOGRX |
- grx_close(); |
-#endif |
- |
- sys_end(); |
- return 0; |
-} |
Index: fsdemo/gbuffer.h |
=================================================================== |
--- fsdemo/gbuffer.h (revision 1656) |
+++ fsdemo/gbuffer.h (nonexistent) |
@@ -1,9 +0,0 @@ |
- |
-#ifndef __GBUFFER_H |
-#define __GBUFFER_H |
- |
-#include "xread.h" |
- |
-int gbuffer_init(struct xbuffer *ptr, int group, int XC, int YC); |
- |
-#endif |
Index: fsdemo/gload.c |
=================================================================== |
--- fsdemo/gload.c (revision 1656) |
+++ fsdemo/gload.c (nonexistent) |
@@ -1,113 +0,0 @@ |
-/* |
- * |
- * |
- */ |
- |
-#include "config.h" |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
-#include <kernel/const.h> |
- |
-#include <drivers/glib.h> |
- |
-#include <stdlib.h> |
-#include <assert.h> |
- |
-#include "mutex.h" |
-#include "gload.h" |
- |
-#define PERIOD 250000 |
-#define WCET 1000 |
- |
-#ifdef FULLCOLOR |
- |
-#define BARCOLOR rgb16(255,0,0) |
-#define BARBG rgb16(0,0,0) |
- |
-#define TEXTCOLOR rgb16(255,255,255) |
-#define TEXTBG rgb16(0,0,0) |
- |
-#else |
- |
-#define BARCOLOR 128 |
-#define BARBG 0 |
- |
-#define TEXTCOLOR 255 |
-#define TEXTBG 0 |
- |
-#endif |
- |
-#define XC (32+64) |
-#define YC 450 |
-#define LEN 100 |
-#define BOR 8 |
- |
-extern void draw_frame(int x, int y, int dx, int dy); |
- |
-/* only for NRT task */ |
-static TASK monitorload(void *arg) |
-{ |
- int oy,y; |
- PID pid=(PID)arg; |
- TIME sum,old; |
- int res; |
- |
- res=jet_getstat(pid,NULL,NULL,NULL,&old); |
- task_endcycle(); |
- |
- oy=YC+LEN-1; |
- for (;;) { |
- res=jet_getstat(pid,NULL,NULL,NULL,&sum); |
- if (res==-1) break; |
-#ifndef NOGRX |
- y=YC+LEN*(sum-old)/PERIOD-1; |
- if (y!=oy) { |
- grxlock(); |
- if (y<oy) grx_box(XC,y,XC+BOR-1,oy,BARCOLOR); |
- else grx_box(XC,oy,XC+BOR-1,y,BARBG); |
- grxunlock(); |
- oy=y; |
- } |
-#else |
- n++; |
- if (n%4==0) |
- cprintf("#%li,%i#",sum); //(1000-sum*1000/PERIOD); |
-#endif |
- old=sum; |
- task_endcycle(); |
- } |
- return 0; |
-} |
- |
-int gload_init(int taskpid) |
-{ |
- SOFT_TASK_MODEL model; |
- PID pid; |
- |
- soft_task_default_model(model); |
- soft_task_def_met(model,WCET); |
- soft_task_def_wcet(model,WCET); |
- soft_task_def_period(model,PERIOD); |
- soft_task_def_periodic(model); |
- soft_task_def_arg(model,(void*)taskpid); |
- /*soft_task_def_group(model,group);*/ |
- |
- pid=task_create("load",monitorload,&model,NULL); |
- if (pid==-1) return -6; |
- |
-#ifndef NOGRX |
- draw_frame(XC,YC,BOR,LEN); |
- grxlock(); |
- grx_text("Load",XC-10,YC+LEN+BOR*2,TEXTCOLOR,TEXTBG); |
- grx_text("100%",XC+BOR*2+1,YC-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 75%",XC+BOR*2+1,YC+LEN/4-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 50%",XC+BOR*2+1,YC+LEN/4*2-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 25%",XC+BOR*2+1,YC+LEN/4*3-4,TEXTCOLOR,TEXTBG); |
- grx_text(" 0%",XC+BOR*2+1,YC+LEN-4,TEXTCOLOR,TEXTBG); |
- grxunlock(); |
-#endif |
- |
- return pid; |
-} |
- |
Index: fsdemo/gphoto.ok |
=================================================================== |
--- fsdemo/gphoto.ok (revision 1656) |
+++ fsdemo/gphoto.ok (nonexistent) |
@@ -1,222 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Luca Abeni <luca@hartik.sssup.it> |
- * Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: gphoto.ok,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:44 $ |
- */ |
- |
-#include "config.h" |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
-#include <kernel/const.h> |
- |
-#include <drivers/glib.h> |
- |
-#include <unistd.h> |
-#include <stdlib.h> |
-#include <fcntl.h> |
- |
-#include "mutex.h" |
-#include "gphoto.h" |
- |
-#ifdef FULLCOLOR |
- |
-/* 16bits format 5:6:5 */ |
-/* 24bits format 8:8:8 */ |
-static void down24to16(WORD *dst, BYTE *src, int dx, int dy) |
-{ |
- int x,y; |
- /* row must be multiple of 4!!! (there are 3 bytes per pixel!)*/ |
- dst+=dx*(dy+1); |
- for (y=0;y<dy;y++) { |
- dst-=dx*2; |
- for (x=0;x<dx;x++,src+=3,dst++) |
- /* blue green red */ |
- *dst=((src[0]&0xf8)>>3)|((src[1]&0xfc)<<3)|((src[2]&0xf8)<<8); |
- } |
-} |
- |
-#define downscaleimage(x,y,z,k) down24to16((WORD*)x,y,z,k) |
- |
-#else |
- |
-static void down24to8(BYTE *dst, BYTE *src, int dx, int dy) |
-{ |
- int x,y; |
- |
- dst+=dx*(dy+1); |
- for (y=0;y<dy;y++) { |
- dst-=dx*2; |
- for (x=0;x<dx;x++,src+=3,dst++) |
- *dst=(((int)src[0])*11+((int)src[1])*59+((int)src[2])*30)/100; |
- } |
-} |
- |
-#define downscaleimage(x,y,z,k) down24to8(x,y,z,k) |
- |
-#endif |
- |
-/* |
- * |
- */ |
- |
-extern void draw_frame(int x, int y, int dx, int dy); |
- |
-int gphoto_show(char *pathname, int x, int y) |
-{ |
- struct BITMAPFILEHEADER *bf; |
- struct BITMAPINFOHEADER *bi; |
- BYTE *src,*dst; |
- long l; |
- int h,n; |
- int dx,dy; |
- |
- bf=(struct BITMAPFILEHEADER *)malloc(sizeof(struct BITMAPFILEHEADER)); |
- bi=(struct BITMAPINFOHEADER *)malloc(sizeof(struct BITMAPINFOHEADER)); |
- |
- if (bf==NULL||bi==NULL) return -1; |
- |
- h=open(pathname,O_RDONLY); |
- if (h==-1) { |
- free(bf); |
- free(bi); |
- return -2; |
- } |
- |
- n=read(h,bf,sizeof(struct BITMAPFILEHEADER)); |
- if (n!=sizeof(struct BITMAPFILEHEADER)) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -4; |
- } |
- |
- n=read(h,bi,sizeof(struct BITMAPINFOHEADER)); |
- if (n!=sizeof(struct BITMAPINFOHEADER)) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -4; |
- } |
- |
- //grx_close(); |
- |
- /* |
- cprintf("type: %c %c\n",bf->bfType&0xff,bf->bfType>>8); |
- cprintf("size: %li\n",bf->bfSize); |
- cprintf("tell: %li\n\n",bf->bfOffBits); |
- |
- cprintf("bitcoutn: %i\n",bi->biBitCount); |
- cprintf("compress: %li\n",bi->biCompression); |
- cprintf("dx: %li\n",bi->biWidth); |
- cprintf("dy: %li\n",bi->biHeight); |
- */ |
- |
- //sys_end(); |
- //return 0; |
- |
- if (bf->bfType!='B'+256*'M'|| |
- bi->biBitCount!=24|| |
- bi->biCompression!=0|| |
- bi->biWidth%4!=0) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -5; |
- } |
- |
- dx=bi->biWidth; |
- dy=bi->biHeight; |
- |
- src=(BYTE*)malloc(dx*dy*3); |
- if (src==NULL) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -6; |
- } |
- |
- dst=(BYTE*)malloc(dx*dy*2); |
- if (dst==NULL) { |
- free(src); |
- close(h); |
- free(bf); |
- free(bi); |
- return -6; |
- } |
- |
- l=lseek(h,bf->bfOffBits,SEEK_SET); |
- if (l!=bf->bfOffBits) { |
- free(dst); |
- free(src); |
- close(h); |
- free(bf); |
- free(bi); |
- return -7; |
- } |
- |
- n=read(h,src,dx*dy*3); |
- if (n!=dx*dy*3) { |
- free(dst); |
- free(src); |
- close(h); |
- free(bf); |
- free(bi); |
- return -8; |
- } |
- |
- downscaleimage(dst,src,dx,dy); |
- |
-#ifndef NOGRX |
- draw_frame(x,y,dx,dy); |
- grxlock(); |
- grx_putimage(x, y, x+dx-1, y+dy-1, dst); |
- grxunlock(); |
-#endif |
- |
- free(dst); |
- free(src); |
- close(h); |
- free(bi); |
- free(bf); |
- |
- return 0; |
-} |
Index: fsdemo/oldmakefile |
=================================================================== |
--- fsdemo/oldmakefile (revision 1656) |
+++ fsdemo/oldmakefile (nonexistent) |
@@ -1,41 +0,0 @@ |
-# |
-# |
-# |
-# TO REMAKE BETTER |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-.PHONY: test all install depend clean cleanall |
- |
-C_INC+= -I$(BASE)/ports |
-LINK_LIB+= -lmpeg |
-LINK_DEP+= $(LIB_PATH)/libmpeg.a |
- |
-#test:: tserv tserv2 |
-test:: mplay |
- |
-clean:: |
- rm -f *.o |
- rm -f mplay |
- |
-OBJS= mplay.o xread.o gclock.o gvideo.o gload.o gbuffer.o gphoto.o |
- |
-mplay: $(OBJS) $(LIB_PATH)/initfs.o $(LIB_DEP) |
- $(LD) $(LINK_OPT) $(LINK_STARTUP) \ |
- $(OBJS) \ |
- $(LIB_PATH)/initfs.o \ |
- --start-group $(LINK_LIB) --end-group \ |
- -o mplay |
- |
-depend:: |
- $(CC) $(C_OPT) -M $(OBJS:.o=.c) > deps |
- |
-deps: |
- $(CC) $(C_OPT) -M $(OBJS:.o=.c) > deps |
- |
-include deps |
Index: fsdemo/gload.h |
=================================================================== |
--- fsdemo/gload.h (revision 1656) |
+++ fsdemo/gload.h (nonexistent) |
@@ -1,7 +0,0 @@ |
- |
-#ifndef __GLOAD_H |
-#define __GLOAD_H |
- |
-int gload_init(int pid); |
- |
-#endif |
Index: fsdemo/makefile |
=================================================================== |
--- fsdemo/makefile (revision 1656) |
+++ fsdemo/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= mplay |
- |
-include $(BASE)/config/example.mk |
- |
-mplay: |
- make -f $(SUBMAKE) APP=mplay INIT= OTHEROBJS="xread.o gclock.o gvideo.o gload.o gbuffer.o gphoto.o initfile.o" OTHERINCL="-I$(BASE)/ports" SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: fsdemo/gphoto.c |
=================================================================== |
--- fsdemo/gphoto.c (revision 1656) |
+++ fsdemo/gphoto.c (nonexistent) |
@@ -1,302 +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 |
- */ |
- |
-/* |
- * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
- * |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: gphoto.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:44 $ |
- */ |
- |
-#include "config.h" |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
-#include <kernel/const.h> |
- |
-#include <drivers/glib.h> |
- |
-#include <unistd.h> |
-#include <stdlib.h> |
-#include <fcntl.h> |
- |
-#include "mutex.h" |
-#include "gphoto.h" |
- |
-#ifdef FULLCOLOR |
-#define COLORFG rgb16(255,255,255) |
-#define COLORBG rgb16(0,0,0) |
-#else |
-#define COLORFG 255 |
-#define COLORBG 0 |
-#endif |
- |
-#ifdef FULLCOLOR |
- |
-/* 16bits format 5:6:5 */ |
-/* 24bits format 8:8:8 */ |
-static void down24to16(int h , |
- WORD *dst, BYTE *src, |
- int xs, int ys, int dx, int dy) |
-{ |
- WORD *pdst; |
- BYTE *psrc; |
- int x,y; |
- int n; |
- |
- /* row must be multiple of 4!!! (there are 3 bytes per pixel!)*/ |
- |
- for (y=0;y<dy;y++) { |
- psrc=src; |
- pdst=dst; |
- |
- n=read(h,src,dx*3); |
- if (n!=dx*3) return; |
- |
- for (x=0;x<dx;x++,psrc+=3,pdst++) |
- /* blue green red */ |
- *pdst=((psrc[0]&0xf8)>>3)|((psrc[1]&0xfc)<<3)|((psrc[2]&0xf8)<<8); |
- |
-#ifndef NOGRX |
- grxlock(); |
- grx_putimage(xs, ys+dy-y-1, xs+dx-1, ys+dy-y-1, dst); |
- grxunlock(); |
-#endif |
- |
- } |
- |
-} |
- |
-#define downscaleimage(h,x,y,a,b,c,d) down24to16(h,(WORD*)x,y,a,b,c,d) |
- |
-#else |
- |
-static void down24to8(int h, |
- BYTE *dst, BYTE *src, |
- int xs, int ys, int dx, int dy) |
-{ |
- BYTE *pdst; |
- BYTE *psrc; |
- int x,y; |
- int n; |
- |
- /* row must be multiple of 4!!! (there are 3 bytes per pixel!)*/ |
- |
- for (y=0;y<dy;y++) { |
- psrc=src; |
- pdst=dst; |
- |
- n=read(h,src,dx*3); |
- if (n!=dx*3) return; |
- |
- for (x=0;x<dx;x++,psrc+=3,pdst++) |
- *pdst=(((int)psrc[0])*11+((int)psrc[1])*59+((int)psrc[2])*30)/100; |
- |
-#ifndef NOGRX |
- grxlock(); |
- grx_putimage(xs, ys+dy-y-1, xs+dx-1, ys+dy-y-1, dst); |
- grxunlock(); |
-#endif |
- |
- } |
-} |
- |
-#define downscaleimage(h,x,y,a,b,c,d) down24to8(h,x,y,a,b,c,d) |
- |
-#endif |
- |
-/* |
- * |
- */ |
- |
-struct taskinfo { |
- int h; |
- BYTE *dst,*src; |
- int x,y; |
- int dx,dy; |
-}; |
- |
-static TASK phototask(void *arg) |
-{ |
- struct taskinfo *p=(struct taskinfo *)arg; |
- |
- downscaleimage(p->h,p->dst,p->src,p->x,p->y,p->dx,p->dy); |
- |
- free(p->dst); |
- free(p->src); |
- close(p->h); |
- |
- free(arg); |
- |
- return NULL; |
-} |
- |
- |
-/* |
- * |
- */ |
- |
-extern void draw_frame(int x, int y, int dx, int dy); |
- |
-int gphoto_show(char *title, char *pathname, int x, int y) |
-{ |
- NRT_TASK_MODEL model; |
- struct BITMAPFILEHEADER *bf; |
- struct BITMAPINFOHEADER *bi; |
- struct taskinfo *info; |
- BYTE *src,*dst; |
- long l; |
- int h,n; |
- int dx,dy; |
- PID pid; |
- |
- bf=(struct BITMAPFILEHEADER *)malloc(sizeof(struct BITMAPFILEHEADER)); |
- bi=(struct BITMAPINFOHEADER *)malloc(sizeof(struct BITMAPINFOHEADER)); |
- |
- if (bf==NULL||bi==NULL) return -11; |
- |
- h=open(pathname,O_RDONLY); |
- if (h==-1) { |
- free(bf); |
- free(bi); |
- return -2; |
- } |
- |
- n=read(h,bf,sizeof(struct BITMAPFILEHEADER)); |
- if (n!=sizeof(struct BITMAPFILEHEADER)) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -4; |
- } |
- |
- n=read(h,bi,sizeof(struct BITMAPINFOHEADER)); |
- if (n!=sizeof(struct BITMAPINFOHEADER)) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -4; |
- } |
- |
- //grx_close(); |
- |
- /* |
- cprintf("type: %c %c\n",bf->bfType&0xff,bf->bfType>>8); |
- cprintf("size: %li\n",bf->bfSize); |
- cprintf("tell: %li\n\n",bf->bfOffBits); |
- |
- cprintf("bitcoutn: %i\n",bi->biBitCount); |
- cprintf("compress: %li\n",bi->biCompression); |
- cprintf("dx: %li\n",bi->biWidth); |
- cprintf("dy: %li\n",bi->biHeight); |
- */ |
- |
- //sys_end(); |
- //return 0; |
- |
- if (bf->bfType!='B'+256*'M'|| |
- bi->biBitCount!=24|| |
- bi->biCompression!=0|| |
- bi->biWidth%4!=0) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -5; |
- } |
- |
- dx=bi->biWidth; |
- dy=bi->biHeight; |
- |
- src=(BYTE*)malloc(dx*3); |
- if (src==NULL) { |
- close(h); |
- free(bf); |
- free(bi); |
- return -6; |
- } |
- |
- dst=(BYTE*)malloc(dx*2); |
- if (dst==NULL) { |
- free(src); |
- close(h); |
- free(bf); |
- free(bi); |
- return -6; |
- } |
- |
- l=lseek(h,bf->bfOffBits,SEEK_SET); |
- if (l!=bf->bfOffBits) { |
- free(dst); |
- free(src); |
- close(h); |
- free(bf); |
- free(bi); |
- return -7; |
- } |
- |
-#ifndef NOGRX |
- draw_frame(x,y,dx,dy); |
- grxlock(); |
- grx_text(title,x,y-14,COLORFG,COLORBG); |
- grxunlock(); |
-#endif |
- |
- free(bi); |
- free(bf); |
- |
- info=(struct taskinfo *)malloc(sizeof(struct taskinfo)); |
- if (info==NULL) { |
- free(dst); |
- free(src); |
- close(h); |
- return -8; |
- } |
- info->h=h; |
- info->src=src; |
- info->dst=dst; |
- info->x=x; |
- info->y=y; |
- info->dx=dx; |
- info->dy=dy; |
- |
- nrt_task_default_model(model); |
- nrt_task_def_arg(model,info); |
- pid=task_create("Photo",phototask,&model,NULL); |
- |
- return pid; |
-} |
Index: fsdemo/gclock.c |
=================================================================== |
--- fsdemo/gclock.c (revision 1656) |
+++ fsdemo/gclock.c (nonexistent) |
@@ -1,81 +0,0 @@ |
- |
-#include "config.h" |
- |
-#include <kernel/func.h> |
-#include <kernel/const.h> |
-#include <kernel/model.h> |
-#include <kernel/types.h> |
- |
-#include <drivers/glib.h> |
- |
-#include <stdlib.h> |
- |
-#include "mutex.h" |
-#include "gclock.h" |
- |
-#ifdef FULLCOLOR |
-#define COLORFG rgb16(255,255,255) |
-#define COLORBG rgb16(0,0,0) |
-#else |
-#define COLORFG 255 |
-#define COLORBG 0 |
-#endif |
- |
-struct info { |
- int x; |
- int y; |
-}; |
- |
-static TASK grxclock(struct info *ptr) |
-{ |
- char buffer[16]; |
- int min,sec; |
- |
- min=sec=0; |
- for (;;) { |
- sprintf(buffer,"%02i:%02i",min,sec); |
-#ifndef NOGRX |
- grxlock(); |
- grx_text(buffer,ptr->x,ptr->y,COLORFG,COLORBG); |
- grxunlock(); |
-#endif |
- sec++; |
- if (sec==60) { |
- sec=0; |
- min++; |
- if (min==60) min=0; |
- } |
- task_endcycle(); |
- } |
- return NULL; |
-} |
- |
-PID gclock_init(int x, int y) |
-{ |
- SOFT_TASK_MODEL model; |
- struct info *ptr; |
- |
- ptr=(struct info *)malloc(sizeof(struct info)); |
- if (ptr==NULL) return -1; |
- ptr->x=x+1; |
- ptr->y=y+1; |
- |
-#ifndef NOGRX |
- grxlock(); |
- grx_box(x-1,y-1,x+GCLOCKDX-1,y+GCLOCKDY-1,COLORBG); |
- grx_rect(x-1,y-1,x+GCLOCKDX-1,y+GCLOCKDY-1,COLORFG); |
- grx_text("00:00",ptr->x,ptr->y,COLORFG,COLORBG); |
- grx_text("Clock",ptr->x,ptr->y-12,COLORFG,COLORBG); |
- grxunlock(); |
-#endif |
- |
- soft_task_default_model(model); |
- soft_task_def_met(model,5000); |
- soft_task_def_wcet(model,5000); |
- soft_task_def_period(model,1000000); |
- soft_task_def_periodic(model); |
- soft_task_def_arg(model,(void*)ptr); |
- //soft_task_def_ctrl_jet(model); |
- |
- return task_create("grxclock", grxclock, &model, NULL); |
-} |
Index: fsdemo/initfile.c |
=================================================================== |
--- fsdemo/initfile.c (revision 1656) |
+++ fsdemo/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 |
- */ |
- |
-/* |
- * 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 |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfile.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1.1.1 $ |
- * Last update: $Date: 2004-05-24 18:03:44 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.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; |
- extern int __register_sub_init_prologue(void); |
- extern int __register_sub_init(void); |
- |
- __register_sub_init_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- __register_sub_init(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern int __bdev_sub_init(void); |
- extern int __fs_sub_init(void); |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- __bdev_sub_init(); |
- __fs_sub_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: fsdemo/xread.c |
=================================================================== |
--- fsdemo/xread.c (revision 1656) |
+++ fsdemo/xread.c (nonexistent) |
@@ -1,240 +0,0 @@ |
-/* |
- * |
- * |
- * |
- * |
- */ |
- |
-#include "config.h" |
- |
-#include <ll/i386/cons.h> |
- |
-#include <kernel/func.h> |
-#include <kernel/int_sem.h> |
-#define seminit(s,v) internal_sem_init(s,v) |
-#define semwait(s) internal_sem_wait(s) |
-#define semsignal(s) internal_sem_post(s) |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <unistd.h> |
-#include <time.h> |
- |
-#include <assert.h> |
- |
-#include "xread.h" |
- |
-/**/ |
- |
-/* |
- */ |
- |
-#ifndef ACTIVATE |
-int x_fseek(FILE *file, long where, int from) |
-{ |
- return fseek(file,where,from); |
-} |
- |
-size_t x_fread(void *buffer, size_t size, size_t n, FILE *file) |
-{ |
- return fread(buffer,size,n,file); |
-} |
- |
-void x_init(void) |
-{} |
- |
-int x_initbuffer(int group, FILE *f, int rate, int band) |
-{ |
- return XUNUSEDPID; |
-} |
- |
-#endif |
- |
-#ifdef ACTIVATE |
-int x_fseek(FILE *file, long where, int from) |
-{ |
- return -1; |
-} |
- |
-#define BLOCKSIZE (512*4) |
-#define BLOCKSPERBUFFER (BUFFERMAXSIZE/BLOCKSIZE) |
- |
-/* in millisecondi */ |
-#define PRELOAD 500 |
- |
-struct xbuffer *table[OPEN_MAX]; |
- |
-int end_counter=0; |
- |
-static TASK bufferfiller(void *arg) |
-{ |
- struct xbuffer *ptr=(struct xbuffer *)arg; |
- int n; |
- |
- for (;;) { |
- if (freespace(ptr)>BLOCKSIZE+8) { |
- //assert(ptr->writeptr>=0); |
- //assert(ptr->writeptr+BLOCKSIZE<=BUFFERMAXSIZE); |
- n=read(ptr->handle,ptr->buffer+ptr->writeptr,BLOCKSIZE); |
-#ifdef NOGRX |
- cprintf("²"); |
-#endif |
- kern_cli(); |
- ptr->writeptr+=n; |
- /* ipotesi: non si legge mai piu' di BUFFERMAXSIZE */ |
- if (ptr->writeptr>=BUFFERMAXSIZE) ptr->writeptr-=BUFFERMAXSIZE; |
- kern_sti(); |
- if (n!=BLOCKSIZE) { |
- //cprintf("<XXX>"); |
- break; |
- } |
- //assert(ptr->writeptr%512==0); |
- } |
- task_endcycle(); |
- } |
- |
- end_counter++; |
- |
- return NULL; |
-} |
- |
-void x_init(void) |
-{ |
- int i; |
- for (i=0;i<OPEN_MAX;i++) table[i]=NULL; |
-} |
- |
-/* rate in bits/sec */ |
-/* band in percentuale *100 */ |
-int x_initbuffer(int group, FILE *f, int rate, int band) |
-{ |
-#ifdef EDFSCHED |
- BDEDF_RES_MODEL resource; |
-#endif |
-#ifdef PSCANSCHED |
- BDPSCAN_RES_MODEL resource; |
-#endif |
- SOFT_TASK_MODEL model; |
- struct xbuffer *ptr; |
- int handle; |
- int period,wcet; |
- int n,preload; |
- PID pid; |
- |
- handle=fileno(f); |
- if (handle>OPEN_MAX||handle<0) return -11; |
- |
- if (table[handle]!=NULL) return -2; |
- |
- ptr=table[handle]=(struct xbuffer *)malloc(sizeof(struct xbuffer)); |
- if (ptr==NULL) return -3; |
- |
- ptr->handle=handle; |
- ptr->writeptr=ptr->readptr=0; |
- n=lseek(ptr->handle,0,SEEK_SET); |
- if (n!=0) { |
- cprintf("can't seek to 0\n"); |
- return -12; |
- } |
- |
- /* PRELOAD */ |
- preload=rate*PRELOAD/8/1000; |
- if (preload<100*1024) preload=100*1024; |
- preload=(preload/BLOCKSIZE+1)*BLOCKSIZE; |
- if (preload>BUFFERMAXSIZE-BLOCKSIZE) return -4; |
- n=read(ptr->handle,ptr->buffer,preload); |
- if (n!=preload) { |
- cprintf("preload: request %li bytes (%li returned)\n", |
- (long)preload,(long)n); |
- return -5; |
- } |
- ptr->writeptr+=n; |
- |
- //cprintf("%li bytes preloaded\n",(long)n); |
- if (rate==0) sys_abort(997); |
- period=1000000l*BLOCKSIZE/rate*8; |
- wcet=period*band/10000; |
- |
- soft_task_default_model(model); |
- soft_task_def_met(model,wcet); |
- soft_task_def_wcet(model,wcet); |
- soft_task_def_period(model,period); |
- soft_task_def_periodic(model); |
- soft_task_def_arg(model,(void*)ptr); |
- soft_task_def_group(model,group); |
- |
-#if defined(EDFSCHED) |
- BDEDF_res_default_model(resource); |
- BDEDF_res_def_dl(resource,period); |
- pid=task_createn("xfill", bufferfiller,(TASK_MODEL*)&model, &resource, NULL); |
-#elif defined(PSCANSCHED) |
- BDPSCAN_res_default_model(resource); |
- BDPSCAN_res_def_priority(resource,0); |
- pid=task_createn("xfill", bufferfiller,(TASK_MODEL*)&model, &resource, NULL); |
-#else |
- pid=task_create("xfill", bufferfiller, &model, NULL); |
-#endif |
- if (pid!=-1) { |
- cprintf("task wcet=%10li period=%10li\n",(long)wcet,(long)period); |
- } |
- |
- return pid; |
-} |
- |
-size_t x_fread(void *buffer, size_t objsize, size_t n, FILE *file) |
-{ |
- struct xbuffer *ptr; |
- int size,sz; |
- int nv; |
- |
- ptr=table[fileno(file)]; |
- if (ptr==NULL) { |
- cprintf("x_fread with bad fd\n"); |
- return 0; |
- } |
- |
- size=objsize*n; |
- //cprintf("[for %i]",size); |
-REDO: |
- if (filledspace(ptr)<size) { |
- /* |
- cprintf("x_fread called for %li bytes (%li available)\n", |
- (long)size, |
- (long)filledspace(ptr)); |
- */ |
- nv=n; |
- n=filledspace(ptr)/objsize; |
- if (n==0) { |
- struct timespec delay; |
- delay.tv_sec=0; |
- delay.tv_nsec=15000000; |
- n=nv; |
- nanosleep(&delay, 0); |
- goto REDO; |
- return 0; |
- } |
- size=objsize*n; |
- /*cprintf("%i will return\n",size);*/ |
- } |
- |
- sz=BUFFERMAXSIZE-ptr->readptr; |
- if (sz>=size) { |
- //cprintf("X"); |
- memcpy(buffer,ptr->buffer+ptr->readptr,size); |
- } else { |
- //cprintf("Y"); |
- memcpy(buffer,ptr->buffer+ptr->readptr,sz); |
- assert(size-sz>0); |
- memcpy(buffer+sz,ptr->buffer,size-sz); |
- } |
- |
- kern_cli(); |
- ptr->readptr+=size; |
- /* ipotesi: non si legge mai piu' di BUFFERMAXSIZE */ |
- if (ptr->readptr>=BUFFERMAXSIZE) ptr->readptr-=BUFFERMAXSIZE; |
- kern_sti(); |
- |
- return n; |
-} |
- |
-#endif |
Index: fsdemo/gphoto.h |
=================================================================== |
--- fsdemo/gphoto.h (revision 1656) |
+++ fsdemo/gphoto.h (nonexistent) |
@@ -1,42 +0,0 @@ |
-/* |
- * |
- * |
- */ |
- |
-#ifndef __GPHOTO_H |
-#define __GPHOTO_H |
- |
-#include <ll/sys/types.h> |
- |
-struct BITMAPFILEHEADER { |
- WORD bfType; |
- DWORD bfSize; |
- WORD bfReserved1; |
- WORD bfReserved2; |
- DWORD bfOffBits; |
-} __attribute__((packed)); |
- |
-struct BITMAPINFOHEADER { |
- DWORD biSize; |
- DWORD biWidth; |
- DWORD biHeight; |
- WORD biPlanes; |
- WORD biBitCount; |
- DWORD biCompression; |
- DWORD biSizeImage; |
- DWORD biXPelsPerMeter; |
- DWORD biYPelsPerMeter; |
- DWORD biClrUsed; |
- DWORD biClrImportant; |
-} __attribute__((packed)); |
- |
-struct RGBQUAD { |
- BYTE rgbBlue; |
- BYTE rgbGreen; |
- BYTE rgbRed; |
- BYTE rgbReserverd; |
-} __attribute__((packed)); |
- |
-int gphoto_show(char *title, char *pathname, int x, int y); |
- |
-#endif |
Index: fsdemo/gclock.h |
=================================================================== |
--- fsdemo/gclock.h (revision 1656) |
+++ fsdemo/gclock.h (nonexistent) |
@@ -1,13 +0,0 @@ |
- |
- |
-#ifndef __GCLOCK_H |
-#define __GCLOCK_H |
- |
-#include <kernel/types.h> |
- |
-PID gclock_init(int x, int y); |
- |
-#define GCLOCKDX (5*8+2) |
-#define GCLOCKDY (1*8+2) |
- |
-#endif |
Index: fsdemo/mutex.h |
=================================================================== |
--- fsdemo/mutex.h (revision 1656) |
+++ fsdemo/mutex.h (nonexistent) |
@@ -1,32 +0,0 @@ |
- |
-#ifndef __GRXMUTEX_H |
-#define __GRXMUTEX_H |
- |
-#include "config.h" |
- |
-#ifdef GRXMUTEX |
- |
-#include <kernel/int_sem.h> |
- |
-#define g_sem_t internal_sem_t |
- |
-#define g_sem_init(s,value) internal_sem_init(s,value) |
-#define g_sem_wait(s) internal_sem_wait(s) |
-#define g_sem_signal(s) internal_sem_post(s) |
- |
-#else |
- |
-#define g_sem_t int |
- |
-#define g_sem_init(s,value) |
-#define g_sem_wait(s) |
-#define g_sem_signal(s) |
- |
-#endif |
- |
-extern g_sem_t grxsem; |
- |
-#define grxlock() g_sem_wait(&grxsem) |
-#define grxunlock() g_sem_signal(&grxsem) |
- |
-#endif |
Index: autostr/autostr.c |
=================================================================== |
--- autostr/autostr.c (revision 1656) |
+++ 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: autostr/initfile.c |
=================================================================== |
--- autostr/initfile.c (revision 1656) |
+++ 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.1.1 2004-05-24 18:03:44 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:44 $ |
- ------------ |
- |
- 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: autostr/makefile |
=================================================================== |
--- autostr/makefile (revision 1656) |
+++ 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: kalm3d/carrello.c |
=================================================================== |
--- kalm3d/carrello.c (revision 1656) |
+++ kalm3d/carrello.c (nonexistent) |
@@ -1,198 +0,0 @@ |
-#include <math.h> |
- |
-#include <modules/hartport.h> |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <ll/i386/x-dos.h> |
- |
-#include "drivers/pclab.h" |
- |
-#include "const.h" |
- |
-float vmax = 0.0, vmin = 0.0, vmaxth = 0.0, vminth = 0.0; |
- |
-int da_motor(float v) |
-{ |
- |
- da_conv( 2.5 , 2 ); |
- da_conv( v + 2.5 , 1 ); |
- |
- return(0); |
- |
-} |
- |
-float v2x(float v) |
-{ |
- float x; |
- |
- x= LUNGH * (v-(vmax+vmin)/2 ) / (vmax-vmin); |
- |
- return x; |
- |
-} |
- |
-float v2theta(float v) |
-{ |
- float theta; |
- |
- theta=2.0*(THETAMAX/FCA) * (v-(vmaxth+vminth)/2 ) / (vmaxth-vminth); |
- |
- return theta; |
- |
-} |
- |
-float bass1(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT * DEADSECX(PERIOD_CARRELLO) *u)/(1+ prm.WCUT * DEADSECX(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float bass2(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT1 * DEADSECX(PERIOD_CARRELLO) *u)/(1+ prm.WCUT1 * DEADSECX(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float bass3(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT * DEADSECTH(PERIOD_CARRELLO) *u)/(1+ prm.WCUT * DEADSECTH(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float bass4(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT1 * DEADSECTH(PERIOD_CARRELLO) *u)/(1+ prm.WCUT1 * DEADSECTH(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float dx(float u) |
-{ |
- static float oldu=0; |
- float y; |
- |
- y=(u-oldu)/DEADSECX(PERIOD_CARRELLO); |
- oldu=u; |
- |
- return y; |
- |
-} |
- |
-float dth(float u) |
-{ |
- static float oldu=0; |
- float y; |
- |
- y=(u-oldu)/DEADSECTH(PERIOD_CARRELLO); |
- oldu=u; |
- |
- return y; |
- |
-} |
- |
-TASK carrello(void) |
-{ |
- float y[2]={0,0}, yp[2]={0,0}; |
- PORT px, pth; |
- |
- float th_input = 0.0,arr_th_input[AVR],th_eff,av_th_input; |
- float x_input = 0.0,arr_x_input[AVR],x_eff,av_x_input; |
- |
- int flag_th=1,flag_x=1,index_th=0,index_x=0; |
- |
- int i; |
- float offset,vout,vout_total; |
- |
- px = port_create("porta1",sizeof(float),1,STICK,WRITE); |
- pth = port_create("porta2",sizeof(float),1,STICK,WRITE); |
- |
- while (1) { |
- |
- task_nopreempt(); |
- th_input=ad_conv(10); |
- task_preempt(); |
- |
- if(flag_th==1) { |
- for(i=0; i<AVR;++i) arr_th_input[i] = th_input; |
- flag_th=0; |
- } |
- av_th_input=0; |
- for(i=0;i<AVR;++i) av_th_input += arr_th_input[i]; |
- av_th_input /= AVR ; |
- |
- if(fabs(th_input-av_th_input)>=prm.NOISE) th_input=av_th_input; |
- |
- arr_th_input[index_th]=th_input; |
- index_th = (index_th+1) % AVR ; |
- |
- th_eff = v2theta(th_input); |
- y[1] = bass3(th_eff); |
- yp[1] = bass4(dth(y[1])); |
- |
- task_nopreempt(); |
- x_input=ad_conv(11); |
- task_preempt(); |
- |
- if(flag_x==1) { |
- for(i=0; i<AVR;++i) arr_x_input[i] = x_input; |
- flag_x=0; |
- } |
- av_x_input=0; |
- for(i=0;i<AVR;++i) av_x_input += arr_x_input[i]; |
- av_x_input /= AVR; |
- if(fabs(x_input-av_x_input)>=prm.NOISE) x_input = av_x_input; |
- |
- arr_x_input[index_x] = x_input; |
- index_x = (index_x+1) % AVR ; |
- |
- x_eff = v2x(x_input); |
- y[0] = bass1(x_eff); |
- yp[0] = bass2(dx(y[0])); |
- |
- vout = prm.COST * (prm.GUAD[0] * (y[0]-v2x((vmax+vmin)/2)) + prm.GUAD[1] * th_eff\ |
- + prm.GUAD[2] * yp[0] + prm.GUAD[3] * yp[1]); |
- |
- if(vout >= 0) offset=prm.OFFSVAL; |
- else offset=-prm.OFFSVAL; |
- |
- vout_total = vout + offset; |
- |
- if(vout_total >= VDANG ) vout_total = VDANG ; |
- if(vout_total <= -VDANG ) vout_total = -VDANG ; |
- |
- da_motor(vout_total); |
- |
- port_send(px, &y[0], NON_BLOCK); |
- port_send(pth, &y[1], NON_BLOCK); |
- |
- task_endcycle(); |
- |
- } |
- |
- port_delete(px); |
- port_delete(pth); |
- |
-} /* FINE DEL TASK CARRELLO */ |
Index: kalm3d/initfile.c |
=================================================================== |
--- kalm3d/initfile.c (revision 1656) |
+++ kalm3d/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.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:47 $ |
- ------------ |
- |
- 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: kalm3d/readme.txt |
=================================================================== |
--- kalm3d/readme.txt (revision 1656) |
+++ kalm3d/readme.txt (nonexistent) |
@@ -1,51 +0,0 @@ |
--------------------------------------- |
-Inverted Pendulum Demo with Mesa |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 17/03/2003 |
--------------------------------------- |
- |
-This is the old Inverted Pendulum control |
-demo rewrited usigng the Mesa support |
- |
-The demo needs a PCL812 card present and |
-the inv.pendulum hardware |
- |
-The graphic cards actually supported are: |
- |
-GEFORCE TNT TNT2 - driver name NV3 |
-RAGE128 RADEON - driver name R128 |
-SAVAGE VIRGE - driver neme SAVAGE |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-KALM3D.C The Inv.Pendulum Demo |
-CARRELLO.C The control task |
- |
--------------------------------------- |
- |
-- 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: kalm3d/const.h |
=================================================================== |
--- kalm3d/const.h (revision 1656) |
+++ kalm3d/const.h (nonexistent) |
@@ -1,36 +0,0 @@ |
-#ifndef __CONST__ |
-#define __CONST__ |
- |
-extern unsigned long int PERIOD_CARRELLO; |
-extern unsigned long int PERIOD_DISEGNA; |
- |
-#define DEADSECX(x) (x * 1.0e-6 ) |
-#define DEADSECTH(x) (x * 1.0e-6 ) |
- |
-#define PARAM {{ 1. , 300 , 0.79 , 23 },0.70 ,2.5 ,20.,20., 0.1, 1 , 1, 0.} |
- |
-#define LUNGH 35.0 |
-#define THETAMAX 45.0 |
-#define FCA 57.29578 |
-#define AVR 10 |
-#define VDANG 2.4 |
-#define NMAX 300 |
-#define SEC_ID 7.0 |
-#define MAXRUN_ID 9 //16 |
- |
-struct Parametri{ |
- float GUAD[4]; |
- float COST; |
- float NOISE; |
- float WCUT; |
- float WCUT1; |
- float OFFSVAL; |
- int DEADLINE; |
- int SCAN; |
- float XTRASL; |
-}; |
- |
-extern struct Parametri prm; |
-extern float vmax, vmin, vmaxth, vminth; |
- |
-#endif |
Index: kalm3d/kalm3d.c |
=================================================================== |
--- kalm3d/kalm3d.c (revision 1656) |
+++ kalm3d/kalm3d.c (nonexistent) |
@@ -1,441 +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 <ll/i386/defs.h> |
- |
-#include <drivers/glib.h> |
-#include <drivers/pclab.h> |
- |
-#include <math.h> |
-#include <stdlib.h> |
-#include <kernel/log.h> |
-#include <GL/osmesa.h> |
-#include <GL/glut.h> |
- |
-#include <modules/hartport.h> |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <ll/i386/x-dos.h> |
-#include <drivers/keyb.h> |
- |
-#include "const.h" |
- |
-#define WIDTH 640 |
-#define HEIGHT 480 |
-#define BYTES_PP 2 |
- |
-unsigned long int PERIOD_CARRELLO = 10000; |
-unsigned long int PERIOD_DISEGNA = 80000; |
-struct Parametri prm=PARAM; |
- |
-unsigned long int WCET_CARRELLO, WCET_DISEGNA; |
- |
-TASK carrello(void *); |
- |
-PID carrello_PID, disegna_PID; |
- |
-unsigned char *buffers = NULL; |
-unsigned char *vbuf = NULL; |
-OSMesaContext ctx; |
- |
-static GLfloat view_rotx = 170.0, view_roty = -200.0, view_rotz = 0.0; |
-static GLfloat angle; |
- |
-GLUquadricObj *quadratic; |
- |
-static GLfloat SUP_W = 110.0; |
-static GLfloat SUP_P = 30.0; |
- |
-extern void da_motor(float v); |
- |
-#ifndef M_PI |
-#define M_PI 3.14159265 |
-#endif |
- |
-void program_end(void) |
-{ |
- |
- da_motor(0.0); |
- |
- OSMesaDestroyContext(ctx); |
- free(buffers); |
- |
- grx_close(); |
- |
- sys_end(); |
- |
-} |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-static void draw_box(GLfloat p1x, GLfloat p1y ,GLfloat p1z, GLfloat p2x, GLfloat p2y, GLfloat p2z) { |
- |
- glBegin(GL_QUADS); |
- |
- // Front Face |
- glVertex3f(p1x, p1y, p1z); |
- glVertex3f(p2x, p1y, p1z); |
- glVertex3f(p2x, p2y, p1z); |
- glVertex3f(p1x, p2y, p1z); |
- |
- // Back Face |
- glVertex3f(p1x, p1y, p2z); |
- glVertex3f(p1x, p2y, p2z); |
- glVertex3f(p2x, p2y, p2z); |
- glVertex3f(p2x, p1y, p2z); |
- |
- // Top Face |
- glVertex3f(p1x, p2y, p2z); |
- glVertex3f(p1x, p2y, p1z); |
- glVertex3f(p2x, p2y, p1z); |
- glVertex3f(p2x, p2y, p2z); |
- |
- // Bottom Face |
- glVertex3f(p1x, p1y, p2z); |
- glVertex3f(p2x, p1y, p2z); |
- glVertex3f(p2x, p1y, p1z); |
- glVertex3f(p1x, p1y, p1z); |
- |
- // Right face |
- glVertex3f(p2x, p1y, p2z); |
- glVertex3f(p2x, p2y, p2z); |
- glVertex3f(p2x, p2y, p1z); |
- glVertex3f(p2x, p1y, p1z); |
- |
- // Left Face |
- glVertex3f(p1x, p1y, p2z); |
- glVertex3f(p1x, p1y, p1z); |
- glVertex3f(p1x, p2y, p1z); |
- glVertex3f(p1x, p2y, p2z); |
- |
- glEnd(); |
- |
-} |
- |
-static void draw_carrello(GLfloat x_scene, GLfloat angle_scene) { |
- |
- static GLfloat gl_white[3] = {1.0f, 1.0f, 1.0f}; |
- static GLfloat gl_dark_gray[3] = {0.3f, 0.3f, 0.3f}; |
- static GLfloat gl_gray[3] = {0.7f, 0.7f, 0.7f}; |
- |
- glPushMatrix(); |
- |
- glColor3fv(gl_dark_gray); |
- |
- glShadeModel(GL_FLAT); |
- |
- glTranslatef(x_scene, 0.0f, 0.0f); |
- |
- draw_box(-6.0f, -6.0f, 9.0f, 6.0f, -2.0f, -9.0f); |
- draw_box(-6.0f, -2.0f, 9.0f, 6.0f, -1.0f, 4.0f); |
- |
- glColor3fv(gl_white); |
- |
- draw_box(-8.0f, -2.0f, -3.0f, 8.0f, -1.0f, -10.0f); |
- |
- glColor3fv(gl_dark_gray); |
- |
- draw_box(-5.0f, 1.0f, 8.0f, 5.0f, 9.0f, 6.0f); |
- draw_box(-5.0f,1.0f,-6.0f,5.0f,9.0f,-8.0f); |
- draw_box(-5.0f,-1.0f,8.0f,5.0f,1.0f,-8.0f); |
- |
- glShadeModel(GL_SMOOTH); |
- |
- glColor3fv(gl_white); |
- |
- glTranslatef(0.0f, 4.5f, -6.0f); |
- gluCylinder(quadratic, 2.2f, 2.2f, 12.0f, 16, 16); |
- |
- glColor3fv(gl_gray); |
- |
- glTranslatef(0.0f, 0.0f, 6.0f); |
- glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); |
- glRotatef(angle_scene, 0.0f, 1.0f, 0.0f); |
- gluCylinder(quadratic, 1.3f, 1.3f, 160.0f, 16, 16); |
- glRotatef(-angle_scene, 0.0f, 1.0f, 0.0f); |
- glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); |
- |
- glTranslatef(-4.0f, -2.5f, -6.0f); |
- gluCylinder(quadratic, 0.5f, 0.5f, 12.0f, 16, 16); |
- |
- glTranslatef(8.0f, 0.0f, 0.0f); |
- gluCylinder(quadratic, 0.5f, 0.5f, 12.0f, 16, 16); |
- |
- glPopMatrix(); |
- |
-} |
- |
-static void draw_support() { |
- |
- static GLfloat gl_dark_gray[3] = {0.3f, 0.3f, 0.3f}; |
- static GLfloat gl_gray[3] = {0.7f, 0.7f, 0.7f}; |
- |
- glPushMatrix(); |
- |
- glColor3fv(gl_gray); |
- |
- glShadeModel(GL_FLAT); |
- |
- draw_box(-SUP_W/2, -0.1f, SUP_P/2, SUP_W/2, 0.1f, -SUP_P/2); |
- |
- glColor3fv(gl_dark_gray); |
- |
- draw_box(-SUP_W/2-3.0f, -0.1f, SUP_P/2, -SUP_W/2, 14.0f, -SUP_P/2-0.2f); |
- draw_box(SUP_W/2, -0.1f, SUP_P/2, SUP_W/2+3.0f, 14.0f, -SUP_P/2-0.2f); |
- |
- glShadeModel(GL_SMOOTH); |
- |
- glColor3fv(gl_gray); |
- |
- glTranslatef(-SUP_W/2, 6.0f, 0.0f); |
- glRotatef(90.0f, 0.0f, 1.0f, 0.0f); |
- gluCylinder(quadratic, 1.5f, 1.5f, SUP_W, 16, 16); |
- |
- glPopMatrix(); |
- |
-} |
- |
-static void draw(GLfloat prm_x, GLfloat prm_th) |
-{ |
- |
- prm_x = -prm_x / LUNGH * (SUP_W-20.0f); |
- prm_th = -prm_th * FCA; |
- |
- glPushMatrix(); |
- |
- glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); |
- glRotatef(view_roty, 0.0f, 1.0f, 0.0f); |
- glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); |
- |
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
- |
- glRotatef(angle, 0.0f, 1.0f, 0.0f); |
- |
- draw_support(); |
- glTranslatef(0.0f, 10.0f, -4.0f); |
- draw_carrello(prm_x,prm_th); |
- |
- glPopMatrix(); |
- |
- glFinish(); |
- |
-} |
- |
-static void init_gl() |
-{ |
- |
- static GLfloat pos0[4] = {40.0f, -70.0f, 180.0f, 1.0f}; |
- |
- glClearColor(0.8f, 0.8f, 0.8f, 1.0f); |
- |
- glLightfv(GL_LIGHT0, GL_POSITION, pos0); |
- glEnable(GL_LIGHTING); |
- glEnable(GL_LIGHT0); |
- glEnable(GL_DEPTH_TEST); |
- glEnable(GL_CULL_FACE); |
- |
- glViewport(0, 0, (GLint) WIDTH, (GLint) HEIGHT); |
- glMatrixMode(GL_PROJECTION); |
- glLoadIdentity(); |
- gluPerspective(45.0f,(GLfloat)WIDTH/(GLfloat)HEIGHT,0.1f,250.0f); |
- glMatrixMode(GL_MODELVIEW); |
- glLoadIdentity(); |
- glTranslatef(0.0f, 30.0f, -120.0f); |
- |
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); |
- |
- quadratic=gluNewQuadric(); |
- |
- glEnable(GL_AUTO_NORMAL); |
- glEnable(GL_COLOR_MATERIAL); |
- glEnable(GL_NORMALIZE); |
- glDepthFunc(GL_LEQUAL); |
- |
-} |
- |
-TASK disegna(void) |
-{ |
- |
- PORT pr_x, pr_th; |
- float prm_x, prm_th; |
- |
- char text[100]; |
- TIME disegna_TIME, carrello_TIME; |
- |
- pr_x = port_connect("porta1",sizeof(float),STICK,READ); |
- pr_th = port_connect("porta2",sizeof(float),STICK,READ); |
- |
- //vbuf = malloc(WIDTH * HEIGHT * 2); //Debug line |
- |
- while(1) { |
- |
- port_receive(pr_x, &prm_x, BLOCK); |
- port_receive(pr_th, &prm_th, BLOCK); |
- |
- angle += 0.2; |
- |
- draw(prm_x,prm_th); |
- |
- jet_gettable(carrello_PID, &carrello_TIME, 1); |
- jet_gettable(disegna_PID, &disegna_TIME, 1); |
- |
- sprintf(text,"Hard Task Control PER:%6d us EX:%6d us",(int)PERIOD_CARRELLO,(int)carrello_TIME); |
- grx_text(text,10,5,rgb16(0,0,255),rgb16(255,255,255)); |
- 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),rgb16(255,255,255)); |
- |
- memcpy(buffers,vbuf,WIDTH*HEIGHT*BYTES_PP); |
- |
- task_endcycle(); |
- |
- } |
- |
- port_disconnect(pr_x); |
- port_disconnect(pr_th); |
- |
- sys_end(); |
- |
-} |
- |
-static void screen() |
-{ |
- extern DWORD flbaddr; |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 16) < 0) { |
- cprintf("GRX Err\n"); |
- sys_abort(1); |
- } |
- |
- vbuf = (unsigned char *)flbaddr; |
- |
-} |
- |
-void waitenter() { |
- |
- KEY_EVT k; |
- char esc = FALSE; |
- |
- while(!esc) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii == 13) esc = TRUE; |
- } |
- |
-} |
- |
- |
-void init_motor(void) |
-{ |
- |
- da_motor(0.0); |
- |
- cprintf("Calibrazione pendolo inverso...\n"); |
- |
- cprintf("Carr a sx e premi enter\n"); |
- waitenter(); |
- vmin=ad_conv(11); |
- |
- cprintf("Carr a dx e premi enter\n"); |
- waitenter(); |
- vmax=ad_conv(11); |
- |
- cprintf("Asta a sx e premi enter\n"); |
- waitenter(); |
- vminth=ad_conv(10); |
- |
- cprintf("Asta a dx e premi enter\n"); |
- waitenter(); |
- vmaxth=ad_conv(10); |
- |
- cprintf("Vxmax:%f Vxmin:%f Vthmax:%f Vthmin:%f\n",vmax,vmin,vmaxth,vminth); |
- waitenter(); |
- |
-} |
- |
-int main (int argc, char *argv[]) |
-{ |
- HARD_TASK_MODEL ht_carrello, ht_disegna; |
- |
- WCET_CARRELLO =((long int) PERIOD_CARRELLO * (0.05)); |
- WCET_DISEGNA =((long int) PERIOD_DISEGNA * (0.875)); |
- |
- clear(); |
- |
- sys_atrunlevel((void *) program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- hard_task_default_model(ht_carrello); |
- hard_task_def_wcet(ht_carrello,WCET_CARRELLO); |
- hard_task_def_mit(ht_carrello,PERIOD_CARRELLO); |
- hard_task_def_usemath(ht_carrello); |
- hard_task_def_group(ht_carrello,1); |
- hard_task_def_ctrl_jet(ht_carrello); |
- |
- carrello_PID = task_create("carrello", carrello, &ht_carrello, NULL); |
- if (carrello_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,60000); |
- |
- 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); |
- } |
- |
- init_motor(); |
- |
- screen(); |
- |
- ctx = OSMesaCreateContext(OSMESA_RGB_565, NULL ); |
- |
- buffers = malloc(WIDTH*HEIGHT*BYTES_PP); |
- |
- OSMesaMakeCurrent(ctx, buffers, GL_UNSIGNED_SHORT_5_6_5, WIDTH, HEIGHT); |
- |
- init_gl(); |
- |
- group_activate(1); |
- |
- return 0; |
- |
-} |
Index: kalm3d/makefile |
=================================================================== |
--- kalm3d/makefile (revision 1656) |
+++ kalm3d/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = kalm3d |
- |
-include $(BASE)/config/example.mk |
- |
-kalm3d: |
- make -f $(SUBMAKE) APP=kalm3d INIT= OTHEROBJS="initfile.o carrello.o" SHARKOPT="__OSMESA__ __PCLAB__ __OLDCHAR__ __GRX__" |
- |
Index: eli/initfile.c |
=================================================================== |
--- eli/initfile.c (revision 1656) |
+++ eli/initfile.c (nonexistent) |
@@ -1,100 +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.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:47 $ |
- ------------ |
- |
- This file is similar to the configuration of Hartik 3.3.1 |
- |
-**/ |
- |
-/* |
- * 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(0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- 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; |
-} |
- |
Index: eli/eli.c |
=================================================================== |
--- eli/eli.c (revision 1656) |
+++ eli/eli.c (nonexistent) |
@@ -1,787 +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: eli.c,v 1.1.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:47 $ |
- ------------ |
- |
- This file is similar to the configuration of Hartik 3.3.1 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and ALLEN-DESTRO |
- * |
- * 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 "eli.h" |
- |
-#include <time.h> |
- |
-//######################################## |
-// Definizione variabili globali |
-//######################################## |
-char tastiera; |
-long double Forza_x,Forza_y,Velocita_x,Velocita_y,Acc_x,Acc_y,Pos_x,Pos_y; |
-long double Pos_pe_y[5]; |
-long double Pos_pe_x[5]; |
-long double T1=0; |
-long double r; |
-int n_peso=0; |
-int peso_agganciato[5]={0,0,0,0,0}; |
-int pre_peso[5]={0,0,0,0,0}; |
-int libero_peso[5]={0,0,0,0,0}; |
-PID pid_peso[5]; |
-PID pid_ruspa[5]; |
-int x_r=200; |
-int n_ruspa=5; |
-int indietro; |
-int eli_occ=0; |
-int kill_p; |
- |
-//PID pid_r0,pid_r1,pid_r2,pid_r3,pid_r4; |
-PID pid_kill_p,pid_pulisci_p,pid_kill_e,pid_pulisci_e; |
- |
- |
-// Definizione del semaforo per l'utilizzo della modalita' grafica |
-sem_t mutex; |
-sem_t pu; |
- |
- |
- |
- |
-//####################################################################### |
-//############### DEFINIZIONE TASK ###################################### |
-//####################################################################### |
- |
-TASK kill_task(int i) |
-{ int x,y,dim; |
- while (1) |
- { |
- |
- if(i==1) |
- { |
- x=Pos_pe_x[kill_p]; |
- y=Pos_pe_y[kill_p]; |
- dim=25; |
- } |
- else |
- { |
- x=Pos_x; |
- y=Pos_y; |
- dim=35; |
- } |
- |
- PULISCI(x,y,dim); |
- ESPLOSIONE(x,y); |
- |
- sem_wait(&pu); |
- |
- if(i==1) task_activate(pid_pulisci_p); |
- else task_activate(pid_pulisci_e); |
- |
- task_endcycle(); |
- |
- } |
- |
- |
-} |
- |
-TASK pulisci(int i) |
-{ |
- int x,y,dim; |
- struct timespec delay; |
- |
- delay.tv_sec=0; |
- delay.tv_nsec=3000000; |
- |
- while (1) |
- { |
- |
- if(i==1) |
- { |
- x=Pos_pe_x[kill_p]; |
- y=Pos_pe_y[kill_p]; |
- dim=25; |
- } |
- else |
- { |
- x=Pos_x; |
- y=Pos_y; |
- dim=35; |
- } |
- |
- |
- nanosleep(&delay, NULL); |
- PULISCI(x,y,dim); |
- |
- sem_post(&pu); |
- |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
- |
-TASK elicottero(int i) |
-{ long double x_old,x_new,y_old,y_new; |
- TIME us_old,us_new; |
- long double delta_T; |
- long double Fx,Fy,Ax,Ay,Vx,Vy,m_el; |
- int Destra_old,Destra_new; |
- // int uccidi,colore; |
- // int prova; |
- |
- m_el=1; |
- Vx=0;Vy=0; |
- Ax=0;Ay=0; |
- Fx=0;Fy=0-m_el*G; // Fy=0; |
- x_old=150; |
- y_old=150; |
- Destra_old=1; |
- Destra_new=1; |
- |
- us_old=sys_gettime(NULL); |
- |
- while (1) |
- { |
- |
- // prova=2; |
- |
- |
- us_new=sys_gettime(NULL); |
- delta_T=(us_new-us_old)/100000; |
- // if(delta_T<0.9) prova=1; |
- // if(delta_T<0) prova=4; |
- // if(delta_T>1.1) prova=3; |
- |
- |
- delta_T=1; |
- Ax=(Fx-(r*Vx))/m_el; |
- Ay=(Fy-(r*Vy)+m_el*G+T1)/m_el; |
- x_new=x_old+Vx*delta_T+0.5*Ax*delta_T*delta_T; |
- y_new=y_old+Vy*delta_T+0.5*Ay*delta_T*delta_T; |
- |
- // if(prova==1) {x_new=300; y_new=150;} |
- // if(prova==3) {x_new=150; y_new=300;} |
- // if(prova==2) {x_new=300; y_new=300;} |
- // if(prova==4) {x_new=400; y_new=400;} |
- |
- Vx=Vx+Ax*delta_T; |
- Vy=Vy+Ay*delta_T; |
- if ((Vx>0)|| ((Vx==0) && (Destra_old==1))) Destra_new=1; |
- else Destra_new=0; |
- |
- if ( ((y_new>=(Y0max-DIM_EL/2-2)) || ( (y_old<=400-DIM_EL/2-2) && (y_new>=400-DIM_EL/2-2) && (x_new>=X0min+151) && (x_new<=X0min+280) )) ) |
- { |
- if ((x_new>=X0min+151) && (x_new<=X0min+280)) y_new=400-DIM_EL/2-2; |
- else y_new=Y0max-DIM_EL/2-2; |
- Vy=0; |
- Vx=0; |
- x_new=x_old; |
- Ay=0; |
- Ax=0; |
- } |
- |
- |
- |
- |
- sem_wait(&mutex); |
- |
- /* |
- uccidi=0; |
- |
- colore=grx_getpixel(x_new-2*DIM_EL,y_new-DIM_EL); |
- if ( (colore!=COL_SFONDO) && (colore!=YELLOW) && (colore!=RED)) uccidi=1; |
- colore=grx_getpixel(x_new+2*DIM_EL,y_new-DIM_EL); |
- if ( (colore!=COL_SFONDO) && (colore!=YELLOW) && (colore!=RED)) uccidi=1; |
- colore=grx_getpixel(x_new-2*DIM_EL,y_new+DIM_EL/2); |
- if ( (colore!=COL_SFONDO) && (colore!=YELLOW) && (colore!=RED)) uccidi=1; |
- colore=grx_getpixel(x_new+2*DIM_EL,y_new+DIM_EL/2); |
- if ( (colore!=COL_SFONDO) && (colore!=YELLOW) && (colore!=RED)) uccidi=1; |
- colore=grx_getpixel(x_new,y_new); |
- if ( (colore!=COL_SFONDO) && (colore!=YELLOW) && (colore!=RED)) uccidi=1; |
- */ |
- |
- if ((x_old>100) && (y_old>100) && (x_old<X0max) ) |
- { |
- if (Destra_old==0) {ELICOTTERO_S(x_old,y_old,DIM_EL,COL_SFONDO,COL_SFONDO);} |
- else {ELICOTTERO_D(x_old,y_old,DIM_EL,COL_SFONDO,COL_SFONDO);} |
- } |
- |
- if ((x_new>100) && (y_new>100) && (x_new<X0max) ) |
- { |
- /* |
- if ( uccidi==1) |
- { |
- // grx_box(10,10,100,100,RED); |
- // task_activate(pid_kill_e); |
- // sem_post(&mutex); |
- // eli_occ=0; |
- sem_post(&mutex); |
- task_abort(); |
- } |
- */ |
- |
- |
- if (Destra_new==0) {ELICOTTERO_S(x_new,y_new,DIM_EL,COL_EL,COL_SFONDO);} |
- else {ELICOTTERO_D(x_new,y_new,DIM_EL,COL_EL,COL_SFONDO);} |
- } |
- sem_post(&mutex); |
- |
- if (tastiera=='c') Fx=Fx+0.25; |
- if (tastiera=='z') Fx=Fx-0.25; |
- if (tastiera=='x') Fy=Fy+0.25; |
- if (tastiera=='s') Fy=Fy-0.25; |
- |
- if (Fx>2) Fx=2; |
- if (Fx<-2) Fx=-2; |
- if (Fy>0) Fy=0; |
- if (Fy<-17.5) Fy=-17.5; |
- |
- Forza_x=Fx; |
- Forza_y=Fy; |
- Acc_x=Ax; |
- Acc_y=Ay; |
- Velocita_x=Vx; |
- Velocita_y=Vy; |
- Pos_x=x_new; |
- Pos_y=y_new; |
- |
- |
- if ( (tastiera=='z') || (tastiera=='x') || (tastiera=='c') || (tastiera=='s') ) |
- tastiera='q'; |
- |
- |
- us_old=us_new; |
- x_old=x_new; |
- y_old=y_new; |
- Destra_old=Destra_new; |
- |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-TASK peso(int i) |
-{ |
- long double delta_T; |
- long double Ay,Vy; |
- long double x_new,x_old,y_old,y_new; |
- int scelta=0; |
- int rit,colore,uccidi; |
- double m_peso[5]={0.5,0.4,0.3,0.1,0.6}; |
- int delta_y1,delta_y2; |
- |
- |
- // PID pid; |
- // MODEL m = BASE_MODEL; |
- |
- Vy=0; |
- Ay=0; |
- |
- x_old=700-DIM_PESO-1; |
- y_old=Y0max-DIM_PESO*2-1; |
- delta_T=1; |
- x_new=700-DIM_PESO-1; |
- |
- libero_peso[i]=0; |
- |
- while (1 ) |
- { |
- uccidi=0; |
- |
- if (scelta==0 ) |
- { |
- |
- y_new=y_old; |
- if (x_new+DIM_PESO==x_r-1) x_new=x_new-1; |
- else x_new=x_new; |
- if (indietro==1) {scelta=1; libero_peso[i]=1;} |
- } |
- |
- if (scelta==1 ) |
- { |
- y_new=y_old; |
- x_new=x_old; |
- if (peso_agganciato[i]==1) scelta=2; |
- } |
- if (scelta==2) |
- { |
- eli_occ=1; |
- Ay=(m_peso[i]*G-(r*Vy)-T1)/m_peso[i]; |
- if(peso_agganciato[i]==1) x_new=Pos_x; |
- else x_new=x_old; |
- y_new=y_old+Vy*delta_T+0.5*Ay*delta_T*delta_T; |
- Vy=Vy+Ay*delta_T; |
- |
- delta_y1=Y0max-y_new; |
- delta_y2=400-y_new; |
- |
- if ( (y_new>=(Y0max-2*DIM_PESO-1)) || ( (y_old<400-2*DIM_PESO-1) && (y_new>=400-2*DIM_PESO-1) && (x_new>=X0min+151-DIM_PESO) && (x_new<=X0min+280+DIM_PESO) ) ) |
- { |
- if ((x_new>=X0min+151-DIM_PESO) && (x_new<=X0min+280+DIM_PESO)) |
- { |
- if (delta_y2<6) uccidi=1; |
- y_new=400-2*DIM_PESO-2; |
- } |
- else { |
- if (delta_y1<6) uccidi=1; |
- y_new=Y0max-2*DIM_PESO-2; |
- } |
- Vy=0; |
- if(peso_agganciato[i]==0) {scelta=3; rit=0;} |
- } |
- } |
- if (scelta==3) |
- { |
- x_new=x_new; |
- y_new=y_new; |
- eli_occ=0; |
- if (y_new==400-2*DIM_PESO-2) rit++; |
- |
- |
- |
- if (rit==100) { |
- peso_agganciato[i]=0; |
- pre_peso[i]=0; |
- sem_wait(&mutex); |
- PESO(x_old,y_old,DIM_PESO,COL_SFONDO); |
- sem_post(&mutex); |
- |
- return NULL; |
- } |
- |
- if(peso_agganciato[i]==1) scelta=2; |
- } |
- |
- sem_wait(&mutex); |
- |
- |
- colore=grx_getpixel(x_new-DIM_PESO,y_new); |
- if ( (colore!=COL_SFONDO) && (colore!=DELTA_COL+i*2) && (colore!=RED)) uccidi=1; |
- |
- colore=grx_getpixel(x_new+DIM_PESO,y_new); |
- if ( (colore!=COL_SFONDO) && (colore!=DELTA_COL+i*2) && (colore!=RED)) uccidi=1; |
- |
- colore=grx_getpixel(x_new-DIM_PESO,y_new+2*DIM_PESO); |
- if ( (colore!=COL_SFONDO) && (colore!=DELTA_COL+i*2) && (colore!=RED)) uccidi=1; |
- |
- colore=grx_getpixel(x_new+DIM_PESO,y_new+2*DIM_PESO); |
- if ( (colore!=COL_SFONDO) && (colore!=DELTA_COL+i*2) && (colore!=RED)) uccidi=1; |
- |
- colore=grx_getpixel(x_new,y_new+DIM_PESO); |
- if ( (colore!=COL_SFONDO) && (colore!=DELTA_COL+i*2) && (colore!=RED)) uccidi=1; |
- |
- |
- |
- if ((x_old>100) && (y_old>100) && (x_old<X0max) ) |
- { |
- PESO(x_old,y_old,DIM_PESO,COL_SFONDO); |
- } |
- |
- y_old=y_new; |
- x_old=x_new; |
- Pos_pe_y[i]=y_new; |
- Pos_pe_x[i]=x_new; |
- |
- |
- if ((x_new>100) && (y_new>100) && (x_new<X0max) ) |
- { |
- if ( uccidi==1) |
- { |
- kill_p=i; |
- task_activate(pid_kill_p); |
- sem_post(&mutex); |
- eli_occ=0; |
- pre_peso[i]=0; |
- peso_agganciato[i]=0; |
- return NULL; |
- } |
- |
- PESO(x_new,y_new,DIM_PESO,DELTA_COL+i*2); |
- } |
- sem_post(&mutex); |
- |
- |
- task_endcycle(); |
- } |
- |
- |
-} |
- |
-TASK ruspa(int i) |
-{ |
- int x,y,ii; |
- int end_peso[5]={370,420,470,520,570}; |
- |
- PID pid; |
- HARD_TASK_MODEL m_hard; |
- |
- pre_peso[i]=1; |
- |
- hard_task_default_model(m_hard); |
- hard_task_def_wcet(m_hard,1); // wcet ignored!!! |
- hard_task_def_mit(m_hard,PER_DISEGNA); |
- hard_task_def_usemath(m_hard); |
- hard_task_def_arg(m_hard,(void *)i); |
- pid=task_create("peso2",peso,&m_hard,NULL); |
- pid_peso[i]=pid; |
- task_activate(pid_peso[i]); |
- |
- |
- x=720; |
- y=Y0max; |
- |
- indietro=0; |
- while (x!=end_peso[i]+DIM_PESO) |
- { |
- sem_wait(&mutex); |
- RUSPA_S(x+1,y,COL_SFONDO,COL_SFONDO); |
- RUSPA_S(x,y,YELLOW-1,LIGHTBLUE); |
- sem_post(&mutex); |
- x_r=x; |
- x--; |
- task_endcycle(); |
- } |
- sem_wait(&mutex); |
- RUSPA_S(x+1,y,COL_SFONDO,COL_SFONDO); |
- sem_post(&mutex); |
- indietro=1; |
- while (x!=730 ) |
- { |
- sem_wait(&mutex); |
- RUSPA_D(x-1+40,y,COL_SFONDO,COL_SFONDO); |
- RUSPA_D(x+40,y,YELLOW-1,LIGHTBLUE); |
- sem_post(&mutex); |
- x++; |
- task_endcycle(); |
- } |
- |
- ii=i+1; |
- |
- while(ii>4) |
- { |
- n_ruspa=5; |
- if(pre_peso[4]==0){ |
- ii=4; |
- if(pre_peso[3]==0){ |
- ii=3; |
- if(pre_peso[2]==0){ |
- ii=2; |
- if(pre_peso[1]==0){ |
- ii=1; |
- if(pre_peso[0]==0){ |
- ii=0; |
- } |
- } |
- } |
- } |
- } |
- task_endcycle(); |
- |
- } |
- |
- hard_task_def_arg(m_hard,(void *)ii); |
- pid_ruspa[ii]=task_create("ruspa",ruspa,&m_hard,NULL); |
- task_activate(pid_ruspa[ii]); |
- n_ruspa=ii; |
- |
- return NULL; |
-} |
- |
- |
- |
- |
-TASK molla(int i) |
-{ |
- double k=0.05; |
- double x,x_old,y1_old,y2_old; |
- double T1_old; //,T2_old; |
- |
- x_old=Pos_x; |
- y1_old=Pos_y; |
- y2_old=Pos_pe_y[n_peso]; |
- |
- while (1) |
- { |
- |
- sem_wait(&mutex); |
- if ((x_old>100-DIM_EL) && (y1_old>100-DIM_EL) && (x_old<X0max) ) |
- { |
- MOLLA(x_old,y1_old+DIM_EL,y2_old,COL_SFONDO) |
- } |
- else if( (y2_old>100) && (x_old<X0max) && (x_old>100) ) |
- { |
- MOLLA(x_old,X0min+100,y2_old,COL_SFONDO) |
- } |
- |
- x_old=Pos_x; |
- y1_old=Pos_y; |
- |
- if(peso_agganciato[n_peso]==0) y2_old=y1_old+20; |
- else y2_old=Pos_pe_y[n_peso]; |
- |
- if ((x_old>100) && (y1_old>100-DIM_EL) && (x_old<X0max) ) |
- { |
- MOLLA(x_old,y1_old+DIM_EL,y2_old,RED) |
- } |
- else if( (y2_old>100) && (x_old<X0max) && (x_old>100)) |
- { |
- MOLLA(x_old,X0min+100,y2_old,RED) |
- } |
- sem_post(&mutex); |
- |
- x=y2_old-y1_old; |
- x=x-20; |
- T1=x*k; |
- T1_old=T1; |
- |
- task_endcycle(); |
- |
- } |
-} |
- |
-TASK seleziona(int i) |
-{ int w,deltax,deltay,disegna; |
- |
- eli_occ=0; |
- disegna=0; |
- |
- while (1) |
- { |
- disegna=0; |
- for (w=0;w<5;w++) |
- { |
- deltax=Pos_pe_x[w]-Pos_x; |
- deltay=Pos_pe_y[w]-Pos_y-DIM_PESO-20+DIM_EL; |
- if ( (pre_peso[w]==1) && (eli_occ==0) && (deltax<4) && (deltax>-4) && (deltay<3) && (deltay>-3) ) |
- { |
- disegna=1; |
- if ( (tastiera=='p') && (libero_peso[w]==1) ) |
- { |
- eli_occ=1; |
- peso_agganciato[w]=1; |
- n_peso=w; |
- |
- } |
- } |
- } |
- |
- if(disegna==1) |
- { |
- sem_wait(&mutex); |
- grx_box(X0max-90,Y0min+5,X0max-5,Y0min+95,RED); |
- // grx_text("Ok", X0max-40, Y0min+50, COL_TESTO, RED); |
- sem_post(&mutex); |
- } else |
- { |
- sem_wait(&mutex); |
- grx_box(X0max-95,Y0min+5,X0max-5,Y0min+95,COL_SFONDO); |
- sem_post(&mutex); |
- } |
- |
- if(eli_occ==1) |
- { |
- sem_wait(&mutex); |
- grx_box(X0max-90-100,Y0min+5,X0max-5-100,Y0min+95,GREEN); |
- // grx_text("Go", X0max-35-100, Y0min+50, COL_TESTO, GREEN); |
- sem_post(&mutex); |
- } else |
- { |
- sem_wait(&mutex); |
- grx_box(X0max-90-100,Y0min+5,X0max-5-100,Y0min+95,COL_SFONDO); |
- sem_post(&mutex); |
- } |
- |
- |
- if (tastiera=='l') peso_agganciato[n_peso]=0; |
- |
- task_endcycle(); |
- |
- } |
-} |
- |
- |
-//############################################################### |
-// ## |
-// Funzione di uscita dal programma ## |
-// ## |
-//################################################################ |
-void my_end(KEY_EVT* e) |
-{ |
- //#################################### |
- // Sezione esecutiva della funzione ## |
- //#################################### |
- |
- grx_close(); |
- cprintf("Ctrl-brk pressed!\n"); |
- sys_end(); |
-} // Fine della funzionemy_end |
- |
-//################################################################ |
-// ## |
-// Funzione di uscita dal programma ## |
-// ## |
-//################################################################ |
-void end() |
-{ |
- //#################################### |
- // Sezione esecutiva della funzione ## |
- //#################################### |
- |
- grx_close(); |
-} // Fine della funzione my_end |
- |
- |
- |
-//############################################################## |
-// ## |
-// Main ## |
-// ## |
-//############################################################## |
-int main() |
-{ |
- //######################################## |
- // Sezione dichiarativa delle variabili ## |
- //######################################## |
- // Identficativi di task generici |
- PID pid0, pid1, pid3, pid5; //, pid2,pid4,pid6; |
- |
- HARD_TASK_MODEL m_hard; |
- NRT_TASK_MODEL m_nrt; |
- |
- // Ascoltatore di eventi |
- KEY_EVT emerg; |
- // Contatori |
- int j; |
- |
- |
- //#################################### |
- // Sezione esecutiva del main ## |
- //#################################### |
- |
- // Inizializzazione dei parametri hartik |
- sem_init(&mutex,0,1); |
- sem_init(&pu,0,1); |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg, my_end); |
- sys_atrunlevel(end, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- if (grx_open(800, 600, 8) < 0) |
- { |
- cprintf("GRX Err\n"); |
- sys_abort(300); |
- } |
- cprintf("scheda ok\n"); |
- |
- r=0.1; |
- |
- /* Disposizione degli elementi grafici statici */ |
- sem_wait(&mutex); |
- draw_static(); |
- sem_post(&mutex); |
- |
- // Attivazione dei task |
- hard_task_default_model(m_hard); |
- hard_task_def_wcet(m_hard,1); // wcet ignored!!! |
- hard_task_def_usemath(m_hard); |
- |
- hard_task_def_mit(m_hard,PER_DISEGNA); |
- pid0=task_create("elicottero",elicottero,&m_hard,NULL); |
- task_activate(pid0); |
- |
- hard_task_def_mit(m_hard,PER_DISEGNA); |
- pid1=task_create("indicometro",disegna_stato,&m_hard,NULL); |
- task_activate(pid1); |
- |
- hard_task_def_mit(m_hard,PER_MOLLA); |
- pid3=task_create("molla",molla,&m_hard,NULL); |
- task_activate(pid3); |
- |
- hard_task_def_mit(m_hard,PER_DISEGNA); |
- pid5=task_create("seleziona",seleziona,&m_hard,NULL); |
- task_activate(pid5); |
- |
- |
- hard_task_def_mit(m_hard,PER_DISEGNA); |
- hard_task_def_arg(m_hard,0); |
- pid_ruspa[0]=task_create("ruspa",ruspa,&m_hard,NULL); |
- task_activate(pid_ruspa[0]); |
- n_ruspa=0; |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_usemath(m_nrt); |
- nrt_task_def_arg(m_nrt,0); |
- pid_kill_e = task_create("kill_task",kill_task, &m_nrt, NULL); |
- pid_pulisci_e = task_create("pulisci",pulisci, &m_nrt, NULL); |
- |
- nrt_task_def_arg(m_nrt,(void *)1); |
- pid_kill_p = task_create("kill_task",kill_task, &m_nrt, NULL); |
- pid_pulisci_p = task_create("pulisci",pulisci, &m_nrt, NULL); |
- |
- |
- |
- |
- do { |
- tastiera = keyb_getch(BLOCK); |
- |
- } while(tastiera!=ESC); |
- |
- task_kill(pid5); |
- task_kill(pid3); |
- task_kill(pid1); |
- task_kill(pid0); |
- |
- task_kill(pid_kill_p); |
- task_kill(pid_kill_e); |
- |
- if (n_ruspa!=5) task_kill(pid_ruspa[n_ruspa]); |
- for(j=0;j<5;j++) { if (pre_peso[j]==1) task_kill(pid_peso[j]); } |
- |
- grx_close(); |
- sys_end(); |
- |
- return 0; |
-} // Fine del main |
- |
-/***************************<Fine del file>*******************************/ |
Index: eli/makefile |
=================================================================== |
--- eli/makefile (revision 1656) |
+++ eli/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= eli |
- |
-include $(BASE)/config/example.mk |
- |
-eli: |
- make -f $(SUBMAKE) APP=eli INIT= OTHEROBJS="initfile.o draw.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: eli/draw.c |
=================================================================== |
--- eli/draw.c (revision 1656) |
+++ eli/draw.c (nonexistent) |
@@ -1,519 +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: draw.c,v 1.1.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:47 $ |
- ------------ |
- |
- This file is similar to the configuration of Hartik 3.3.1 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and ALLEN-DESTRO |
- * |
- * 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 "eli.h" |
- |
-void draw_static() |
-{ |
- int i; |
- /************************************/ |
- /* Sezione esecutiva della funzione */ |
- /************************************/ |
- |
- grx_rect(X0min,Y0min,X0max,Y0max,COL_CORNICE); |
- // grx_rect(X0min+100,Y0min+100,X0max,Y0max,COL_CORNICE); |
- grx_line(X0min,Y0min+100,X0min+100,Y0min+100,COL_CORNICE); |
- // grx_line(X0min,Y0min+350,X0min+100,Y0min+350,COL_CORNICE); |
- |
- grx_line(X0min+25,Y0min+100,X0min+25,Y0max,COL_CORNICE); |
- grx_line(X0min+50,Y0min+100,X0min+50,Y0max,COL_CORNICE); |
- grx_line(X0min+75,Y0min+100,X0min+75,Y0max,COL_CORNICE); |
- |
- grx_line(X0min,Y0min+100+127,X0min+25,Y0min+100+127,LIGHTBLUE); |
- grx_line(X0min+50,Y0min+100+127,X0min+100,Y0min+100+127,LIGHTBLUE); |
- grx_line(X0min+50,Y0min+100+127+250,X0min+100,Y0min+100+127+250,LIGHTBLUE); |
- |
- |
- grx_box(X0min+101+50,400,X0min+230+50,Y0max-1,BROWN); |
- for(i=1;i<6;i++){ |
- grx_box(X0min+101+50+38,400+35*i-10,X0min+101+50+48,400+35*i,CYAN); |
- grx_box(X0min+101+50+81,400+35*i-10,X0min+101+50+91,400+35*i,CYAN); |
- } |
- grx_box(X0min+101+50+60,Y0max-30,X0min+101+50+70,Y0max-1,GREEN); |
- |
- |
- grx_box(700,520,X0max-1,Y0max-1,CYAN); |
- |
- |
- |
- grx_text("Fx", X0min+5, Y0min+90, COL_TESTO, COL_SFONDO); |
- grx_text("Fy", X0min+30, Y0min+90, COL_TESTO, COL_SFONDO); |
- grx_text("Ax", X0min+55, Y0min+90, COL_TESTO, COL_SFONDO); |
- grx_text("Ay", X0min+80, Y0min+90, COL_TESTO, COL_SFONDO); |
- // grx_text("M", X0min+10, Y0min+351, COL_TESTO, COL_SFONDO); |
- // grx_text("P", X0min+35, Y0min+351, COL_TESTO, COL_SFONDO); |
- grx_text("Vx", X0min+55, Y0min+351, COL_TESTO, COL_SFONDO); |
- grx_text("Vy", X0min+80, Y0min+351, COL_TESTO, COL_SFONDO); |
- |
- grx_text("S : Su", X0min+110, Y0min+15, COL_TESTO, COL_SFONDO); |
- grx_text("Z : Sinistra", X0min+110, Y0min+25, COL_TESTO, COL_SFONDO); |
- grx_text("X : Giu", X0min+110, Y0min+35, COL_TESTO, COL_SFONDO); |
- grx_text("C : Destra", X0min+110, Y0min+45, COL_TESTO, COL_SFONDO); |
- grx_text("P : aggancia Peso", X0min+110, Y0min+55, COL_TESTO, COL_SFONDO); |
- grx_text("L : Libera peso", X0min+110, Y0min+65, COL_TESTO, COL_SFONDO); |
- grx_text("Esc : Usita Programma", X0min+110, Y0min+75, COL_TESTO, COL_SFONDO); |
- |
- |
-} // Fine della funzione draw_static |
- |
-TASK disegna_stato(int i) |
-{ //double j; |
- |
- while (1) |
- { |
- |
- sem_wait(&mutex); |
- |
- grx_rect(X0min+100,Y0min+100,X0max,Y0max,COL_CORNICE); |
- |
- grx_box(700,565,770,Y0max-1,LIGHTCYAN); |
- |
- grx_box(X0min+101+50,400,X0min+230+50,420,BROWN); |
- |
- |
- //####################### FORZA X ############################# |
- if ( 0.25<=Forza_x) grx_box(7,Y0min+210,26,Y0min+220,GREEN); |
- else grx_box(7,Y0min+210,26,Y0min+220,COL_SFONDO); |
- if ( 0.5<=Forza_x) grx_box(7,Y0min+195,26,Y0min+205,GREEN); |
- else grx_box(7,Y0min+195,26,Y0min+205,COL_SFONDO); |
- if ( 0.75<=Forza_x) grx_box(7,Y0min+180,26,Y0min+190,GREEN); |
- else grx_box(7,Y0min+180,26,Y0min+190,COL_SFONDO); |
- if ( 1<=Forza_x) grx_box(7,Y0min+165,26,Y0min+175,GREEN); |
- else grx_box(7,Y0min+165,26,Y0min+175,COL_SFONDO); |
- if ( 1.25<=Forza_x) grx_box(7,Y0min+150,26,Y0min+160,GREEN); |
- else grx_box(7,Y0min+150,26,Y0min+160,COL_SFONDO); |
- if ( 1.50<=Forza_x) grx_box(7,Y0min+135,26,Y0min+145,YELLOW); |
- else grx_box(7,Y0min+135,26,Y0min+145,COL_SFONDO); |
- if ( 1.75<=Forza_x) grx_box(7,Y0min+120,26,Y0min+130,RED); |
- else grx_box(7,Y0min+120,26,Y0min+130,COL_SFONDO); |
- if ( 2<=Forza_x) grx_box(7,Y0min+105,26,Y0min+115,RED); |
- else grx_box(7,Y0min+105,26,Y0min+115,COL_SFONDO); |
- //########### ------ |
- if (-0.25>=Forza_x) grx_box(7,Y0min+230,26,Y0min+240,GREEN); |
- else grx_box(7,Y0min+230,26,Y0min+240,COL_SFONDO); |
- if ( -0.5>=Forza_x) grx_box(7,Y0min+245,26,Y0min+255,GREEN); |
- else grx_box(7,Y0min+245,26,Y0min+255,COL_SFONDO); |
- if ( -0.75>=Forza_x) grx_box(7,Y0min+260,26,Y0min+270,GREEN); |
- else grx_box(7,Y0min+260,26,Y0min+270,COL_SFONDO); |
- if ( -1>=Forza_x) grx_box(7,Y0min+275,26,Y0min+285,GREEN); |
- else grx_box(7,Y0min+275,26,Y0min+285,COL_SFONDO); |
- if ( -1.25>=Forza_x) grx_box(7,Y0min+290,26,Y0min+300,GREEN); |
- else grx_box(7,Y0min+290,26,Y0min+300,COL_SFONDO); |
- if ( -1.50>=Forza_x) grx_box(7,Y0min+305,26,Y0min+315,YELLOW); |
- else grx_box(7,Y0min+305,26,Y0min+315,COL_SFONDO); |
- if ( -1.75>=Forza_x) grx_box(7,Y0min+320,26,Y0min+330,RED); |
- else grx_box(7,Y0min+320,26,Y0min+330,COL_SFONDO); |
- if ( -2>=Forza_x) grx_box(7,Y0min+335,26,Y0min+345,RED); |
- else grx_box(7,Y0min+335,26,Y0min+345,COL_SFONDO); |
- //####################### FORZA Y ############################# |
- if ( -0.5>=Forza_y) grx_box(32,Y0min+340,51,Y0min+345,GREEN); |
- else grx_box(32,Y0min+340,51,Y0min+345,COL_SFONDO); |
- if ( -1>=Forza_y) grx_box(32,Y0min+333,51,Y0min+338,GREEN); |
- else grx_box(32,Y0min+333,51,Y0min+338,COL_SFONDO); |
- if ( -1.5>=Forza_y) grx_box(32,Y0min+326,51,Y0min+331,GREEN); |
- else grx_box(32,Y0min+326,51,Y0min+331,COL_SFONDO); |
- if ( -2>=Forza_y) grx_box(32,Y0min+319,51,Y0min+324,GREEN); |
- else grx_box(32,Y0min+319,51,Y0min+324,COL_SFONDO); |
- if ( -2.5>=Forza_y) grx_box(32,Y0min+312,51,Y0min+317,GREEN); |
- else grx_box(32,Y0min+312,51,Y0min+317,COL_SFONDO); |
- if ( -3>=Forza_y) grx_box(32,Y0min+305,51,Y0min+310,GREEN); |
- else grx_box(32,Y0min+305,51,Y0min+310,COL_SFONDO); |
- if ( -3.5>=Forza_y) grx_box(32,Y0min+298,51,Y0min+303,GREEN); |
- else grx_box(32,Y0min+298,51,Y0min+303,COL_SFONDO); |
- if ( -4>=Forza_y) grx_box(32,Y0min+291,51,Y0min+296,GREEN); |
- else grx_box(32,Y0min+291,51,Y0min+296,COL_SFONDO); |
- if ( -4.5>=Forza_y) grx_box(32,Y0min+284,51,Y0min+289,GREEN); |
- else grx_box(32,Y0min+284,51,Y0min+289,COL_SFONDO); |
- if ( -5>=Forza_y) grx_box(32,Y0min+277,51,Y0min+282,GREEN); |
- else grx_box(32,Y0min+277,51,Y0min+282,COL_SFONDO); |
- if ( -5.5>=Forza_y) grx_box(32,Y0min+270,51,Y0min+275,GREEN); |
- else grx_box(32,Y0min+270,51,Y0min+275,COL_SFONDO); |
- if ( -6>=Forza_y) grx_box(32,Y0min+263,51,Y0min+268,GREEN); |
- else grx_box(32,Y0min+263,51,Y0min+268,COL_SFONDO); |
- if ( -6.5>=Forza_y) grx_box(32,Y0min+256,51,Y0min+261,GREEN); |
- else grx_box(32,Y0min+256,51,Y0min+261,COL_SFONDO); |
- if ( -7>=Forza_y) grx_box(32,Y0min+249,51,Y0min+254,GREEN); |
- else grx_box(32,Y0min+249,51,Y0min+254,COL_SFONDO); |
- if ( -7.5>=Forza_y) grx_box(32,Y0min+242,51,Y0min+247,GREEN); |
- else grx_box(32,Y0min+242,51,Y0min+247,COL_SFONDO); |
- if ( -8>=Forza_y) grx_box(32,Y0min+235,51,Y0min+240,GREEN); |
- else grx_box(32,Y0min+235,51,Y0min+240,COL_SFONDO); |
- if ( -8.5>=Forza_y) grx_box(32,Y0min+228,51,Y0min+233,GREEN); |
- else grx_box(32,Y0min+228,51,Y0min+233,COL_SFONDO); |
- if ( -9>=Forza_y) grx_box(32,Y0min+221,51,Y0min+226,GREEN); |
- else grx_box(32,Y0min+221,51,Y0min+226,COL_SFONDO); |
- if ( -9.5>=Forza_y) grx_box(32,Y0min+214,51,Y0min+219,GREEN); |
- else grx_box(32,Y0min+214,51,Y0min+219,COL_SFONDO); |
- if ( -10>=Forza_y) grx_box(32,Y0min+207,51,Y0min+212,GREEN); |
- else grx_box(32,Y0min+207,51,Y0min+212,COL_SFONDO); |
- if ( -10.5>=Forza_y) grx_box(32,Y0min+200,51,Y0min+205,GREEN); |
- else grx_box(32,Y0min+200,51,Y0min+205,COL_SFONDO); |
- if ( -11>=Forza_y) grx_box(32,Y0min+193,51,Y0min+198,GREEN); |
- else grx_box(32,Y0min+193,51,Y0min+198,COL_SFONDO); |
- if ( -11.5>=Forza_y) grx_box(32,Y0min+186,51,Y0min+191,GREEN); |
- else grx_box(32,Y0min+186,51,Y0min+191,COL_SFONDO); |
- if ( -12>=Forza_y) grx_box(32,Y0min+179,51,Y0min+184,GREEN); |
- else grx_box(32,Y0min+179,51,Y0min+184,COL_SFONDO); |
- if ( -12.5>=Forza_y) grx_box(32,Y0min+172,51,Y0min+177,GREEN); |
- else grx_box(32,Y0min+172,51,Y0min+177,COL_SFONDO); |
- if ( -13>=Forza_y) grx_box(32,Y0min+165,51,Y0min+170,GREEN); |
- else grx_box(32,Y0min+165,51,Y0min+170,COL_SFONDO); |
- if ( -13.5>=Forza_y) grx_box(32,Y0min+158,51,Y0min+163,GREEN); |
- else grx_box(32,Y0min+158,51,Y0min+163,COL_SFONDO); |
- if ( -14>=Forza_y) grx_box(32,Y0min+151,51,Y0min+156,GREEN); |
- else grx_box(32,Y0min+151,51,Y0min+156,COL_SFONDO); |
- if ( -14.5>=Forza_y) grx_box(32,Y0min+144,51,Y0min+149,GREEN); |
- else grx_box(32,Y0min+144,51,Y0min+149,COL_SFONDO); |
- if ( -15>=Forza_y) grx_box(32,Y0min+137,51,Y0min+142,YELLOW); |
- else grx_box(32,Y0min+137,51,Y0min+142,COL_SFONDO); |
- if ( -15.5>=Forza_y) grx_box(32,Y0min+130,51,Y0min+135,YELLOW); |
- else grx_box(32,Y0min+130,51,Y0min+135,COL_SFONDO); |
- if ( -16>=Forza_y) grx_box(32,Y0min+123,51,Y0min+128,RED); |
- else grx_box(32,Y0min+123,51,Y0min+128,COL_SFONDO); |
- if ( -16.5>=Forza_y) grx_box(32,Y0min+116,51,Y0min+121,RED); |
- else grx_box(32,Y0min+116,51,Y0min+121,COL_SFONDO); |
- if ( -17>=Forza_y) grx_box(32,Y0min+109,51,Y0min+114,RED); |
- else grx_box(32,Y0min+109,51,Y0min+114,COL_SFONDO); |
- if ( -17.5>=Forza_y) grx_box(32,Y0min+102,51,Y0min+107,RED); |
- else grx_box(32,Y0min+102,51,Y0min+107,COL_SFONDO); |
- |
- //####################### ACCELERAZIONE X ############################# |
- if ( -2.125>=Acc_x)grx_box(56,Y0min+340,75,Y0min+345,RED); |
- else grx_box(55,Y0min+340,75,Y0min+345,COL_SFONDO); |
- if ( -2>=Acc_x) grx_box(56,Y0min+333,75,Y0min+338,RED); |
- else grx_box(56,Y0min+333,75,Y0min+338,COL_SFONDO); |
- if ( -1.875>=Acc_x)grx_box(56,Y0min+326,75,Y0min+331,RED); |
- else grx_box(56,Y0min+326,75,Y0min+331,COL_SFONDO); |
- if ( -1.750>=Acc_x) grx_box(56,Y0min+319,75,Y0min+324,YELLOW); |
- else grx_box(56,Y0min+319,75,Y0min+324,COL_SFONDO); |
- if ( -1.625>=Acc_x)grx_box(56,Y0min+312,75,Y0min+317,YELLOW); |
- else grx_box(56,Y0min+312,75,Y0min+317,COL_SFONDO); |
- if ( -1.5>=Acc_x) grx_box(56,Y0min+305,75,Y0min+310,GREEN); |
- else grx_box(56,Y0min+305,75,Y0min+310,COL_SFONDO); |
- if ( -1.375>=Acc_x)grx_box(56,Y0min+298,75,Y0min+303,GREEN); |
- else grx_box(56,Y0min+298,75,Y0min+303,COL_SFONDO); |
- if ( -1.250>=Acc_x) grx_box(56,Y0min+291,75,Y0min+296,GREEN); |
- else grx_box(56,Y0min+291,75,Y0min+296,COL_SFONDO); |
- if ( -1.125>=Acc_x)grx_box(56,Y0min+284,75,Y0min+289,GREEN); |
- else grx_box(56,Y0min+284,75,Y0min+289,COL_SFONDO); |
- if ( -1>=Acc_x) grx_box(56,Y0min+277,75,Y0min+282,GREEN); |
- else grx_box(56,Y0min+277,75,Y0min+282,COL_SFONDO); |
- if ( -0.875>=Acc_x)grx_box(56,Y0min+270,75,Y0min+275,GREEN); |
- else grx_box(56,Y0min+270,75,Y0min+275,COL_SFONDO); |
- if ( -0.750>=Acc_x) grx_box(56,Y0min+263,75,Y0min+268,GREEN); |
- else grx_box(56,Y0min+263,75,Y0min+268,COL_SFONDO); |
- if ( -0.625>=Acc_x)grx_box(56,Y0min+256,75,Y0min+261,GREEN); |
- else grx_box(56,Y0min+256,75,Y0min+261,COL_SFONDO); |
- if ( -0.5>=Acc_x) grx_box(56,Y0min+249,75,Y0min+254,GREEN); |
- else grx_box(56,Y0min+249,75,Y0min+254,COL_SFONDO); |
- if ( -0.375>=Acc_x)grx_box(56,Y0min+242,75,Y0min+247,GREEN); |
- else grx_box(56,Y0min+242,75,Y0min+247,COL_SFONDO); |
- if ( -0.250>=Acc_x) grx_box(56,Y0min+235,75,Y0min+240,GREEN); |
- else grx_box(56,Y0min+235,75,Y0min+240,COL_SFONDO); |
- if ( -0.125>=Acc_x)grx_box(56,Y0min+228,75,Y0min+233,GREEN); |
- else grx_box(56,Y0min+228,75,Y0min+233,COL_SFONDO); |
- //############# ------ |
- if ( 0.125<=Acc_x) grx_box(56,Y0min+221,75,Y0min+226,GREEN); |
- else grx_box(56,Y0min+221,75,Y0min+226,COL_SFONDO); |
- if ( 0.250<=Acc_x)grx_box(56,Y0min+214,75,Y0min+219,GREEN); |
- else grx_box(56,Y0min+214,75,Y0min+219,COL_SFONDO); |
- if ( 0.375<=Acc_x) grx_box(56,Y0min+207,75,Y0min+212,GREEN); |
- else grx_box(56,Y0min+207,75,Y0min+212,COL_SFONDO); |
- if (0.5<=Acc_x)grx_box(56,Y0min+200,75,Y0min+205,GREEN); |
- else grx_box(56,Y0min+200,75,Y0min+205,COL_SFONDO); |
- if ( 0.625<=Acc_x) grx_box(56,Y0min+193,75,Y0min+198,GREEN); |
- else grx_box(56,Y0min+193,75,Y0min+198,COL_SFONDO); |
- if (0.750<=Acc_x)grx_box(56,Y0min+186,75,Y0min+191,GREEN); |
- else grx_box(56,Y0min+186,75,Y0min+191,COL_SFONDO); |
- if (0.875<=Acc_x) grx_box(56,Y0min+179,75,Y0min+184,GREEN); |
- else grx_box(56,Y0min+179,75,Y0min+184,COL_SFONDO); |
- if (1<=Acc_x)grx_box(56,Y0min+172,75,Y0min+177,GREEN); |
- else grx_box(56,Y0min+172,75,Y0min+177,COL_SFONDO); |
- if (1.125<=Acc_x) grx_box(56,Y0min+165,75,Y0min+170,GREEN); |
- else grx_box(56,Y0min+165,75,Y0min+170,COL_SFONDO); |
- if (1.250<=Acc_x)grx_box(56,Y0min+158,75,Y0min+163,GREEN); |
- else grx_box(56,Y0min+158,75,Y0min+163,COL_SFONDO); |
- if (1.375<=Acc_x) grx_box(56,Y0min+151,75,Y0min+156,GREEN); |
- else grx_box(56,Y0min+151,75,Y0min+156,COL_SFONDO); |
- if (1.5<=Acc_x)grx_box(56,Y0min+144,75,Y0min+149,GREEN); |
- else grx_box(56,Y0min+144,75,Y0min+149,COL_SFONDO); |
- if (1.625<=Acc_x) grx_box(56,Y0min+137,75,Y0min+142,YELLOW); |
- else grx_box(56,Y0min+137,75,Y0min+142,COL_SFONDO); |
- if (1.750<=Acc_x)grx_box(56,Y0min+130,75,Y0min+135,YELLOW); |
- else grx_box(56,Y0min+130,75,Y0min+135,COL_SFONDO); |
- if (1.875<=Acc_x) grx_box(56,Y0min+123,75,Y0min+128,RED); |
- else grx_box(56,Y0min+123,75,Y0min+128,COL_SFONDO); |
- if (2<=Acc_x)grx_box(56,Y0min+116,75,Y0min+121,RED); |
- else grx_box(56,Y0min+116,75,Y0min+121,COL_SFONDO); |
- if (2.125<=Acc_x) grx_box(56,Y0min+109,75,Y0min+114,RED); |
- else grx_box(56,Y0min+109,75,Y0min+114,COL_SFONDO); |
- //####################### ACCELERAZIONE Y ############################# |
- if ( 2.5<=Acc_y) { grx_box(81,Y0min+340,100,Y0min+345,RED); |
- grx_box(81+5,Y0min+340+1,100-5,Y0min+345-1,BLUE); |
- } |
- else grx_box(81,Y0min+340,100,Y0min+345,COL_SFONDO); |
- if ( 2.200<=Acc_y) grx_box(81,Y0min+333,100,Y0min+338,RED); |
- else grx_box(81,Y0min+333,100,Y0min+338,COL_SFONDO); |
- if ( 1.950<=Acc_y) grx_box(81,Y0min+326,100,Y0min+331,RED); |
- else grx_box(81,Y0min+326,100,Y0min+331,COL_SFONDO); |
- if ( 1.750<=Acc_y) grx_box(81,Y0min+319,100,Y0min+324,YELLOW); |
- else grx_box(81,Y0min+319,100,Y0min+324,COL_SFONDO); |
- if ( 1.625<=Acc_y) grx_box(81,Y0min+312,100,Y0min+317,YELLOW); |
- else grx_box(81,Y0min+312,100,Y0min+317,COL_SFONDO); |
- if ( 1.5<=Acc_y) grx_box(81,Y0min+305,100,Y0min+310,GREEN); |
- else grx_box(81,Y0min+305,100,Y0min+310,COL_SFONDO); |
- if ( 1.375<=Acc_y) grx_box(81,Y0min+298,100,Y0min+303,GREEN); |
- else grx_box(81,Y0min+298,100,Y0min+303,COL_SFONDO); |
- if ( 1.250<=Acc_y) grx_box(81,Y0min+291,100,Y0min+296,GREEN); |
- else grx_box(81,Y0min+291,100,Y0min+296,COL_SFONDO); |
- if ( 1.125<=Acc_y) grx_box(81,Y0min+284,100,Y0min+289,GREEN); |
- else grx_box(81,Y0min+284,100,Y0min+289,COL_SFONDO); |
- if ( 1<=Acc_y) grx_box(81,Y0min+277,100,Y0min+282,GREEN); |
- else grx_box(81,Y0min+277,100,Y0min+282,COL_SFONDO); |
- if ( 0.875<=Acc_y) grx_box(81,Y0min+270,100,Y0min+275,GREEN); |
- else grx_box(81,Y0min+270,100,Y0min+275,COL_SFONDO); |
- if ( 0.750<=Acc_y) grx_box(81,Y0min+263,100,Y0min+268,GREEN); |
- else grx_box(81,Y0min+263,100,Y0min+268,COL_SFONDO); |
- if ( 0.625<=Acc_y) grx_box(81,Y0min+256,100,Y0min+261,GREEN); |
- else grx_box(81,Y0min+256,100,Y0min+261,COL_SFONDO); |
- if ( 0.5<=Acc_y) grx_box(81,Y0min+249,100,Y0min+254,GREEN); |
- else grx_box(81,Y0min+249,100,Y0min+254,COL_SFONDO); |
- if ( 0.375<=Acc_y) grx_box(81,Y0min+242,100,Y0min+247,GREEN); |
- else grx_box(81,Y0min+242,100,Y0min+247,COL_SFONDO); |
- if ( 0.25<=Acc_y) grx_box(81,Y0min+235,100,Y0min+240,GREEN); |
- else grx_box(81,Y0min+235,100,Y0min+240,COL_SFONDO); |
- if ( 0.125<=Acc_y) grx_box(81,Y0min+228,100,Y0min+233,GREEN); |
- else grx_box(81,Y0min+228,100,Y0min+233,COL_SFONDO); |
- //############# ------ |
- if ( -0.125>=Acc_y) grx_box(81,Y0min+221,100,Y0min+226,GREEN); |
- else grx_box(81,Y0min+221,100,Y0min+226,COL_SFONDO); |
- if ( -0.250>=Acc_y) grx_box(81,Y0min+214,100,Y0min+219,GREEN); |
- else grx_box(81,Y0min+214,100,Y0min+219,COL_SFONDO); |
- if ( -0.375>=Acc_y) grx_box(81,Y0min+207,100,Y0min+212,GREEN); |
- else grx_box(81,Y0min+207,100,Y0min+212,COL_SFONDO); |
- if (-0.5>=Acc_y) grx_box(81,Y0min+200,100,Y0min+205,GREEN); |
- else grx_box(81,Y0min+200,100,Y0min+205,COL_SFONDO); |
- if ( -0.625>=Acc_y) grx_box(81,Y0min+193,100,Y0min+198,GREEN); |
- else grx_box(81,Y0min+193,100,Y0min+198,COL_SFONDO); |
- if (-0.750>=Acc_y) grx_box(81,Y0min+186,100,Y0min+191,GREEN); |
- else grx_box(81,Y0min+186,100,Y0min+191,COL_SFONDO); |
- if (-0.875>=Acc_y) grx_box(81,Y0min+179,100,Y0min+184,GREEN); |
- else grx_box(81,Y0min+179,100,Y0min+184,COL_SFONDO); |
- if (-1>=Acc_y) grx_box(81,Y0min+172,100,Y0min+177,GREEN); |
- else grx_box(81,Y0min+172,100,Y0min+177,COL_SFONDO); |
- if (-1.125>=Acc_y) grx_box(81,Y0min+165,100,Y0min+170,YELLOW); |
- else grx_box(81,Y0min+165,100,Y0min+170,COL_SFONDO); |
- if (-1.250>=Acc_y) grx_box(81,Y0min+158,100,Y0min+163,YELLOW); |
- else grx_box(81,Y0min+158,100,Y0min+163,COL_SFONDO); |
- if (-1.375>=Acc_y) grx_box(81,Y0min+151,100,Y0min+156,YELLOW); |
- else grx_box(81,Y0min+151,100,Y0min+156,COL_SFONDO); |
- if (-1.5>=Acc_y) grx_box(81,Y0min+144,100,Y0min+149,YELLOW); |
- else grx_box(81,Y0min+144,100,Y0min+149,COL_SFONDO); |
- if (-1.625>=Acc_y) grx_box(81,Y0min+137,100,Y0min+142,RED); |
- else grx_box(81,Y0min+137,100,Y0min+142,COL_SFONDO); |
- if (-1.750>=Acc_y) grx_box(81,Y0min+130,100,Y0min+135,RED); |
- else grx_box(81,Y0min+130,100,Y0min+135,COL_SFONDO); |
- if (-1.875>=Acc_y) grx_box(81,Y0min+123,100,Y0min+128,RED); |
- else grx_box(81,Y0min+123,100,Y0min+128,COL_SFONDO); |
- if (-2>=Acc_y) grx_box(81,Y0min+116,100,Y0min+121,RED); |
- else grx_box(81,Y0min+116,100,Y0min+121,COL_SFONDO); |
- if (-2.3>=Acc_y) grx_box(81,Y0min+109,100,Y0min+114,RED); |
- else grx_box(81,Y0min+109,100,Y0min+114,COL_SFONDO); |
- //####################### VELOCITA X ############################# |
- //if ( -21.25>=Velocita_x)grx_box(56,Y0min+340+250,75,Y0min+345+250,RED); |
- //else grx_box(55,Y0min+340+250,75,Y0min+345+250,COL_SFONDO); |
- if ( -20>=Velocita_x) grx_box(56,Y0min+333+250,75,Y0min+338+250,RED); |
- else grx_box(56,Y0min+333+250,75,Y0min+338+250,COL_SFONDO); |
- if ( -18.75>=Velocita_x)grx_box(56,Y0min+326+250,75,Y0min+331+250,RED); |
- else grx_box(56,Y0min+326+250,75,Y0min+331+250,COL_SFONDO); |
- if ( -17.50>=Velocita_x)grx_box(56,Y0min+319+250,75,Y0min+324+250,YELLOW); |
- else grx_box(56,Y0min+319+250,75,Y0min+324+250,COL_SFONDO); |
- if ( -16.25>=Velocita_x)grx_box(56,Y0min+312+250,75,Y0min+317+250,YELLOW); |
- else grx_box(56,Y0min+312+250,75,Y0min+317+250,COL_SFONDO); |
- if ( -15>=Velocita_x) grx_box(56,Y0min+305+250,75,Y0min+310+250,GREEN); |
- else grx_box(56,Y0min+305+250,75,Y0min+310+250,COL_SFONDO); |
- if ( -13.75>=Velocita_x)grx_box(56,Y0min+298+250,75,Y0min+303+250,GREEN); |
- else grx_box(56,Y0min+298+250,75,Y0min+303+250,COL_SFONDO); |
- if ( -12.50>=Velocita_x)grx_box(56,Y0min+291+250,75,Y0min+296+250,GREEN); |
- else grx_box(56,Y0min+291+250,75,Y0min+296+250,COL_SFONDO); |
- if ( -11.25>=Velocita_x)grx_box(56,Y0min+284+250,75,Y0min+289+250,GREEN); |
- else grx_box(56,Y0min+284+250,75,Y0min+289+250,COL_SFONDO); |
- if ( -10>=Velocita_x) grx_box(56,Y0min+277+250,75,Y0min+282+250,GREEN); |
- else grx_box(56,Y0min+277+250,75,Y0min+282+250,COL_SFONDO); |
- if ( -8.75>=Velocita_x)grx_box(56,Y0min+270+250,75,Y0min+275+250,GREEN); |
- else grx_box(56,Y0min+270+250,75,Y0min+275+250,COL_SFONDO); |
- if ( -7.50>=Velocita_x)grx_box(56,Y0min+263+250,75,Y0min+268+250,GREEN); |
- else grx_box(56,Y0min+263+250,75,Y0min+268+250,COL_SFONDO); |
- if ( -6.25>=Velocita_x)grx_box(56,Y0min+256+250,75,Y0min+261+250,GREEN); |
- else grx_box(56,Y0min+256+250,75,Y0min+261+250,COL_SFONDO); |
- if ( -5>=Velocita_x) grx_box(56,Y0min+249+250,75,Y0min+254+250,GREEN); |
- else grx_box(56,Y0min+249+250,75,Y0min+254+250,COL_SFONDO); |
- if ( -3.75>=Velocita_x)grx_box(56,Y0min+242+250,75,Y0min+247+250,GREEN); |
- else grx_box(56,Y0min+242+250,75,Y0min+247+250,COL_SFONDO); |
- if ( -2.50>=Velocita_x)grx_box(56,Y0min+235+250,75,Y0min+240+250,GREEN); |
- else grx_box(56,Y0min+235+250,75,Y0min+240+250,COL_SFONDO); |
- if ( -1.25>=Velocita_x)grx_box(56,Y0min+228+250,75,Y0min+233+250,GREEN); |
- else grx_box(56,Y0min+228+250,75,Y0min+233+250,COL_SFONDO); |
- //############# ------ |
- if ( 1.25<=Velocita_x) grx_box(56,Y0min+221+250,75,Y0min+226+250,GREEN); |
- else grx_box(56,Y0min+221+250,75,Y0min+226+250,COL_SFONDO); |
- if ( 2.50<=Velocita_x) grx_box(56,Y0min+214+250,75,Y0min+219+250,GREEN); |
- else grx_box(56,Y0min+214+250,75,Y0min+219+250,COL_SFONDO); |
- if ( 3.75<=Velocita_x) grx_box(56,Y0min+207+250,75,Y0min+212+250,GREEN); |
- else grx_box(56,Y0min+207+250,75,Y0min+212+250,COL_SFONDO); |
- if (5<=Velocita_x) grx_box(56,Y0min+200+250,75,Y0min+205+250,GREEN); |
- else grx_box(56,Y0min+200+250,75,Y0min+205+250,COL_SFONDO); |
- if ( 6.25<=Velocita_x) grx_box(56,Y0min+193+250,75,Y0min+198+250,GREEN); |
- else grx_box(56,Y0min+193+250,75,Y0min+198+250,COL_SFONDO); |
- if (7.50<=Velocita_x) grx_box(56,Y0min+186+250,75,Y0min+191+250,GREEN); |
- else grx_box(56,Y0min+186+250,75,Y0min+191+250,COL_SFONDO); |
- if (8.75<=Velocita_x) grx_box(56,Y0min+179+250,75,Y0min+184+250,GREEN); |
- else grx_box(56,Y0min+179+250,75,Y0min+184+250,COL_SFONDO); |
- if (10<=Velocita_x) grx_box(56,Y0min+172+250,75,Y0min+177+250,GREEN); |
- else grx_box(56,Y0min+172+250,75,Y0min+177+250,COL_SFONDO); |
- if (11.25<=Velocita_x) grx_box(56,Y0min+165+250,75,Y0min+170+250,GREEN); |
- else grx_box(56,Y0min+165+250,75,Y0min+170+250,COL_SFONDO); |
- if (12.50<=Velocita_x) grx_box(56,Y0min+158+250,75,Y0min+163+250,GREEN); |
- else grx_box(56,Y0min+158+250,75,Y0min+163+250,COL_SFONDO); |
- if (13.75<=Velocita_x) grx_box(56,Y0min+151+250,75,Y0min+156+250,GREEN); |
- else grx_box(56,Y0min+151+250,75,Y0min+156+250,COL_SFONDO); |
- if (15<=Velocita_x) grx_box(56,Y0min+144+250,75,Y0min+149+250,GREEN); |
- else grx_box(56,Y0min+144+250,75,Y0min+149+250,COL_SFONDO); |
- if (16.25<=Velocita_x) grx_box(56,Y0min+137+250,75,Y0min+142+250,YELLOW); |
- else grx_box(56,Y0min+137+250,75,Y0min+142+250,COL_SFONDO); |
- if (17.50<=Velocita_x) grx_box(56,Y0min+130+250,75,Y0min+135+250,YELLOW); |
- else grx_box(56,Y0min+130+250,75,Y0min+135+250,COL_SFONDO); |
- if (18.75<=Velocita_x) grx_box(56,Y0min+123+250,75,Y0min+128+250,RED); |
- else grx_box(56,Y0min+123+250,75,Y0min+128+250,COL_SFONDO); |
- if (20<=Velocita_x) grx_box(56,Y0min+116+250,75,Y0min+121+250,RED); |
- else grx_box(56,Y0min+116+250,75,Y0min+121+250,COL_SFONDO); |
- if (21.25<=Velocita_x) grx_box(56,Y0min+109+250,75,Y0min+114+250,RED); |
- else grx_box(56,Y0min+109+250,75,Y0min+114+250,COL_SFONDO); |
- |
- //####################### VELOCITA Y ############################# |
- // if ( 160<=Velocita_y)grx_box(81,Y0min+340+250,100,Y0min+345+250,RED); |
- // else grx_box(81,Y0min+340+250,100,Y0min+345+250,COL_SFONDO); |
- if ( 40<=Velocita_y) grx_box(81,Y0min+333+250,100,Y0min+338+250,RED); |
- else grx_box(81,Y0min+333+250,100,Y0min+338+250,COL_SFONDO); |
- if ( 37.5<=Velocita_y)grx_box(81,Y0min+326+250,100,Y0min+331+250,RED); |
- else grx_box(81,Y0min+326+250,100,Y0min+331+250,COL_SFONDO); |
- if ( 35<=Velocita_y)grx_box(81,Y0min+319+250,100,Y0min+324+250,YELLOW); |
- else grx_box(81,Y0min+319+250,100,Y0min+324+250,COL_SFONDO); |
- if ( 32.5<=Velocita_y)grx_box(81,Y0min+312+250,100,Y0min+317+250,YELLOW); |
- else grx_box(81,Y0min+312+250,100,Y0min+317+250,COL_SFONDO); |
- if ( 30<=Velocita_y) grx_box(81,Y0min+305+250,100,Y0min+310+250,GREEN); |
- else grx_box(81,Y0min+305+250,100,Y0min+310+250,COL_SFONDO); |
- if ( 27.5<=Velocita_y)grx_box(81,Y0min+298+250,100,Y0min+303+250,GREEN); |
- else grx_box(81,Y0min+298+250,100,Y0min+303+250,COL_SFONDO); |
- if ( 25<=Velocita_y)grx_box(81,Y0min+291+250,100,Y0min+296+250,GREEN); |
- else grx_box(81,Y0min+291+250,100,Y0min+296+250,COL_SFONDO); |
- if ( 22.5<=Velocita_y)grx_box(81,Y0min+284+250,100,Y0min+289+250,GREEN); |
- else grx_box(81,Y0min+284+250,100,Y0min+289+250,COL_SFONDO); |
- if ( 20<=Velocita_y) grx_box(81,Y0min+277+250,100,Y0min+282+250,GREEN); |
- else grx_box(81,Y0min+277+250,100,Y0min+282+250,COL_SFONDO); |
- if ( 17.5<=Velocita_y) grx_box(81,Y0min+270+250,100,Y0min+275+250,GREEN); |
- else grx_box(81,Y0min+270+250,100,Y0min+275+250,COL_SFONDO); |
- if ( 15<=Velocita_y) grx_box(81,Y0min+263+250,100,Y0min+268+250,GREEN); |
- else grx_box(81,Y0min+263+250,100,Y0min+268+250,COL_SFONDO); |
- if ( 12.5<=Velocita_y) grx_box(81,Y0min+256+250,100,Y0min+261+250,GREEN); |
- else grx_box(81,Y0min+256+250,100,Y0min+261+250,COL_SFONDO); |
- if ( 10<=Velocita_y) grx_box(81,Y0min+249+250,100,Y0min+254+250,GREEN); |
- else grx_box(81,Y0min+249+250,100,Y0min+254+250,COL_SFONDO); |
- if ( 7.5<=Velocita_y) grx_box(81,Y0min+242+250,100,Y0min+247+250,GREEN); |
- else grx_box(81,Y0min+242+250,100,Y0min+247+250,COL_SFONDO); |
- if ( 5<=Velocita_y) grx_box(81,Y0min+235+250,100,Y0min+240+250,GREEN); |
- else grx_box(81,Y0min+235+250,100,Y0min+240+250,COL_SFONDO); |
- if ( 2.5<=Velocita_y) grx_box(81,Y0min+228+250,100,Y0min+233+250,GREEN); |
- else grx_box(81,Y0min+228+250,100,Y0min+233+250,COL_SFONDO); |
- //############# ------ |
- if (-2.5>=Velocita_y) grx_box(81,Y0min+221+250,100,Y0min+226+250,GREEN); |
- else grx_box(81,Y0min+221+250,100,Y0min+226+250,COL_SFONDO); |
- if (-5>=Velocita_y) grx_box(81,Y0min+214+250,100,Y0min+219+250,GREEN); |
- else grx_box(81,Y0min+214+250,100,Y0min+219+250,COL_SFONDO); |
- if (-7.5>=Velocita_y) grx_box(81,Y0min+207+250,100,Y0min+212+250,GREEN); |
- else grx_box(81,Y0min+207+250,100,Y0min+212+250,COL_SFONDO); |
- if (-10>=Velocita_y) grx_box(81,Y0min+200+250,100,Y0min+205+250,GREEN); |
- else grx_box(81,Y0min+200+250,100,Y0min+205+250,COL_SFONDO); |
- if (-12.5>=Velocita_y) grx_box(81,Y0min+193+250,100,Y0min+198+250,GREEN); |
- else grx_box(81,Y0min+193+250,100,Y0min+198+250,COL_SFONDO); |
- if (-15>=Velocita_y) grx_box(81,Y0min+186+250,100,Y0min+191+250,GREEN); |
- else grx_box(81,Y0min+186+250,100,Y0min+191+250,COL_SFONDO); |
- if (-17.5>=Velocita_y) grx_box(81,Y0min+179+250,100,Y0min+184+250,GREEN); |
- else grx_box(81,Y0min+179+250,100,Y0min+184+250,COL_SFONDO); |
- if (-20>=Velocita_y) grx_box(81,Y0min+172+250,100,Y0min+177+250,GREEN); |
- else grx_box(81,Y0min+172+250,100,Y0min+177+250,COL_SFONDO); |
- if (-22.5>=Velocita_y) grx_box(81,Y0min+165+250,100,Y0min+170+250,GREEN); |
- else grx_box(81,Y0min+165+250,100,Y0min+170+250,COL_SFONDO); |
- if (-25>=Velocita_y) grx_box(81,Y0min+158+250,100,Y0min+163+250,GREEN); |
- else grx_box(81,Y0min+158+250,100,Y0min+163+250,COL_SFONDO); |
- if (-27.5>=Velocita_y) grx_box(81,Y0min+151+250,100,Y0min+156+250,GREEN); |
- else grx_box(81,Y0min+151+250,100,Y0min+156+250,COL_SFONDO); |
- if (-30>=Velocita_y) grx_box(81,Y0min+144+250,100,Y0min+149+250,GREEN); |
- else grx_box(81,Y0min+144+250,100,Y0min+149+250,COL_SFONDO); |
- if (-32.5>=Velocita_y) grx_box(81,Y0min+137+250,100,Y0min+142+250,YELLOW); |
- else grx_box(81,Y0min+137+250,100,Y0min+142+250,COL_SFONDO); |
- if (-35>=Velocita_y) grx_box(81,Y0min+130+250,100,Y0min+135+250,YELLOW); |
- else grx_box(81,Y0min+130+250,100,Y0min+135+250,COL_SFONDO); |
- if (-37.5>=Velocita_y) grx_box(81,Y0min+123+250,100,Y0min+128+250,RED); |
- else grx_box(81,Y0min+123+250,100,Y0min+128+250,COL_SFONDO); |
- if (-40>=Velocita_y) grx_box(81,Y0min+116+250,100,Y0min+121+250,RED); |
- else grx_box(81,Y0min+116+250,100,Y0min+121+250,COL_SFONDO); |
- if (-42.5>=Velocita_y) grx_box(81,Y0min+109+250,100,Y0min+114+250,RED); |
- else grx_box(81,Y0min+109+250,100,Y0min+114+250,COL_SFONDO); |
- |
- |
- sem_post(&mutex); |
- |
- |
- task_endcycle(); |
- } |
-} |
- |
- |
Index: eli/eli.h |
=================================================================== |
--- eli/eli.h (revision 1656) |
+++ eli/eli.h (nonexistent) |
@@ -1,173 +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: eli.h,v 1.1.1.1 2004-05-24 18:03:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2004-05-24 18:03:47 $ |
- ------------ |
- |
- This file is similar to the configuration of Hartik 3.3.1 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 ALLEN-DESTRO and 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 |
- * |
- */ |
- |
- |
-/***************************************/ |
-/* Corso di Informatica Industriale */ |
-/* Libreria con le funzioni di disegno */ |
-/* Creata da ALLEN-DESTRO */ |
-/***************************************/ |
- |
-//######################################## |
-// Librerie standard del linguaggio C |
-//####################################### |
-#include <math.h> |
-#include <stdlib.h> |
-#include <string.h> |
- |
-//######################################## |
-// Librerie Hartik |
-//######################################## |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <ll/i386/cons.h> |
-#include <semaphore.h> |
- |
-//######################################## |
-// Definizione delle costanti del programma |
-//######################################## |
- |
-#define PER_DISEGNA 100000 |
-#define PER_MOLLA 100000 |
-#define PER_KILL 200000 |
-#define G 10 |
-#define DIM_EL 12 |
-#define DIM_PESO 10 |
-#define COL_EL YELLOW |
- |
- |
-#define X0min 4 // Ascissa minima della finestra grafica |
-#define Y0min 4 // Ordinata minima della finestra grafica |
-#define X0max 796 // Ascissa massima della finestra grafica |
-#define Y0max 596 // Ordinata massima della finestra grafica |
-#define TERRA 400 // Ordinata della pista di atteraggio |
-#define COL_SFONDO 0 // Colore di sfondo della finestra grafica |
-#define COL_TESTO 7 // Colore del testo della finestra grafica |
-#define COL_CORNICE RED // Colore cornici della finestra grafica |
-#define DELTA_COL 32 |
- |
- |
-// Valore di pigreco |
-#define PIGRECO 3.14159 |
- |
-#define ELICOTTERO_S(x,y,dim,col,sfo) grx_disc(x,y,dim,col); \ |
- grx_box(x-dim,y,x+dim,y+dim,sfo); \ |
- grx_line(x-dim*2,y-dim,x+dim*2,y-dim,col); \ |
- grx_box(x-dim,y,x+(dim*2),y+(dim/3),col); \ |
- grx_line(x-dim,y+dim/2,x+2*dim,y+dim/2,col); \ |
- grx_circle(x+dim*2,y,dim/2,col); \ |
- grx_box(x-dim/10,y,x+dim/10,y+dim/2,col) |
- |
-#define ELICOTTERO_D(x,y,dim,col,sfo) grx_disc(x,y,dim,col); \ |
- grx_box(x-dim,y,x+dim,y+dim,sfo); \ |
- grx_line(x-dim*2,y-dim,x+dim*2,y-dim,col); \ |
- grx_box(x-(dim*2),y,x+dim,y+(dim/3),col); \ |
- grx_line(x-2*dim,y+dim/2,x+dim,y+dim/2,col); \ |
- grx_circle(x-dim*2,y,dim/2,col); \ |
- grx_box(x-dim/10,y,x+dim/10,y+dim/2,col) |
- |
-#define PESO(x,y,dim,col) grx_box(x-dim,y,x+dim,y+2*dim,col) |
- |
-#define MOLLA(x,y1,y2,col) { \ |
- int w; \ |
- for (w=y1;w<y2;w=w+2) grx_line(x-3,w,x+3,w,col); \ |
- } |
- |
-#define RUSPA_S(x,y,col,colvet) grx_box(x,y-20,x+2,y,col); \ |
- grx_line(x,y-10,x+5,y-10,col); \ |
- grx_box(x+5,y-30,x+20,y-5,col); \ |
- grx_box(x+5,y-10,x+40,y-5,col); \ |
- grx_disc(x+10,y-5,5,col); \ |
- grx_disc(x+30,y-5,5,col); \ |
- grx_box(x+5,y-25,x+12,y-15,colvet) |
- |
-#define RUSPA_D(x,y,col,colvet) grx_box(x-2,y-20,x,y,col); \ |
- grx_line(x-5,y-10,x,y-10,col); \ |
- grx_box(x-20,y-30,x-5,y-5,col); \ |
- grx_box(x-40,y-10,x-5,y-5,col); \ |
- grx_disc(x-10,y-5,5,col); \ |
- grx_disc(x-30,y-5,5,col); \ |
- grx_box(x-12,y-25,x-5,y-15,colvet) |
- |
-#define ESPLOSIONE(x,y) grx_box(x-2,y-2,x+1,y+1,RED+1); \ |
- grx_box(x-5,y-5,x-4,y-3,RED+1); \ |
- grx_box(x-6,y-2,x-4,y,RED+1); \ |
- grx_box(x+3,y+4,x+4,y+7,RED+1); \ |
- grx_box(x+5,y-6,x+8,y-4,RED+1); \ |
- grx_box(x-10,y+10,x-8,y+8,RED+1); \ |
- grx_box(x-1,y-10,x+1,y-8,RED+1); \ |
- grx_box(x-13,y-1,x-10,y+1,RED+1); \ |
- grx_box(x+8,y-7,x+10,y-5,RED+1); \ |
- grx_box(x,y+6,x-1,y+8,RED+1); \ |
- grx_box(x-DIM_PESO-1,y-1,x-DIM_PESO+1,y+1,RED+1); \ |
- grx_box(x-DIM_PESO-1,y+2*DIM_PESO-1,x-DIM_PESO+1,y+2*DIM_PESO+1,RED+1); \ |
- grx_box(x+DIM_PESO-1,y-1,x+DIM_PESO+1,y+1,RED+1); \ |
- grx_box(x+DIM_PESO-1,y+2*DIM_PESO-1,x+DIM_PESO+1,y+2*DIM_PESO+1,RED+1); \ |
- grx_box(x-1,y+DIM_PESO-1,x+1,y+DIM_PESO+1,RED+1); \ |
- grx_box(x+4,y+DIM_PESO-1,x+6,y+DIM_PESO+1,RED+1); \ |
- |
-//#define PULISCI(x,y) grx_box(x-14,y-11,x+DIM_PESO+2,y+2*DIM_PESO+2,COL_SFONDO) |
-#define PULISCI(x,y,d) grx_disc(x,y,d,COL_SFONDO) |
- |
-/*********************************************************************/ |
-/* */ |
-/* Funzione per disegnare gli elementi statici */ |
-/* */ |
-/*********************************************************************/ |
-extern char tastiera; |
-extern long double Forza_x,Forza_y,Velocita_x,Velocita_y,Acc_x,Acc_y,Massa; |
-// Definizione del semaforo per l'utilizzo della modalità grafica |
-extern sem_t mutex; |
- |
-TASK disegna_stato(int i); |
- |
- |
- |
Index: auto/tracks/brazil.raw |
=================================================================== |
--- auto/tracks/brazil.raw (revision 1656) |
+++ auto/tracks/brazil.raw (nonexistent) |
@@ -1,2 +0,0 @@ |
-
- ! " |
---|