Rev 1650 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1624 | giacomo | 1 | #include "kernel/kern.h" |
1651 | pj | 2 | #include "cabs/cabs/cabs.h" |
1624 | giacomo | 3 | |
4 | #include "tmwtypes.h" |
||
5 | |||
6 | #include "rtw.h" |
||
7 | |||
8 | extern CAB output_cid[NOUTPUTCAB]; |
||
9 | |||
10 | TASK ACTUATOR_body(void *output_port) { |
||
11 | |||
12 | real_T *p, value; |
||
13 | int out = (int)(output_port); |
||
14 | |||
15 | if (out >= NOUTPUTCAB) return NULL; |
||
16 | |||
17 | while(1) { |
||
18 | |||
19 | /* Get CAB message */ |
||
20 | p = (real_T *)cab_getmes(output_cid[out]); |
||
21 | |||
22 | /* Set value */ |
||
23 | value = *p; |
||
24 | |||
25 | /* Release CAB message */ |
||
26 | cab_unget(output_cid[out], p); |
||
27 | |||
28 | cprintf("Value = %lf\n",value); |
||
29 | |||
30 | task_endcycle(); |
||
31 | |||
32 | } |
||
33 | |||
34 | return NULL; |
||
35 | |||
36 | } |
||
37 | |||
38 | void activate_actuators() { |
||
39 | |||
40 | HARD_TASK_MODEL ACTUATOR_task; |
||
41 | PID ACTUATOR_pid; |
||
42 | |||
43 | hard_task_default_model(ACTUATOR_task); |
||
44 | hard_task_def_mit(ACTUATOR_task,20000); |
||
45 | hard_task_def_wcet(ACTUATOR_task,4000); |
||
46 | /* Set actuator port number */ |
||
47 | hard_task_def_arg(ACTUATOR_task,(void *)(0)); |
||
48 | hard_task_def_usemath(ACTUATOR_task); |
||
49 | hard_task_def_ctrl_jet(ACTUATOR_task); |
||
50 | |||
51 | ACTUATOR_pid = task_create("ACTUATOR0",ACTUATOR_body,&ACTUATOR_task,NULL); |
||
52 | if (ACTUATOR_pid == NIL) { |
||
53 | cprintf("Error: Cannot create RealTime Workshop [ACTUATOR0] Task\n"); |
||
1650 | pj | 54 | exit(1); |
1624 | giacomo | 55 | } |
56 | |||
57 | task_activate(ACTUATOR_pid); |
||
58 | |||
59 | } |
||
60 | |||
61 | |||
62 |