Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1394 → Rev 1395

/demos/trunk/chimera/chimera.c
11,98 → 11,86
*/
 
#include "chimera.h"
#include <FTrace_chunk.h>
#include <FTrace_udp.h>
#include <tracer.h>
 
void my_close(void *arg)
int a;
 
void program_key_end(KEY_EVT* e)
{
 
int i;
TIME tmp;
 
end_send();
 
FTrace_disable();
 
FTrace_OSD_init_udp(1, "192.168.82.43", "192.168.82.20");
 
FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
 
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);
}
 
sys_end();
 
}
 
void action_stand_up(void) {
static struct action_event e[20];
int i = 0;
struct action_event e;
int event;
status.power = 1;
 
kern_gettime(&(e[i].time));
ADDUSEC2TIMESPEC( 5000000,&(e[i].time));
kern_gettime(&(e.time));
ADDUSEC2TIMESPEC(5000000,&(e.time));
e[i].type = EVT_SET_MASK_LEG_ANGLE;
e[i].mask = 0x3F;
e[i].ang.a = 0 * 3600;
e[i].ang.b = 70 * 3600;
e[i].ang.c = 0;
e[i].pwm = 7;
e.type = EVT_SET_MASK_LEG_ANGLE;
e.mask = 0x3F;
e.ang.a = 0 * 3600;
e.ang.b = 70 * 3600;
e.ang.c = 0;
e.pwm = 7;
insert_action_event(&(e[i]));
kern_gettime(&(e[i+1].time));
ADDUSEC2TIMESPEC( 6000000,&(e[i+1].time));
e[i+1].type = EVT_SET_MASK_LEG_ANGLE;
e[i+1].mask = 0x3F;
e[i+1].ang.a = 90 * 3600;
e[i+1].ang.b = 70 * 3600;
e[i+1].ang.c = 0;
e[i+1].pwm = 7;
insert_action_event(&(e[i+1]));
event = insert_action_event(&(e));
 
kern_gettime(&(e[i+2].time));
ADDUSEC2TIMESPEC( 7000000,&(e[i+2].time));
e[i+2].type = EVT_SET_MASK_LEG_ANGLE;
e[i+2].mask = 0x3F;
e[i+2].ang.a = 90 * 3600;
e[i+2].ang.b = -50 * 3600;
e[i+2].ang.c = 0;
e[i+2].pwm = 7;
insert_action_event(&(e[i+2]));
ADDUSEC2TIMESPEC(1000000,&(e.time));
 
kern_gettime(&(e[i+3].time));
ADDUSEC2TIMESPEC( 8000000,&(e[i+3].time));
e.type = EVT_SET_MASK_LEG_ANGLE;
e.mask = 0x3F;
e.ang.a = 0 * 3600;
e.ang.b = 0 * 3600;
e.ang.c = 0;
e.pwm = 7;
e[i+3].type = EVT_SET_MASK_LEG_ANGLE;
e[i+3].mask = 0x3F;
e[i+3].ang.a = 90 * 3600;
e[i+3].ang.b = 0 * 3600;
e[i+3].ang.c = 0;
e[i+3].pwm = 7;
event = insert_action_event(&(e));
insert_action_event(&(e[i+3]));
 
kern_gettime(&(e[i+4].time));
ADDUSEC2TIMESPEC(10000000,&(e[i+4].time));
e[i+4].type = EVT_SET_MASK_LEG_ANGLE;
e[i+4].mask = 0x3F;
e[i+4].ang.a = 90 * 3600;
e[i+4].ang.b = 0 * 3600;
e[i+4].ang.c = 0;
e[i+4].pwm = 7;
insert_action_event(&(e[i+4]));
 
}
 
int main(int argc, char **argv)
{
TIME seme;
KEY_EVT k;
 
seme = sys_gettime(NULL);
srand(seme);
 
sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
k.flag = ALTL_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,program_key_end);
 
a = FTrace_chunk_create(20000000, 10, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
 
FTrace_actual_chunk_select(a);
 
FTrace_enable();
 
clear();
 
init_send(); /* Comunication */
/demos/trunk/chimera/action.c
13,15 → 13,45
#include "chimera.h"
 
struct action_event *first_action_event = NULL;
struct action_event *action_event_list;
int total_events = 0;
 
int get_free_slot();
 
int init_action_event(int number_of_events) {
 
action_event_list = calloc(number_of_events * sizeof(struct action_event),0);
total_events = number_of_events;
 
if (action_event_list != NULL) return 0;
 
total_events = 0;
return -1;
 
}
 
int insert_action_event(struct action_event *e) {
 
struct action_event *t = first_action_event, *k = NULL;
int free;
 
SYS_FLAGS f;
 
f = kern_fsave();
 
free = get_free_slot();
 
if (free != -1) {
memcpy(&(action_event_list[free]),e,sizeof(struct action_event));
e = &(action_event_list[free]);
 
} else {
 
return -1;
 
}
 
e->status = EVT_STATUS_WAIT;
 
if (!t) {
48,17 → 78,18
 
kern_frestore(f);
 
return 0;
return free;
 
}
 
int delete_action_event(struct action_event *e) {
int delete_action_event(int event) {
struct action_event *t = first_action_event;
struct action_event *e = &(action_event_list[event]);
SYS_FLAGS f;
if (!t) return -1;
if ((!t || !e) && (e->status != EVT_STATUS_FREE)) return -1;
f = kern_fsave();
65,6 → 96,7
if (t == e) {
 
first_action_event = t->next;
e->status = EVT_STATUS_FREE;
kern_frestore(f);
return 0;
 
78,6 → 110,7
if (t) {
t->next = e->next;
e->status = EVT_STATUS_FREE;
kern_frestore(f);
return 0;
}
88,6 → 121,23
}
 
int get_free_slot() {
 
int k = 0;
 
while (k < total_events) {
 
if (action_event_list[k].status == EVT_STATUS_FREE ||
action_event_list[k].status == EVT_STATUS_DONE)
return k;
k++;
 
}
 
return -1;
 
}
 
struct action_event * get_first_old_event(struct timespec *time) {
 
struct action_event *t = first_action_event;