Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1664 | pj | 1 | #include <kernel/kern.h> |
2 | #include <drivers/glib.h> |
||
3 | #include <drivers/keyb.h> |
||
4 | #include <kernel/func.h> |
||
5 | #include <modules/cabs.h> |
||
6 | #include <semaphore.h> |
||
7 | #include <stdlib.h> |
||
8 | #include <math.h> |
||
9 | |||
10 | #define MAX_TRAIN 25 /* max number of trains*/ |
||
11 | #define MAX_CITY 4 /* max number of cities*/ |
||
12 | #define MAX_TRACK 12 /* max number of TRACKS*/ |
||
13 | #define NCAB 10 /* max number of CABs */ |
||
14 | #define NCAR 26 /* generated characters */ |
||
15 | |||
16 | #define sgn(x) ((x<0)?-1:((x>0)?1:0)) /* macro to return the sign of a |
||
17 | number */ |
||
18 | #define YMENU 10 /* menu level */ |
||
19 | #define XMIN 50 |
||
20 | #define XMAX 1000 |
||
21 | #define YMIN 200 |
||
22 | #define YMAX 700 |
||
23 | #define VEL 5 /* linear velocity (def. = 5) */ |
||
24 | #define ANG 30 /* angolo massimo sterzata (30) */ |
||
25 | #define D 3 /* raggio mosca */ |
||
26 | #define ESC 27 /* ASCII code of ESCAPE key */ |
||
27 | #define MAX_P 35 /* max number of flies */ |
||
28 | #define FLYGROUP 1 |
||
29 | |||
30 | struct{ |
||
31 | int source,desti,tracknum,check; |
||
32 | } train[MAX_TRAIN]; |
||
33 | |||
34 | struct{ |
||
35 | int id,col; |
||
36 | } param; |
||
37 | |||
38 | |||
39 | struct{ |
||
40 | int cx,cy,source,destination,track; |
||
41 | } traininfo[MAX_TRAIN]; |
||
42 | |||
43 | static int count = 0; |
||
44 | static int start = 0; |
||
45 | |||
46 | char *cname[NCAB] = {"cab1", "cab2", "cab3", "cab4","cab5","cab6","cab7","cab8","cab10","cab11","cab12"}; |
||
47 | char *pname1[NCAB] = {"wr1", "wr2", "wr3", "wr4"}; |
||
48 | char *pname2[NCAB] = {"rd1", "rd2", "rd3", "rd4"}; |
||
49 | |||
50 | CAB cid[NCAB]; /* CAB identifiers */ |
||
51 | PID p1[NCAB], p2[NCAB]; /* task identifiers */ |
||
52 | |||
53 | /* Task Periods */ |
||
54 | TIME t1 = 100000; //for producer |
||
55 | TIME t2[NCAB] = {400000, 400000, 150000, 200000}; /*for telling the reached station */ |
||
56 | |||
57 | /* Task WCETS */ |
||
58 | TIME w1 = 10000; |
||
59 | TIME w2[NCAB] = {10000, 10000, 10000, 10000}; |
||
60 | |||
61 | TIME my_time; |
||
62 | PID ptas_for_train[MAX_TRAIN]; |
||
63 | PID controller; |
||
64 | |||
65 | |||
66 | sem_t mx_segments[10], mx_graphics, mx_flag[MAX_TRACK]; /** mutex semaphores */ |
||
67 | sem_t mx_track[MAX_CITY]; |
||
68 | int status[MAX_TRAIN]; /** THIS IS USED BY THE CONTROLLER*/ |
||
69 | int speed[MAX_TRAIN]; /** THIS IS USED BY THE CONTROLLER*/ |
||
70 | int plan[MAX_CITY][MAX_CITY][10]; /** THIS IS USED BY THE CONTROLLER*/ |
||
71 | int flag[MAX_TRACK]; |
||
72 | // variable for track |
||
73 | int graph[MAX_CITY][2] ={ |
||
74 | { 195,250 }, |
||
75 | { 500,250}, |
||
76 | { 500,600 }, |
||
77 | { 195,600} |
||
78 | }; |
||
79 | |||
80 | int source[MAX_CITY][2] ={ |
||
81 | { 200,250 }, |
||
82 | { 500,255}, |
||
83 | { 495,600 }, |
||
84 | { 195,595} |
||
85 | }; |
||
86 | int destination[MAX_CITY][2] ={ |
||
87 | { 195,255 }, |
||
88 | { 495,250}, |
||
89 | { 500,595 }, |
||
90 | { 200,600} |
||
91 | }; |
||
92 | |||
93 | |||
94 | // look for illa.c for previous working version |
||
95 | int track_taken; |
||
96 | |||
97 | double tick = 1.0; /* system tick = 1 ms */ |
||
98 | int H_fly_period = 20000; /* task period */ |
||
99 | int H_fly_wcet = 1000; /* task wcet */ |
||
100 | int S_fly_period = 30000; /* task period */ |
||
101 | int S_fly_wcet = 1000; /* task wcet */ |
||
102 | PID pid; |
||
103 | sem_t mutex; |
||
104 | float _i_blocking[MAX_TRAIN]; |