Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1664 | pj | 1 | #include "train.h" |
2 | |||
3 | /******************************************************************/ |
||
4 | |||
5 | void init_display() |
||
6 | { |
||
7 | int i,j; |
||
8 | for (i = 0; i < MAX_CITY; i++) |
||
9 | grx_disc(graph[i][0],graph[i][1],10,14); |
||
10 | |||
11 | for (i = 0; i < MAX_CITY; i++) |
||
12 | for (j = 0; j < MAX_CITY; j++) |
||
13 | { |
||
14 | if(i!=j) |
||
15 | grx_line(source[i][0],source[i][1],destination[j][0],destination[j][1],5); |
||
16 | |||
17 | } |
||
18 | |||
19 | }// display ends here |
||
20 | |||
21 | void geninfo(int identi) |
||
22 | { |
||
23 | int src,des,track; |
||
24 | int flag; |
||
25 | |||
26 | track =rand() % 12; |
||
27 | |||
28 | if(track==0 || track ==6) |
||
29 | { |
||
30 | // flag= rand()%2; |
||
31 | if(track==0){ |
||
32 | src = 0; |
||
33 | des = 1; |
||
34 | } |
||
35 | else{ |
||
36 | src = 1; |
||
37 | des = 0; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | if(track==1 || track ==7) |
||
42 | { |
||
43 | |||
44 | //flag= rand()%2; |
||
45 | if(track==1){ |
||
46 | src = 1; |
||
47 | des = 2; |
||
48 | } |
||
49 | else{ |
||
50 | src = 2; |
||
51 | des = 1; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | if(track==2 || track ==8) |
||
56 | { |
||
57 | |||
58 | //flag= rand()%2; |
||
59 | if(track==2){ |
||
60 | src = 2; |
||
61 | des = 3; |
||
62 | } |
||
63 | else{ |
||
64 | src = 3; |
||
65 | des = 2; |
||
66 | } |
||
67 | } |
||
68 | |||
69 | if(track==3 || track ==9) |
||
70 | { |
||
71 | |||
72 | //flag= rand()%2; |
||
73 | if(track==3){ |
||
74 | src = 3; |
||
75 | des = 0; |
||
76 | } |
||
77 | else{ |
||
78 | src = 0; |
||
79 | des = 3; |
||
80 | } |
||
81 | } |
||
82 | |||
83 | if(track==4 || track ==10) |
||
84 | { |
||
85 | |||
86 | //flag= rand()%2; |
||
87 | if(track==4){ |
||
88 | src = 0; |
||
89 | des = 2; |
||
90 | } |
||
91 | else{ |
||
92 | src = 2; |
||
93 | des = 0; |
||
94 | } |
||
95 | } |
||
96 | |||
97 | if(track==5 || track ==11) |
||
98 | { |
||
99 | if(track==5){ |
||
100 | src = 1; |
||
101 | des = 3; |
||
102 | } |
||
103 | else{ |
||
104 | src = 3; |
||
105 | des = 1; |
||
106 | } |
||
107 | } |
||
108 | |||
109 | |||
110 | train[identi].tracknum = track; |
||
111 | train[identi].source= src; |
||
112 | train[identi].desti = des; |
||
113 | |||
114 | if(track==0 || track==2 ) |
||
115 | train[identi].check = 0; |
||
116 | if(track==6 ||track==8 ) |
||
117 | train[identi].check = 1; |
||
118 | if(track==1 || track==4 ||track==5 ||track==9 ) |
||
119 | train[identi].check = 2; |
||
120 | if(track==3 || track==11 ||track==10 ||track==7 ) |
||
121 | train[identi].check = 3; |
||
122 | |||
123 | |||
124 | }//geninfo ends here |
||
125 | |||
126 | int check_reach(int ox1,int oy1,int ox2,int oy2,int f) |
||
127 | { |
||
128 | if(f==0 ) |
||
129 | { |
||
130 | if( ox1 >= ox2) |
||
131 | return 0; // reached the destination |
||
132 | else return 1; |
||
133 | |||
134 | } |
||
135 | |||
136 | if(f==1 ) |
||
137 | { |
||
138 | if( ox1 <= ox2) |
||
139 | return 0; // reached the destination |
||
140 | else return 1; |
||
141 | |||
142 | } |
||
143 | else if(f==2 ) |
||
144 | { |
||
145 | if( oy1 >= oy2) |
||
146 | return 0; // reached the destination |
||
147 | else return 1; |
||
148 | } |
||
149 | else if(f==3 ) |
||
150 | { |
||
151 | if( oy1 <= oy2) |
||
152 | return 0; // reached the destination |
||
153 | else return 1; |
||
154 | } |
||
155 | |||
156 | }// check if train reached destination |
||
157 | |||
158 | |||
159 | |||
160 | |||
161 | |||
162 | TASK display(void *arg){ |
||
163 | |||
164 | char temp1[200]; |
||
165 | char temp2[200]; |
||
166 | char temp3[200]; |
||
167 | int i,j; |
||
168 | int pos = 30; |
||
169 | int gposx = 700; |
||
170 | int gposy = 40; |
||
171 | int cab_val; |
||
172 | char *c; |
||
173 | char rbuf[2]; |
||
174 | |||
175 | while(1){ |
||
176 | j=1; |
||
177 | if(start){ |
||
178 | for(i=0;i<count;i++) { |
||
179 | c = cab_getmes(cid[i]); |
||
180 | memcpy(rbuf,c,2*sizeof(char)); |
||
181 | sscanf(rbuf,"%2d",&cab_val); |
||
182 | cab_unget(cid[i], c); |
||
183 | pos+=10; |
||
184 | sprintf(temp1," "); |
||
185 | sprintf(temp1,"TRAIN NO %d is At X %d Y %d GOING CITY %d TO CITY %d ON TRACK %d BLOCKTIME %f",i,traininfo[i].cx,traininfo[i].cy,traininfo[i].source,traininfo[i].destination,cab_val,_i_blocking[i]); |
||
186 | grx_text(temp1, 30,pos,15,0); |
||
187 | }// for1 |
||
188 | |||
189 | // display status here |
||
190 | for(i=0;i<count;i++) { |
||
191 | |||
192 | j++; |
||
193 | |||
194 | if(status[i]==0){ |
||
195 | // display red; |
||
196 | sprintf(temp2,"NO %d ",i); |
||
197 | grx_text(temp2, gposx,gposy,15,0); |
||
198 | gposx +=60; |
||
199 | grx_disc(gposx,gposy,10,12); |
||
200 | gposx += 35; |
||
201 | |||
202 | if((j%3)==0){ |
||
203 | gposy+=40; |
||
204 | gposx =700; |
||
205 | }//if |
||
206 | |||
207 | }// outer |
||
208 | |||
209 | else { |
||
210 | |||
211 | // display green; |
||
212 | sprintf(temp2,"NO %d",i); |
||
213 | grx_text(temp2, gposx,gposy,15,0); |
||
214 | gposx +=60; |
||
215 | grx_disc(gposx,gposy,10,10); |
||
216 | gposx += 35; |
||
217 | |||
218 | if((j%3)==0){ |
||
219 | gposy+=40; |
||
220 | gposx = 700; |
||
221 | }//if |
||
222 | |||
223 | }//else |
||
224 | |||
225 | }// for2 |
||
226 | }// if |
||
227 | pos = 30; |
||
228 | gposx= 700; |
||
229 | gposy = 40; |
||
230 | j = 1; |
||
231 | task_endcycle(); |
||
232 | } //while |
||
233 | }// display |
||
234 | |||
235 | |||
236 | |||
237 | |||
238 | ////////////////display task ends here |
||
239 | |||
240 | TASK controls(void *arg){ |
||
241 | |||
242 | char temp1[200]; |
||
243 | char temp2[200]; |
||
244 | char temp3[200]; |
||
245 | int i,j; |
||
246 | int pos = 30; |
||
247 | int gposx = 700; |
||
248 | int gposy = 40; |
||
249 | int cab_val; |
||
250 | char *c; |
||
251 | char rbuf[2]; |
||
252 | |||
253 | while(1){ |
||
254 | j=1; |
||
255 | if(start){ |
||
256 | for(i=0;i<count;i++) { |
||
257 | c = cab_getmes(cid[i]); |
||
258 | memcpy(rbuf,c,2*sizeof(char)); |
||
259 | sscanf(rbuf,"%2d",&cab_val); |
||
260 | cab_unget(cid[i], c); |
||
261 | pos+=10; |
||
262 | sprintf(temp1," "); |
||
263 | sprintf(temp1,"TRAIN NO %d is At X %d Y %d GOING FROM CITY %d TO CITY %d ON TRACK %d ",i,traininfo[i].cx,traininfo[i].cy,traininfo[i].source,traininfo[i].destination,cab_val); |
||
264 | grx_text(temp1, 30,pos,15,0); |
||
265 | }// for1 |
||
266 | |||
267 | // display status here |
||
268 | for(i=0;i<count;i++) { |
||
269 | |||
270 | j++; |
||
271 | |||
272 | if(status[i]==0){ |
||
273 | // display red; |
||
274 | sprintf(temp2,"NO %d ",i); |
||
275 | grx_text(temp2, gposx,gposy,15,0); |
||
276 | gposx +=60; |
||
277 | grx_disc(gposx,gposy,10,12); |
||
278 | gposx += 35; |
||
279 | |||
280 | if((j%3)==0){ |
||
281 | gposy+=40; |
||
282 | gposx =700; |
||
283 | }//if |
||
284 | |||
285 | }// outer |
||
286 | |||
287 | else { |
||
288 | |||
289 | // display green; |
||
290 | sprintf(temp2,"NO %d",i); |
||
291 | grx_text(temp2, gposx,gposy,15,0); |
||
292 | gposx +=60; |
||
293 | grx_disc(gposx,gposy,10,10); |
||
294 | gposx += 35; |
||
295 | |||
296 | if((j%3)==0){ |
||
297 | gposy+=40; |
||
298 | gposx = 700; |
||
299 | }//if |
||
300 | |||
301 | }//else |
||
302 | |||
303 | }// for2 |
||
304 | }// if |
||
305 | pos = 30; |
||
306 | gposx= 700; |
||
307 | gposy = 40; |
||
308 | j = 1; |
||
309 | task_endcycle(); |
||
310 | } //while |
||
311 | }// contoller |
||
312 | |||
313 | |||
314 | TASK fly(void *arg) |
||
315 | { |
||
316 | |||
317 | //int x, y; |
||
318 | char *p,*c; |
||
319 | char wbuf[2],rbuf[2]; |
||
320 | char temp1[600]; |
||
321 | char temp2[650]; |
||
322 | char temp3[650]; |
||
323 | char cab_str[200]; |
||
324 | int ox1, ox2,oy1,oy2,cab_val; |
||
325 | int dx, dy, da; |
||
326 | int teta, col,cur_col,id; |
||
327 | int outx, outy; |
||
328 | double r,step_vel; |
||
329 | int src,des; |
||
330 | int i=0; |
||
331 | int no_of_times,dt; |
||
332 | int stepx,stepy,track; |
||
333 | int semval,wait; |
||
334 | int go = 1; |
||
335 | |||
336 | int _i_distance,_i_speed,_i_time_required,cur_speed; |
||
337 | //Time t; |
||
338 | TIME _time_this,_time_unblock; |
||
339 | float _i_waiting_time; |
||
340 | id = (int) arg; |
||
341 | status[id] = 0; |
||
342 | _i_blocking[id]=0.0; |
||
343 | _i_speed = rand() % 3+1; |
||
344 | |||
345 | geninfo(id); |
||
346 | cid[id] = cab_create(cname[id], 2*sizeof(char), 2); |
||
347 | track = train[id].tracknum; |
||
348 | src = train[id].source; |
||
349 | des = train[id].desti; |
||
350 | |||
351 | ox1 =source[src][0]; |
||
352 | ox2 =destination[des][0]; |
||
353 | oy1 = source[src][1]; |
||
354 | oy2 = destination[des][1]; |
||
355 | //convert(&ox1,&ox2,&oy1,&oy2,src,des); |
||
356 | traininfo[id].source=src; |
||
357 | traininfo[id].destination=des; |
||
358 | traininfo[id].track= track; |
||
359 | traininfo[id].cx= ox1; |
||
360 | traininfo[id].cy= oy1; |
||
361 | /// getting the distance; |
||
362 | |||
363 | //sys_gettime(&_time_this); |
||
364 | |||
365 | _i_distance = (int)sqrt((abs(ox1 - ox2)*abs(ox1 - ox2))+(abs(oy1-oy2)*abs(oy1-oy2))); |
||
366 | _i_time_required = (int)( _i_distance / _i_speed ); |
||
367 | |||
368 | step_vel = _i_speed / _i_time_required; |
||
369 | /// |
||
370 | grx_text(" in the fly",15,20,10,14); |
||
371 | dy = oy2 - oy1; |
||
372 | dx = ox2 - ox1; |
||
373 | |||
374 | if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } |
||
375 | if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } |
||
376 | dy <<= 1; // dy is now 2*dy |
||
377 | dx <<= 1; // dx is now 2*dx |
||
378 | //grx_text(temp1,ox1,oy1+5,15,0); |
||
379 | if(id==0) col=15; |
||
380 | else col =10; |
||
381 | cur_col = col; // if the train is delayed the coler of the train will be shown diffrent |
||
382 | |||
383 | while(1) |
||
384 | { |
||
385 | |||
386 | p = cab_reserve(cid[id]); |
||
387 | sprintf(wbuf,"%2d",track); |
||
388 | //grx_text(temp1,350,700+(id*8),15,0); |
||
389 | memcpy(p,wbuf,2*sizeof(char)); |
||
390 | cab_putmes(cid[id], p); |
||
391 | |||
392 | sys_gettime(&_time_this); |
||
393 | |||
394 | sem_wait(&mx_track[track]); |
||
395 | |||
396 | if(flag[track]==1) |
||
397 | { |
||
398 | sem_post(&mx_track[track]); |
||
399 | go = 0; |
||
400 | status[id]=0; |
||
401 | |||
402 | } |
||
403 | else |
||
404 | if(flag[track]==0) |
||
405 | { |
||
406 | flag[track]=1; |
||
407 | go = 1; |
||
408 | sem_post(&mx_track[track]); |
||
409 | } |
||
410 | |||
411 | if(go){ |
||
412 | sys_gettime(&_time_unblock); |
||
413 | _i_waiting_time = (float) (_time_unblock - _time_this); |
||
414 | |||
415 | _i_blocking[id] = _i_waiting_time; |
||
416 | |||
417 | cur_speed = _i_speed + (step_vel * _i_blocking[id]); |
||
418 | /**** |
||
419 | if(_i_blocking[id] >= 0.010) |
||
420 | { |
||
421 | grx_text(" train is late",15,620,10,14); |
||
422 | cur_col = 4; |
||
423 | } |
||
424 | */ status[id] = 1; |
||
425 | |||
426 | if (dx > dy) |
||
427 | { |
||
428 | int fraction = dy - (dx >> 1); |
||
429 | while (src!=des) { |
||
430 | |||
431 | grx_disc(ox1,oy1,2,0); |
||
432 | if(check_reach(ox1,oy1,ox2,oy2,train[id].check) == 0 ) |
||
433 | { |
||
434 | flag[track]=0; |
||
435 | geninfo(id); |
||
436 | |||
437 | track = train[id].tracknum; |
||
438 | src = train[id].source; |
||
439 | des = train[id].desti; |
||
440 | |||
441 | /*ox1 =graph[src][0]; |
||
442 | ox2 =graph[des][0]; |
||
443 | oy1 = graph[src][1]; |
||
444 | oy2 = graph[des][1];*/ |
||
445 | ox1 =source[src][0]; |
||
446 | ox2 =destination[des][0]; |
||
447 | oy1 = source[src][1]; |
||
448 | oy2 = destination[des][1]; |
||
449 | traininfo[id].source=src; |
||
450 | traininfo[id].destination=des; |
||
451 | traininfo[id].track= track; |
||
452 | traininfo[id].cx= ox1; |
||
453 | traininfo[id].cy= oy1; |
||
454 | |||
455 | // grx_text(" in the fly",15,20,10,14); |
||
456 | dy = oy2 - oy1; |
||
457 | dx = ox2 - ox1; |
||
458 | |||
459 | if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } |
||
460 | if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } |
||
461 | dy <<= 1; // dy is now 2*dy |
||
462 | dx <<= 1; // dx is now 2*dx |
||
463 | |||
464 | break; |
||
465 | //src = des; |
||
466 | } |
||
467 | if (fraction >= 0) |
||
468 | { |
||
469 | oy1 += stepy * cur_speed; |
||
470 | fraction -= dx; // same as fraction -= 2*dx |
||
471 | }// if |
||
472 | |||
473 | ox1 += stepx * cur_speed; |
||
474 | fraction += dy; // same as fraction -= 2*dy |
||
475 | |||
476 | traininfo[id].cx= ox1; |
||
477 | traininfo[id].cy= oy1; |
||
478 | grx_line(source[src][0],source[src][1],destination[des][0],destination[des][1],5); |
||
479 | grx_disc(ox1,oy1,2,cur_col); |
||
480 | |||
481 | task_endcycle(); |
||
482 | continue; |
||
483 | }//while |
||
484 | |||
485 | }// main if (dx > dy) |
||
486 | |||
487 | |||
488 | |||
489 | else |
||
490 | { |
||
491 | int fraction = dx - (dy >> 1); |
||
492 | sem_wait(&mx_track[track]); |
||
493 | if(flag[track]==1) |
||
494 | { |
||
495 | sem_post(&mx_track[track]); |
||
496 | task_endcycle(); |
||
497 | //continue; |
||
498 | } |
||
499 | else if(flag[track]==0) |
||
500 | { |
||
501 | flag[track]=1; |
||
502 | sem_post(&mx_track[track]); |
||
503 | } |
||
504 | |||
505 | while (src!=des) |
||
506 | { |
||
507 | grx_disc(ox1,oy1,2,0); |
||
508 | if(check_reach(ox1,oy1,ox2,oy2,train[id].check) == 0) |
||
509 | { |
||
510 | flag[track]=0; |
||
511 | geninfo(id); |
||
512 | track = train[id].tracknum; |
||
513 | src = train[id].source; |
||
514 | des = train[id].desti; |
||
515 | |||
516 | ox1 =source[src][0]; |
||
517 | ox2 =destination[des][0]; |
||
518 | oy1 = source[src][1]; |
||
519 | oy2 = destination[des][1]; |
||
520 | |||
521 | traininfo[id].source=src; |
||
522 | traininfo[id].destination=des; |
||
523 | traininfo[id].track= track; |
||
524 | traininfo[id].cx= ox1; |
||
525 | traininfo[id].cy= oy1; |
||
526 | //grx_text(" in the fly",15,20,10,14); |
||
527 | dy = oy2 - oy1; |
||
528 | dx = ox2 - ox1; |
||
529 | |||
530 | if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } |
||
531 | if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } |
||
532 | dy <<= 1; // dy is now 2*dy |
||
533 | dx <<= 1; // dx is now 2*dx |
||
534 | |||
535 | break; |
||
536 | } |
||
537 | if (fraction >= 0) { |
||
538 | ox1 += stepx * cur_speed; |
||
539 | fraction -= dy; |
||
540 | } |
||
541 | oy1 += stepy * cur_speed; |
||
542 | fraction += dx; |
||
543 | traininfo[id].cx= ox1; |
||
544 | traininfo[id].cy= oy1; |
||
545 | grx_line(source[src][0],source[src][1],destination[des][0],destination[des][1],5); |
||
546 | grx_disc(ox1,oy1,2,cur_col); |
||
547 | task_endcycle(); |
||
548 | continue; |
||
549 | }// while |
||
550 | } |
||
551 | }// else |
||
552 | task_endcycle(); |
||
553 | }// outer while |
||
554 | }// main |
||
555 | /****************************************************************/ |
||
556 | |||
557 | /* This function is called when the system exits */ |
||
558 | void byebye(void *arg) |
||
559 | { |
||
560 | grx_close(); |
||
561 | cprintf("!!!!!!!!!!!!!!!!HAVE A NICE DAY !!!!!!!!!!!\n"); |
||
562 | } |
||
563 | |||
564 | /****************************** MAIN ******************************/ |
||
565 | |||
566 | int main(int argc, char **argv) |
||
567 | { |
||
568 | HARD_TASK_MODEL m; |
||
569 | SOFT_TASK_MODEL mp; |
||
570 | |||
571 | int j,sg,val; |
||
572 | char c; /* character from keyboard */ |
||
573 | int i = 0; /* number of tasks created */ |
||
574 | TIME seme; /* used to init the random seed */ |
||
575 | char temp1[200]; |
||
576 | |||
577 | /* Set the closing function */ |
||
578 | sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
||
579 | |||
580 | /* graphic card Initialization */ |
||
581 | if (grx_init() < 1) { |
||
582 | sys_abort(1); |
||
583 | } |
||
584 | |||
585 | if (grx_open(1024,768, 8) < 0) { |
||
586 | cprintf("GRX Err\n"); |
||
587 | sys_abort(1); |
||
588 | } |
||
589 | for(i=0;i<MAX_TRACK;i++) |
||
590 | sem_init(&mx_track[i],0,1); |
||
591 | |||
592 | |||
593 | for(i=0;i<MAX_TRACK;i++) |
||
594 | flag[i]=0; |
||
595 | |||
596 | /* The scenario */ |
||
597 | grx_rect(XMIN-D-1, YMIN-D-1, XMAX+D+1, YMAX+D+1, 14); |
||
598 | grx_text("Simulation of Train Status", XMIN, YMENU+10, 13, 0); |
||
599 | grx_text("SPACE create a Train" , XMIN, YMENU+20, 12, 0); |
||
600 | grx_text("ESC exit to DOS" , XMIN, YMENU+30, 12, 0); |
||
601 | init_display(); |
||
602 | |||
603 | soft_task_default_model(mp); |
||
604 | soft_task_def_level(mp,1); |
||
605 | soft_task_def_ctrl_jet(mp); |
||
606 | soft_task_def_arg(mp, (void *)count); |
||
607 | // soft_task_def_group(mp, FLYGROUP); |
||
608 | soft_task_def_met(mp, S_fly_wcet); |
||
609 | soft_task_def_period(mp,S_fly_period); |
||
610 | soft_task_def_usemath(mp); |
||
611 | controller = task_create("controller",controls,&mp,NULL); |
||
612 | task_activate(controller); |
||
613 | if (controller == NIL) { |
||
614 | grx_close(); |
||
615 | perror("Could not create controller "); |
||
616 | sys_abort(1); |
||
617 | } |
||
618 | //grx_text(" contoller here ",15,30,10,14); |
||
619 | /* The program waits a space to create a fly */ |
||
620 | c = keyb_getch(BLOCK); |
||
621 | |||
622 | /* randomize!!!! */ |
||
623 | seme = sys_gettime(NULL); |
||
624 | srand(seme); |
||
625 | |||
626 | do { |
||
627 | if (c == ' ') { |
||
628 | |||
629 | //itoa(count,train_str+5); |
||
630 | if(count == 0){ |
||
631 | param.id = count; |
||
632 | param.col = RED; |
||
633 | hard_task_default_model(m); |
||
634 | hard_task_def_ctrl_jet (m); |
||
635 | hard_task_def_arg (m, (void *)count); |
||
636 | hard_task_def_wcet (m, H_fly_wcet); |
||
637 | hard_task_def_mit (m, H_fly_period); |
||
638 | hard_task_def_group (m, FLYGROUP); |
||
639 | hard_task_def_usemath (m); |
||
640 | //pid = task_create("fly", fly, &m, NULL); |
||
641 | ptas_for_train[count] = task_create("train",fly,&m,NULL); |
||
642 | } |
||
643 | |||
644 | |||
645 | else{ |
||
646 | param.id = count; |
||
647 | param.col = 15; |
||
648 | soft_task_default_model(mp); |
||
649 | soft_task_def_level(mp,1); |
||
650 | soft_task_def_ctrl_jet(mp); |
||
651 | soft_task_def_arg(mp, (void *)count); |
||
652 | soft_task_def_group(mp, FLYGROUP); |
||
653 | soft_task_def_met(mp, S_fly_wcet); |
||
654 | soft_task_def_period(mp,S_fly_period); |
||
655 | soft_task_def_usemath(mp); |
||
656 | ptas_for_train[count] = task_create("train",fly,&mp,NULL); |
||
657 | // grx_text(" soft returned ",15,30,10,14); |
||
658 | } |
||
659 | |||
660 | |||
661 | i++; |
||
662 | |||
663 | if (ptas_for_train[count] == NIL) { |
||
664 | grx_close(); |
||
665 | perror("Could not create task <train>"); |
||
666 | sys_abort(1); |
||
667 | } |
||
668 | task_activate(ptas_for_train[count]); |
||
669 | |||
670 | sprintf(temp1," PID = %d ",ptas_for_train[count]); |
||
671 | grx_text(temp1,75,40,15,12); |
||
672 | count++; |
||
673 | |||
674 | if (count == 1) { |
||
675 | start = 1; |
||
676 | } |
||
677 | } |
||
678 | c = keyb_getch(BLOCK); |
||
679 | |||
680 | } while (c != ESC); |
||
681 | |||
682 | sys_end(); |
||
683 | |||
684 | return 0;} |