/unsupported/trunk/pendulum/CAMERA.ERR |
---|
0,0 → 1,4 |
camera.c: In function `tracking_task': |
camera.c:273: warning: unused variable `k' |
camera.c: In function `init_framegrabber': |
camera.c:446: warning: unused variable `my_key' |
/unsupported/trunk/pendulum/INTG1 |
---|
0,0 → 1,0 |
2114 11000 79.3087 0.8879 15 845 4399 |
/unsupported/trunk/pendulum/COMMG1 |
---|
0,0 → 1,15 |
x1 kalm1 11000 2114 0.3 |
x1 kalm1 12000 2114 0.3 |
x1 kalm1 13000 2114 0.3 |
x1 kalm1 14000 2114 0.3 |
x1 kalm1 15000 2114 0.3 |
x1 kalm1 16000 2114 0.3 |
x1 kalm1 17000 2114 0.3 |
x1 kalm1 18000 2114 0.3 |
x1 kalm1 19000 2114 0.3 |
x1 kalm1 20000 2114 0.3 |
x1 kalm1 21000 2114 0.3 |
x1 kalm1 22000 2114 0.3 |
x1 kalm1 23000 2114 0.3 |
x1 kalm1 24000 2114 0.3 |
x1 kalm1 25000 2114 0.3 |
/unsupported/trunk/pendulum/INTDATA |
---|
0,0 → 1,0 |
15000 20000 NaN NaN 0 6000 7999 |
/unsupported/trunk/pendulum/COMMG2 |
---|
0,0 → 1,15 |
x1 kalm1 13000 1503 0.3 |
x1 kalm1 14000 1503 0.3 |
x1 kalm1 15000 1503 0.3 |
x1 kalm1 16000 1503 0.3 |
x1 kalm1 17000 1503 0.3 |
x1 kalm1 18000 1503 0.3 |
x1 kalm1 19000 1503 0.3 |
x1 kalm1 20000 1503 0.3 |
x1 kalm1 21000 1503 0.3 |
x1 kalm1 22000 1503 0.3 |
x1 kalm1 23000 1503 0.3 |
x1 kalm1 24000 1503 0.3 |
x1 kalm1 25000 1503 0.3 |
x1 kalm1 26000 1503 0.3 |
x1 kalm1 27000 1503 0.3 |
/unsupported/trunk/pendulum/INITFILE.C |
---|
0,0 → 1,98 |
#define PI |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/cbs.h" |
#include "modules/rr.h" |
/* |
#ifndef PI |
#include "modules/rrsoft.h" |
#endif |
*/ |
#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 "drivers/keyb.h" |
#include "drivers/glib.h" |
/*+ system tick in us +*/ |
#define TICK 500 |
/*+ RR tick in us +*/ |
//#define RRTICK 10000 |
#define RRTICK 3000 |
TIME __kernel_register_levels__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
#ifdef PI |
EDF_register_level(0); //EDF_ENABLE_ALL); |
CBS_register_level(0,0); //CBS_ENABLE_ALL, 0); |
#else |
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs |
#endif |
RR_register_level(RRTICK, RR_MAIN_YES, mb); |
dummy_register_level(); |
SEM_register_module(); |
CABS_register_module(); |
PI_register_module(); |
NOP_register_module(); |
return TICK; |
} |
TASK __init__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
HARTPORT_init(); |
kern_printf("TIME=%d\n",sys_gettime(NULL)); |
KEYB_init(NULL); |
kern_printf("TIME=%d\n",sys_gettime(NULL)); |
grx_init(); |
__call_main__(mb); |
return (void *)0; |
} |
#ifdef PI |
void app_mutex_init(mutex_t *m) |
{ |
PI_mutexattr_t attr; |
PI_mutexattr_default(attr); |
mutex_init(m, &attr); |
} |
/*#else |
void app_mutex_init(mutex_t *m) |
{ |
NOP_mutexattr_t attr; |
NOP_mutexattr_default(attr); |
mutex_init(m, &attr); |
}*/ |
#endif |
/unsupported/trunk/pendulum/COMMG3 |
---|
0,0 → 1,12 |
x1 kalm1 14000 1273 0.3 |
x1 kalm1 16000 1273 0.3 |
x1 kalm1 18000 1273 0.3 |
x1 kalm1 20000 1273 0.3 |
x1 kalm1 22000 1273 0.3 |
x1 kalm1 24000 1273 0.3 |
x1 kalm1 26000 1273 0.3 |
x1 kalm1 28000 1273 0.3 |
x1 kalm1 30000 1273 0.3 |
x1 kalm1 32000 1273 0.3 |
x1 kalm1 34000 1273 0.3 |
x1 kalm1 36000 1273 0.3 |
/unsupported/trunk/pendulum/DEMO1.C |
---|
0,0 → 1,69 |
#include "demo.h" |
#include <kernel/func.h> |
#include <string.h> |
#include <stdlib.h> |
#include <drivers/keyb.h> |
#include <drivers/glib.h> |
/* graphic mutex... */ |
mutex_t mutex; |
void app_mutex_init(mutex_t *m); |
void my_close(void *arg) |
{ |
grx_close(); |
} |
/* |
void endfun(KEY_EVT *k) |
{ |
grx_close(); |
cprintf("Ctrl-Brk pressed! Ending...\n"); |
sys_end(); |
} |
void zerofun(KEY_EVT *k) |
{ |
int i; |
for (i=0; i<MAX_PROC; i++) jet_delstat(i); |
} |
*/ |
int main(int argc, char **argv) |
{ |
int modenum; |
KEY_EVT k; |
struct sigaction action; |
srand(4); |
sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
modenum = grx_getmode(800, 600, 16); //(640, 480, 16); |
grx_setmode(modenum); |
/* init the graphic mutex */ |
app_mutex_init(&mutex); |
grx_text("HARTIK 4.0 " , 0,0, rgb16(0,255,0),BLACK); |
grx_text("Thesis Demo", 0,8, rgb16(0,255,0), BLACK); |
init_framegrabber(); /* fra le altre cose attiva i task della camera */ |
PXC_Start(); |
group_activate(1); |
return 0; |
} |
/unsupported/trunk/pendulum/KALM1.C |
---|
0,0 → 1,1207 |
/************************************************************* |
* * |
* Stabilizzazione di un pendolo inverso * |
* * |
* * |
*Written by: Gabriele Bolognini - Scuola S.Anna -- Pisa * |
* * |
*************************************************************/ |
#include "demo.h" |
#include "pclab.h" |
#include "cost.h" /* Contiene le costanti del task DISEGNA */ |
#ifdef SOFTPROG |
long int PERIOD_CARRELLO={1200}, PERIOD_TRACKING={12000}; |
long int WCET_CARRELLO={240}, WCET_TRACKING={7200}; |
#else |
long int PERIOD_CARRELLO={1800}, PERIOD_TRACKING={22200}; |
#endif |
#define LUNGH 35.0 |
#define THETAMAX 45.0 |
#define VDANG 2.4 |
#define NMAX 300 |
#define SEC_ID 7.0 |
#define MAXRUN_ID 9 //16 |
int start_id=0; |
// dati da scrivere nei files |
static long int contat_id=-1, num_id=0; |
#ifdef DATAPLANT |
struct DATA_FILE { |
TIME time; |
float xist ; |
float thist ; |
float par1 ; |
float par2 ; |
float par3 ; |
float par4 ; |
} dati[NMAX]; |
long int numdat=0; // numero dati scritti su DATI[NMAX] |
#endif |
#define NSAMPLES 500 |
#define NTASKS 10 |
static float timetab[NSAMPLES][NTASKS]; |
static int index[NTASKS]; |
static float somma[MAXRUN_ID][2]; // valore dello indice di prestazione |
mutex_t mutex,mutexadc; |
#define MAX_TEMPI 15 |
static char stringa[MAX_TEMPI][250]; |
// **- ACHTUNG!!!: param. iniz. del guadagno, deadline, ecc.-----******* / |
#define INIPARAMS {{ 2.3 , 300 , 0.5 , 15 },1.,1.0,20.,20., 0.1, 1 , 1, 0.} |
#define MODPARAMS {{ 1. , 300 , 0.9 , 34 },0.74 ,1.,20.,20., 0.2, 1 , 1, 0.} |
#define PARAM2 {{ 1. , 300 , 0.79 , 23 },0.70 ,2.5 ,20.,20., 0.1, 1 , 1, 0.} |
/* |
struct Parametri{ |
float GUAD[4]; |
float COST; |
float NOISE; |
float WCUT; |
float WCUT1; |
float OFFSVAL; |
int DEADLINE; |
int SCAN; |
float XTRASL; |
}; |
struct Data_cab1 { |
float rif; |
int imp; |
}; |
struct Data_cab2 { |
float x; |
float y; |
} ; |
*/ |
struct Parametri prm=PARAM2, prmbase=INIPARAMS, prmmod=MODPARAMS, prm2=PARAM2; |
#define DEADSECX(x) ( x /*PERIOD_TRACKING*/ * 1.0e-6 ) // mit task TRACK in sec |
#define DEADSECTH(x) (x /*PERIOD_CARRELLO*/ * 1.0e-6 ) // mit task CARRELLO in sec |
CAB cab1, cab2; |
float vmax, vmin, vmaxth, vminth; |
float vin=0, vout, yout, thout; |
void graphframe(void); |
void my_end(void); |
void scritt(void); |
void scritt1(void); |
void scritt2(void); |
void scritt3(void); |
void nuovi_tempi(long int*); |
void initial(void); |
void scenario_jetcontrol(void); |
void init_jetcontrol(void); |
TASK jetslide_task(void *); |
TASK jetctrl_task(void *); |
TASK jetdummy_task(void *); |
void framegrabber_close(void *); |
TASK camera_task(void *); |
TASK tracking_task(void *); |
extern int white, black, red, gray, green, blue; |
float integrale(float y[], float u, int flag) |
{ |
static float sum=0, oldcoeff=0; |
float coeff=0 ; |
static float R=1 , Q[2][2]={1,0,0,1.5} ; |
if(flag) sum=0; //reset |
coeff=Q[0][0]*y[0]*y[0]+Q[0][1]*y[0]*y[1]+Q[1][0]*y[1]*y[0]+Q[1][1]*y[1]*y[1]+R*u*u; |
sum += (coeff+oldcoeff)*DEADSECTH(PERIOD_CARRELLO) / 2.0 ; |
oldcoeff=coeff; |
return sum; |
} |
void zerofun(KEY_EVT *k) |
{ |
int i; |
for (i=0; i<MAX_PROC; i++) jet_delstat(i); |
} |
int da_motor(float v) |
{ |
da_conv( 2.5 , 2 ); |
da_conv( v + 2.5 , 1 ); |
return(0); |
} |
float v2x(float v) |
{ /* trasforma i volt in x */ |
float x; |
x= LUNGH * (v-(vmax+vmin)/2 ) / (vmax-vmin); |
return x; |
} |
float v2theta(float v) |
{ /* trasforma i volt in angoli */ |
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_TRACKING) *u)/(1+ prm.WCUT * DEADSECX(PERIOD_TRACKING)); |
oldy=y; |
return y; |
} |
float bass2(float u) |
{ |
float y; |
static float oldy=0; |
y=(oldy + prm.WCUT1 * DEADSECX(PERIOD_TRACKING) *u)/(1+ prm.WCUT1 * DEADSECX(PERIOD_TRACKING)); |
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_TRACKING); |
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 eval(void) |
{ |
int x,y; |
char str[100]; |
mutex_lock(&mutex); |
grx_rect(10,325,XTI - 20,479,blue); |
x = 20; |
y = 350; |
grx_text("PARAMETRI DI CONTROLLO ( R , T ) ", x+60, y-18 , red, 0); |
grx_text("Guad=", x, y,green, 0);y+=18; |
grx_text("Cost=", x, y,green, 0); y+=18; |
grx_text("WCUT=", x, y,green, 0); y+=18; |
grx_text("WCUT1=", x, y,green, 0); y+=18; |
grx_text("NOISE=", x, y,green, 0); y+=18; |
grx_text("DEADL=", x, y,green, 0);y+=18; |
grx_text("OFFS=", x, y,green, 0);y+=18; |
{ /* legenda */ |
int x=280, y=350; |
grx_text("Guad 1,2 3,4 5,6 7,8", x, y,green, 0);y+=18; |
grx_text("Cost [ , ]", x, y,green, 0); y+=18; |
grx_text("WCUT o , p", x , y,green, 0); y+=18; |
grx_text("WCUT1 k , l", x, y,green, 0); y+=18; |
grx_text("NOISE n , m", x, y,green, 0); y+=18; |
grx_text("DEADL - , +", x, y,green, 0);y+=18; |
grx_text("OFFS / , *", x, y,green, 0);y+=18; |
} |
{ /* frame dei valori rilevati dai sensori */ |
int x=15, y=YTI+10; |
grx_rect(10,YTI,XTI - 20,YTI+70,red); |
grx_text("V_com = ", x, y,green, 0);y+=14; |
grx_text("V+offs = ", x, y,green, 0);y+=14; |
grx_text("V_sens_x = ", x, y,green, 0);y+=14; |
grx_text("SCAN = ", x, y,green, 0);y+=14; |
} |
mutex_unlock(&mutex); |
while(1){ |
x = 70; |
y = 350; |
mutex_lock(&mutex); |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%6.2f %6.2f %6.2f %6.2f ", prm.GUAD[0],prm.GUAD[1],prm.GUAD[2],prm.GUAD[3]); |
grx_text(str, x, y, blue, 0);y+=18; |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%6.2f ", prm.COST); |
grx_text(str, x, y, blue, 0); y += 18; |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%6.2f Hz", prm.WCUT); |
grx_text(str, x, y, blue, 0); y += 18; |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%6.2f Hz ", prm.WCUT1); |
grx_text(str, x, y, blue, 0); y += 18; |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%6.2f Volt ", prm.NOISE); |
grx_text(str, x, y, blue, 0); y += 18; |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%d ticks ", prm.DEADLINE); |
grx_text(str, x, y, blue, 0); y += 18; |
grx_text(" ", x, y, 12, 0); |
sprintf(str, "%6.2f Volt ", prm.OFFSVAL); |
grx_text(str, x, y, blue, 0); y += 18; |
mutex_unlock(&mutex); |
/* scrivo vin , vout (vin+offs) , SCAN e PARAMETRIBASE*/ |
{ int x=95, y= YTI + 10; |
mutex_lock(&mutex); |
grx_text(" ", x, y, 0, 0); |
sprintf(str, "%7.4f ", vin); |
grx_text(str, x, y, blue, 0);y += 14; |
grx_text(" ", x, y, 0, 0); |
sprintf(str, "%7.4f", vout); |
grx_text(str, x, y, blue, 0);y += 14; |
grx_text(" ", x, y, 0, 0); |
sprintf(str, "%7.3f", yout); |
grx_text(str, x, y , blue, 0); y += 14; |
grx_text(" ", x, y, 0, 0); |
sprintf(str, "%3.2d c , v", prm.SCAN); |
grx_text(str, x, y , blue, 0); y += 14; |
mutex_unlock(&mutex); |
} |
task_endcycle(); |
} |
} |
/*------------------------------------------------------------------------ |
Il task CARRELLO controlla la posizione del carrello |
y = posizione angolare dell'asta (non usata) |
x = posizione lineare del carrello |
-----------------------------------------------------------------------*/ |
float xrif=0, orif=1; |
TASK carrello(void) |
{ |
float thist=0, y[2]={0,0}, yp[2]={0,0}; /* valori attuali */ |
PORT pa, pb; /* communication ports */ |
struct Data_cab1 data; |
struct Data_cab2 tmp; |
char *pun, *pun2; |
int i; |
float offset; |
long int k=0; |
long int stime =0 ; |
/* Si creano 2 per mandare al task DISEGNA le var.di stato x1 e x3 */ |
pa = port_create("porta1",sizeof(float),1,STICK,WRITE); |
pb = port_create("porta2",sizeof(float),1,STICK,WRITE); |
while (1) { |
/* prendo i dati sul riferimento in volt per la x */ |
pun = cab_getmes(cab1); |
memcpy(&data, pun, sizeof(struct Data_cab1)); |
cab_unget(cab1, pun); |
/* prendo i dati sulle posizioni dal trasduttore ADC */ |
task_nopreempt(); |
thout=ad_conv(10); |
task_preempt(); |
/* taglio brusco dei livelli di rumore sopra il NOISE */ |
{ |
#define AVR 10 |
static float othout[AVR]; |
float avth; |
static int index=0, flag=1; |
if(flag==1) { |
for(i=0; i<AVR;++i) { othout[i] = thout;} |
flag=0; |
} |
avth=0; |
for(i=0;i<AVR;++i) { avth += othout[i]; } |
avth /= AVR ; |
if(fabs(thout-avth)>=prm.NOISE) { thout=avth;} |
othout[index]=thout; |
index = (index+1) % AVR ; |
} |
/* converto i valori dei sensori in posizioni */ |
/* calcolo le velocita' lineari e angolari opportunamente filtrate */ |
thist=v2theta(thout); |
y[1]=bass3(thist); |
yp[1] = bass4(dth(y[1])); |
/* a questo punto dovrei prendere i valori dall'altro task CARR2 */ |
pun2 = cab_getmes(cab2); |
memcpy(&tmp , pun2, sizeof(struct Data_cab2)); |
cab_unget(cab2, pun2); |
y[0]=yout=tmp.x; |
yp[0]=tmp.y; |
/* PARAMETRI del controllore :1 */ |
vin = prm.COST * (prm.GUAD[0] * (y[0]-v2x(data.rif+prm.XTRASL))+ prm.GUAD[1] * thist + prm.GUAD[2] * yp[0] + prm.GUAD[3] * yp[1]) ; |
/* metto un offset che mi elimina l'attrito */ |
if( vin >= 0) offset=prm.OFFSVAL; |
else offset=-prm.OFFSVAL; |
vout=vin+offset; |
if(vout >= VDANG ) vout = VDANG ; |
if(vout <= -VDANG ) vout = -VDANG ; |
/* la applico */ |
da_motor(vout); |
/* mando i dati sulle posizioni al task DISEGNA */ |
port_send(pa, &y[1], NON_BLOCK); |
port_send(pb, &y[0], NON_BLOCK); |
{ |
char str[5]; |
static long int contatwait=-1; |
// extern float xrif; |
if(start_id == 1) { |
start_id=0; |
contat_id=(int) (SEC_ID / DEADSECTH(PERIOD_CARRELLO)); |
num_id++; |
somma[num_id-1][1]=contat_id; |
integrale(y,vout,1); |
contatwait=(long int) (1.5 * SEC_ID / DEADSECTH(PERIOD_CARRELLO)); |
} |
if(contat_id > 0) { |
xrif=0.0; //pone la xrif a zero |
somma[num_id-1][0]=integrale(y,vout,0); |
somma[num_id-1][1]= --contat_id; |
} |
if(contat_id == 0) { |
if(num_id>= (MAXRUN_ID-1)) nuovi_tempi(&contatwait); //sys_end(); |
xrif=-10.0; |
contatwait--; if(contatwait==0) start_id=1;//attiva la racc. dati |
} |
if(contat_id == -1 ) ; // vero solo allo inizio del programma |
} |
/* aggiorno i riferimenti utilizzati in questo task, piu' in alto*/ |
data.rif=(vmax+vmin)/2. + xrif * (vmax-vmin)/LUNGH; |
data.imp=0; |
pun = cab_reserve(cab1); |
memcpy(pun, &data, sizeof(struct Data_cab1)); |
cab_putmes(cab1, pun); |
/* scrivo i dati istantanei (fino a NMAX) nella struttura 'dati' */ |
#ifdef DATAPLANT |
if((contat_id>0)&&(k<(NMAX-1))) { |
dati[k].time=sys_gettime(NULL)/1000; |
dati[k].xist=y[0]; |
dati[k].thist=thist; |
dati[k].par1=vout; |
dati[k].par2=yp[0]; |
dati[k].par3=yp[1]; |
dati[k].par4=thist*FCA; |
numdat=k++; |
} |
#endif |
task_endcycle(); |
} |
/* Eliminazione porte di comunicazione */ |
port_delete(pa); |
port_delete(pb); |
} /* FINE DEL TASK CARRELLO */ |
/*--------------------------------------------------------------*/ |
/* Il task DISEGNA riceve dal task CONTROLLO i valori delle */ |
/* variabili x1 e x3 e disegna il pendolo corrispondente */ |
/*--------------------------------------------------------------*/ |
TASK diseg(void) |
{ |
WORD xp, yp, oxp, oyp; /* coordinate carrello */ |
WORD xa, ya, oxa, oya; /* coordinate asta */ |
float x1, x3; /* variabili di stato */ |
char str[100]; |
PORT pra, prb, prc; /* communication ports */ |
int delta; /* dimensione finestre */ |
/* Connessione alle porte create dal task CONTROLLO */ |
pra = port_connect("porta1",sizeof(float),STICK,READ); |
prb = port_connect("porta2",sizeof(float),STICK,READ); |
delta = 120; |
/* Inizializzazione variabili carrello e asta */ |
xp = oxp = 100; |
xa = oxa = 100; |
yp = oyp = 105 + delta - H; |
ya = oya = 105 + delta - H; |
graphframe(); |
while (1) { |
/*if(contat_id==0)*/ { |
char str1[15]; |
mutex_lock(&mutex); |
grx_text(" ", XTI, YTI+174, 0, 0); |
sprintf(str1, "%d ", contat_id); |
grx_text(str1, XTI, YTI+174, red, 0); |
grx_text(" ", XTI, YTI+188, 0, 0); |
sprintf(str1, "%d ", num_id); |
grx_text(str1, XTI, YTI+188,green , 0); |
grx_text(" ", XTI, YTI+202, 0, 0); |
sprintf(str1, "%f ", somma[num_id-1][0]); |
grx_text(str1, XTI, YTI+202,green , 0); |
grx_text(" ", XTI, YTI+216, 0, 0); |
sprintf(str1, "carr= %d %d %f", PERIOD_CARRELLO, WCET_CARRELLO, ((float) WCET_CARRELLO) / PERIOD_CARRELLO ); |
grx_text(str1, XTI, YTI+216,green , 0); |
grx_text(" ", XTI, YTI+230, 0, 0); |
sprintf(str1, "track= %d %d %f", PERIOD_TRACKING, WCET_TRACKING, ((float) WCET_TRACKING) / PERIOD_TRACKING ); |
grx_text(str1, XTI, YTI+230,green , 0); |
mutex_unlock(&mutex); |
} |
/* disegna il pendolo */ |
port_receive(pra, &x1, BLOCK); |
port_receive(prb, &x3, BLOCK); |
/* scrivo posizione del carrello e angolo dell'asta */ |
mutex_lock(&mutex); |
grx_text(" ", XTI+45, YTI+28, 0, 0); |
sprintf(str, "%5.2f", x3); |
grx_text(str, XTI+45, YTI+28, blue, 0); |
grx_text(" ", XTI+50, YTI+42, 0, 0); |
sprintf(str, "%4.3f", x1 * FCA ); |
grx_text(str, XTI+50, YTI+42, blue, 0); |
mutex_unlock(&mutex); |
/* calcolo ascissa del punto P del carrello */ |
xp = XMED + x3 * SGX; |
/* calcolo ascissa e ordinata dell'estremo dell'asta */ |
xa = xp + LA * sin((double)(x1 * SGA)); |
ya = yp - LA * cos((double)(x1 * SGA)); |
mutex_lock(&mutex); |
/* cancella e disegna il carrello */ |
grx_box(oxp-LC,oyp,oxp+LC,oyp+H,0); |
grx_box(xp-LC,yp,xp+LC,yp+H,blue); |
/* cancella e disegna la ruota sinistra del carrello */ |
grx_circle(oxp-LC+8,oyp+H+4,RAGGIO+2,0); |
grx_circle(xp-LC+8,yp+H+4,RAGGIO+2,green); |
/* cancella e disegna la ruota destra del carrello */ |
grx_circle(oxp+LC-8,oyp+H+4,RAGGIO+2,0); |
grx_circle(xp+LC-8,yp+H+4,RAGGIO+2,green); |
/* cancella e disegna l'asta */ |
grx_line(oxp,oyp,oxa,oya,0); |
grx_line(xp,yp,xa,ya,red); |
/* cancella e disegna la pallina sull'asta */ |
grx_circle(oxa,oya,RAGGIO,0); |
grx_circle(xa,ya,RAGGIO,blue); |
mutex_unlock(&mutex); |
/* aggiornamento variabili */ |
oxp = xp; |
oyp = yp; |
oxa = xa; |
oya = ya; |
task_endcycle(); |
} |
port_disconnect(pra); |
port_disconnect(prb); |
port_disconnect(prc); |
} /* FINE TASK DISEGNA */ |
TASK query(void) |
{ |
char c, str[100]; |
int count = 0; |
char *pun; |
struct Data_cab1 data={0,0}; |
while(1) |
{ |
do { |
c = keyb_getch(BLOCK); |
switch (c) { |
case 'd': xrif += 1; break; |
case 's': xrif -= 1; break; |
case 'D': xrif=7; break; |
case 'S': xrif=-7; break; |
case '0': xrif =0 ; break; |
case '1': prm.GUAD[0] -= 0.1 ; break; |
case '2': prm.GUAD[0] += 0.1; break; |
case '3': prm.GUAD[1] -= 10 ; break; |
case '4': prm.GUAD[1] += 10 ; break; |
case '5': prm.GUAD[2] -= 0.05; break; |
case '6': prm.GUAD[2] += 0.05; break; |
case '7': prm.GUAD[3] -= 0.5; break; |
case '8': prm.GUAD[3] += 0.5; break; |
case 'o': prm.WCUT -= 2. ; break; |
case 'p': prm.WCUT += 2. ; break; |
case 'k': prm.WCUT1 -= 2. ; break; |
case 'l': prm.WCUT1 += 2. ; break; |
case 'n': prm.NOISE -= 0.1; break; |
case 'm': prm.NOISE += 0.1; break; |
case '/': prm.OFFSVAL -= 0.1; break; |
case '*': prm.OFFSVAL += 0.1; break; |
case '[': prm.COST -= 0.02; break; |
case ']': prm.COST += 0.02; break; |
case 'c': prm.SCAN -= 1; break; |
case 'v': prm.SCAN += 1; break; |
case 'R': prm = prmbase; break; |
case 'T': prm = prmmod; break; |
case 'U': prm = prm2; break; |
case '<': prm.XTRASL -= .05; break; |
case '>': prm.XTRASL += .05; break; |
case '!': start_id=1; break; |
case '@': if(num_id>0) num_id--; break; |
default: break; |
} |
data.rif=(vmax+vmin)/2. + xrif * (vmax-vmin)/LUNGH; |
/* controllo che il riferim non vada fuori scala massima */ |
if (data.rif > vmax) data.rif = vmax; |
if (data.rif < vmin) data.rif = vmin; |
/* controllo l'impulso */ |
if (count>0) count--; |
if (data.imp != 0 && count==0) data.imp = 0; |
/* scrivo sul cab1 i riferim ( rif + imp) per il carrello */ |
pun = cab_reserve(cab1); |
memcpy(pun, &data, sizeof(struct Data_cab1)); |
cab_putmes(cab1, pun); |
/* si visualizza il riferimento del carrello. */ |
if (xrif != orif) { |
orif = xrif; |
mutex_lock(&mutex); |
grx_text(" ", XTI+45, YTI+14, 0, 0); |
sprintf(str, "%2.1f cm.", xrif); |
grx_text(str, XTI+55, YTI+14, green, 0); |
mutex_unlock(&mutex); |
} |
} while (c != 27); |
sys_end(); |
task_endcycle(); |
} |
} |
int printglob; |
TASK timejet(void *arg) |
{ |
TIME table[JET_TABLE_DIM]; |
int k, nistan; |
PID i; |
int printed; |
while(1) { |
for (i=2, printed=0; i<NTASKS ; i++) { |
if ( (nistan=jet_gettable(i,(TIME *) table, -1)) != -1) { |
for(k=0;k<nistan;k++){ |
if(index[i] >= NSAMPLES) break; |
if( i>=NTASKS ) {grx_close();perror("Ntask too high for jet");sys_end();} |
timetab[ index[i] ][i] = (float) table[k]; |
index[i]++; |
} |
printed++; |
} |
} |
printglob=printed; |
task_endcycle(); |
} |
} |
/****************** * MAIN * ******************************/ |
PID pc,pc2, pd, pe, pq, pt; |
PID camera_PID; |
PID tracking_PID; |
void main(int argc, char **argv) |
{ |
int modenum; |
HARD_TASK_MODEL m; |
SOFT_TASK_MODEL ms, md, mt; |
SOFT_TASK_MODEL m1, m2; |
HARD_TASK_MODEL m3; |
white = rgb16(255,255,255); |
black = rgb16(0,0,0); |
red = rgb16(255,0,0); |
gray = rgb16(128,128,128); |
green = rgb16(0,255,0); |
blue = rgb16(0,0,255); |
#ifdef SOFTPROG |
if(argc!=4) {perror("numero di parametri errato. Rilancia");keyb_getchar();sys_end();} |
PERIOD_TRACKING=atol(argv[1]); |
PERIOD_CARRELLO=atol(argv[2]); |
WCET_TRACKING =(long int) PERIOD_TRACKING *( 1.0 - (atof(argv[3])) - 0.2) ; |
WCET_CARRELLO =(long int) PERIOD_CARRELLO * ( atof(argv[3])); |
#else |
if(argc!=3) {perror("numero di parametri errato. Rilancia");keyb_getchar();sys_end();} |
PERIOD_TRACKING=atol(argv[1]); |
PERIOD_CARRELLO=atol(argv[2]); |
#endif |
sys_atrunlevel((void *) my_end,NULL, RUNLEVEL_BEFORE_EXIT); |
#ifdef TIMEJET |
sys_atrunlevel((void *) scritt,NULL, RUNLEVEL_AFTER_EXIT); |
#endif |
#ifdef DATAPLANT |
sys_atrunlevel((void *) scritt1,NULL, RUNLEVEL_AFTER_EXIT); |
#endif |
sys_atrunlevel((void *) scritt2,NULL, RUNLEVEL_AFTER_EXIT); |
sys_atrunlevel((void *) scritt3,NULL, RUNLEVEL_AFTER_EXIT); |
modenum = grx_getmode(800, 600, 16); |
if (modenum == -1) { |
cprintf("Errore in grx_mode"); |
sys_end(); |
exit(2); |
} |
if (grx_setmode(modenum) == -1) { |
cprintf("Non posso andare in modo grafico"); |
sys_end(); |
exit(3); |
} |
init_framegrabber(); |
{ char str[50]; |
sprintf(str, "CARRELLO = %d TRACK = %d ", PERIOD_CARRELLO, PERIOD_TRACKING); |
grx_text(str, 20 , 20 , green, 0); |
grx_text("Premi un tasto per continuare", 20 , 30 , green, 0); |
keyb_getchar(); |
grx_text(" ", 20 , 20 , black, 0); |
grx_text(" ", 20 , 30 , black, 0); |
} |
initial(); |
app_mutex_init(&mutex); |
scenario_jetcontrol(); |
{ |
KEY_EVT k; |
k.flag = ALTL_BIT; |
k.scan = KEY_C; |
k.ascii = 'c'; |
keyb_hook(k,zerofun); |
} |
/* Creazione dei CAB */ |
cab1 = cab_create("cab1", sizeof(struct Data_cab1), 3); |
cab2 = cab_create("cab2", sizeof(struct Data_cab2), 3); |
/* Creazione dei task */ |
#ifdef SOFTPROG |
soft_task_default_model(m1); |
soft_task_def_level(m1,1); |
soft_task_def_met(m1,WCET_TRACKING); |
soft_task_def_usemath(m1); |
soft_task_def_period(m1,(PERIOD_TRACKING)); |
soft_task_def_group(m1,1); |
soft_task_def_ctrl_jet(m1); |
// soft_task_def_skip_arrivals(m1); |
tracking_PID = task_create("track", tracking_task, &m1, NULL); |
if (tracking_PID == -1) { |
sys_end(); |
exit(4); |
} |
#else |
hard_task_default_model(m3); |
//hard_task_def_level(m3,1); |
hard_task_def_wcet(m3,WCET_TRACKING); |
hard_task_def_mit(m3,(PERIOD_TRACKING)); |
hard_task_def_usemath(m3); |
hard_task_def_group(m3,1); |
hard_task_def_ctrl_jet(m3); |
tracking_PID = task_create("track", tracking_task, &m3, NULL); |
if (tracking_PID == -1) { |
sys_end(); |
exit(4); |
} |
#endif |
soft_task_default_model(m2); |
soft_task_def_level(m2,1); |
soft_task_def_met(m2,WCET_CAMERA); |
soft_task_def_usemath(m2); |
soft_task_def_period(m2,PERIOD_CAMERA); |
soft_task_def_group(m2,1); |
soft_task_def_ctrl_jet(m2); |
camera_PID = task_create("cam", camera_task, &m2, NULL); |
if (camera_PID == -1) { |
sys_end(); |
exit(4); |
} |
hard_task_default_model(m); |
hard_task_def_mit(m, PERIOD_CARRELLO ); |
hard_task_def_wcet(m,WCET_CARRELLO ); |
hard_task_def_group(m,2); |
hard_task_def_ctrl_jet(m); |
hard_task_def_usemath(m); |
soft_task_default_model(ms); |
soft_task_def_period(ms, PERIOD_CARRELLO ); |
soft_task_def_met(ms,WCET_CARRELLO ); |
soft_task_def_group(ms,2); |
soft_task_def_ctrl_jet(ms); |
soft_task_def_usemath(ms); |
soft_task_default_model(md); |
soft_task_def_level(md,1); |
soft_task_def_period(md,PERIOD_DESIGN); |
soft_task_def_met(md, WCET_DESIGN); |
soft_task_def_group(md, 2); |
soft_task_def_ctrl_jet(md); |
soft_task_def_usemath(md); |
#ifdef TIMEJET |
soft_task_default_model(mt); |
soft_task_def_level(mt,1); |
soft_task_def_period(mt,PERIOD_TIMEJET); |
soft_task_def_met(mt, WCET_TIMEJET); |
soft_task_def_group(mt, 2); |
soft_task_def_ctrl_jet(mt); |
soft_task_def_usemath(mt); |
#endif |
#ifndef TIMEJET |
init_jetcontrol(); |
#else |
pt = task_create("timejet",(TASK) timejet,&md,NULL); |
if (pt == -1) { |
sys_end(); |
exit(4); |
} |
#endif |
#ifdef SOFTPROG |
pc = task_create("carrello",(TASK) carrello, &ms, NULL); |
if (pc == -1) { |
sys_end(); |
exit(4); |
} |
#else |
pc = task_create("carrello",(TASK) carrello, &m, NULL); |
if (pc == -1) { |
sys_end(); |
exit(4); |
} |
#endif |
pe = task_create("eval",(TASK) eval,&md, NULL); |
if (pe == -1) { |
sys_end(); |
exit(4); |
} |
pd = task_create("diseg",(TASK) diseg,&md,NULL); |
if (pd == -1) { |
sys_end(); |
exit(4); |
} |
pq = task_create("query",(TASK) query,&md,NULL); |
if (pq == -1) { |
sys_end(); |
exit(4); |
} |
/* Attivo i task per controllare e disegnare il carrello */ |
#ifdef TIMEJET |
task_activate(pt); |
#endif |
// task_activate(pc2); |
task_activate(pd); |
task_activate(pc); |
task_activate(pe); |
task_activate(pq); |
group_activate(1); |
} |
/****************************************************************/ |
/* initial */ |
/****************************************************************/ |
void initial(void) |
{ |
int x, y; |
grx_rect(1, 1, 639, 243, blue); /* dialog box pendolo */ |
da_motor(0.); |
x = 10; |
y = YTI; |
grx_text("INIZIALIZZ.", x, y, blue, 0); y += 42; |
grx_text("Carr a sx e premi un tasto", x, y, green, 0);y += 28; |
keyb_getchar(); |
vmin=ad_conv(11); |
grx_text("Carr a dx e premi un tasto",x,y,green,0); y += 28; |
keyb_getchar(); |
vmax=ad_conv(11); |
grx_text("Asta a sx e premi un tasto", x, y, green, 0);y += 28; |
keyb_getchar(); |
vminth=ad_conv(10); |
grx_text("Asta a dx e premi un tasto", x, y, green, 0);y += 28; |
keyb_getchar(); |
vmaxth=ad_conv(10); |
grx_text("Premi 'y' per l' identificazione ", x, y, green, 0);y += 28; |
keyb_getchar(); |
grx_clear(0); |
} |
/****************************************************************/ |
/* graphframe */ |
/****************************************************************/ |
void graphframe(void) |
{ |
int x, y; |
mutex_lock(&mutex); |
grx_rect(XTI-15,245,639,479,blue); /* finestra di stato */ |
grx_rect(1, 1, 450 /*639*/, 243, blue); /* dialog box pendolo */ |
x = XTI; |
y = YTI; |
grx_text("PENDOLO", x, y, red, 0); y += 14; |
grx_text("Rif.:", x, y, green, 0); y += 14; |
grx_text("X =", x, y, green, 0); y += 14; |
grx_text("Ang =", x, y, green, 0); y += 14; |
grx_text("s sx, d dx", x, y, green, 0); y += 14; |
grx_text("S: xrif-> -7 ", x, y, green, 0); y += 14; |
grx_text("D: xrif-> +7 ", x, y, green, 0); y += 14; |
grx_text("0: xrif-> 0 ", x, y, green, 0); y += 14; |
grx_text("S imp-,D imp+", x, y, green, 0); y += 14; |
grx_text("CALIBRAZ: < , >", x, y, green, 0); y += 14; |
grx_text("Dati Start: !", x, y, green, 0); y += 14; |
grx_text("Cancel Last: @", x, y, green, 0); y += 14; |
mutex_unlock(&mutex); |
} |
/*--------------------------------------------------------------*/ |
/* This function is called at system termination */ |
/*--------------------------------------------------------------*/ |
void my_end(void) |
{ |
da_motor(0.0); |
grx_close(); |
// sys_status(CLOCK_STATUS|SCHED_STATUS); |
sys_end(); |
} |
/*--------------------------------------------------------------*/ |
/* This function writes the data in the file DATA */ |
/*--------------------------------------------------------------*/ |
void scritt(void) |
{ |
DOS_FILE *file; |
long int i , k; |
char str[500]; |
file = DOS_fopen("data","w"); |
#if 1 |
for(i=2;i<NTASKS;i++) { |
sprintf(str,"%s ",proc_table[i].name); |
cprintf("%s", str); |
DOS_fwrite(str,1,strlen(str) ,file); |
} |
DOS_fwrite("\n",1,1,file); |
cprintf("%s", "\n"); |
#endif |
for(k=0;k<NSAMPLES;k++){ |
for(i=2;i<NTASKS;i++) { |
sprintf(str,"%f ",timetab[k][i]); |
cprintf("%s", str); |
// keyb_getchar(); |
DOS_fwrite(str,1,strlen(str) ,file); |
} |
DOS_fwrite("\n",1,1,file); |
cprintf("%s", "\n"); |
} |
DOS_fclose(file); |
} |
#ifdef DATAPLANT |
void scritt1(void) |
{ |
DOS_FILE *file; |
char str[300]; |
long int i; |
float pippy=3.14; |
file = DOS_fopen("dataplant","w"); |
for(i=0;i<numdat;i++) { |
sprintf(str,"%lu %f %f %f %f %f %f \n",dati[i].time , dati[i].xist,dati[i].thist,dati[i].par1, dati[i].par2, dati[i].par3, dati[i].par4 ); |
cprintf("%lu %f %f %f %f %f %f \n",dati[i].time , dati[i].xist,dati[i].thist,dati[i].par1, dati[i].par2, dati[i].par3, dati[i].par4 ); |
if(DOS_fwrite(str,1,strlen(str),file)==0) perror("Errore in write"); |
} |
DOS_fclose(file); |
} |
#endif |
void scritt2(void) |
{ |
DOS_FILE *file; |
char tmp[15]={0}, str[250]; |
int i; |
float parz=0.0 , average=0.0, sumsq=0.0, confid_int=0.0; |
float t_stud[20]={0.0, 6.314,2.920,2.353,2.132,2.015,1.943,1.895,1.860,\ |
1.833,1.812,1.796,1.782,1.771,1.761,1.753,1.746,1.740,1.734,1.729}; |
file = DOS_fopen("integrale","wa"); |
for(i=0;i<num_id;i++) { |
sprintf(tmp,"%f %f \n",somma[i][0],somma[i][1]); |
strcat(str,tmp); |
} |
for(i=0;i<num_id;i++) parz += somma[i][0]; |
average=parz /num_id; |
for(i=0;i<num_id;i++) sumsq +=(average-somma[i][0])*(average-somma[i][0]); |
confid_int= t_stud[num_id-1]*sqrt((double) sumsq/((float) num_id*(num_id-1))); |
sprintf(tmp,"n.run=%d aver=%f confid_int=%f \n",num_id,average,confid_int); |
strcat(str,tmp); |
if(DOS_fwrite(str,1,strlen(str),file)==0) perror("Errore in write"); |
DOS_fclose(file); |
file = DOS_fopen("intdata","wa"); |
sprintf(str,"%d %d %f %f %d %d %d \n",PERIOD_CARRELLO, PERIOD_TRACKING,average,confid_int, num_id,WCET_CARRELLO, WCET_TRACKING ); |
// strcat(str,tmp); |
if(DOS_fwrite(str,1,strlen(str),file)==0) perror("Errore in write"); |
DOS_fclose(file); |
} |
void nuovi_tempi(long int * contatwait) |
{ |
int i; |
float parz=0.0 , average=0.0, sumsq=0.0, confid_int=0.0; |
float t_stud[20]={0.0, 6.314,2.920,2.353,2.132,2.015,1.943,1.895,1.860,\ |
1.833,1.812,1.796,1.782,1.771,1.761,1.753,1.746,1.740,1.734,1.729}; |
static int num_tempi=0; |
// calcolo la media e lo interv di confidenza |
for(i=0;i<num_id;i++) parz += somma[i][0]; |
average=parz /num_id; |
for(i=0;i<num_id;i++) sumsq +=(average-somma[i][0])*(average-somma[i][0]); |
confid_int= t_stud[num_id-1]*sqrt((double) sumsq/((float) num_id*(num_id-1))); |
// scrivo i dati relativi alrun in una matrice globale |
sprintf(stringa[num_tempi],"%d %d %f %f %d %d %d \n",PERIOD_CARRELLO, PERIOD_TRACKING,average,confid_int, num_id,WCET_CARRELLO, WCET_TRACKING ); |
num_tempi++; |
if(num_tempi >= MAX_TEMPI) sys_end(); |
// cambio i periodi-banda dei tasks |
{ |
double band; |
band=((float) WCET_CARRELLO)/PERIOD_CARRELLO; |
PERIOD_CARRELLO = PERIOD_CARRELLO; // + 500; |
PERIOD_TRACKING = PERIOD_TRACKING; // +2000; |
band+=0.1; |
WCET_CARRELLO = band * PERIOD_CARRELLO; |
WCET_TRACKING = ( 0.8 - band) * PERIOD_TRACKING; |
} |
CBS_modify_bandwidth(pc,(TIME) PERIOD_CARRELLO,(int) WCET_CARRELLO); |
CBS_modify_bandwidth(tracking_PID,(TIME) PERIOD_TRACKING,(int) WCET_TRACKING); |
// resetto le variabili per il run successivo |
num_id=0; |
*contatwait=(long int) (1.5 * SEC_ID / DEADSECTH(PERIOD_CARRELLO)); |
} |
void scritt3(void) |
{ |
DOS_FILE *file; |
char tmp[1000]={0}; |
int i; |
file = DOS_fopen("totaldata","wa"); |
for(i=0;i<MAX_TEMPI;i++) { |
if(DOS_fwrite(stringa[i],1,strlen(stringa[i]),file)==0) perror("Errore in write"); |
// strcat(tmp, stringa[i][0]); |
} |
// if(DOS_fwrite(tmp,1,strlen(tmp),file)==0) perror("Errore in write"); |
DOS_fclose(file); |
} |
/unsupported/trunk/pendulum/INTDIR/INTOUT |
---|
0,0 → 1,63 |
çµqÄ\rÄ\r(]rܵqÄ\r®dq4]r<]r78.7698 0 |
77.4059 0 |
76.0983 0 |
76.1722 0 |
73.5694 0 |
73.9977 0 |
77.1772 0 |
74.809 0 |
77.152 0 |
73.6139 0 |
n.run=10 aver=75.8766 confid_int=1.0454 |
Ü\ràRq78.285 0 |
78.1921 0 |
74.2018 0 |
77.8378 0 |
71.0703 0 |
74.2567 0 |
75.3337 0 |
75.0806 0 |
76.2923 0 |
67.9952 0 |
73.7665 0 |
n.run=11 aver=74.7556 confid_int=1.7049 |
84.7805 0 |
85.7624 0 |
107.4614 0 |
96.7407 0 |
107.754 0 |
86.0293 0 |
99.482 0 |
95.9617 0 |
96.5085 0 |
105.0103 0 |
81.311 0 |
92.455 0 |
n.run=12 aver=94.9381 confid_int=4.7118 |
72.3848 0 |
79.7338 0 |
76.5855 0 |
75.0214 0 |
79.5618 0 |
83.6138 0 |
75.705 0 |
79.8631 0 |
74.4328 0 |
90.4947 0 |
92.3488 0 |
81.1682 0 |
63.2695 0 |
n.run=13 aver=78.7833 confid_int=3.7256 |
128.8931 0 |
88.7952 0 |
127.9526 0 |
86.7683 0 |
87.4571 0 |
127.5284 0 |
95.8795 0 |
111.2734 0 |
119.7814 0 |
81.1899 0 |
99.7919 0 |
n.run=11 aver=105.0283 confid_int=10.1375 |
/unsupported/trunk/pendulum/INTDIR/INTEGRAL |
---|
0,0 → 1,10 |
ç²q81.5895 0 |
78.8374 0 |
68.6844 0 |
86.3867 0 |
84.3205 0 |
82.5948 0 |
86.8545 0 |
81.3735 0 |
80.8773 0 |
n.run=9 aver=81.2798 confid_int=3.346 |
/unsupported/trunk/pendulum/INTDIR/OUT |
---|
0,0 → 1,6 |
2331 19000 75.8766 1.0454 10 600 10000 |
2114 20000 74.7556 1.7049 11 600 10000 |
1451 27000 78.7833 3.7256 13 600 10000 |
1273 32000 94.9381 4.7118 12 600 10000 |
1273 32000 94.9381 4.7118 12 600 10000 |
1152 38000 105.0283 10.1375 11 600 10000 |
/unsupported/trunk/pendulum/INTDIR/INT1 |
---|
0,0 → 1,13 |
8643 14000 113.3934 3.0521 11 600 10000 |
3780 16000 92.2722 1.752 11 600 10000 |
1451 27000 85.3176 2.6436 11 600 10000 |
2629 18000 79.3446 1.1486 11 600 10000 |
2114 20000 80.861 1.3404 11 600 10000 |
1152 38000 120.2788 5.1264 11 600 10000 |
1822 22000 81.6772 1.7735 11 600 10000 |
1634 24000 79.3911 1.3985 11 600 10000 |
1634 24000 79.3911 1.3985 11 600 10000 |
1503 26000 84.1363 2.2404 11 600 10000 |
/unsupported/trunk/pendulum/DEMO.H0 |
---|
0,0 → 1,236 |
#define PI |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/cbs.h" |
#include "modules/rr.h" |
#ifndef PI |
#include "modules/rrsoft.h" |
#endif |
#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 "drivers/keyb.h" |
#include "drivers/glib.h" |
/*+ system tick in us +*/ |
#define TICK 1000 |
/*+ RR tick in us +*/ |
#define RRTICK 10000 |
//#define RRTICK 3000 |
TIME __kernel_register_levels__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
#ifdef PI |
EDF_register_level(EDF_ENABLE_WCET_CHECK); |
CBS_register_level(0,0); //CBS_ENABLE_ALL, 0); |
#else |
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs |
#endif |
RR_register_level(RRTICK, RR_MAIN_YES, mb); |
dummy_register_level(); |
SEM_register_module(); |
CABS_register_module(); |
PI_register_module(); |
NOP_register_module(); |
return TICK; |
} |
TASK __init__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
HARTPORT_init(); |
kern_printf("TIME=%d\n",sys_gettime(NULL)); |
KEYB_init(NULL); |
kern_printf("TIME=%d\n",sys_gettime(NULL)); |
grx_init(); |
__call_main__(mb); |
return (void *)0; |
} |
#ifdef PI |
void app_mutex_init(mutex_t *m) |
{ |
PI_mutexattr_t attr; |
PI_mutexattr_default(attr); |
mutex_init(m, &attr); |
} |
#else |
void app_mutex_init(mutex_t *m) |
{ |
NOP_mutexattr_t attr; |
NOP_mutexattr_default(attr); |
mutex_init(m, &attr); |
} |
#endif |
E_WCET_CHECK); |
CBS_register_level(0,0); //CBS_ENABLE_ALL, 0); |
#else |
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs |
#endif |
RR_register_level(RRTICK, RR_MAIN_YES, mb |
B cab1, cab2; |
extern struct Parametri prm; |
void app_mutex_init(mutex_t *); |
int da_motor(float v); |
float v2x(float v); |
float v2theta(float v); |
float bass1(float u); |
float bass2(float u); |
float bass3(float u); |
float bass4(float u); |
float dx(float u); |
float dth(float u); |
/* scenario */ |
#define SCENARIO_NLABEL 16 |
/* |
* Global Stuffs |
*/ |
/* graphic mutex... */ |
extern mutex_t mutex; |
/* useful colors... */ |
int white; |
int black; |
int red; |
int gray; |
int green; |
int blue; |
void init_jetcontrol(); |
void init_framegrabber(); |
/* |
* |
* JETCONTROL stuffs |
* |
*/ |
#define JET_NTASK 13 |
#define JET_Y_NAME 480 //500 |
#define DUMMY_PID 1 |
#define JET_DUMMY_WIDTH 210 |
#define JET_DUMMY_HEIGHT 40 |
/* the point (x, y) is the top left corner */ |
#define JET_DUMMY_X 60 |
#define JET_DUMMY_Y 514 |
#define JET_SLIDE_WIDTH 50 |
#define JET_SLIDE_X (384+200) |
/* |
* |
* FRAMEGRABBER stuffs |
* |
*/ |
// if defined... object black on a white background |
#ifndef __BLACK_ON_WHITE |
#define __BLACK_ON_WHITE |
#endif |
#define ABS_NUM(a) ((a >= 0) ? a : -a) |
#define MIN_NUM(a, b) ((a < b) ? a : b) |
#define MAX_NUM(a, b) ((a > b) ? a : b) |
// Cols and rows of the framegrabber image |
#define N_COL 384 // 384 |
#define N_ROW 288 |
#define N_BPS 8 // Bits per pixel |
#define N_GRIGI 256 |
#define N_FRAMES 20 // 100 |
/* pixel of the video image */ |
#define IMG_COL 230 // 230 //256 |
#define IMG_ROW 160 // 160 //192 |
/* position of the video image */ |
#define IMG_X 500 // 644 // 384 |
#define IMG_Y 32 // 200 // 32 |
// I singoli pixel sono caratteri a 8 bit |
typedef unsigned char TPixel; |
typedef struct { |
int x1, y1; |
int x2, y2; |
int xb, yb; |
TIME time_stamp; |
} TDataObj; |
typedef struct { |
int found; |
int top_frame; |
int vx,vy; |
int predx; |
int predy; |
TDataObj current; |
} TTracking; |
float distance(unsigned int x1, unsigned int y1, |
unsigned int x2, unsigned int y2); |
char scan_all_frame(TDataObj *data, TPixel *in_frame); |
char scan_window_frame(TDataObj *data, TPixel *in_frame, \ |
unsigned int xc, unsigned int yc, int border, int border_y); |
void threshold_up_function(KEY_EVT key); |
void threshold_down_function(KEY_EVT key); |
void border_up_function(KEY_EVT key); |
void border_down_function(KEY_EVT key); |
void tracking(int top_frame, int *track_x, int *track_y, int *int_vx, int *int_vy, int time_to); |
TASK elab_image_TASK(void); |
/unsupported/trunk/pendulum/COMMHARD |
---|
0,0 → 1,15 |
x1 kalm1 500000 1000 |
x1 kalm1 31250 2000 |
x1 kalm1 23809 3000 |
x1 kalm1 21276 4000 |
x1 kalm1 20000 5000 |
x1 kalm1 19230 6000 |
x1 kalm1 18716 7000 |
x1 kalm1 18348 8000 |
x1 kalm1 18072 9000 |
x1 kalm1 17857 10000 |
x1 kalm1 17684 11000 |
x1 kalm1 17543 12000 |
x1 kalm1 17426 13000 |
x1 kalm1 17326 14000 |
x1 kalm1 17241 15000 |
/unsupported/trunk/pendulum/DISTRIB/TIMEJET |
---|
0,0 → 1,120 |
3.7700000e-002 1.4285714e-003 |
3.9100000e-002 0.0000000e+000 |
4.0500000e-002 4.2857143e-003 |
4.1900000e-002 1.4285714e-003 |
4.3300000e-002 3.8571429e-002 |
4.4700000e-002 1.5714286e-002 |
4.6100000e-002 8.5714286e-003 |
4.7500000e-002 8.5714286e-003 |
4.8900000e-002 1.4285714e-003 |
5.0300000e-002 1.4285714e-003 |
5.1700000e-002 7.1428571e-003 |
5.3100000e-002 4.2857143e-003 |
5.4500000e-002 8.8571429e-002 |
5.5900000e-002 9.1428571e-002 |
5.7300000e-002 2.3428571e-001 |
5.8700000e-002 8.7142857e-002 |
6.0100000e-002 6.1428571e-002 |
6.1500000e-002 9.0000000e-002 |
6.2900000e-002 3.0000000e-002 |
6.4300000e-002 4.1428571e-002 |
6.5700000e-002 5.7142857e-003 |
6.7100000e-002 2.8571429e-003 |
6.8500000e-002 5.7142857e-003 |
6.9900000e-002 7.1428571e-003 |
7.1300000e-002 1.2857143e-002 |
7.2700000e-002 2.0000000e-002 |
7.4100000e-002 1.8571429e-002 |
7.5500000e-002 5.1428571e-002 |
7.6900000e-002 2.2857143e-002 |
7.8300000e-002 1.5714286e-002 |
7.9700000e-002 0.0000000e+000 |
8.1100000e-002 0.0000000e+000 |
8.2500000e-002 2.8571429e-003 |
8.3900000e-002 1.4285714e-003 |
8.5300000e-002 4.2857143e-003 |
8.6700000e-002 0.0000000e+000 |
8.8100000e-002 0.0000000e+000 |
8.9500000e-002 0.0000000e+000 |
9.0900000e-002 0.0000000e+000 |
9.2300000e-002 0.0000000e+000 |
9.3700000e-002 0.0000000e+000 |
9.5100000e-002 0.0000000e+000 |
9.6500000e-002 0.0000000e+000 |
9.7900000e-002 0.0000000e+000 |
9.9300000e-002 0.0000000e+000 |
1.0070000e-001 0.0000000e+000 |
1.0210000e-001 0.0000000e+000 |
1.0350000e-001 0.0000000e+000 |
1.0490000e-001 0.0000000e+000 |
1.0630000e-001 0.0000000e+000 |
1.0770000e-001 0.0000000e+000 |
1.0910000e-001 0.0000000e+000 |
1.1050000e-001 0.0000000e+000 |
1.1190000e-001 0.0000000e+000 |
1.1330000e-001 0.0000000e+000 |
1.1470000e-001 0.0000000e+000 |
1.1610000e-001 1.4285714e-003 |
1.1750000e-001 0.0000000e+000 |
1.1890000e-001 0.0000000e+000 |
1.2030000e-001 1.4285714e-003 |
1.2170000e-001 0.0000000e+000 |
1.2310000e-001 1.4285714e-003 |
1.2450000e-001 0.0000000e+000 |
1.2590000e-001 0.0000000e+000 |
1.2730000e-001 0.0000000e+000 |
1.2870000e-001 0.0000000e+000 |
1.3010000e-001 0.0000000e+000 |
1.3150000e-001 0.0000000e+000 |
1.3290000e-001 0.0000000e+000 |
1.3430000e-001 0.0000000e+000 |
1.3570000e-001 0.0000000e+000 |
1.3710000e-001 0.0000000e+000 |
1.3850000e-001 1.4285714e-003 |
1.3990000e-001 0.0000000e+000 |
1.4130000e-001 0.0000000e+000 |
1.4270000e-001 0.0000000e+000 |
1.4410000e-001 0.0000000e+000 |
1.4550000e-001 0.0000000e+000 |
1.4690000e-001 0.0000000e+000 |
1.4830000e-001 0.0000000e+000 |
1.4970000e-001 0.0000000e+000 |
1.5110000e-001 0.0000000e+000 |
1.5250000e-001 1.4285714e-003 |
1.5390000e-001 0.0000000e+000 |
1.5530000e-001 0.0000000e+000 |
1.5670000e-001 0.0000000e+000 |
1.5810000e-001 0.0000000e+000 |
1.5950000e-001 0.0000000e+000 |
1.6090000e-001 0.0000000e+000 |
1.6230000e-001 0.0000000e+000 |
1.6370000e-001 0.0000000e+000 |
1.6510000e-001 0.0000000e+000 |
1.6650000e-001 0.0000000e+000 |
1.6790000e-001 0.0000000e+000 |
1.6930000e-001 1.4285714e-003 |
1.7070000e-001 0.0000000e+000 |
1.7210000e-001 0.0000000e+000 |
1.7350000e-001 0.0000000e+000 |
1.7490000e-001 0.0000000e+000 |
1.7630000e-001 0.0000000e+000 |
1.7770000e-001 0.0000000e+000 |
1.7910000e-001 0.0000000e+000 |
1.8050000e-001 0.0000000e+000 |
1.8190000e-001 0.0000000e+000 |
1.8330000e-001 0.0000000e+000 |
1.8470000e-001 0.0000000e+000 |
1.8610000e-001 1.4285714e-003 |
1.8750000e-001 0.0000000e+000 |
1.8890000e-001 0.0000000e+000 |
1.9030000e-001 0.0000000e+000 |
1.9170000e-001 0.0000000e+000 |
1.9310000e-001 0.0000000e+000 |
1.9450000e-001 0.0000000e+000 |
1.9590000e-001 0.0000000e+000 |
1.9730000e-001 0.0000000e+000 |
1.9870000e-001 0.0000000e+000 |
2.0010000e-001 0.0000000e+000 |
2.0150000e-001 0.0000000e+000 |
2.0290000e-001 0.0000000e+000 |
2.0430000e-001 1.4285714e-003 |
/unsupported/trunk/pendulum/DISTRIB/CARRELLO |
---|
0,0 → 1,120 |
1.2835417e+002 1.4285714e-003 |
1.2906250e+002 1.4285714e-003 |
1.2977083e+002 0.0000000e+000 |
1.3047917e+002 0.0000000e+000 |
1.3118750e+002 0.0000000e+000 |
1.3189583e+002 2.8571429e-003 |
1.3260417e+002 0.0000000e+000 |
1.3331250e+002 5.7142857e-003 |
1.3402083e+002 1.2857143e-002 |
1.3472917e+002 7.1428571e-003 |
1.3543750e+002 0.0000000e+000 |
1.3614583e+002 5.7142857e-003 |
1.3685417e+002 8.5714286e-003 |
1.3756250e+002 0.0000000e+000 |
1.3827083e+002 1.1428571e-002 |
1.3897917e+002 8.5714286e-003 |
1.3968750e+002 7.1428571e-003 |
1.4039583e+002 0.0000000e+000 |
1.4110417e+002 8.5714286e-003 |
1.4181250e+002 1.4285714e-003 |
1.4252083e+002 0.0000000e+000 |
1.4322917e+002 2.8571429e-003 |
1.4393750e+002 1.4285714e-003 |
1.4464583e+002 2.8571429e-003 |
1.4535417e+002 0.0000000e+000 |
1.4606250e+002 1.4285714e-003 |
1.4677083e+002 1.4285714e-003 |
1.4747917e+002 0.0000000e+000 |
1.4818750e+002 1.4285714e-003 |
1.4889583e+002 0.0000000e+000 |
1.4960417e+002 0.0000000e+000 |
1.5031250e+002 1.4285714e-003 |
1.5102083e+002 2.8571429e-003 |
1.5172917e+002 1.0000000e-002 |
1.5243750e+002 0.0000000e+000 |
1.5314583e+002 1.2857143e-002 |
1.5385417e+002 1.4285714e-002 |
1.5456250e+002 0.0000000e+000 |
1.5527083e+002 2.1428571e-002 |
1.5597917e+002 3.2857143e-002 |
1.5668750e+002 3.4285714e-002 |
1.5739583e+002 0.0000000e+000 |
1.5810417e+002 5.1428571e-002 |
1.5881250e+002 5.2857143e-002 |
1.5952083e+002 0.0000000e+000 |
1.6022917e+002 6.5714286e-002 |
1.6093750e+002 6.5714286e-002 |
1.6164583e+002 6.1428571e-002 |
1.6235417e+002 0.0000000e+000 |
1.6306250e+002 8.8571429e-002 |
1.6377083e+002 5.8571429e-002 |
1.6447917e+002 0.0000000e+000 |
1.6518750e+002 6.5714286e-002 |
1.6589583e+002 6.5714286e-002 |
1.6660417e+002 0.0000000e+000 |
1.6731250e+002 4.5714286e-002 |
1.6802083e+002 3.7142857e-002 |
1.6872917e+002 2.5714286e-002 |
1.6943750e+002 0.0000000e+000 |
1.7014583e+002 2.4285714e-002 |
1.7085417e+002 1.1428571e-002 |
1.7156250e+002 0.0000000e+000 |
1.7227083e+002 1.4285714e-002 |
1.7297917e+002 8.5714286e-003 |
1.7368750e+002 4.2857143e-003 |
1.7439583e+002 0.0000000e+000 |
1.7510417e+002 1.0000000e-002 |
1.7581250e+002 1.4285714e-003 |
1.7652083e+002 0.0000000e+000 |
1.7722917e+002 0.0000000e+000 |
1.7793750e+002 4.2857143e-003 |
1.7864583e+002 0.0000000e+000 |
1.7935417e+002 0.0000000e+000 |
1.8006250e+002 1.4285714e-003 |
1.8077083e+002 1.4285714e-003 |
1.8147917e+002 0.0000000e+000 |
1.8218750e+002 0.0000000e+000 |
1.8289583e+002 0.0000000e+000 |
1.8360417e+002 0.0000000e+000 |
1.8431250e+002 0.0000000e+000 |
1.8502083e+002 0.0000000e+000 |
1.8572917e+002 0.0000000e+000 |
1.8643750e+002 0.0000000e+000 |
1.8714583e+002 0.0000000e+000 |
1.8785417e+002 0.0000000e+000 |
1.8856250e+002 0.0000000e+000 |
1.8927083e+002 0.0000000e+000 |
1.8997917e+002 0.0000000e+000 |
1.9068750e+002 0.0000000e+000 |
1.9139583e+002 0.0000000e+000 |
1.9210417e+002 0.0000000e+000 |
1.9281250e+002 0.0000000e+000 |
1.9352083e+002 0.0000000e+000 |
1.9422917e+002 0.0000000e+000 |
1.9493750e+002 1.4285714e-003 |
1.9564583e+002 0.0000000e+000 |
1.9635417e+002 0.0000000e+000 |
1.9706250e+002 0.0000000e+000 |
1.9777083e+002 0.0000000e+000 |
1.9847917e+002 0.0000000e+000 |
1.9918750e+002 0.0000000e+000 |
1.9989583e+002 2.8571429e-003 |
2.0060417e+002 0.0000000e+000 |
2.0131250e+002 1.4285714e-003 |
2.0202083e+002 0.0000000e+000 |
2.0272917e+002 0.0000000e+000 |
2.0343750e+002 0.0000000e+000 |
2.0414583e+002 0.0000000e+000 |
2.0485417e+002 0.0000000e+000 |
2.0556250e+002 0.0000000e+000 |
2.0627083e+002 0.0000000e+000 |
2.0697917e+002 0.0000000e+000 |
2.0768750e+002 1.4285714e-003 |
2.0839583e+002 0.0000000e+000 |
2.0910417e+002 0.0000000e+000 |
2.0981250e+002 0.0000000e+000 |
2.1052083e+002 0.0000000e+000 |
2.1122917e+002 0.0000000e+000 |
2.1193750e+002 1.4285714e-003 |
2.1264583e+002 1.4285714e-003 |
/unsupported/trunk/pendulum/DISTRIB/TRACK |
---|
0,0 → 1,120 |
1.6983167e+000 2.9585799e-003 |
1.7429500e+000 4.4378698e-003 |
1.7875833e+000 0.0000000e+000 |
1.8322167e+000 4.4378698e-003 |
1.8768500e+000 1.4792899e-003 |
1.9214833e+000 1.4792899e-003 |
1.9661167e+000 7.3964497e-003 |
2.0107500e+000 1.0355030e-002 |
2.0553833e+000 1.3313609e-002 |
2.1000167e+000 1.1834320e-002 |
2.1446500e+000 1.0355030e-002 |
2.1892833e+000 1.4792899e-003 |
2.2339167e+000 2.9585799e-003 |
2.2785500e+000 1.4792899e-003 |
2.3231833e+000 0.0000000e+000 |
2.3678167e+000 1.4792899e-003 |
2.4124500e+000 5.9171598e-003 |
2.4570833e+000 7.3964497e-003 |
2.5017167e+000 1.4792899e-002 |
2.5463500e+000 1.6272189e-002 |
2.5909833e+000 1.3313609e-002 |
2.6356167e+000 2.2189349e-002 |
2.6802500e+000 1.1834320e-002 |
2.7248833e+000 3.9940828e-002 |
2.7695167e+000 2.9585799e-002 |
2.8141500e+000 2.3668639e-002 |
2.8587833e+000 1.7751479e-002 |
2.9034167e+000 2.0710059e-002 |
2.9480500e+000 2.0710059e-002 |
2.9926833e+000 2.9585799e-003 |
3.0373167e+000 1.3313609e-002 |
3.0819500e+000 1.0355030e-002 |
3.1265833e+000 1.1834320e-002 |
3.1712167e+000 8.8757396e-003 |
3.2158500e+000 1.1834320e-002 |
3.2604833e+000 7.3964497e-003 |
3.3051167e+000 1.4792899e-002 |
3.3497500e+000 1.0355030e-002 |
3.3943833e+000 1.0355030e-002 |
3.4390167e+000 1.0355030e-002 |
3.4836500e+000 7.3964497e-003 |
3.5282833e+000 7.3964497e-003 |
3.5729167e+000 8.8757396e-003 |
3.6175500e+000 5.9171598e-003 |
3.6621833e+000 2.9585799e-003 |
3.7068167e+000 7.3964497e-003 |
3.7514500e+000 1.4792899e-002 |
3.7960833e+000 1.3313609e-002 |
3.8407167e+000 2.5147929e-002 |
3.8853500e+000 1.6272189e-002 |
3.9299833e+000 2.0710059e-002 |
3.9746167e+000 2.5147929e-002 |
4.0192500e+000 3.2544379e-002 |
4.0638833e+000 3.5502959e-002 |
4.1085167e+000 4.8816568e-002 |
4.1531500e+000 4.2899408e-002 |
4.1977833e+000 3.8461538e-002 |
4.2424167e+000 3.8461538e-002 |
4.2870500e+000 3.8461538e-002 |
4.3316833e+000 2.9585799e-002 |
4.3763167e+000 1.7751479e-002 |
4.4209500e+000 1.9230769e-002 |
4.4655833e+000 2.9585799e-003 |
4.5102167e+000 2.9585799e-003 |
4.5548500e+000 5.9171598e-003 |
4.5994833e+000 8.8757396e-003 |
4.6441167e+000 1.4792899e-003 |
4.6887500e+000 1.4792899e-003 |
4.7333833e+000 0.0000000e+000 |
4.7780167e+000 0.0000000e+000 |
4.8226500e+000 1.4792899e-003 |
4.8672833e+000 0.0000000e+000 |
4.9119167e+000 1.4792899e-003 |
4.9565500e+000 0.0000000e+000 |
5.0011833e+000 2.9585799e-003 |
5.0458167e+000 1.4792899e-003 |
5.0904500e+000 1.4792899e-003 |
5.1350833e+000 1.4792899e-003 |
5.1797167e+000 0.0000000e+000 |
5.2243500e+000 0.0000000e+000 |
5.2689833e+000 0.0000000e+000 |
5.3136167e+000 1.4792899e-003 |
5.3582500e+000 0.0000000e+000 |
5.4028833e+000 0.0000000e+000 |
5.4475167e+000 0.0000000e+000 |
5.4921500e+000 0.0000000e+000 |
5.5367833e+000 0.0000000e+000 |
5.5814167e+000 0.0000000e+000 |
5.6260500e+000 0.0000000e+000 |
5.6706833e+000 0.0000000e+000 |
5.7153167e+000 0.0000000e+000 |
5.7599500e+000 2.9585799e-003 |
5.8045833e+000 1.4792899e-003 |
5.8492167e+000 0.0000000e+000 |
5.8938500e+000 0.0000000e+000 |
5.9384833e+000 0.0000000e+000 |
5.9831167e+000 0.0000000e+000 |
6.0277500e+000 1.4792899e-003 |
6.0723833e+000 0.0000000e+000 |
6.1170167e+000 0.0000000e+000 |
6.1616500e+000 0.0000000e+000 |
6.2062833e+000 0.0000000e+000 |
6.2509167e+000 0.0000000e+000 |
6.2955500e+000 0.0000000e+000 |
6.3401833e+000 0.0000000e+000 |
6.3848167e+000 2.9585799e-003 |
6.4294500e+000 0.0000000e+000 |
6.4740833e+000 1.4792899e-003 |
6.5187167e+000 0.0000000e+000 |
6.5633500e+000 0.0000000e+000 |
6.6079833e+000 0.0000000e+000 |
6.6526167e+000 0.0000000e+000 |
6.6972500e+000 0.0000000e+000 |
6.7418833e+000 0.0000000e+000 |
6.7865167e+000 5.9171598e-003 |
6.8311500e+000 8.8757396e-003 |
6.8757833e+000 4.4378698e-003 |
6.9204167e+000 2.9585799e-003 |
6.9650500e+000 0.0000000e+000 |
7.0096833e+000 2.9585799e-003 |
/unsupported/trunk/pendulum/DISTRIB/EVAL |
---|
0,0 → 1,120 |
1.2203575e+001 1.4285714e-003 |
1.2318725e+001 0.0000000e+000 |
1.2433875e+001 1.4285714e-003 |
1.2549025e+001 0.0000000e+000 |
1.2664175e+001 0.0000000e+000 |
1.2779325e+001 2.8571429e-003 |
1.2894475e+001 4.2857143e-003 |
1.3009625e+001 2.2857143e-002 |
1.3124775e+001 1.1428571e-002 |
1.3239925e+001 5.7142857e-003 |
1.3355075e+001 1.4285714e-003 |
1.3470225e+001 1.4285714e-003 |
1.3585375e+001 1.4285714e-003 |
1.3700525e+001 1.4285714e-003 |
1.3815675e+001 0.0000000e+000 |
1.3930825e+001 1.4285714e-003 |
1.4045975e+001 2.8571429e-003 |
1.4161125e+001 1.4285714e-003 |
1.4276275e+001 1.5714286e-002 |
1.4391425e+001 3.0000000e-002 |
1.4506575e+001 4.4285714e-002 |
1.4621725e+001 3.8571429e-002 |
1.4736875e+001 6.1428571e-002 |
1.4852025e+001 5.8571429e-002 |
1.4967175e+001 8.8571429e-002 |
1.5082325e+001 1.0857143e-001 |
1.5197475e+001 9.1428571e-002 |
1.5312625e+001 1.2000000e-001 |
1.5427775e+001 1.5142857e-001 |
1.5542925e+001 9.5714286e-002 |
1.5658075e+001 3.1428571e-002 |
1.5773225e+001 0.0000000e+000 |
1.5888375e+001 0.0000000e+000 |
1.6003525e+001 0.0000000e+000 |
1.6118675e+001 0.0000000e+000 |
1.6233825e+001 0.0000000e+000 |
1.6348975e+001 0.0000000e+000 |
1.6464125e+001 0.0000000e+000 |
1.6579275e+001 0.0000000e+000 |
1.6694425e+001 0.0000000e+000 |
1.6809575e+001 0.0000000e+000 |
1.6924725e+001 0.0000000e+000 |
1.7039875e+001 0.0000000e+000 |
1.7155025e+001 0.0000000e+000 |
1.7270175e+001 0.0000000e+000 |
1.7385325e+001 0.0000000e+000 |
1.7500475e+001 0.0000000e+000 |
1.7615625e+001 0.0000000e+000 |
1.7730775e+001 1.4285714e-003 |
1.7845925e+001 0.0000000e+000 |
1.7961075e+001 0.0000000e+000 |
1.8076225e+001 0.0000000e+000 |
1.8191375e+001 0.0000000e+000 |
1.8306525e+001 0.0000000e+000 |
1.8421675e+001 0.0000000e+000 |
1.8536825e+001 0.0000000e+000 |
1.8651975e+001 0.0000000e+000 |
1.8767125e+001 0.0000000e+000 |
1.8882275e+001 0.0000000e+000 |
1.8997425e+001 0.0000000e+000 |
1.9112575e+001 0.0000000e+000 |
1.9227725e+001 0.0000000e+000 |
1.9342875e+001 0.0000000e+000 |
1.9458025e+001 0.0000000e+000 |
1.9573175e+001 0.0000000e+000 |
1.9688325e+001 0.0000000e+000 |
1.9803475e+001 0.0000000e+000 |
1.9918625e+001 0.0000000e+000 |
2.0033775e+001 0.0000000e+000 |
2.0148925e+001 0.0000000e+000 |
2.0264075e+001 0.0000000e+000 |
2.0379225e+001 0.0000000e+000 |
2.0494375e+001 0.0000000e+000 |
2.0609525e+001 0.0000000e+000 |
2.0724675e+001 0.0000000e+000 |
2.0839825e+001 0.0000000e+000 |
2.0954975e+001 0.0000000e+000 |
2.1070125e+001 0.0000000e+000 |
2.1185275e+001 0.0000000e+000 |
2.1300425e+001 0.0000000e+000 |
2.1415575e+001 0.0000000e+000 |
2.1530725e+001 0.0000000e+000 |
2.1645875e+001 0.0000000e+000 |
2.1761025e+001 0.0000000e+000 |
2.1876175e+001 0.0000000e+000 |
2.1991325e+001 0.0000000e+000 |
2.2106475e+001 0.0000000e+000 |
2.2221625e+001 0.0000000e+000 |
2.2336775e+001 0.0000000e+000 |
2.2451925e+001 0.0000000e+000 |
2.2567075e+001 0.0000000e+000 |
2.2682225e+001 0.0000000e+000 |
2.2797375e+001 0.0000000e+000 |
2.2912525e+001 0.0000000e+000 |
2.3027675e+001 0.0000000e+000 |
2.3142825e+001 0.0000000e+000 |
2.3257975e+001 0.0000000e+000 |
2.3373125e+001 0.0000000e+000 |
2.3488275e+001 0.0000000e+000 |
2.3603425e+001 0.0000000e+000 |
2.3718575e+001 0.0000000e+000 |
2.3833725e+001 0.0000000e+000 |
2.3948875e+001 0.0000000e+000 |
2.4064025e+001 0.0000000e+000 |
2.4179175e+001 0.0000000e+000 |
2.4294325e+001 0.0000000e+000 |
2.4409475e+001 0.0000000e+000 |
2.4524625e+001 0.0000000e+000 |
2.4639775e+001 0.0000000e+000 |
2.4754925e+001 0.0000000e+000 |
2.4870075e+001 0.0000000e+000 |
2.4985225e+001 0.0000000e+000 |
2.5100375e+001 0.0000000e+000 |
2.5215525e+001 0.0000000e+000 |
2.5330675e+001 0.0000000e+000 |
2.5445825e+001 0.0000000e+000 |
2.5560975e+001 0.0000000e+000 |
2.5676125e+001 0.0000000e+000 |
2.5791275e+001 0.0000000e+000 |
2.5906425e+001 1.4285714e-003 |
/unsupported/trunk/pendulum/DISTRIB/CAMERA |
---|
0,0 → 1,120 |
1.3494042e+001 2.8571429e-003 |
1.3592125e+001 0.0000000e+000 |
1.3690208e+001 2.8571429e-003 |
1.3788292e+001 0.0000000e+000 |
1.3886375e+001 1.4285714e-003 |
1.3984458e+001 0.0000000e+000 |
1.4082542e+001 0.0000000e+000 |
1.4180625e+001 0.0000000e+000 |
1.4278708e+001 0.0000000e+000 |
1.4376792e+001 0.0000000e+000 |
1.4474875e+001 0.0000000e+000 |
1.4572958e+001 4.2857143e-003 |
1.4671042e+001 0.0000000e+000 |
1.4769125e+001 2.8571429e-003 |
1.4867208e+001 1.4285714e-003 |
1.4965292e+001 0.0000000e+000 |
1.5063375e+001 4.2857143e-003 |
1.5161458e+001 1.4285714e-003 |
1.5259542e+001 0.0000000e+000 |
1.5357625e+001 0.0000000e+000 |
1.5455708e+001 1.4285714e-003 |
1.5553792e+001 1.4285714e-003 |
1.5651875e+001 1.4285714e-003 |
1.5749958e+001 1.4285714e-003 |
1.5848042e+001 4.2857143e-003 |
1.5946125e+001 0.0000000e+000 |
1.6044208e+001 2.8571429e-003 |
1.6142292e+001 4.2857143e-003 |
1.6240375e+001 1.4285714e-003 |
1.6338458e+001 5.7142857e-003 |
1.6436542e+001 8.5714286e-003 |
1.6534625e+001 2.2857143e-002 |
1.6632708e+001 3.0000000e-002 |
1.6730792e+001 1.8571429e-002 |
1.6828875e+001 1.7142857e-002 |
1.6926958e+001 4.0000000e-002 |
1.7025042e+001 5.7142857e-002 |
1.7123125e+001 4.5714286e-002 |
1.7221208e+001 6.0000000e-002 |
1.7319292e+001 6.8571429e-002 |
1.7417375e+001 6.7142857e-002 |
1.7515458e+001 4.4285714e-002 |
1.7613542e+001 5.0000000e-002 |
1.7711625e+001 7.8571429e-002 |
1.7809708e+001 1.6142857e-001 |
1.7907792e+001 1.2142857e-001 |
1.8005875e+001 4.7142857e-002 |
1.8103958e+001 1.1428571e-002 |
1.8202042e+001 1.4285714e-003 |
1.8300125e+001 0.0000000e+000 |
1.8398208e+001 0.0000000e+000 |
1.8496292e+001 1.4285714e-003 |
1.8594375e+001 0.0000000e+000 |
1.8692458e+001 0.0000000e+000 |
1.8790542e+001 0.0000000e+000 |
1.8888625e+001 0.0000000e+000 |
1.8986708e+001 0.0000000e+000 |
1.9084792e+001 0.0000000e+000 |
1.9182875e+001 0.0000000e+000 |
1.9280958e+001 0.0000000e+000 |
1.9379042e+001 0.0000000e+000 |
1.9477125e+001 0.0000000e+000 |
1.9575208e+001 0.0000000e+000 |
1.9673292e+001 0.0000000e+000 |
1.9771375e+001 0.0000000e+000 |
1.9869458e+001 0.0000000e+000 |
1.9967542e+001 0.0000000e+000 |
2.0065625e+001 0.0000000e+000 |
2.0163708e+001 0.0000000e+000 |
2.0261792e+001 0.0000000e+000 |
2.0359875e+001 0.0000000e+000 |
2.0457958e+001 0.0000000e+000 |
2.0556042e+001 0.0000000e+000 |
2.0654125e+001 0.0000000e+000 |
2.0752208e+001 0.0000000e+000 |
2.0850292e+001 0.0000000e+000 |
2.0948375e+001 0.0000000e+000 |
2.1046458e+001 0.0000000e+000 |
2.1144542e+001 0.0000000e+000 |
2.1242625e+001 0.0000000e+000 |
2.1340708e+001 0.0000000e+000 |
2.1438792e+001 0.0000000e+000 |
2.1536875e+001 0.0000000e+000 |
2.1634958e+001 0.0000000e+000 |
2.1733042e+001 0.0000000e+000 |
2.1831125e+001 0.0000000e+000 |
2.1929208e+001 0.0000000e+000 |
2.2027292e+001 0.0000000e+000 |
2.2125375e+001 0.0000000e+000 |
2.2223458e+001 0.0000000e+000 |
2.2321542e+001 0.0000000e+000 |
2.2419625e+001 0.0000000e+000 |
2.2517708e+001 0.0000000e+000 |
2.2615792e+001 0.0000000e+000 |
2.2713875e+001 0.0000000e+000 |
2.2811958e+001 0.0000000e+000 |
2.2910042e+001 0.0000000e+000 |
2.3008125e+001 0.0000000e+000 |
2.3106208e+001 0.0000000e+000 |
2.3204292e+001 0.0000000e+000 |
2.3302375e+001 0.0000000e+000 |
2.3400458e+001 0.0000000e+000 |
2.3498542e+001 0.0000000e+000 |
2.3596625e+001 0.0000000e+000 |
2.3694708e+001 0.0000000e+000 |
2.3792792e+001 0.0000000e+000 |
2.3890875e+001 0.0000000e+000 |
2.3988958e+001 0.0000000e+000 |
2.4087042e+001 0.0000000e+000 |
2.4185125e+001 0.0000000e+000 |
2.4283208e+001 0.0000000e+000 |
2.4381292e+001 0.0000000e+000 |
2.4479375e+001 0.0000000e+000 |
2.4577458e+001 0.0000000e+000 |
2.4675542e+001 0.0000000e+000 |
2.4773625e+001 0.0000000e+000 |
2.4871708e+001 0.0000000e+000 |
2.4969792e+001 0.0000000e+000 |
2.5067875e+001 0.0000000e+000 |
2.5165958e+001 1.4285714e-003 |
/unsupported/trunk/pendulum/DISTRIB/DISEG |
---|
0,0 → 1,120 |
2.2915667e+000 1.7142857e-002 |
2.3747000e+000 2.8571429e-003 |
2.4578333e+000 1.4285714e-002 |
2.5409667e+000 5.1428571e-002 |
2.6241000e+000 5.0000000e-002 |
2.7072333e+000 3.7142857e-002 |
2.7903667e+000 3.4142857e-001 |
2.8735000e+000 2.9857143e-001 |
2.9566333e+000 1.7000000e-001 |
3.0397667e+000 4.2857143e-003 |
3.1229000e+000 0.0000000e+000 |
3.2060333e+000 1.4285714e-003 |
3.2891667e+000 0.0000000e+000 |
3.3723000e+000 0.0000000e+000 |
3.4554333e+000 1.4285714e-003 |
3.5385667e+000 0.0000000e+000 |
3.6217000e+000 1.4285714e-003 |
3.7048333e+000 0.0000000e+000 |
3.7879667e+000 0.0000000e+000 |
3.8711000e+000 0.0000000e+000 |
3.9542333e+000 0.0000000e+000 |
4.0373667e+000 0.0000000e+000 |
4.1205000e+000 0.0000000e+000 |
4.2036333e+000 0.0000000e+000 |
4.2867667e+000 0.0000000e+000 |
4.3699000e+000 0.0000000e+000 |
4.4530333e+000 0.0000000e+000 |
4.5361667e+000 0.0000000e+000 |
4.6193000e+000 0.0000000e+000 |
4.7024333e+000 0.0000000e+000 |
4.7855667e+000 0.0000000e+000 |
4.8687000e+000 0.0000000e+000 |
4.9518333e+000 0.0000000e+000 |
5.0349667e+000 0.0000000e+000 |
5.1181000e+000 0.0000000e+000 |
5.2012333e+000 0.0000000e+000 |
5.2843667e+000 0.0000000e+000 |
5.3675000e+000 0.0000000e+000 |
5.4506333e+000 0.0000000e+000 |
5.5337667e+000 0.0000000e+000 |
5.6169000e+000 0.0000000e+000 |
5.7000333e+000 0.0000000e+000 |
5.7831667e+000 0.0000000e+000 |
5.8663000e+000 0.0000000e+000 |
5.9494333e+000 0.0000000e+000 |
6.0325667e+000 1.4285714e-003 |
6.1157000e+000 0.0000000e+000 |
6.1988333e+000 0.0000000e+000 |
6.2819667e+000 0.0000000e+000 |
6.3651000e+000 0.0000000e+000 |
6.4482333e+000 0.0000000e+000 |
6.5313667e+000 0.0000000e+000 |
6.6145000e+000 0.0000000e+000 |
6.6976333e+000 0.0000000e+000 |
6.7807667e+000 0.0000000e+000 |
6.8639000e+000 0.0000000e+000 |
6.9470333e+000 0.0000000e+000 |
7.0301667e+000 0.0000000e+000 |
7.1133000e+000 0.0000000e+000 |
7.1964333e+000 0.0000000e+000 |
7.2795667e+000 0.0000000e+000 |
7.3627000e+000 0.0000000e+000 |
7.4458333e+000 0.0000000e+000 |
7.5289667e+000 0.0000000e+000 |
7.6121000e+000 0.0000000e+000 |
7.6952333e+000 0.0000000e+000 |
7.7783667e+000 0.0000000e+000 |
7.8615000e+000 1.4285714e-003 |
7.9446333e+000 0.0000000e+000 |
8.0277667e+000 0.0000000e+000 |
8.1109000e+000 0.0000000e+000 |
8.1940333e+000 0.0000000e+000 |
8.2771667e+000 0.0000000e+000 |
8.3603000e+000 0.0000000e+000 |
8.4434333e+000 0.0000000e+000 |
8.5265667e+000 0.0000000e+000 |
8.6097000e+000 0.0000000e+000 |
8.6928333e+000 0.0000000e+000 |
8.7759667e+000 0.0000000e+000 |
8.8591000e+000 0.0000000e+000 |
8.9422333e+000 0.0000000e+000 |
9.0253667e+000 0.0000000e+000 |
9.1085000e+000 0.0000000e+000 |
9.1916333e+000 0.0000000e+000 |
9.2747667e+000 0.0000000e+000 |
9.3579000e+000 0.0000000e+000 |
9.4410333e+000 0.0000000e+000 |
9.5241667e+000 0.0000000e+000 |
9.6073000e+000 0.0000000e+000 |
9.6904333e+000 0.0000000e+000 |
9.7735667e+000 0.0000000e+000 |
9.8567000e+000 0.0000000e+000 |
9.9398333e+000 0.0000000e+000 |
1.0022967e+001 0.0000000e+000 |
1.0106100e+001 1.4285714e-003 |
1.0189233e+001 0.0000000e+000 |
1.0272367e+001 0.0000000e+000 |
1.0355500e+001 0.0000000e+000 |
1.0438633e+001 0.0000000e+000 |
1.0521767e+001 0.0000000e+000 |
1.0604900e+001 0.0000000e+000 |
1.0688033e+001 0.0000000e+000 |
1.0771167e+001 0.0000000e+000 |
1.0854300e+001 0.0000000e+000 |
1.0937433e+001 0.0000000e+000 |
1.1020567e+001 0.0000000e+000 |
1.1103700e+001 0.0000000e+000 |
1.1186833e+001 1.4285714e-003 |
1.1269967e+001 0.0000000e+000 |
1.1353100e+001 0.0000000e+000 |
1.1436233e+001 0.0000000e+000 |
1.1519367e+001 0.0000000e+000 |
1.1602500e+001 0.0000000e+000 |
1.1685633e+001 0.0000000e+000 |
1.1768767e+001 0.0000000e+000 |
1.1851900e+001 0.0000000e+000 |
1.1935033e+001 0.0000000e+000 |
1.2018167e+001 0.0000000e+000 |
1.2101300e+001 1.4285714e-003 |
1.2184433e+001 1.4285714e-003 |
/unsupported/trunk/pendulum/PCLAB.C |
---|
0,0 → 1,131 |
/*==============================================================*/ |
/* LIBRERIA DI GESTIONE DELLA SCHEDA PCL-812 */ |
/* Marco Caccamo, 6-2-2000 */ |
/*==============================================================*/ |
/*--------------------------------------------------------------*/ |
/* Register bit: 7 6 5 4 3 2 1 0 */ |
/*--------------------------------------------------------------*/ |
/* ABUFL D7 D6 D5 D4 D3 D2 D1 D0 */ |
/* ABUFH 0 0 0 DRDY D3 D2 D1 D0 */ |
/*--------------------------------------------------------------*/ |
/* SELEC X X X X C3 C2 C1 C0 */ |
/*--------------------------------------------------------------*/ |
/* CTRLB X X X X X S2 S1 S0 */ |
/*--------------------------------------------------------------*/ |
/* TRIGG X X X X X X X TR */ |
#include <kernel/kern.h> |
#define BASE 0x220 /* indirizzo base BIT */ |
#define ABUFL (BASE + 4) /* low byte for AD/DA (0 - 7) */ |
#define ABUFH (BASE + 5) /* high byte for AD/DA (8 -13) */ |
#define IBUFL (BASE + 6) /* low byte for DIN (0 - 7) */ |
#define IBUFH (BASE + 7) /* high byte for DIN (8 -15) */ |
#define SELEC (BASE + 10) /* select AD channel (0 - 3) */ |
#define CTRLB (BASE + 11) /* control register (0 - 2) */ |
#define TRIGG (BASE + 12) /* A/D trigger control (0) */ |
#define OBUFL (BASE + 13) /* low byte for DOUT (0 - 7) */ |
#define OBUFH (BASE + 14) /* high byte for DOUT (8 -15) */ |
/*--------------------------------------------------------------*/ |
/* AD_CONV(ch) ritorna il valore (in volt) convertito */ |
/* dal canale ch dell'ingresso analogico. */ |
/* Volt range: [-10,10], Resolution: 2.4 mV */ |
/*--------------------------------------------------------------*/ |
float ad_conv(int ch) /* AD channel [0-15] */ |
{ |
int lb, hb; /* low byte, high byte [0,255] */ |
int n; /* converted value [-8192,8191] */ |
float v; /* value in volt [-10,10] */ |
outp(SELEC, ch); /* set AD channel */ |
outp(CTRLB, 1); /* enable software trigger */ |
outp(TRIGG, 1); /* trigger AD converter */ |
do { /* wait conversion */ |
hb = 0xff & inp(ABUFH); /* read high byte */ |
} while ((hb & 0x10) == 16); /* loop if (bit 4 == 1) */ |
lb = 0xff & inp(ABUFL); /* read low byte */ |
n = (hb * 256 + lb); // -4096; //- 2048; /* compose number */ |
//cprintf(); |
v = (20. * (float)n ) / 4096 - 10.; //2048.; /* convert n in volt */ |
return(v); |
} |
/*--------------------------------------------------------------*/ |
/* DA_CONV(float v,int ch) converte in analogico il valore in volt */ |
/* passato come parametro sul canale ch. */ |
/* Volt range: [0,5], Resolution: 1.2 mV */ |
/* return(-1) se non viene eseguita la conversione */ |
/* altrimenti return(0) */ |
/*--------------------------------------------------------------*/ |
int da_conv(float v, int ch) /* value (in volt) to convert */ |
{ |
int lb, hb; /* low byte, high byte */ |
float x; /* value to convert */ |
if (v > 5 || v < 0) |
return(-1); |
else{ |
x = ((v / 5.) * 4095.); /* compose number */ |
hb = (int) x / 256; /* compute high byte */ |
lb = (int) x % 256; /* compute low byte */ |
if(ch == 2) { |
outp(IBUFL, lb); /* write lb in IBUFL */ |
outp(IBUFH, hb); /* write hb in IBUFL */ |
} |
else if(ch == 1) { |
outp(ABUFL, lb); /* write lb in ABUFL */ |
outp(ABUFH, hb); /* write hb in ABUFH */ |
} |
else return(-1); |
return(0); |
} |
} |
/*--------------------------------------------------------------*/ |
/* PAR_IN() ritorna il valore letto sui 16 bit */ |
/* della porta parallela di ingresso. */ |
/*--------------------------------------------------------------*/ |
int par_in() |
{ |
int lb, hb; /* low byte, high byte */ |
int n; /* value on 16 bit */ |
lb = 0xff & inp(IBUFL); /* read low byte */ |
hb = 0xff & inp(IBUFH); /* read high byte */ |
n = hb * 256 + lb; /* compose number */ |
return(n); |
} |
/*--------------------------------------------------------------*/ |
/* PAR_OUT(n) scrive il valore n sui 16 bit */ |
/* della porta parallela di uscita. */ |
/*--------------------------------------------------------------*/ |
void par_out(n) |
int n; /* value to write */ |
{ |
int lb, hb; /* low byte, high byte */ |
hb = n / 256; /* extract high byte */ |
lb = n % 256; /* extract low byte */ |
outp(OBUFL,lb); /* write low byte */ |
outp(OBUFH,hb); /* write high byte */ |
} |
/*--------------------------------------------------------------*/ |
/unsupported/trunk/pendulum/COEF.H |
---|
0,0 → 1,20 |
/*--------------------------------------------------------------*/ |
/* File: coef.h */ |
/* Definisce i coefficienti del sistema in termini di variabili */ |
/* di stato. I valori sono stati ottenuti mediante il file */ |
/* MATLAB contif.m con un tempo di campionamento pari a 100 ms */ |
/*--------------------------------------------------------------*/ |
#define AA -2.7528 |
#define BB -10.9526 |
#define CC 0.0043 |
#define DD 28.5812 |
#define EE 24.9179 |
#define FF -0.0441 |
#define GG 1.9432 |
#define HH -4.4385 |
#define DELTA 0.030 |
#define KK1 -29.2616 |
#define KK2 -5.5492 |
#define KK3 -7.1996 |
#define KK4 -9.8654 |
/*--------------------------------------------------------------*/ |
/unsupported/trunk/pendulum/JETCON.C |
---|
0,0 → 1,205 |
#include "kernel/kern.h" |
#include "demo.h" |
extern int white, gray, red, green, blue; |
TASK jetdummy_task(void *arg) |
{ |
TIME now_dummy, last_dummy, diff_dummy, slice; |
struct timespec now, last, diff; |
int x = 0; |
int height; |
NULL_TIMESPEC(&last); |
last_dummy = 0; |
for (;;) { |
task_nopreempt(); |
jet_getstat(DUMMY_PID, NULL, NULL, NULL, &now_dummy); |
sys_gettime(&now); |
task_preempt(); |
SUBTIMESPEC(&now, &last, &diff); |
slice = diff.tv_sec * 1000000 + diff.tv_nsec/1000; |
diff_dummy = now_dummy - last_dummy; |
height = (int)(JET_DUMMY_HEIGHT*((float)diff_dummy)/((float)slice)); |
TIMESPEC_ASSIGN(&last, &now); |
last_dummy = now_dummy; |
mutex_lock(&mutex); |
grx_line(JET_DUMMY_X+x,JET_DUMMY_Y, |
JET_DUMMY_X+x,JET_DUMMY_Y+height ,BLACK); |
grx_line(JET_DUMMY_X+x,JET_DUMMY_Y+height, |
JET_DUMMY_X+x,JET_DUMMY_Y+JET_DUMMY_HEIGHT,white); |
grx_line(JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y, |
JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y+JET_DUMMY_HEIGHT,white); |
mutex_unlock(&mutex); |
x = (x+1)%JET_DUMMY_WIDTH; |
task_endcycle(); |
} |
} |
TASK jetctrl_task(void *arg) |
{ |
char st[50]; |
TIME sum, max; |
int n; |
PID i; |
int printed = 0; |
for (;;) { |
for (i=2, printed=0; i<MAX_PROC && printed<JET_NTASK; i++) { |
if (jet_getstat(i, &sum, &max, &n, NULL) != -1) { |
if (!n) n=1; |
mutex_lock(&mutex); |
sprintf(st,"%6d %6d %10s", (int)sum/n,(int)max, proc_table[i].name); |
grx_text(st, 354, JET_Y_NAME+16+printed*10, green, BLACK); |
mutex_unlock(&mutex); |
printed++; |
} |
} |
while (printed<JET_NTASK) { |
mutex_lock(&mutex); |
grx_text(" ", |
354, JET_Y_NAME+16+printed*10, gray, BLACK); |
mutex_unlock(&mutex); |
printed++; |
} |
task_endcycle(); |
} |
} |
TASK jetslide_task(void *arg) |
{ |
TIME sum, curr, max; |
TIME total[JET_NTASK]; |
int slides[JET_NTASK]; |
PID i; |
int printed = 0; |
for (;;) { |
// Fill the total array in a nonpreemptive section |
task_nopreempt(); |
for (i=2, printed=0; i<MAX_PROC && printed<JET_NTASK; i++) { |
if (jet_getstat(i, &sum, NULL, NULL, &curr) != -1) { |
total[printed] = sum+curr; |
printed++; |
} |
} |
task_preempt(); |
while (printed < JET_NTASK) |
total[printed++] = 0; |
// Compute the Max elapsed time |
max = 0; |
for (i=0; i<JET_NTASK; i++) |
if (total[i] > max) max = total[i]; |
if (!max) max = 1; |
// Compute the slides width |
for (i=0; i<JET_NTASK; i++) |
slides[i] = (int)( (((float)total[i])/max) * JET_SLIDE_WIDTH); |
// print the data |
mutex_lock(&mutex); |
for (i=0; i<JET_NTASK; i++) { |
grx_box(JET_SLIDE_X, JET_Y_NAME+16+i*10, \ |
JET_SLIDE_X+slides[i], JET_Y_NAME+23+i*10, blue); |
grx_box(JET_SLIDE_X+slides[i], JET_Y_NAME+16+i*10, \ |
JET_SLIDE_X+JET_SLIDE_WIDTH, JET_Y_NAME+23+i*10, BLACK); |
} |
while (i<JET_NTASK) { |
grx_box(JET_SLIDE_X, JET_Y_NAME+16+i*10, \ |
JET_SLIDE_X+JET_SLIDE_WIDTH, JET_Y_NAME+20+i*10, BLACK); |
i++; |
} |
mutex_unlock(&mutex); |
task_endcycle(); |
} |
} |
void scenario_jetcontrol(void) |
{ mutex_lock(&mutex); |
grx_rect(10,JET_DUMMY_Y-30, JET_DUMMY_X+600,JET_DUMMY_Y+70,red); |
grx_text("System load" , JET_DUMMY_X+36 ,JET_DUMMY_Y-16 , green, BLACK); |
grx_text(" Mean Max Name Slide",354 ,JET_Y_NAME, green,BLACK); |
grx_rect(JET_DUMMY_X-1, JET_DUMMY_Y-1, JET_DUMMY_X+JET_DUMMY_WIDTH, JET_DUMMY_Y+JET_DUMMY_HEIGHT+1, gray); |
grx_text("100%", JET_DUMMY_X-40, JET_DUMMY_Y, green, BLACK); |
grx_text(" 0%", JET_DUMMY_X-40, JET_DUMMY_Y+JET_DUMMY_HEIGHT-8,green,BLACK); |
grx_line(JET_DUMMY_X-1, JET_DUMMY_Y, JET_DUMMY_X-5, JET_DUMMY_Y, gray); |
grx_line(JET_DUMMY_X-1, JET_DUMMY_Y+JET_DUMMY_HEIGHT, JET_DUMMY_X-5, JET_DUMMY_Y+JET_DUMMY_HEIGHT, gray); |
mutex_unlock(&mutex); |
} |
void init_jetcontrol(void) |
{ |
SOFT_TASK_MODEL m3, m4, m5; |
PID p3, p4, p5; |
soft_task_default_model(m3); |
soft_task_def_level(m3,1); |
soft_task_def_period(m3, PERIOD_JETCTRL); |
soft_task_def_met(m3, WCET_JETCTRL); |
soft_task_def_ctrl_jet(m3); |
soft_task_def_group(m3, 1); |
p3 = task_create("jctrl", jetctrl_task, &m3, NULL); |
if (p3 == -1) { |
grx_close(); |
perror("FFTPlay: Could not create task <jetctrl>\n"); |
ll_abort(54); |
sys_end(); |
} |
soft_task_default_model(m4); |
soft_task_def_level(m4,1); |
soft_task_def_period(m4, PERIOD_JETDUMMY); |
soft_task_def_met(m4, WCET_JETDUMMY); |
soft_task_def_group(m4, 1); |
soft_task_def_usemath(m4); |
soft_task_def_ctrl_jet(m4); |
p4 = task_create("jdmy", jetdummy_task, &m4, NULL); |
if (p4 == -1) { |
grx_close(); |
perror("FFTPlay: Could not create task <jetdummy>\n"); |
ll_abort(54); |
sys_end(); |
} |
soft_task_default_model(m5); |
soft_task_def_level(m5,1); |
soft_task_def_period(m5, PERIOD_JETSLIDE); |
soft_task_def_met(m5, WCET_JETSLIDE); |
soft_task_def_group(m5, 1); |
soft_task_def_usemath(m5); |
soft_task_def_ctrl_jet(m5); |
p5 = task_create("jsli", jetslide_task, &m5, NULL); |
if (p5 == -1) { |
grx_close(); |
perror("FFTPlay: Could not create task <jetslide>\n"); |
ll_abort(54); |
sys_end(); |
} |
} |
/unsupported/trunk/pendulum/XXX.GDT |
---|
0,0 → 1,28 |