Rev 1085 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* (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: jetctrl.c,v 1.1.1.1 2002-09-02 09:37:44 pj Exp $
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2002-09-02 09:37:44 $
------------
**/
/*
* 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
*
*/
/*
* this file is directly derived from the demos/jumpball/jetctrl.c .
* I just added this controls to check when the system will become overloaded
*/
#define WCET_JETDUMMY 200
#define PERIOD_JETDUMMY 100000
#define DUMMY_PID 1
#define JET_DUMMY_WIDTH (CMD_WIDTH-370)
#define JET_DUMMY_HEIGHT (CMD_HEIGHT-40)
/* the point (x, y) is the top left corner */
#define JET_DUMMY_X (TRACK_X1+360)
#define JET_DUMMY_Y (TRACK_Y2+32)
// from jetdummy in the auto demo
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
/* Track dimensions */
#define TRACK_WIDTH 500
#define TRACK_HEIGHT 500
/* Track position */
#define TRACK_X1 0
#define TRACK_Y1 0
#define TRACK_X2 TRACK_X1+TRACK_WIDTH-1
#define TRACK_Y2 TRACK_Y1+TRACK_HEIGHT-1
#define CMD_WIDTH TRACK_WIDTH
#define CMD_HEIGHT (SCREEN_HEIGHT-TRACK_HEIGHT-3)
// JetControl
#include "kernel/func.h"
#include "drivers/glib.h"
/* useful colors... */
int white
;
int black
;
int red
;
int lightgray
;
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
;
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
,255);
x
= (x
+1)%JET_DUMMY_WIDTH
;
task_endcycle
();
}
}
void init_jetcontrol
(void)
{
SOFT_TASK_MODEL m4
;
PID p4
;
/* useful colors ... */
white
= rgb16
(255,255,255);
black
= rgb16
(0,0,0);
red
= rgb16
(255,0,0);
lightgray
= rgb16
(128,128,128);
/* scenario */
grx_text
("System load",
JET_DUMMY_X
+8, JET_DUMMY_Y
-10, lightgray
, black
);
grx_rect
(JET_DUMMY_X
-1, JET_DUMMY_Y
-1,
JET_DUMMY_X
+JET_DUMMY_WIDTH
, JET_DUMMY_Y
+JET_DUMMY_HEIGHT
+1, lightgray
);
grx_text
("100%", JET_DUMMY_X
-40, JET_DUMMY_Y
, lightgray
, black
);
grx_text
(" 0%", JET_DUMMY_X
-40, JET_DUMMY_Y
+JET_DUMMY_HEIGHT
-8, lightgray
, black
);
grx_line
(JET_DUMMY_X
-1, JET_DUMMY_Y
, JET_DUMMY_X
-5, JET_DUMMY_Y
, lightgray
);
grx_line
(JET_DUMMY_X
-1, JET_DUMMY_Y
+JET_DUMMY_HEIGHT
, JET_DUMMY_X
-5, JET_DUMMY_Y
+JET_DUMMY_HEIGHT
, lightgray
);
/* jetdummy task */
soft_task_default_model
(m4
);
soft_task_def_period
(m4
, PERIOD_JETDUMMY
);
soft_task_def_met
(m4
, WCET_JETDUMMY
);
soft_task_def_usemath
(m4
);
p4
= task_create
("jdmy", jetdummy_task
, &m4
, NULL
);
if (p4
== -1) {
grx_close
();
perror("Could not create task <jetdummy>");
sys_end
();
}
task_activate
(p4
);
}