Generation working and Compilation of MARTe components

This commit is contained in:
ferrog
2025-05-13 16:03:11 +00:00
parent 3a5e378d99
commit 4faee3802a
1571 changed files with 611466 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
Build/

View File

@@ -0,0 +1,103 @@
#test configuration file2,,,,,,
#Time,MHVPS,BPS,APS,MC,GC,FHPS
0,60,45,0,10,10,10
10,55,40,-2,9,9,9
20,50,35,-4,8,8,8
30,45,30,-6,7,7,7
40,40,25,-8,6,6,6
50,35,20,-10,5,5,5
60,30,15,-12,4,4,4
70,25,10,-14,3,3,3
80,20,5,-16,2,2,2
90,15,0,-18,1,1,1
100,10,-5,-20,0,0,0
110,5,0,-22,1,1,1
120,0,5,-20,2,2,2
130,-5,10,-18,3,3,3
140,0,15,-16,4,4,4
150,5,20,-14,5,5,5
160,10,25,-12,6,6,6
170,15,30,-10,7,7,7
180,20,35,-8,8,8,8
190,25,40,-6,9,9,9
200,30,45,-4,10,10,10
210,35,40,-2,9,9,9
220,40,35,0,8,8,8
230,45,30,-2,7,7,7
240,50,25,-4,6,6,6
250,55,20,-6,5,5,5
260,60,15,-8,4,4,4
270,55,10,-10,3,3,3
280,50,5,-12,2,2,2
290,45,0,-14,1,1,1
300,40,-5,-16,0,0,0
310,35,0,-18,1,1,1
320,30,5,-20,2,2,2
330,25,10,-25,3,3,3
340,20,15,-20,4,4,4
350,15,20,-18,5,5,5
360,10,25,-16,6,6,6
370,5,30,-14,7,7,7
380,0,35,-12,8,8,8
390,-5,40,-10,9,9,9
400,0,45,-8,10,10,10
410,5,40,-6,9,9,9
420,10,35,-4,8,8,8
430,15,30,-2,7,7,7
440,20,25,0,6,6,6
450,25,20,-2,5,5,5
460,30,15,-4,4,4,4
470,35,10,-6,3,3,3
480,40,5,-8,2,2,2
490,45,0,-10,1,1,1
500,50,-5,-12,0,0,0
510,55,0,-14,1,1,1
520,60,5,-16,2,2,2
530,55,10,-18,3,3,3
540,50,15,-20,4,4,4
550,45,20,-30,5,5,5
560,40,25,-20,6,6,6
570,35,30,-18,7,7,7
580,30,35,-16,8,8,8
590,25,40,-14,9,9,9
600,20,45,-12,10,10,10
610,15,40,-10,9,9,9
620,10,35,-8,8,8,8
630,5,30,-6,7,7,7
640,0,25,-4,6,6,6
650,-5,20,-2,5,5,5
660,0,15,0,4,4,4
670,5,10,-2,3,3,3
680,10,5,-4,2,2,2
690,15,0,-6,1,1,1
700,20,-5,-8,0,0,0
710,25,0,-10,1,1,1
720,30,5,-12,2,2,2
730,35,10,-14,3,3,3
740,40,15,-16,4,4,4
750,45,20,-18,5,5,5
760,50,25,-20,6,6,6
770,55,30,-22,7,7,7
780,60,35,-20,8,8,8
790,55,40,-18,9,9,9
800,50,45,-16,10,10,10
810,45,40,-14,9,9,9
820,40,35,-12,8,8,8
830,35,30,-10,7,7,7
840,30,25,-8,6,6,6
850,25,20,-6,5,5,5
860,20,15,-4,4,4,4
870,15,10,-2,3,3,3
880,10,5,0,2,2,2
890,5,0,-2,1,1,1
900,0,-5,-4,0,0,0
910,-5,0,-6,1,1,1
920,0,5,-8,2,2,2
930,5,10,-10,3,3,3
940,10,15,-12,4,4,4
950,15,20,-14,5,5,5
960,20,25,-16,6,6,6
970,25,30,-18,7,7,7
980,30,35,-20,8,8,8
990,35,40,-22,9,9,9
1000,40,45,-20,10,10,10
1 #test configuration file2
2 #Time MHVPS BPS APS MC GC FHPS
3 0 60 45 0 10 10 10
4 10 55 40 -2 9 9 9
5 20 50 35 -4 8 8 8
6 30 45 30 -6 7 7 7
7 40 40 25 -8 6 6 6
8 50 35 20 -10 5 5 5
9 60 30 15 -12 4 4 4
10 70 25 10 -14 3 3 3
11 80 20 5 -16 2 2 2
12 90 15 0 -18 1 1 1
13 100 10 -5 -20 0 0 0
14 110 5 0 -22 1 1 1
15 120 0 5 -20 2 2 2
16 130 -5 10 -18 3 3 3
17 140 0 15 -16 4 4 4
18 150 5 20 -14 5 5 5
19 160 10 25 -12 6 6 6
20 170 15 30 -10 7 7 7
21 180 20 35 -8 8 8 8
22 190 25 40 -6 9 9 9
23 200 30 45 -4 10 10 10
24 210 35 40 -2 9 9 9
25 220 40 35 0 8 8 8
26 230 45 30 -2 7 7 7
27 240 50 25 -4 6 6 6
28 250 55 20 -6 5 5 5
29 260 60 15 -8 4 4 4
30 270 55 10 -10 3 3 3
31 280 50 5 -12 2 2 2
32 290 45 0 -14 1 1 1
33 300 40 -5 -16 0 0 0
34 310 35 0 -18 1 1 1
35 320 30 5 -20 2 2 2
36 330 25 10 -25 3 3 3
37 340 20 15 -20 4 4 4
38 350 15 20 -18 5 5 5
39 360 10 25 -16 6 6 6
40 370 5 30 -14 7 7 7
41 380 0 35 -12 8 8 8
42 390 -5 40 -10 9 9 9
43 400 0 45 -8 10 10 10
44 410 5 40 -6 9 9 9
45 420 10 35 -4 8 8 8
46 430 15 30 -2 7 7 7
47 440 20 25 0 6 6 6
48 450 25 20 -2 5 5 5
49 460 30 15 -4 4 4 4
50 470 35 10 -6 3 3 3
51 480 40 5 -8 2 2 2
52 490 45 0 -10 1 1 1
53 500 50 -5 -12 0 0 0
54 510 55 0 -14 1 1 1
55 520 60 5 -16 2 2 2
56 530 55 10 -18 3 3 3
57 540 50 15 -20 4 4 4
58 550 45 20 -30 5 5 5
59 560 40 25 -20 6 6 6
60 570 35 30 -18 7 7 7
61 580 30 35 -16 8 8 8
62 590 25 40 -14 9 9 9
63 600 20 45 -12 10 10 10
64 610 15 40 -10 9 9 9
65 620 10 35 -8 8 8 8
66 630 5 30 -6 7 7 7
67 640 0 25 -4 6 6 6
68 650 -5 20 -2 5 5 5
69 660 0 15 0 4 4 4
70 670 5 10 -2 3 3 3
71 680 10 5 -4 2 2 2
72 690 15 0 -6 1 1 1
73 700 20 -5 -8 0 0 0
74 710 25 0 -10 1 1 1
75 720 30 5 -12 2 2 2
76 730 35 10 -14 3 3 3
77 740 40 15 -16 4 4 4
78 750 45 20 -18 5 5 5
79 760 50 25 -20 6 6 6
80 770 55 30 -22 7 7 7
81 780 60 35 -20 8 8 8
82 790 55 40 -18 9 9 9
83 800 50 45 -16 10 10 10
84 810 45 40 -14 9 9 9
85 820 40 35 -12 8 8 8
86 830 35 30 -10 7 7 7
87 840 30 25 -8 6 6 6
88 850 25 20 -6 5 5 5
89 860 20 15 -4 4 4 4
90 870 15 10 -2 3 3 3
91 880 10 5 0 2 2 2
92 890 5 0 -2 1 1 1
93 900 0 -5 -4 0 0 0
94 910 -5 0 -6 1 1 1
95 920 0 5 -8 2 2 2
96 930 5 10 -10 3 3 3
97 940 10 15 -12 4 4 4
98 950 15 20 -14 5 5 5
99 960 20 25 -16 6 6 6
100 970 25 30 -18 7 7 7
101 980 30 35 -20 8 8 8
102 990 35 40 -22 9 9 9
103 1000 40 45 -20 10 10 10

View File

@@ -0,0 +1,103 @@
#test configuration file2,,,,,,
#Time,MHVPS,BPS,APS,MC,GC,FHPS
0,60,45,10,10,10,10
10,55,40,9,9,9,9
20,50,35,8,8,8,8
30,45,30,7,7,7,7
40,40,25,6,6,6,6
50,35,20,5,5,5,5
60,30,15,4,4,4,4
70,25,10,3,3,3,3
80,20,5,2,2,2,2
90,15,0,1,1,1,1
100,10,-5,0,0,0,0
110,5,0,1,1,1,1
120,0,5,2,2,2,2
130,-5,10,3,3,3,3
140,0,15,4,4,4,4
150,5,20,5,5,5,5
160,10,25,6,6,6,6
170,15,30,7,7,7,7
180,20,35,8,8,8,8
190,25,40,9,9,9,9
200,30,45,10,10,10,10
210,35,40,11,9,9,9
220,40,35,12,8,8,8
230,45,30,11,7,7,7
240,50,25,10,6,6,6
250,55,20,9,5,5,5
260,60,15,8,4,4,4
270,55,10,7,3,3,3
280,50,5,6,2,2,2
290,45,0,5,1,1,1
300,40,-5,4,0,0,0
310,35,0,3,1,1,1
320,30,5,2,2,2,2
330,25,10,1,3,3,3
340,20,15,0,4,4,4
350,15,20,1,5,5,5
360,10,25,2,6,6,6
370,5,30,3,7,7,7
380,0,35,4,8,8,8
390,-5,40,5,9,9,9
400,0,45,6,10,10,10
410,5,40,7,9,9,9
420,10,35,8,8,8,8
430,15,30,9,7,7,7
440,20,25,10,6,6,6
450,25,20,11,5,5,5
460,30,15,12,4,4,4
470,35,10,11,3,3,3
480,40,5,10,2,2,2
490,45,0,9,1,1,1
500,50,-5,8,0,0,0
510,55,0,7,1,1,1
520,60,5,6,2,2,2
530,55,10,5,3,3,3
540,50,15,4,4,4,4
550,45,20,3,5,5,5
560,40,25,2,6,6,6
570,35,30,1,7,7,7
580,30,35,0,8,8,8
590,25,40,1,9,9,9
600,20,45,2,10,10,10
610,15,40,3,9,9,9
620,10,35,4,8,8,8
630,5,30,5,7,7,7
640,0,25,6,6,6,6
650,-5,20,7,5,5,5
660,0,15,8,4,4,4
670,5,10,9,3,3,3
680,10,5,10,2,2,2
690,15,0,11,1,1,1
700,20,-5,12,0,0,0
710,25,0,11,1,1,1
720,30,5,10,2,2,2
730,35,10,9,3,3,3
740,40,15,8,4,4,4
750,45,20,7,5,5,5
760,50,25,6,6,6,6
770,55,30,5,7,7,7
780,60,35,4,8,8,8
790,55,40,3,9,9,9
800,50,45,2,10,10,10
810,45,40,1,9,9,9
820,40,35,0,8,8,8
830,35,30,1,7,7,7
840,30,25,2,6,6,6
850,25,20,3,5,5,5
860,20,15,4,4,4,4
870,15,10,5,3,3,3
880,10,5,6,2,2,2
890,5,0,7,1,1,1
900,0,-5,8,0,0,0
910,-5,0,9,1,1,1
920,0,5,10,2,2,2
930,5,10,11,3,3,3
940,10,15,12,4,4,4
950,15,20,11,5,5,5
960,20,25,10,6,6,6
970,25,30,9,7,7,7
980,30,35,8,8,8,8
990,35,40,7,9,9,9
1000,40,45,6,10,10,10
1 #test configuration file2
2 #Time MHVPS BPS APS MC GC FHPS
3 0 60 45 10 10 10 10
4 10 55 40 9 9 9 9
5 20 50 35 8 8 8 8
6 30 45 30 7 7 7 7
7 40 40 25 6 6 6 6
8 50 35 20 5 5 5 5
9 60 30 15 4 4 4 4
10 70 25 10 3 3 3 3
11 80 20 5 2 2 2 2
12 90 15 0 1 1 1 1
13 100 10 -5 0 0 0 0
14 110 5 0 1 1 1 1
15 120 0 5 2 2 2 2
16 130 -5 10 3 3 3 3
17 140 0 15 4 4 4 4
18 150 5 20 5 5 5 5
19 160 10 25 6 6 6 6
20 170 15 30 7 7 7 7
21 180 20 35 8 8 8 8
22 190 25 40 9 9 9 9
23 200 30 45 10 10 10 10
24 210 35 40 11 9 9 9
25 220 40 35 12 8 8 8
26 230 45 30 11 7 7 7
27 240 50 25 10 6 6 6
28 250 55 20 9 5 5 5
29 260 60 15 8 4 4 4
30 270 55 10 7 3 3 3
31 280 50 5 6 2 2 2
32 290 45 0 5 1 1 1
33 300 40 -5 4 0 0 0
34 310 35 0 3 1 1 1
35 320 30 5 2 2 2 2
36 330 25 10 1 3 3 3
37 340 20 15 0 4 4 4
38 350 15 20 1 5 5 5
39 360 10 25 2 6 6 6
40 370 5 30 3 7 7 7
41 380 0 35 4 8 8 8
42 390 -5 40 5 9 9 9
43 400 0 45 6 10 10 10
44 410 5 40 7 9 9 9
45 420 10 35 8 8 8 8
46 430 15 30 9 7 7 7
47 440 20 25 10 6 6 6
48 450 25 20 11 5 5 5
49 460 30 15 12 4 4 4
50 470 35 10 11 3 3 3
51 480 40 5 10 2 2 2
52 490 45 0 9 1 1 1
53 500 50 -5 8 0 0 0
54 510 55 0 7 1 1 1
55 520 60 5 6 2 2 2
56 530 55 10 5 3 3 3
57 540 50 15 4 4 4 4
58 550 45 20 3 5 5 5
59 560 40 25 2 6 6 6
60 570 35 30 1 7 7 7
61 580 30 35 0 8 8 8
62 590 25 40 1 9 9 9
63 600 20 45 2 10 10 10
64 610 15 40 3 9 9 9
65 620 10 35 4 8 8 8
66 630 5 30 5 7 7 7
67 640 0 25 6 6 6 6
68 650 -5 20 7 5 5 5
69 660 0 15 8 4 4 4
70 670 5 10 9 3 3 3
71 680 10 5 10 2 2 2
72 690 15 0 11 1 1 1
73 700 20 -5 12 0 0 0
74 710 25 0 11 1 1 1
75 720 30 5 10 2 2 2
76 730 35 10 9 3 3 3
77 740 40 15 8 4 4 4
78 750 45 20 7 5 5 5
79 760 50 25 6 6 6 6
80 770 55 30 5 7 7 7
81 780 60 35 4 8 8 8
82 790 55 40 3 9 9 9
83 800 50 45 2 10 10 10
84 810 45 40 1 9 9 9
85 820 40 35 0 8 8 8
86 830 35 30 1 7 7 7
87 840 30 25 2 6 6 6
88 850 25 20 3 5 5 5
89 860 20 15 4 4 4 4
90 870 15 10 5 3 3 3
91 880 10 5 6 2 2 2
92 890 5 0 7 1 1 1
93 900 0 -5 8 0 0 0
94 910 -5 0 9 1 1 1
95 920 0 5 10 2 2 2
96 930 5 10 11 3 3 3
97 940 10 15 12 4 4 4
98 950 15 20 11 5 5 5
99 960 20 25 10 6 6 6
100 970 25 30 9 7 7 7
101 980 30 35 8 8 8 8
102 990 35 40 7 9 9 9
103 1000 40 45 6 10 10 10

View File

@@ -0,0 +1,103 @@
#test configuration file2,,,,,,
#Time,MHVPS,BPS,APS,MC,GC,FHPS
0,60,45,10,10,10,10
10,55,40,7,9,9,9
20,50,35,4,8,8,8
30,45,30,1,7,7,7
40,40,25,-2,6,6,6
50,35,20,-5,5,5,5
60,30,15,-8,4,4,4
70,25,10,-11,3,3,3
80,20,5,-14,2,2,2
90,15,0,-17,1,1,1
100,10,-5,-20,0,0,0
110,5,0,-23,1,1,1
120,0,5,-20,2,2,2
130,-5,10,-17,3,3,3
140,0,15,-14,4,4,4
150,5,20,-11,5,5,5
160,10,25,-8,6,6,6
170,15,30,-5,7,7,7
180,20,35,-2,8,8,8
190,25,40,1,9,9,9
200,30,45,4,10,10,10
210,35,40,7,9,9,9
220,40,35,10,8,8,8
230,45,30,13,7,7,7
240,50,25,10,6,6,6
250,55,20,7,5,5,5
260,60,15,4,4,4,4
270,55,10,1,3,3,3
280,50,5,-2,2,2,2
290,45,0,-5,1,1,1
300,40,-5,-8,0,0,0
310,35,0,-11,1,1,1
320,30,5,-14,2,2,2
330,25,10,-17,3,3,3
340,20,15,-20,4,4,4
350,15,20,-23,5,5,5
360,10,25,-20,6,6,6
370,5,30,-17,7,7,7
380,0,35,-14,8,8,8
390,-5,40,-11,9,9,9
400,0,45,-8,10,10,10
410,5,40,-5,9,9,9
420,10,35,-2,8,8,8
430,15,30,1,7,7,7
440,20,25,4,6,6,6
450,25,20,7,5,5,5
460,30,15,10,4,4,4
470,35,10,13,3,3,3
480,40,5,10,2,2,2
490,45,0,7,1,1,1
500,50,-5,4,0,0,0
510,55,0,1,1,1,1
520,60,5,-2,2,2,2
530,55,10,-5,3,3,3
540,50,15,-8,4,4,4
550,45,20,-11,5,5,5
560,40,25,-14,6,6,6
570,35,30,-17,7,7,7
580,30,35,-20,8,8,8
590,25,40,-23,9,9,9
600,20,45,-20,10,10,10
610,15,40,-17,9,9,9
620,10,35,-14,8,8,8
630,5,30,-11,7,7,7
640,0,25,-8,6,6,6
650,-5,20,-5,5,5,5
660,0,15,-2,4,4,4
670,5,10,1,3,3,3
680,10,5,4,2,2,2
690,15,0,7,1,1,1
700,20,-5,10,0,0,0
710,25,0,13,1,1,1
720,30,5,10,2,2,2
730,35,10,7,3,3,3
740,40,15,4,4,4,4
750,45,20,1,5,5,5
760,50,25,-2,6,6,6
770,55,30,-5,7,7,7
780,60,35,-8,8,8,8
790,55,40,-11,9,9,9
800,50,45,-14,10,10,10
810,45,40,-17,9,9,9
820,40,35,-20,8,8,8
830,35,30,-23,7,7,7
840,30,25,-20,6,6,6
850,25,20,-17,5,5,5
860,20,15,-14,4,4,4
870,15,10,-11,3,3,3
880,10,5,-8,2,2,2
890,5,0,-5,1,1,1
900,0,-5,-2,0,0,0
910,-5,0,1,1,1,1
920,0,5,4,2,2,2
930,5,10,7,3,3,3
940,10,15,10,4,4,4
950,15,20,13,5,5,5
960,20,25,10,6,6,6
970,25,30,7,7,7,7
980,30,35,4,8,8,8
990,35,40,1,9,9,9
1000,40,45,-2,10,10,10
1 #test configuration file2
2 #Time MHVPS BPS APS MC GC FHPS
3 0 60 45 10 10 10 10
4 10 55 40 7 9 9 9
5 20 50 35 4 8 8 8
6 30 45 30 1 7 7 7
7 40 40 25 -2 6 6 6
8 50 35 20 -5 5 5 5
9 60 30 15 -8 4 4 4
10 70 25 10 -11 3 3 3
11 80 20 5 -14 2 2 2
12 90 15 0 -17 1 1 1
13 100 10 -5 -20 0 0 0
14 110 5 0 -23 1 1 1
15 120 0 5 -20 2 2 2
16 130 -5 10 -17 3 3 3
17 140 0 15 -14 4 4 4
18 150 5 20 -11 5 5 5
19 160 10 25 -8 6 6 6
20 170 15 30 -5 7 7 7
21 180 20 35 -2 8 8 8
22 190 25 40 1 9 9 9
23 200 30 45 4 10 10 10
24 210 35 40 7 9 9 9
25 220 40 35 10 8 8 8
26 230 45 30 13 7 7 7
27 240 50 25 10 6 6 6
28 250 55 20 7 5 5 5
29 260 60 15 4 4 4 4
30 270 55 10 1 3 3 3
31 280 50 5 -2 2 2 2
32 290 45 0 -5 1 1 1
33 300 40 -5 -8 0 0 0
34 310 35 0 -11 1 1 1
35 320 30 5 -14 2 2 2
36 330 25 10 -17 3 3 3
37 340 20 15 -20 4 4 4
38 350 15 20 -23 5 5 5
39 360 10 25 -20 6 6 6
40 370 5 30 -17 7 7 7
41 380 0 35 -14 8 8 8
42 390 -5 40 -11 9 9 9
43 400 0 45 -8 10 10 10
44 410 5 40 -5 9 9 9
45 420 10 35 -2 8 8 8
46 430 15 30 1 7 7 7
47 440 20 25 4 6 6 6
48 450 25 20 7 5 5 5
49 460 30 15 10 4 4 4
50 470 35 10 13 3 3 3
51 480 40 5 10 2 2 2
52 490 45 0 7 1 1 1
53 500 50 -5 4 0 0 0
54 510 55 0 1 1 1 1
55 520 60 5 -2 2 2 2
56 530 55 10 -5 3 3 3
57 540 50 15 -8 4 4 4
58 550 45 20 -11 5 5 5
59 560 40 25 -14 6 6 6
60 570 35 30 -17 7 7 7
61 580 30 35 -20 8 8 8
62 590 25 40 -23 9 9 9
63 600 20 45 -20 10 10 10
64 610 15 40 -17 9 9 9
65 620 10 35 -14 8 8 8
66 630 5 30 -11 7 7 7
67 640 0 25 -8 6 6 6
68 650 -5 20 -5 5 5 5
69 660 0 15 -2 4 4 4
70 670 5 10 1 3 3 3
71 680 10 5 4 2 2 2
72 690 15 0 7 1 1 1
73 700 20 -5 10 0 0 0
74 710 25 0 13 1 1 1
75 720 30 5 10 2 2 2
76 730 35 10 7 3 3 3
77 740 40 15 4 4 4 4
78 750 45 20 1 5 5 5
79 760 50 25 -2 6 6 6
80 770 55 30 -5 7 7 7
81 780 60 35 -8 8 8 8
82 790 55 40 -11 9 9 9
83 800 50 45 -14 10 10 10
84 810 45 40 -17 9 9 9
85 820 40 35 -20 8 8 8
86 830 35 30 -23 7 7 7
87 840 30 25 -20 6 6 6
88 850 25 20 -17 5 5 5
89 860 20 15 -14 4 4 4
90 870 15 10 -11 3 3 3
91 880 10 5 -8 2 2 2
92 890 5 0 -5 1 1 1
93 900 0 -5 -2 0 0 0
94 910 -5 0 1 1 1 1
95 920 0 5 4 2 2 2
96 930 5 10 7 3 3 3
97 940 10 15 10 4 4 4
98 950 15 20 13 5 5 5
99 960 20 25 10 6 6 6
100 970 25 30 7 7 7 7
101 980 30 35 4 8 8 8
102 990 35 40 1 9 9 9
103 1000 40 45 -2 10 10 10

View File

@@ -0,0 +1,41 @@
-100,0,0,0,0,0,0
-90,1,1,1,1,1,1
-80,2,2,2,2,2,2
-70,3,3,3,3,3,3
-60,4,4,4,4,4,4
-50,5,5,5,5,5,5
-40,6,6,6,6,6,6
-30,7,7,7,7,7,7
-20,8,8,8,8,8,8
-10,9,9,9,9,9,9
0,10,10,10,10,10,10
10,9,9,9,9,9,9
20,8,8,8,8,8,8
30,7,7,7,7,7,7
40,6,6,6,6,6,6
50,5,5,5,5,5,5
60,4,4,4,4,4,4
70,3,3,3,3,3,3
80,2,2,2,2,2,2
90,1,1,1,1,1,1
100,0,0,0,0,0,0
110,1,1,1,1,1,1
120,2,2,2,2,2,2
130,3,3,3,3,3,3
140,4,4,4,4,4,4
150,5,5,5,5,5,5
160,6,6,6,6,6,6
170,7,7,7,7,7,7
180,8,8,8,8,8,8
190,9,9,9,9,9,9
200,10,10,10,10,10,10
210,9,9,9,9,9,9
220,8,8,8,8,8,8
230,7,7,7,7,7,7
240,6,6,6,6,6,6
250,5,5,5,5,5,5
260,4,4,4,4,4,4
270,3,3,3,3,3,3
280,2,2,2,2,2,2
290,1,1,1,1,1,1
300,0,0,0,0,0,0
1 -100 0 0 0 0 0 0
2 -90 1 1 1 1 1 1
3 -80 2 2 2 2 2 2
4 -70 3 3 3 3 3 3
5 -60 4 4 4 4 4 4
6 -50 5 5 5 5 5 5
7 -40 6 6 6 6 6 6
8 -30 7 7 7 7 7 7
9 -20 8 8 8 8 8 8
10 -10 9 9 9 9 9 9
11 0 10 10 10 10 10 10
12 10 9 9 9 9 9 9
13 20 8 8 8 8 8 8
14 30 7 7 7 7 7 7
15 40 6 6 6 6 6 6
16 50 5 5 5 5 5 5
17 60 4 4 4 4 4 4
18 70 3 3 3 3 3 3
19 80 2 2 2 2 2 2
20 90 1 1 1 1 1 1
21 100 0 0 0 0 0 0
22 110 1 1 1 1 1 1
23 120 2 2 2 2 2 2
24 130 3 3 3 3 3 3
25 140 4 4 4 4 4 4
26 150 5 5 5 5 5 5
27 160 6 6 6 6 6 6
28 170 7 7 7 7 7 7
29 180 8 8 8 8 8 8
30 190 9 9 9 9 9 9
31 200 10 10 10 10 10 10
32 210 9 9 9 9 9 9
33 220 8 8 8 8 8 8
34 230 7 7 7 7 7 7
35 240 6 6 6 6 6 6
36 250 5 5 5 5 5 5
37 260 4 4 4 4 4 4
38 270 3 3 3 3 3 3
39 280 2 2 2 2 2 2
40 290 1 1 1 1 1 1
41 300 0 0 0 0 0 0

View File

@@ -0,0 +1,41 @@
-100,0,0,0,0,0
-90,1,1,1,1,1
-80,2,2,2,2,2
-70,3,3,3,3,3
-60,4,4,4,4,4
-50,5,5,5,5,5
-40,6,6,6,6,6
-30,7,7,7,7,7
-20,8,8,8,8,8
-10,9,9,9,9,9
0,10,10,10,10,10
10,9,9,9,9,9
20,8,8,8,8,8
30,7,7,7,7,7
40,6,6,6,6,6
50,5,5,5,5,5
60,4,4,4,4,4
70,3,3,3,3,3
80,2,2,2,2,2
90,1,1,1,1,1
100,0,0,0,0,0
110,1,1,1,1,1
120,2,2,2,2,2
130,3,3,3,3,3
140,4,4,4,4,4
150,5,5,5,5,5
160,6,6,6,6,6
170,7,7,7,7,7
180,8,8,8,8,8
190,9,9,9,9,9
200,10,10,10,10,10
210,9,9,9,9,9
220,8,8,8,8,8
230,7,7,7,7,7
240,6,6,6,6,6
250,5,5,5,5,5
260,4,4,4,4,4
270,3,3,3,3,3
280,2,2,2,2,2
290,1,1,1,1,1
300,0,0,0,0,0

View File

@@ -0,0 +1,103 @@
#test configuration file2,,,,,,
#Time,MHVPS,BPS,APS,MC,GC,FHPS
0,10,10,10,10,10,10
10,9,9,9,9,9,9
20,8,8,8,8,8,8
30,7,7,7,7,7,7
40,6,6,6,6,6,6
50,5,5,5,5,5,5
60,4,4,4,4,4,4
70,3,3,3,3,3,3
80,2,2,2,2,2,2
90,1,1,1,1,1,1
100,0,0,0,0,0,0
110,1,1,1,1,1,1
120,2,2,2,2,2,2
130,3,3,3,3,3,3
140,4,4,4,4,4,4
150,5,5,5,5,5,5
160,6,6,6,6,6,6
170,7,7,7,7,7,7
180,8,8,8,8,8,8
190,9,9,9,9,9,9
200,10,10,10,10,10,10
210,9,9,9,9,9,9
220,8,8,8,8,8,8
230,7,7,7,7,7,7
240,6,6,6,6,6,6
250,5,5,5,5,5,5
260,4,4,4,4,4,4
270,3,3,3,3,3,3
280,2,2,2,2,2,2
290,1,1,1,1,1,1
300,0,0,0,0,0,0
310,1,1,1,1,1,1
320,2,2,2,2,2,2
330,3,3,3,3,3,3
340,4,4,4,4,4,4
350,5,5,5,5,5,5
360,6,6,6,6,6,6
370,7,7,7,7,7,7
380,8,8,8,8,8,8
390,9,9,9,9,9,9
400,10,10,10,10,10,10
410,9,9,9,9,9,9
420,8,8,8,8,8,8
430,7,7,7,7,7,7
440,6,6,6,6,6,6
450,5,5,5,5,5,5
460,4,4,4,4,4,4
470,3,3,3,3,3,3
480,2,2,2,2,2,2
490,1,1,1,1,1,1
500,0,0,0,0,0,0
510,1,1,1,1,1,1
520,2,2,2,2,2,2
530,3,3,3,3,3,3
540,4,4,4,4,4,4
550,5,5,5,5,5,5
560,6,6,6,6,6,6
570,7,7,7,7,7,7
580,8,8,8,8,8,8
590,9,9,9,9,9,9
600,10,10,10,10,10,10
610,9,9,9,9,9,9
620,8,8,8,8,8,8
630,7,7,7,7,7,7
640,6,6,6,6,6,6
650,5,5,5,5,5,5
660,4,4,4,4,4,4
670,3,3,3,3,3,3
680,2,2,2,2,2,2
690,1,1,1,1,1,1
700,0,0,0,0,0,0
710,1,1,1,1,1,1
720,2,2,2,2,2,2
730,3,3,3,3,3,3
740,4,4,4,4,4,4
750,5,5,5,5,5,5
760,6,6,6,6,6,6
770,7,7,7,7,7,7
780,8,8,8,8,8,8
790,9,9,9,9,9,9
800,10,10,10,10,10,10
810,9,9,9,9,9,9
820,8,8,8,8,8,8
830,7,7,7,7,7,7
840,6,6,6,6,6,6
850,5,5,5,5,5,5
860,4,4,4,4,4,4
870,3,3,3,3,3,3
880,2,2,2,2,2,2
890,1,1,1,1,1,1
900,0,0,0,0,0,0
910,1,1,1,1,1,1
920,2,2,2,2,2,2
930,3,3,3,3,3,3
940,4,4,4,4,4,4
950,5,5,5,5,5,5
960,6,6,6,6,6,6
970,7,7,7,7,7,7
980,8,8,8,8,8,8
990,9,9,9,9,9,9
1000,10,10,10,10,10,10
1 #test configuration file2
2 #Time MHVPS BPS APS MC GC FHPS
3 0 10 10 10 10 10 10
4 10 9 9 9 9 9 9
5 20 8 8 8 8 8 8
6 30 7 7 7 7 7 7
7 40 6 6 6 6 6 6
8 50 5 5 5 5 5 5
9 60 4 4 4 4 4 4
10 70 3 3 3 3 3 3
11 80 2 2 2 2 2 2
12 90 1 1 1 1 1 1
13 100 0 0 0 0 0 0
14 110 1 1 1 1 1 1
15 120 2 2 2 2 2 2
16 130 3 3 3 3 3 3
17 140 4 4 4 4 4 4
18 150 5 5 5 5 5 5
19 160 6 6 6 6 6 6
20 170 7 7 7 7 7 7
21 180 8 8 8 8 8 8
22 190 9 9 9 9 9 9
23 200 10 10 10 10 10 10
24 210 9 9 9 9 9 9
25 220 8 8 8 8 8 8
26 230 7 7 7 7 7 7
27 240 6 6 6 6 6 6
28 250 5 5 5 5 5 5
29 260 4 4 4 4 4 4
30 270 3 3 3 3 3 3
31 280 2 2 2 2 2 2
32 290 1 1 1 1 1 1
33 300 0 0 0 0 0 0
34 310 1 1 1 1 1 1
35 320 2 2 2 2 2 2
36 330 3 3 3 3 3 3
37 340 4 4 4 4 4 4
38 350 5 5 5 5 5 5
39 360 6 6 6 6 6 6
40 370 7 7 7 7 7 7
41 380 8 8 8 8 8 8
42 390 9 9 9 9 9 9
43 400 10 10 10 10 10 10
44 410 9 9 9 9 9 9
45 420 8 8 8 8 8 8
46 430 7 7 7 7 7 7
47 440 6 6 6 6 6 6
48 450 5 5 5 5 5 5
49 460 4 4 4 4 4 4
50 470 3 3 3 3 3 3
51 480 2 2 2 2 2 2
52 490 1 1 1 1 1 1
53 500 0 0 0 0 0 0
54 510 1 1 1 1 1 1
55 520 2 2 2 2 2 2
56 530 3 3 3 3 3 3
57 540 4 4 4 4 4 4
58 550 5 5 5 5 5 5
59 560 6 6 6 6 6 6
60 570 7 7 7 7 7 7
61 580 8 8 8 8 8 8
62 590 9 9 9 9 9 9
63 600 10 10 10 10 10 10
64 610 9 9 9 9 9 9
65 620 8 8 8 8 8 8
66 630 7 7 7 7 7 7
67 640 6 6 6 6 6 6
68 650 5 5 5 5 5 5
69 660 4 4 4 4 4 4
70 670 3 3 3 3 3 3
71 680 2 2 2 2 2 2
72 690 1 1 1 1 1 1
73 700 0 0 0 0 0 0
74 710 1 1 1 1 1 1
75 720 2 2 2 2 2 2
76 730 3 3 3 3 3 3
77 740 4 4 4 4 4 4
78 750 5 5 5 5 5 5
79 760 6 6 6 6 6 6
80 770 7 7 7 7 7 7
81 780 8 8 8 8 8 8
82 790 9 9 9 9 9 9
83 800 10 10 10 10 10 10
84 810 9 9 9 9 9 9
85 820 8 8 8 8 8 8
86 830 7 7 7 7 7 7
87 840 6 6 6 6 6 6
88 850 5 5 5 5 5 5
89 860 4 4 4 4 4 4
90 870 3 3 3 3 3 3
91 880 2 2 2 2 2 2
92 890 1 1 1 1 1 1
93 900 0 0 0 0 0 0
94 910 1 1 1 1 1 1
95 920 2 2 2 2 2 2
96 930 3 3 3 3 3 3
97 940 4 4 4 4 4 4
98 950 5 5 5 5 5 5
99 960 6 6 6 6 6 6
100 970 7 7 7 7 7 7
101 980 8 8 8 8 8 8
102 990 9 9 9 9 9 9
103 1000 10 10 10 10 10 10

View File

@@ -0,0 +1,103 @@
#test configuration file2
#Time,BPS,APS,MC,GC,FHPS
0,10,10,10,10,10
10,9,9,9,9,9
20,8,8,8,8,8
30,7,7,7,7,7
40,6,6,6,6,6
50,5,5,5,5,5
60,4,4,4,4,4
70,3,3,3,3,3
80,2,2,2,2,2
90,1,1,1,1,1
100,0,0,0,0,0
110,1,1,1,1,1
120,2,2,2,2,2
130,3,3,3,3,3
140,4,4,4,4,4
150,5,5,5,5,5
160,6,6,6,6,6
170,7,7,7,7,7
180,8,8,8,8,8
190,9,9,9,9,9
200,10,10,10,10,10
210,9,9,9,9,9
220,8,8,8,8,8
230,7,7,7,7,7
240,6,6,6,6,6
250,5,5,5,5,5
260,4,4,4,4,4
270,3,3,3,3,3
280,2,2,2,2,2
290,1,1,1,1,1
300,0,0,0,0,0
310,1,1,1,1,1
320,2,2,2,2,2
330,3,3,3,3,3
340,4,4,4,4,4
350,5,5,5,5,5
360,6,6,6,6,6
370,7,7,7,7,7
380,8,8,8,8,8
390,9,9,9,9,9
400,10,10,10,10,10
410,9,9,9,9,9
420,8,8,8,8,8
430,7,7,7,7,7
440,6,6,6,6,6
450,5,5,5,5,5
460,4,4,4,4,4
470,3,3,3,3,3
480,2,2,2,2,2
490,1,1,1,1,1
500,0,0,0,0,0
510,1,1,1,1,1
520,2,2,2,2,2
530,3,3,3,3,3
540,4,4,4,4,4
550,5,5,5,5,5
560,6,6,6,6,6
570,7,7,7,7,7
580,8,8,8,8,8
590,9,9,9,9,9
600,10,10,10,10,10
610,9,9,9,9,9
620,8,8,8,8,8
630,7,7,7,7,7
640,6,6,6,6,6
650,5,5,5,5,5
660,4,4,4,4,4
670,3,3,3,3,3
680,2,2,2,2,2
690,1,1,1,1,1
700,0,0,0,0,0
710,1,1,1,1,1
720,2,2,2,2,2
730,3,3,3,3,3
740,4,4,4,4,4
750,5,5,5,5,5
760,6,6,6,6,6
770,7,7,7,7,7
780,8,8,8,8,8
790,9,9,9,9,9
800,10,10,10,10,10
810,9,9,9,9,9
820,8,8,8,8,8
830,7,7,7,7,7
840,6,6,6,6,6
850,5,5,5,5,5
860,4,4,4,4,4
870,3,3,3,3,3
880,2,2,2,2,2
890,1,1,1,1,1
900,0,0,0,0,0
910,1,1,1,1,1
920,2,2,2,2,2
930,3,3,3,3,3
940,4,4,4,4,4
950,5,5,5,5,5
960,6,6,6,6,6
970,7,7,7,7,7
980,8,8,8,8,8
990,9,9,9,9,9
1000,10,10,10,10,10

View File

@@ -0,0 +1,396 @@
+StateMachine = {
Class = StateMachine
+INITIAL = {
Class = ReferenceContainer
+Start = {
Class = StateMachineEvent
NextState = "WAITSTANDBY"
NextStateError = "WAITSTANDBY"
+PrepareNextStateMsg = {
Class = Message
Destination = JAGyrotronRTApp
Mode = ExpectsReply
Function = PrepareNextState
+Parameters = {
Class = ConfigurationDatabase
param1 = WaitStandby
}
}
+StartNextStateExecutionMsg = {
Class = Message
Destination = JAGyrotronRTApp
Function = StartNextStateExecution
Mode = ExpectsReply
}
}
}
+WAITSTANDBY = {
Class = ReferenceContainer
+Stay = {
Class = StateMachineEvent
NextState = "WAITSTANDBY"
NextStateError = "WAITSTANDBY"
+StopCurrentStateExecutionMsg = {
Class = Message
Destination = JAGyrotronRTApp
Function = StopCurrentStateExecution
Mode = ExpectsReply
}
+PrepareNextStateMsg = {
Class = Message
Destination = JAGyrotronRTApp
Mode = ExpectsReply
Function = PrepareNextState
+Parameters = {
Class = ConfigurationDatabase
param1 = WaitStandby
}
}
+StartNextStateExecutionMsg = {
Class = Message
Destination = JAGyrotronRTApp
Function = StartNextStateExecution
Mode = ExpectsReply
}
}
}
}
+JAGyrotronRTApp = {
Class = RealTimeApplication
+Functions = {
Class = ReferenceContainer
+GAMSDNSubCommand = {
Class = IOGAM
InputSignals = {
Command = {
DataSource = SDNSubCommands
Type = uint16
NumberOfDimensions = 1
NumberOfElements = 64
Ranges = {{0 0}}
Frequency = 1
}
ESDNTime = {
DataSource = SDNSubCommands
Type = uint32
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNTimeDisplay = {
Alias = ESDNTime
DataSource = SDNSubCommands
Type = uint32
NumberOfDimensions = 1
NumberOfElements = 1
}
}
OutputSignals = {
Command = {
DataSource = Display
Type = uint16
}
ESDNTime = {
DataSource = DDB1
Type = uint32
}
ESDNTimeDisplay = {
DataSource = Display
Type = uint32
}
}
}
+GAMSDNSubWaveform = {
Class = IOGAM
InputSignals = {
GYA_FHPS_SP = {
DataSource = SDNSubWaveform
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_MCPS_SP = {
DataSource = SDNSubWaveform
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_CCPS_SP = {
DataSource = SDNSubWaveform
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
MHVPS_SP = {
DataSource = SDNSubWaveform
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_BPS_SP = {
DataSource = SDNSubWaveform
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_APS_SP = {
DataSource = SDNSubWaveform
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
WaveformPacketIDFor1kHz = {
DataSource = SDNSubWaveform
Alias = WaveformPacketID
Type = uint16
}
}
OutputSignals = {
GYA_FHPS_SP = {
DataSource = DDB1
Type = float32
}
GYA_MCPS_SP = {
DataSource = DDB1
Type = float32
}
GYA_CCPS_SP = {
DataSource = DDB1
Type = float32
}
MHVPS_SP = {
DataSource = DDB1
Type = float32
}
GYA_BPS_SP = {
DataSource = DDB1
Type = float32
}
GYA_APS_SP = {
DataSource = DDB1
Type = float32
}
WaveformPacketIDFor1kHz = {
DataSource = DDB1
Alias = WaveformPacketID
Type = uint16
}
}
}
+GAMReply = {
Class = IOGAM
InputSignals = {
ESDNTime = {
DataSource = DDB1
Type = uint32
}
WaveformPacketID = {
DataSource = DDB1
Type = uint16
}
}
OutputSignals = {
ESDNTime = {
DataSource = SDNReply
Type = uint32
Trigger = 1
}
ReplyWaveformAck = {
DataSource = SDNReply
Type = uint16
}
}
}
}
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
+DDB1 = {
Class = GAMDataSource
}
+Timings = {
Class = TimingDataSource
}
+Display = {
Class = LoggerDataSource
}
+SDNSubCommands = {
Class = SDN::SDNSubscriber
Topic = ECPC2SCUJA
Interface = lo
CPUs = 0x2
Locked = 1
Timeout = 1000 // TODO: change to 1 ms
Signals = {
Header = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 48
}
ESDNHeaderVersionId = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNHeaderSize = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNStatus = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNDoNotUse = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNTime = {
Type = uint32
NumberOfDimensions = 1
NumberOfElements = 1
}
Command = {
Type = uint16
NumberOfDimensions = 1
NumberOfElements = 64
}
}
}
+SDNReply = {
Class = SDN::SDNPublisher
Topic = SCUJA2ECPC
Interface = lo
CPUs = 0x8
Locked = 1
Signals = {
Header = {
Type = uint8
NumberOfElements = 48
}
ESDNHeaderVersionId = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNHeaderSize = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNStatus = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNDoNotUse = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNTime = {
Type = uint32
NumberOfDimensions = 1
NumberOfElements = 1
}
ReplyStatus = {
Type = uint16
NumberOfDimensions = 1
NumberOfElements = 1
}
ReplyWaveformAck = {
Type = uint16
NumberOfDimensions = 1
NumberOfElements = 1
}
}
}
+SDNSubWaveform = {
Class = SDN::SDNSubscriber
Topic = ECPC2SCUJAWF
Interface = lo
Locked = 1
Timeout = 1000 // TODO: change to 1 ms
Signals = {
Header = {
Type = uint8
NumberOfElements = 48
}
ESDNHeaderVersionId = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNHeaderSize = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNStatus = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNDoNotUse = {
Type = uint8
NumberOfDimensions = 1
NumberOfElements = 1
}
ESDNTime = {
Type = uint32
NumberOfDimensions = 1
NumberOfElements = 1
}
WaveformPacketID = {
Type = uint16
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_MCPS_SP = {
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_CCPS_SP = {
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
MHVPS_SP = {
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_BPS_SP = {
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
GYA_APS_SP = {
Type = float32
NumberOfDimensions = 1
NumberOfElements = 1
}
}
}
}
+States = {
Class = ReferenceContainer
+WaitStandby = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
Functions = {GAMSDNSubCommand GAMSDNSubWaveform GAMReply}
CPUs = 0x1
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}

View File

@@ -0,0 +1,249 @@
// +LoggerService = {
// Class = LoggerService
// CPUs = 0x1
// StackSize = 32768
// NumberOfLogPages = 128
// +ConLogger = {
// Class = ConsoleLogger
// Format = "EtOoFmC"
// PrintKeys = 1
// }
// }
+StateMachine = {
Class = StateMachine
+INITIAL = {
Class = ReferenceContainer
+START = {
Class = StateMachineEvent
NextState = "RUNNING"
NextStateError = "ERROR"
+PrepareNextStateOnOurRTApp = {
Class = Message
Destination = MyDemoApp
Mode = ExpectsReply
Function = PrepareNextState
+Parameters = {
Class = ConfigurationDatabase
param1 = State1
}
}
+StartNextStateExecutionMsg = {
Class = Message
Destination = MyDemoApp
Function = StartNextStateExecution
Mode = ExpectsReply
}
}
}
+RUNNING = {
Class = ReferenceContainer
+LOCKEDFOREVER = {
Class = StateMachineEvent
NextState = RUNNING
NextStateError = ERROR
}
}
+ERROR = {
Class = ReferenceContainer
+LOCKEDFOREVER = {
Class = StateMachineEvent
NextState = ERROR
NextStateError = ERROR
}
}
}
+MyDemoApp = {
Class = RealTimeApplication
+Functions = {
Class = ReferenceContainer
+GAMTimer = {
Class = IOGAM
InputSignals = {
Time = {
DataSource = Timer
Type = uint32
}
Counter = {
DataSource = Timer
Type = uint32
Frequency = 1 //in Hz. Cycle for one state execution.
}
RTThreadPerf = {
DataSource = Timings
Alias = "State1.Thread1_CycleTime"
Type = uint32
}
}
OutputSignals = {
Time = {
DataSource = DDB1
Type = uint32
}
Counter = {
DataSource = DDB1
Type = uint32
}
RTThreadPerf = {
DataSource = DDB1
Type = uint32
}
}
}
+PV2DDB1 = {
Class = IOGAM
InputSignals = {
AiValue = {
DataSource = EPICSCAInput
Type = float32
}
LongInValue = {
DataSource = EPICSCAInput
Type = uint32
}
StringInValue = {
DataSource = EPICSCAInput
Type = char8
NumberOfElements = 40
}
}
OutputSignals = {
AValue = {
DataSource = DDB1
Type = float32
}
LValue = {
DataSource = DDB1
Type = uint32
}
SValue = {
DataSource = DDB1
Type = char8
NumberOfElements = 40
}
}
}
+DDB12PV = {
Class = IOGAM
InputSignals = {
AValue = {
DataSource = DDB1
Type = float32
}
LValue = {
DataSource = DDB1
Type = uint32
}
SValue = {
DataSource = DDB1
Type = char8
NumberOfElements = 40
}
}
OutputSignals = {
AoValue = {
DataSource = EPICSCAOutput
Type = float32
}
LongOutValue = {
DataSource = EPICSCAOutput
Type = uint32
}
StringOutValue = {
DataSource = EPICSCAOutput
Type = char8
NumberOfElements = 40
}
}
}
}
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
+DDB1 = {
Class = GAMDataSource
}
+Timer = {
Class = LinuxTimer
SleepNature = "Busy"
SleepPercentage = 0
ExecutionMode = RealTimeThread
CPUMask = 0x1
Signals = {
Counter = {
Type = uint32
}
Time = {
Type = uint32
}
}
}
+EPICSCAInput = {
//Class = "EPICSCA::EPICSCAInput"
Class = "JAEPICSCA::JAEPICSCAInput"
CPUMask = "1"
StackSize = "10000000"
Signals = {
AiValue = {
PVName = "ai"
Type = float32
}
LongInValue = {
PVName = "longin"
Type = uint32
}
StringInValue = {
PVName = "stringin"
Type = char8
NumberOfElements = 40
}
}
}
+EPICSCAOutput = {
//Class = "EPICSCA::EPICSCAOutput"
Class = "JAEPICSCA::JAEPICSCAOutput"
CPUMask = "1"
StackSize = "10000000"
NumberOfBuffers = 2
Signals = {
AoValue = {
PVName = "ao"
Type = float32
}
LongOutValue = {
PVName = "longout"
Type = uint32
}
StringOutValue = {
PVName = "stringout"
Type = char8
NumberOfElements = 40
}
}
}
+Display = {
Class = LoggerDataSource
}
+Timings = {
Class = TimingDataSource
}
}
+States = {
Class = ReferenceContainer
+State1 = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
Functions = {GAMTimer PV2DDB1 DDB12PV}
CPUMask = 0x1
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}

View File

@@ -0,0 +1,18 @@
record(longin, longin){
field(SCAN, "Passive")
}
record(longout, longout){
field(SCAN, "Passive")
}
record(ai, ai){
field(SCAN, "Passive")
}
record(ao, ao){
field(SCAN, "Passive")
}
record(stringin, stringin){
field(SCAN, "Passive")
}
record(stringout, stringout){
field(SCAN, "Passive")
}

View File

@@ -0,0 +1,257 @@
### The board on the Right Side Slots
# NI6259 P0 PVs
record(bo, "ni6259:d1:p0:do0"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do4"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do5"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do6"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d1:p0:do7"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
#NI6528 P3 PVs
record(bo, "ni6528:d1:p3:do0"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do4"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do5"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do6"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p3:do7"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
#NI6528 P4 PVs
record(bo, "ni6528:d1:p4:do0"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do4"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do5"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do6"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d1:p4:do7"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
### Left Side Slots
# NI6259 P0 PVs
record(bo, "ni6259:d0:p0:do0"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do4"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do5"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do6"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6259:d0:p0:do7"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
#NI6528 P3 PVs
record(bo, "ni6528:d0:p3:do0"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do4"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do5"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do6"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p3:do7"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
#NI6528 P4 PVs
record(bo, "ni6528:d0:p4:do0"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do4"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do5"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do6"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "ni6528:d0:p4:do7"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}

View File

@@ -0,0 +1,191 @@
+LoggerService = {
Class = LoggerService
CPUs = 0x1
StackSize = 32768
NumberOfLogPages = 128
+ConLogger = {
Class = ConsoleLogger
Format = "EtOoFmC"
PrintKeys = 1
}
}
+StateMachine = {
Class = StateMachine
+INITIAL = {
Class = ReferenceContainer
+START = {
Class = StateMachineEvent
NextState = "RUNNING"
NextStateError = "ERROR"
+PrepareNextStateOnOurRTApp = {
Class = Message
Destination = MyDemoApp
Mode = ExpectsReply
Function = PrepareNextState
+Parameters = {
Class = ConfigurationDatabase
param1 = State1
}
}
+StartNextStateExecutionMsg = {
Class = Message
Destination = MyDemoApp
Function = StartNextStateExecution
Mode = ExpectsReply
}
}
}
+RUNNING = {
Class = ReferenceContainer
+LOCKEDFOREVER = {
Class = StateMachineEvent
NextState = RUNNING
NextStateError = ERROR
}
}
+ERROR = {
Class = ReferenceContainer
+LOCKEDFOREVER = {
Class = StateMachineEvent
NextState = ERROR
NextStateError = ERROR
}
}
}
+MyDemoApp = {
Class = RealTimeApplication
+Functions = {
Class = ReferenceContainer
+GAMTimer = {
Class = IOGAM
InputSignals = {
Time = {
DataSource = Timer
Type = uint32
}
Counter = {
DataSource = Timer
Type = uint32
Frequency = 1 //in Hz. Cycle for one state execution.
}
RTThreadPerf = {
DataSource = Timings
Alias = "State1.Thread1_CycleTime"
Type = uint32
}
}
OutputSignals = {
Time = {
DataSource = DDB1
Type = uint32
}
Counter = {
DataSource = DDB1
Type = uint32
}
RTThreadPerf = {
DataSource = DDB1
Type = uint32
}
}
}
+GAMEPICSCA = {
Class = IOGAM
InputSignals = {
doValue = {
DataSource = EPICSCAInput
Type = uint8
}
}
OutputSignals = {
Value = {
DataSource = DDB1
Type = uint8
}
}
}
+GAMDebug = {
Class = IOGAM
InputSignals = {
Value = {
DataSource = DDB1
Type = uint8
}
}
OutputSignals = {
Value = {
DataSource = NI6528
Type = uint8
}
}
}
}
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
+DDB1 = {
Class = GAMDataSource
}
+Timer = {
Class = LinuxTimer
SleepNature = "Busy"
SleepPercentage = 0
ExecutionMode = RealTimeThread
CPUMask = 0x1
Signals = {
Counter = {
Type = uint32
}
Time = {
Type = uint32
}
}
}
+NI6528 = {
Class = NI6528
DeviceName = "/dev/pxi6528.0"
Port = 3
Value = {
Counter = {
Type = uint8
}
}
}
+EPICSCAInput = {
Class = "EPICSCA::EPICSCAInput"
CPUMask = "1"
StackSize = "10000000"
Signals = {
doValue = {
PVName = "test:doValue"
}
}
}
+Display = {
Class = LoggerDataSource
}
+Timings = {
Class = TimingDataSource
}
}
+States = {
Class = ReferenceContainer
+State1 = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
Functions = {GAMTimer GAMEPICSCA GAMDebug}
CPUMask = 0x1
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}

View File

@@ -0,0 +1,18 @@
record(bo, "test:do1"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "test:do2"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(bo, "test:do3"){
field(SCAN,"Passive")
field(ONAM, "ON")
field(ZNAM, "OFF")
}
record(longin, test:doValue){
field(SCAN, "Passive")
}

View File

@@ -0,0 +1,29 @@
ECPCSubscriber.cfg is a configuration for testing ECPC simulator (JAECPCSimulator.cfg).
Setup:
1) Run softIoc. In qst-gyrotron-fast-controller/Configurations execute command:
softIoc -d ECPC_IOC.db
2) Run ECPC simulator. In qst-gyrotron-fast-controller/Startup execute command:
./Main.sh -f ../Configurations/JAECPCSimulator.cfg -l RealTimeLoader -m StateMachine:Start
3) Run ECPC subscriber. In qst-gyrotron-fast-controller/Startup execute command:
./Main.sh -f ../Configurations/tests/ECPCSubscriber.cfg -l RealTimeLoader -m StateMachine:Start
The ECPC simulator should automatically start sending waveforms, which will be printed by the ECPC subscriber every 10 milliseconds.
The ECPC simulator will also be sending command, which is printed by the ECPC subscriber every millisecond.
To change command that is being sent, you have to caput 1 to one of following PVs:
MHVPS_ON (command 1)
GYA_BPS_SWON (command 2)
GYA_APS_SWON (command 3)
GYB_BPS_SWON (command 4)
GYB_APS_SWON (command 5)
GYA_BPS_SWOFF (command 6)
GYA_APS_SWOFF (command 7)
GYB_BPS_SWOFF (command 8)
GYB_APS_SWOFF (command 9)
RF_OFF (command 10)
To stop sending that command, caput 0 to that PV.

View File

@@ -0,0 +1,163 @@
+LoggerService = {
Class = LoggerService
CPUs = 0x1
StackSize = 32768
NumberOfLogPages = 128
+ConLogger = {
Class = ConsoleLogger
Format = "EtOoFmC"
PrintKeys = 1
}
}
+StateMachine = {
Class = StateMachine
+INITIAL = {
Class = ReferenceContainer
+START = {
Class = StateMachineEvent
NextState = "RUNNING"
NextStateError = "ERROR"
+PrepareNextStateOnOurRTApp = {
Class = Message
Destination = MyDemoApp
Mode = ExpectsReply
Function = PrepareNextState
+Parameters = {
Class = ConfigurationDatabase
param1 = State1
}
}
+StartNextStateExecutionMsg = {
Class = Message
Destination = MyDemoApp
Function = StartNextStateExecution
Mode = ExpectsReply
}
}
}
+RUNNING = {
Class = ReferenceContainer
+LOCKEDFOREVER = {
Class = StateMachineEvent
NextState = RUNNING
NextStateError = ERROR
}
}
+ERROR = {
Class = ReferenceContainer
+LOCKEDFOREVER = {
Class = StateMachineEvent
NextState = ERROR
NextStateError = ERROR
}
}
}
+MyDemoApp = {
Class = RealTimeApplication
+Functions = {
Class = ReferenceContainer
+GAMTimer = {
Class = IOGAM
InputSignals = {
Time = { //Time attribute is updated with us resolution.
DataSource = Timer
Type = uint32
}
Counter = {
DataSource = Timer
Type = uint32
Frequency = 10 //in Hz. Cycle for one state execution.
}
RTThreadPerf = {
DataSource = Timings
Alias = "State1.Thread1_CycleTime"
Type = uint32
}
}
OutputSignals = {
Time = {
DataSource = DDB1
Type = uint32
}
Counter = {
DataSource = DDB1
Type = uint32
}
RTThreadPerf = {
DataSource = DDB1
Type = uint32
}
}
}
+TimerDisplayGAM = {
Class = IOGAM
InputSignals = {
Time = {
DataSource = DDB1
Type = uint32
}
Counter = {
DataSource = DDB1
Type = uint32
}
}
OutputSignals = {
TimeDISP = {
DataSource = Display
Type = uint32
}
CounterDISP = {
DataSource = Display
Type = uint32
}
}
}
}
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
+DDB1 = {
Class = GAMDataSource
}
+Timer = {
Class = LinuxTimer
SleepNature = "Busy"
SleepPercentage = 0
ExecutionMode = RealTimeThread
CPUMask = 0x1
Signals = {
Counter = {
Type = uint32
}
Time = {
Type = uint32
}
}
}
+Display = {
Class = LoggerDataSource
}
+Timings = {
Class = TimingDataSource
}
}
+States = {
Class = ReferenceContainer
+State1 = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
Functions = {GAMTimer TimerDisplayGAM}
CPUMask = 0x1
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}

View File

@@ -0,0 +1,366 @@
/**
* @file JAEPICSCAInput.cpp
* @brief Source file for class JAEPICSCAInput
* @date 20/04/2017
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JAEPICSCAInput (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include "JAEPICSCAInput.h"
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "MemoryMapInputBroker.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
namespace MARTe {
/**
* @brief Callback function for the ca_create_subscription. Single point of access which
* delegates the events to the corresponding JAEPICSPV instance.
*/
static FastPollingMutexSem eventCallbackFastMux;
/*lint -e{1746} function must match required prototype and thus cannot be changed to constant reference.*/
void JAEPICSCAInputEventCallback(struct event_handler_args const args) {
(void) eventCallbackFastMux.FastLock();
PVWrapper *pv = static_cast<PVWrapper *>(args.usr);
if (pv != NULL_PTR(PVWrapper *)) {
(void) MemoryOperationsHelper::Copy(pv->memory, args.dbr, pv->memorySize);
}
eventCallbackFastMux.FastUnLock();
}
}
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
namespace MARTe {
JAEPICSCAInput::JAEPICSCAInput() :
DataSourceI(), EmbeddedServiceMethodBinderI(), executor(*this) {
pvs = NULL_PTR(PVWrapper *);
stackSize = THREADS_DEFAULT_STACKSIZE * 4u;
cpuMask = 0xffu;
eventCallbackFastMux.Create();
}
/*lint -e{1551} must stop the SingleThreadService in the destructor.*/
JAEPICSCAInput::~JAEPICSCAInput() {
if (!executor.Stop()) {
if (!executor.Stop()) {
REPORT_ERROR(ErrorManagement::FatalError, "Could not stop SingleThreadService.");
}
}
(void) eventCallbackFastMux.FastLock();
uint32 nOfSignals = GetNumberOfSignals();
if (pvs != NULL_PTR(PVWrapper *)) {
uint32 n;
for (n = 0u; (n < nOfSignals); n++) {
if (pvs[n].memory != NULL_PTR(void *)) {
GlobalObjectsDatabase::Instance()->GetStandardHeap()->Free(pvs[n].memory);
}
}
delete[] pvs;
}
eventCallbackFastMux.FastUnLock();
}
bool JAEPICSCAInput::Initialise(StructuredDataI & data) {
bool ok = DataSourceI::Initialise(data);
if (ok) {
if (!data.Read("CPUs", cpuMask)) {
REPORT_ERROR(ErrorManagement::Information, "No CPUs defined. Using default = %d", cpuMask);
}
if (!data.Read("StackSize", stackSize)) {
REPORT_ERROR(ErrorManagement::Information, "No StackSize defined. Using default = %d", stackSize);
}
executor.SetStackSize(stackSize);
executor.SetCPUMask(cpuMask);
}
if (ok) {
ok = data.MoveRelative("Signals");
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section");
}
if (ok) {
ok = data.Copy(originalSignalInformation);
}
if (ok) {
ok = originalSignalInformation.MoveToRoot();
}
//Do not allow to add signals in run-time
if (ok) {
ok = signalsDatabase.MoveRelative("Signals");
}
if (ok) {
ok = signalsDatabase.Write("Locked", 1u);
}
if (ok) {
ok = signalsDatabase.MoveToAncestor(1u);
}
}
if (ok) {
ok = data.MoveToAncestor(1u);
}
return ok;
}
bool JAEPICSCAInput::SetConfiguredDatabase(StructuredDataI & data) {
bool ok = DataSourceI::SetConfiguredDatabase(data);
//Check the signal index of the timing signal.
uint32 nOfSignals = GetNumberOfSignals();
if (ok) {
ok = (nOfSignals > 0u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined");
}
}
if (ok) {
//Do not allow samples
uint32 functionNumberOfSignals = 0u;
uint32 n;
if (GetFunctionNumberOfSignals(InputSignals, 0u, functionNumberOfSignals)) {
for (n = 0u; (n < functionNumberOfSignals) && (ok); n++) {
uint32 nSamples;
ok = GetFunctionSignalSamples(InputSignals, 0u, n, nSamples);
if (ok) {
ok = (nSamples == 1u);
}
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly 1");
}
}
}
}
if (ok) {
pvs = new PVWrapper[nOfSignals];
uint32 n;
for (n = 0u; (n < nOfSignals); n++) {
pvs[n].memory = NULL_PTR(void *);
}
for (n = 0u; (n < nOfSignals) && (ok); n++) {
//Note that the RealTimeApplicationConfigurationBuilder is allowed to change the order of the signals w.r.t. to the originalSignalInformation
StreamString orderedSignalName;
ok = GetSignalName(n, orderedSignalName);
if (ok) {
//Have to mix and match between the original setting of the DataSource signal
//and the ones which are later added by the RealTimeApplicationConfigurationBuilder
ok = originalSignalInformation.MoveRelative(orderedSignalName.Buffer());
}
StreamString pvName;
if (ok) {
ok = originalSignalInformation.Read("PVName", pvName);
if (!ok) {
uint32 nn = n;
REPORT_ERROR(ErrorManagement::ParametersError, "No PVName specified for signal at index %d", nn);
}
}
TypeDescriptor td = GetSignalType(n);
if (ok) {
(void) StringHelper::CopyN(&pvs[n].pvName[0], pvName.Buffer(), PV_NAME_MAX_SIZE);
if (td == CharString) {
pvs[n].pvType = DBR_STRING;
}
else if (td == Character8Bit) {
pvs[n].pvType = DBR_STRING;
}
else if (td == SignedInteger8Bit) {
pvs[n].pvType = DBR_CHAR;
}
else if (td == UnsignedInteger8Bit) {
pvs[n].pvType = DBR_CHAR;
}
else if (td == SignedInteger16Bit) {
pvs[n].pvType = DBR_SHORT;
}
else if (td == UnsignedInteger16Bit) {
pvs[n].pvType = DBR_SHORT;
}
else if (td == SignedInteger32Bit) {
pvs[n].pvType = DBR_LONG;
}
else if (td == UnsignedInteger32Bit) {
pvs[n].pvType = DBR_LONG;
}
else if (td == Float32Bit) {
pvs[n].pvType = DBR_FLOAT;
}
else if (td == Float64Bit) {
pvs[n].pvType = DBR_DOUBLE;
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Type %s is not supported", TypeDescriptor::GetTypeNameFromTypeDescriptor(td));
ok = false;
}
}
uint32 numberOfElements = 1u;
if (ok) {
ok = GetSignalNumberOfElements(n, numberOfElements);
}
if (ok) {
if (pvs[n].pvType == DBR_STRING) {
ok = (numberOfElements == 40u);
}
if (!ok) {
//Could support arrays of strings with multiples of char8[40]
REPORT_ERROR(ErrorManagement::ParametersError, "Strings shall be defined with 40 elements char8[40]. Arrays of strings are not currently supported");
}
}
if (ok) {
pvs[n].numberOfElements = numberOfElements;
}
if (ok) {
pvs[n].memorySize = td.numberOfBits;
pvs[n].memorySize /= 8u;
pvs[n].memorySize *= numberOfElements;
pvs[n].memory = GlobalObjectsDatabase::Instance()->GetStandardHeap()->Malloc(pvs[n].memorySize);
ok = originalSignalInformation.MoveToAncestor(1u);
}
}
}
if (ok) {
ok = (executor.Start() == ErrorManagement::NoError);
}
return ok;
}
bool JAEPICSCAInput::AllocateMemory() {
return true;
}
uint32 JAEPICSCAInput::GetNumberOfMemoryBuffers() {
return 1u;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The signalAddress is independent of the bufferIdx.*/
bool JAEPICSCAInput::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void*& signalAddress) {
bool ok = (pvs != NULL_PTR(PVWrapper *));
if (ok) {
ok = (signalIdx < GetNumberOfSignals());
}
if (ok) {
//lint -e{613} pvs cannot as otherwise ok would be false
signalAddress = pvs[signalIdx].memory;
}
return ok;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The brokerName only depends on the direction */
const char8* JAEPICSCAInput::GetBrokerName(StructuredDataI& data, const SignalDirection direction) {
const char8* brokerName = "";
if (direction == InputSignals) {
brokerName = "MemoryMapInputBroker";
}
return brokerName;
}
bool JAEPICSCAInput::GetInputBrokers(ReferenceContainer& inputBrokers, const char8* const functionName, void* const gamMemPtr) {
ReferenceT<MemoryMapInputBroker> broker("MemoryMapInputBroker");
bool ok = broker->Init(InputSignals, *this, functionName, gamMemPtr);
if (ok) {
ok = inputBrokers.Insert(broker);
}
return ok;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: OutputBrokers are not supported. Function returns false irrespectively of the parameters.*/
bool JAEPICSCAInput::GetOutputBrokers(ReferenceContainer& outputBrokers, const char8* const functionName, void* const gamMemPtr) {
return false;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: NOOP at StateChange, independently of the function parameters.*/
bool JAEPICSCAInput::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) {
return true;
}
ErrorManagement::ErrorType JAEPICSCAInput::Execute(ExecutionInfo& info) {
ErrorManagement::ErrorType err = ErrorManagement::NoError;
if (info.GetStage() == ExecutionInfo::StartupStage) {
(void) eventCallbackFastMux.FastLock();
/*lint -e{9130} -e{835} -e{845} -e{747} Several false positives. lint is getting confused here for some reason.*/
if (ca_context_create(ca_enable_preemptive_callback) != ECA_NORMAL) {
err = ErrorManagement::FatalError;
REPORT_ERROR(err, "ca_enable_preemptive_callback failed");
}
uint32 n;
uint32 nOfSignals = GetNumberOfSignals();
if (pvs != NULL_PTR(PVWrapper *)) {
for (n = 0u; (n < nOfSignals); n++) {
/*lint -e{9130} -e{835} -e{845} -e{747} Several false positives. lint is getting confused here for some reason.*/
if (ca_create_channel(&pvs[n].pvName[0], NULL_PTR(caCh *), NULL_PTR(void *), 20u, &pvs[n].pvChid) != ECA_NORMAL) {
err = ErrorManagement::FatalError;
REPORT_ERROR(err, "ca_create_channel failed for PV with name %s", pvs[n].pvName);
}
if (err.ErrorsCleared()) {
/*lint -e{9130} -e{835} -e{845} -e{747} Several false positives. lint is getting confused here for some reason.*/
if (ca_create_subscription(pvs[n].pvType, pvs[n].numberOfElements, pvs[n].pvChid, DBE_VALUE, &JAEPICSCAInputEventCallback, &pvs[n],
&pvs[n].pvEvid) != ECA_NORMAL) {
err = ErrorManagement::FatalError;
REPORT_ERROR(err, "ca_create_subscription failed for PV %s", pvs[n].pvName);
}
}
}
}
eventCallbackFastMux.FastUnLock();
}
else if (info.GetStage() != ExecutionInfo::BadTerminationStage) {
Sleep::Sec(1.0F);
}
else {
(void) eventCallbackFastMux.FastLock();
uint32 n;
uint32 nOfSignals = GetNumberOfSignals();
if (pvs != NULL_PTR(PVWrapper *)) {
for (n = 0u; (n < nOfSignals); n++) {
(void) ca_clear_subscription(pvs[n].pvEvid);
(void) ca_clear_event(pvs[n].pvEvid);
(void) ca_clear_channel(pvs[n].pvChid);
}
}
ca_detach_context();
ca_context_destroy();
eventCallbackFastMux.FastUnLock();
}
return err;
}
uint32 JAEPICSCAInput::GetStackSize() const {
return stackSize;
}
uint32 JAEPICSCAInput::GetCPUMask() const {
return cpuMask;
}
bool JAEPICSCAInput::Synchronise() {
return false;
}
CLASS_REGISTER(JAEPICSCAInput, "1.0")
}

View File

@@ -0,0 +1,260 @@
/**
* @file EPICSCAInput.h
* @brief Header file for class EPICSCAInput
* @date 20/04/2017
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class EPICSCAInput
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef JAEPICSCAINPUT_H_
#define JAEPICSCAINPUT_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include <cadef.h>
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "DataSourceI.h"
#include "EmbeddedServiceMethodBinderI.h"
#include "EventSem.h"
#include "SingleThreadService.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
namespace MARTe {
/**
* Maximum size that a PV name may have
*/
/*lint -esym(551, MARTe::PV_NAME_MAX_SIZE) the symbol is used to define the size of PVWrapper below*/
const uint32 PV_NAME_MAX_SIZE = 64u;
/**
* Wraps a PV
*/
struct PVWrapper {
/**
* The channel identifier
*/
chid pvChid;
/**
* The event identifier
*/
evid pvEvid;
/**
* The PV type
*/
chtype pvType;
/**
* The memory of the signal associated to this channel
*/
void *memory;
void *previousValue;
/**
* The number of elements > 0
*/
uint32 numberOfElements;
/**
* The memory size
*/
uint32 memorySize;
/**
* The PV name
*/
char8 pvName[PV_NAME_MAX_SIZE];
};
/**
* @brief A DataSource which allows to retrieved data from any number of PVs using the EPICS channel access client protocol.
* Data is asynchronously retrieved using ca_create_subscriptions in the context of a different thread (w.r.t. to the real-time thread).
*
* The configuration syntax is (names are only given as an example):
*
* <pre>
* +EPICSCAInput_1 = {
* Class = JAEPICSCA::JAEPICSCAInput
* StackSize = 1048576 //Optional the EmbeddedThread stack size. Default value is THREADS_DEFAULT_STACKSIZE * 4u
* CPUs = 0xff //Optional the affinity of the EmbeddedThread (where the EPICS context is attached).
* Signals = {
* PV1 = { //At least one shall be defined
* PVName = My::PV1 //Compulsory. Name of the PV.
* Type = uint32 //Compulsory. Supported types are char8[40], string[40], uint8, int8, uint16, int16, int32, uint32, uint64, int64, float32 and float64
* NumberOfElements = 1 //Arrays also supported
* }
* ...
* }
* }
*
* </pre>
*/
class JAEPICSCAInput: public DataSourceI, public EmbeddedServiceMethodBinderI {
public:
CLASS_REGISTER_DECLARATION()
/**
* @brief Default constructor. NOOP.
*/
JAEPICSCAInput();
/**
* @brief Destructor.
* @details TODO.
*/
virtual ~JAEPICSCAInput();
/**
* @brief See DataSourceI::AllocateMemory. NOOP.
* @return true.
*/
virtual bool AllocateMemory();
/**
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @return 1.
*/
virtual uint32 GetNumberOfMemoryBuffers();
/**
* @brief See DataSourceI::GetSignalMemoryBuffer.
* @pre
* SetConfiguredDatabase
*/
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx,
const uint32 bufferIdx,
void *&signalAddress);
/**
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @details Only InputSignals are supported.
* @return MemoryMapInputBroker.
*/
virtual const char8 *GetBrokerName(StructuredDataI &data,
const SignalDirection direction);
/**
* @brief See DataSourceI::GetInputBrokers.
* @details adds a memory MemoryMapInputBroker instance to the inputBrokers
* @return true.
*/
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers,
const char8* const functionName,
void * const gamMemPtr);
/**
* @brief See DataSourceI::GetOutputBrokers.
* @return false.
*/
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers,
const char8* const functionName,
void * const gamMemPtr);
/**
* @brief See DataSourceI::PrepareNextState. NOOP.
* @return true.
*/
virtual bool PrepareNextState(const char8 * const currentStateName,
const char8 * const nextStateName);
/**
* @brief Loads and verifies the configuration parameters detailed in the class description.
* @return true if all the mandatory parameters are correctly specified and if the specified optional parameters have valid values.
*/
virtual bool Initialise(StructuredDataI & data);
/**
* @brief Final verification of all the parameters. Setup of the memory required to hold all the signals.
* @details This method verifies that all the parameters requested by the GAMs interacting with this DataSource
* are valid and consistent with the parameters set during the initialisation phase.
* In particular the following conditions shall be met:
* - All the signals have the PVName defined
* - All the signals have one of the following types: uint32, int32, float32 or float64.
* @return true if all the parameters are valid and the conditions above are met.
*/
virtual bool SetConfiguredDatabase(StructuredDataI & data);
/**
* @brief Gets the affinity of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
* @return the the affinity of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
*/
uint32 GetCPUMask() const;
/**
* @brief Gets the stack size of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
* @return the stack size of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
*/
uint32 GetStackSize() const;
/**
* @brief Provides the context to execute all the EPICS relevant calls.
* @details Executes in the context of a spawned thread the following EPICS calls:
* ca_context_create, ca_create_channel, ca_create_subscription, ca_clear_subscription,
* ca_clear_event, ca_clear_channel, ca_detach_context and ca_context_destroy
* @return ErrorManagement::NoError if all the EPICS calls return without any error.
*/
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info);
/**
* @brief See DataSourceI::Synchronise.
* @return false.
*/
virtual bool Synchronise();
/**
* @brief Registered as the ca_create_subscription callback function.
* It calls updates the memory of the corresponding PV variable.
*/
friend void JAEPICSCAInputEventCallback(struct event_handler_args args);
private:
/**
* List of PVs.
*/
PVWrapper *pvs;
/**
* The CPU mask for the executor
*/
uint32 cpuMask;
/**
* The stack size
*/
uint32 stackSize;
/**
* The EmbeddedThread where the ca_pend_event is executed.
*/
SingleThreadService executor;
/**
* Stores the configuration information received at Initialise.
*/
ConfigurationDatabase originalSignalInformation;
};
}
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* EPICSCADATASOURCE_H_ */

View File

@@ -0,0 +1,375 @@
/**
* @file EPICSCAOutput.cpp
* @brief Source file for class EPICSCAOutput
* @date 20/04/2017
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class EPICSCAOutput (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include "JAEPICSCAOutput.h"
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "MemoryMapAsyncOutputBroker.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
namespace MARTe {
JAEPICSCAOutput::JAEPICSCAOutput() :
DataSourceI() {
pvs = NULL_PTR(PVWrapper *);
stackSize = THREADS_DEFAULT_STACKSIZE * 4u;
cpuMask = 0xffu;
numberOfBuffers = 0u;
ignoreBufferOverrun = 1u;
threadContextSet = false;
}
/*lint -e{1551} must free the memory allocated to the different PVs.*/
JAEPICSCAOutput::~JAEPICSCAOutput() {
uint32 nOfSignals = GetNumberOfSignals();
if (pvs != NULL_PTR(PVWrapper *)) {
uint32 n;
for (n = 0u; (n < nOfSignals); n++) {
if (pvs[n].pvChid != NULL_PTR(chid)) {
(void) ca_clear_channel(pvs[n].pvChid);
}
if (pvs[n].memory != NULL_PTR(void *)) {
GlobalObjectsDatabase::Instance()->GetStandardHeap()->Free(pvs[n].memory);
GlobalObjectsDatabase::Instance()->GetStandardHeap()->Free(pvs[n].previousValue);
}
}
delete[] pvs;
}
}
bool JAEPICSCAOutput::Initialise(StructuredDataI & data) {
bool ok = DataSourceI::Initialise(data);
if (ok) {
ok = data.Read("NumberOfBuffers", numberOfBuffers);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "NumberOfBuffers shall be specified");
}
}
if (ok) {
if (!data.Read("CPUs", cpuMask)) {
REPORT_ERROR(ErrorManagement::Information, "No CPUs defined. Using default = %d", cpuMask);
}
if (!data.Read("StackSize", stackSize)) {
REPORT_ERROR(ErrorManagement::Information, "No StackSize defined. Using default = %d", stackSize);
}
if (!data.Read("IgnoreBufferOverrun", ignoreBufferOverrun)) {
REPORT_ERROR(ErrorManagement::Information, "No IgnoreBufferOverrun defined. Using default = %d", ignoreBufferOverrun);
}
}
if (ok) {
ok = data.MoveRelative("Signals");
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section");
}
if (ok) {
ok = data.Copy(originalSignalInformation);
}
if (ok) {
ok = originalSignalInformation.MoveToRoot();
}
//Do not allow to add signals in run-time
if (ok) {
ok = signalsDatabase.MoveRelative("Signals");
}
if (ok) {
ok = signalsDatabase.Write("Locked", 1u);
}
if (ok) {
ok = signalsDatabase.MoveToAncestor(1u);
}
}
if (ok) {
ok = data.MoveToAncestor(1u);
}
return ok;
}
bool JAEPICSCAOutput::SetConfiguredDatabase(StructuredDataI & data) {
bool ok = DataSourceI::SetConfiguredDatabase(data);
//Check the signal index of the timing signal.
uint32 nOfSignals = GetNumberOfSignals();
if (ok) {
ok = (nOfSignals > 0u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined");
}
}
if (ok) {
//Do not allow samples
uint32 functionNumberOfSignals = 0u;
uint32 n;
if (GetFunctionNumberOfSignals(OutputSignals, 0u, functionNumberOfSignals)) {
for (n = 0u; (n < functionNumberOfSignals) && (ok); n++) {
uint32 nSamples;
ok = GetFunctionSignalSamples(OutputSignals, 0u, n, nSamples);
if (ok) {
ok = (nSamples == 1u);
}
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly 1");
}
}
}
}
//Only one and one GAM allowed to interact with this DataSourceI
if (ok) {
ok = (GetNumberOfFunctions() == 1u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Exactly one Function allowed to interact with this DataSourceI");
}
}
if (ok) {
pvs = new PVWrapper[nOfSignals];
uint32 n;
for (n = 0u; (n < nOfSignals); n++) {
pvs[n].memory = NULL_PTR(void *); //value to write PV
pvs[n].previousValue = NULL_PTR(void *); //written value
pvs[n].pvChid = NULL_PTR(chid);
}
for (n = 0u; (n < nOfSignals) && (ok); n++) {
//Note that the RealTimeApplicationConfigurationBuilder is allowed to change the order of the signals w.r.t. to the originalSignalInformation
StreamString orderedSignalName;
ok = GetSignalName(n, orderedSignalName);
if (ok) {
//Have to mix and match between the original setting of the DataSource signal
//and the ones which are later added by the RealTimeApplicationConfigurationBuilder
ok = originalSignalInformation.MoveRelative(orderedSignalName.Buffer());
}
StreamString pvName;
if (ok) {
ok = originalSignalInformation.Read("PVName", pvName);
if (!ok) {
uint32 nn = n;
REPORT_ERROR(ErrorManagement::ParametersError, "No PVName specified for signal at index %d", nn);
}
}
TypeDescriptor td = GetSignalType(n);
if (ok) {
(void) StringHelper::CopyN(&pvs[n].pvName[0], pvName.Buffer(), PV_NAME_MAX_SIZE);
if (td == CharString) {
pvs[n].pvType = DBR_STRING;
}
else if (td == Character8Bit) {
pvs[n].pvType = DBR_STRING;
}
else if (td == SignedInteger8Bit) {
pvs[n].pvType = DBR_CHAR;
}
else if (td == UnsignedInteger8Bit) {
pvs[n].pvType = DBR_CHAR;
}
else if (td == SignedInteger16Bit) {
pvs[n].pvType = DBR_SHORT;
}
else if (td == UnsignedInteger16Bit) {
pvs[n].pvType = DBR_SHORT;
}
else if (td == SignedInteger32Bit) {
pvs[n].pvType = DBR_LONG;
}
else if (td == UnsignedInteger32Bit) {
pvs[n].pvType = DBR_LONG;
}
else if (td == Float32Bit) {
pvs[n].pvType = DBR_FLOAT;
}
else if (td == Float64Bit) {
pvs[n].pvType = DBR_DOUBLE;
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Type %s is not supported", TypeDescriptor::GetTypeNameFromTypeDescriptor(td));
ok = false;
}
}
uint32 numberOfElements = 1u;
if (ok) {
ok = GetSignalNumberOfElements(n, numberOfElements);
}
if (ok) {
if (pvs[n].pvType == DBR_STRING) {
ok = (numberOfElements == 40u);
}
if (!ok) {
//Could support arrays of strings with multiples of char8[40]
REPORT_ERROR(ErrorManagement::ParametersError,
"Strings shall be defined with 40 elements char8[40]. Arrays of strings are not currently supported");
}
}
if (ok) {
pvs[n].numberOfElements = numberOfElements;
}
if (ok) {
pvs[n].memorySize = td.numberOfBits;
pvs[n].memorySize /= 8u;
pvs[n].memorySize *= numberOfElements;
pvs[n].memory = GlobalObjectsDatabase::Instance()->GetStandardHeap()->Malloc(pvs[n].memorySize);
pvs[n].previousValue = GlobalObjectsDatabase::Instance()->GetStandardHeap()->Malloc(pvs[n].memorySize);
ok = originalSignalInformation.MoveToAncestor(1u);
}
}
}
return ok;
}
bool JAEPICSCAOutput::AllocateMemory() {
return true;
}
uint32 JAEPICSCAOutput::GetNumberOfMemoryBuffers() {
return 1u;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The signalAddress is independent of the bufferIdx.*/
bool JAEPICSCAOutput::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void*& signalAddress) {
bool ok = (pvs != NULL_PTR(PVWrapper *));
if (ok) {
ok = (signalIdx < GetNumberOfSignals());
}
if (ok) {
//lint -e{613} pvs cannot as otherwise ok would be false
signalAddress = pvs[signalIdx].memory;
}
return ok;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The brokerName only depends on the direction */
const char8* JAEPICSCAOutput::GetBrokerName(StructuredDataI& data, const SignalDirection direction) {
const char8* brokerName = "";
if (direction == OutputSignals) {
brokerName = "MemoryMapAsyncOutputBroker";
}
return brokerName;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: InputBrokers are not supported. Function returns false irrespectively of the parameters.*/
bool JAEPICSCAOutput::GetInputBrokers(ReferenceContainer& inputBrokers, const char8* const functionName, void* const gamMemPtr) {
return false;
}
bool JAEPICSCAOutput::GetOutputBrokers(ReferenceContainer& outputBrokers, const char8* const functionName, void* const gamMemPtr) {
ReferenceT<MemoryMapAsyncOutputBroker> broker("MemoryMapAsyncOutputBroker");
bool ok = broker->InitWithBufferParameters(OutputSignals, *this, functionName, gamMemPtr, numberOfBuffers, cpuMask, stackSize);
if (ok) {
ok = outputBrokers.Insert(broker);
broker->SetIgnoreBufferOverrun(ignoreBufferOverrun == 1u);
}
return ok;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: NOOP at StateChange, independently of the function parameters.*/
bool JAEPICSCAOutput::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) {
return true;
}
uint32 JAEPICSCAOutput::GetStackSize() const {
return stackSize;
}
uint32 JAEPICSCAOutput::GetCPUMask() const {
return cpuMask;
}
uint32 JAEPICSCAOutput::GetNumberOfBuffers() const {
return numberOfBuffers;
}
bool JAEPICSCAOutput::Synchronise() {
bool ok = true;
uint32 n;
uint32 nOfSignals = GetNumberOfSignals();
if (!threadContextSet) {
ok = (ca_context_create(ca_enable_preemptive_callback) == ECA_NORMAL);
if (!ok) {
REPORT_ERROR(ErrorManagement::FatalError, "ca_enable_preemptive_callback failed");
}
threadContextSet = ok;
if (pvs != NULL_PTR(PVWrapper *)) {
for (n = 0u; (n < nOfSignals); n++) {
ok = (ca_create_channel(&pvs[n].pvName[0], NULL_PTR(caCh *), NULL_PTR(void *), 20u, &pvs[n].pvChid) == ECA_NORMAL);
if (!ok) {
REPORT_ERROR(ErrorManagement::FatalError, "ca_create_channel failed for PV with name %s", pvs[n].pvName);
}
}
}
}
//Allow to write event at the first time!
if (threadContextSet) {
if (pvs != NULL_PTR(PVWrapper *)) {
for (n = 0u; (n < nOfSignals); n++) {
bool isNewValue = true;
if (pvs[n].pvType == DBR_STRING) {
if(strcmp((char*)pvs[n].memory,(char*)pvs[n].previousValue)==0){
isNewValue = false;
continue;
}
if(isNewValue){
ok = (ca_put(pvs[n].pvType, pvs[n].pvChid, pvs[n].memory) == ECA_NORMAL);
memcpy(pvs[n].previousValue,pvs[n].memory, pvs[n].numberOfElements);
}
}
else {
if(memcmp(pvs[n].memory, pvs[n].previousValue, pvs[n].numberOfElements)==0){
isNewValue = false;
continue;
}
if(isNewValue){
ok = (ca_array_put(pvs[n].pvType, pvs[n].numberOfElements, pvs[n].pvChid, pvs[n].memory) == ECA_NORMAL);
memcpy(pvs[n].previousValue, pvs[n].memory, pvs[n].numberOfElements);
}
}
if (!ok) {
REPORT_ERROR(ErrorManagement::FatalError, "ca_put failed for PV: %s", pvs[n].pvName);
}
(void) ca_pend_io(0.1);
}
}
}
return ok;
}
bool JAEPICSCAOutput::IsIgnoringBufferOverrun() const {
return (ignoreBufferOverrun == 1u);
}
CLASS_REGISTER(JAEPICSCAOutput, "1.0")
}

View File

@@ -0,0 +1,233 @@
/**
* @file EPICSCAOutput.h
* @brief Header file for class EPICSCAOutput
* @date 20/04/2017
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class EPICSCAOutput
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef JAEPICSCAOutput_H_
#define JAEPICSCAOutput_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include <cadef.h>
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "DataSourceI.h"
#include "JAEPICSCAInput.h"
#include "EmbeddedServiceMethodBinderI.h"
#include "EventSem.h"
#include "SingleThreadService.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
namespace MARTe {
//Maximum size that a PV name may have
/**
* @brief A DataSource which allows to output data into any number of PVs using the EPICS channel access client protocol.
* Data is asynchronously ca_put in the context of a different thread (w.r.t. to the real-time thread).
*
* The configuration syntax is (names are only given as an example):
*
* <pre>
* +EPICSCAOutput_1 = {
* Class = EPICSCA::EPICSCAOutput
* StackSize = 1048576 //Optional the EmbeddedThread stack size. Default value is THREADS_DEFAULT_STACKSIZE * 4u
* CPUs = 0xff //Optional the affinity of the EmbeddedThread (where the EPICS context is attached).
* IgnoreBufferOverrun = 1 //Optional. If true no error will be triggered when the thread that writes into EPICS does not consume the data fast enough.
* NumberOfBuffers = 10 //Compulsory. Number of buffers in a circular buffer that asynchronously writes the PV values. Each buffer is capable of holding a copy of all the DataSourceI signals.
* Signals = {
* PV1 = { //At least one shall be defined
* PVName = My::PV1 //Compulsory. Name of the PV.
* Type = uint32 //Compulsory. Supported types are char8[40], string[40], uint8, int8, uint16, int16, int32, uint32, float32 and float64
* }
* ...
* }
* }
*
* </pre>
*/
class JAEPICSCAOutput: public DataSourceI {
public:
CLASS_REGISTER_DECLARATION()
/**
* @brief Default constructor. NOOP.
*/
JAEPICSCAOutput();
/**
* @brief Destructor.
* @details TODO.
*/
virtual ~JAEPICSCAOutput();
/**
* @brief See DataSourceI::AllocateMemory. NOOP.
* @return true.
*/
virtual bool AllocateMemory();
/**
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @return 1.
*/
virtual uint32 GetNumberOfMemoryBuffers();
/**
* @brief See DataSourceI::GetSignalMemoryBuffer.
* @pre
* SetConfiguredDatabase
*/
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx,
const uint32 bufferIdx,
void *&signalAddress);
/**
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @details Only OutputSignals are supported.
* @return MemoryMapAsyncOutputBroker.
*/
virtual const char8 *GetBrokerName(StructuredDataI &data,
const SignalDirection direction);
/**
* @brief See DataSourceI::GetInputBrokers.
* @return false.
*/
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers,
const char8* const functionName,
void * const gamMemPtr);
/**
* @brief See DataSourceI::GetOutputBrokers.
* @details adds a memory MemoryMapOutputBroker instance to the outputBrokers
* @return true.
*/
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers,
const char8* const functionName,
void * const gamMemPtr);
/**
* @brief See DataSourceI::PrepareNextState. NOOP.
* @return true.
*/
virtual bool PrepareNextState(const char8 * const currentStateName,
const char8 * const nextStateName);
/**
* @brief Loads and verifies the configuration parameters detailed in the class description.
* @return true if all the mandatory parameters are correctly specified and if the specified optional parameters have valid values.
*/
virtual bool Initialise(StructuredDataI & data);
/**
* @brief Final verification of all the parameters. Setup of the memory required to hold all the signals.
* @details This method verifies that all the parameters requested by the GAMs interacting with this DataSource
* are valid and consistent with the parameters set during the initialisation phase.
* In particular the following conditions shall be met:
* - All the signals have the PVName defined
* - All the signals have one of the following types: uint32, int32, float32 or float64.
* @return true if all the parameters are valid and the conditions above are met.
*/
virtual bool SetConfiguredDatabase(StructuredDataI & data);
/**
* @brief Gets the affinity of the thread which is going to be used to asynchronously write data with ca_put.
* @return the affinity of the thread which is going to be used to asynchronously write data with ca_put.
*/
uint32 GetCPUMask() const;
/**
* @brief Gets the stack size of the thread which is going to be used to asynchronously write data with ca_put.
* @return the stack size of the thread which is going to be used to asynchronously write data with ca_put.
*/
uint32 GetStackSize() const;
/**
* @brief Gets the number of buffers in the circular buffer that asynchronously writes the PV values.
* @return the number of buffers in the circular buffer that asynchronously writes the PV values.
*/
uint32 GetNumberOfBuffers() const;
/**
* @brief Provides the context to execute all the EPICS ca_put calls.
* @details Executes in the context of the MemoryMapAsyncOutputBroker thread the following EPICS calls:
* ca_context_create, ca_create_channel, ca_create_subscription, ca_clear_subscription,
* ca_clear_event, ca_clear_channel, ca_detach_context and ca_context_destroy
* @return true if all the EPICS calls return without any error.
*/
virtual bool Synchronise();
/**
* @brief Gets if buffer overruns is being ignored (i.e. the consumer thread which writes into EPICS is not consuming the data fast enough).
* @return if true no error is to be triggered when there is a buffer overrun.
*/
bool IsIgnoringBufferOverrun() const;
private:
/**
* List of PVs.
*/
PVWrapper *pvs;
/**
* The CPU mask for the executor
*/
uint32 cpuMask;
/**
* The stack size
*/
uint32 stackSize;
/**
* Stores the configuration information received at Initialise.
*/
ConfigurationDatabase originalSignalInformation;
/**
* The number of buffers for the circular buffer that flushes data into EPICS
*/
uint32 numberOfBuffers;
/**
* True once the epics thread context is set
*/
bool threadContextSet;
/**
* If true no error will be triggered when the data cannot be consumed by the thread doing the caputs.
*/
uint32 ignoreBufferOverrun;
};
}
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* EPICSCADATASOURCE_H_ */

View File

@@ -0,0 +1,29 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc
LIBRARIES += -L$(EPICS_BASE)/lib/$(EPICS_HOST_ARCH)/ -lca

View File

@@ -0,0 +1,58 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JAEPICSCAOutput.x JAEPICSCAInput.x
PACKAGE=DataSources
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(EPICS_BASE)/include/
INCLUDES += -I$(EPICS_BASE)/include/os/Linux/
INCLUDES += -I$(EPICS_BASE)/include/compiler/gcc/
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JAEPICSCA$(LIBEXT) \
$(BUILD_DIR)/JAEPICSCA$(DLLEXT)
echo $(OBJS)
include depends.$(TARGET)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,26 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,42 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
SPB = RandomDataSource.x NI6528.x JAEPICSCA.x
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
ROOT_DIR=..
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
all: $(OBJS) $(SUBPROJ) check-env
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
check-env:
ifndef MARTe2_DIR
$(error MARTe2_DIR is undefined)
endif

View File

@@ -0,0 +1,30 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc
LIBRARIES += -L$(CODAC_ROOT)/lib/ -lpxi6528

View File

@@ -0,0 +1,53 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=NI6528.x
PACKAGE=DataSources
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(CODAC_ROOT)/include/
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/NI6528$(LIBEXT) \
$(BUILD_DIR)/NI6528$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,141 @@
/**
* @file NI6528.cpp
* @brief Source file for class NI6528
* @date 01/03/2017
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class NI6528 (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "CompilerTypes.h"
#include "NI6528.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
NI6528::NI6528() :
MARTe::DataSourceI() {
using namespace MARTe;
previousValue = 0u;
value = 0u;
port = 0u;
boardFileDescriptor = 0;
}
NI6528::~NI6528() {
using namespace MARTe;
(void) pxi6528_close_device(boardFileDescriptor);
}
bool NI6528::SetConfiguredDatabase(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = (DataSourceI::SetConfiguredDatabase(data));
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "DataSourceI::SetConfiguredDatabas() failed");
}
if (ok) {
ok = (GetNumberOfSignals() == 1u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "GetNumberOfSignals() != 1u");
}
}
if (ok) {
ok = (GetSignalType(0u) == UnsignedInteger8Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "GetSignalType(0u) != UnsignedInteger8Bit");
}
}
return ok;
}
bool NI6528::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = DataSourceI::Initialise(data);
if (ok) {
ok = data.Read("Port", port);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The Port shall be specified");
}
}
if (ok) {
ok = data.Read("DeviceName", deviceName);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceName shall be specified");
}
}
int32 ret = pxi6528_open_device(&boardFileDescriptor, deviceName.Buffer(), O_NONBLOCK);
ok = (ret == 0);
if (!ok) {
StreamString err = strerror(-ret);
REPORT_ERROR(ErrorManagement::FatalError, "Could not open device (%s) : %s", deviceName.Buffer(), err.Buffer());
}
return ok;
}
bool NI6528::Synchronise() {
using namespace MARTe;
if(previousValue != value){
int32 ret = (pxi6528_write_port(boardFileDescriptor, port, value) > 0);
previousValue = value;
bool ok = (ret > -1);
if (!ok) {
StreamString err = strerror(-ret);
REPORT_ERROR(ErrorManagement::FatalError, "Could not write to device (%s) : %s", deviceName.Buffer(), err.Buffer());
}
}
return true;
}
bool NI6528::AllocateMemory() {
return true;
}
bool NI6528::GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress) {
signalAddress = &value;
return true;
}
const MARTe::char8 *NI6528::GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction) {
using namespace MARTe;
return "MemoryMapSynchronisedOutputBroker";
}
bool NI6528::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
CLASS_REGISTER(NI6528, "1.0")

View File

@@ -0,0 +1,143 @@
/**
* @file NI6528.h
* @brief Header file for class NI6528
* @date 07/06/2018
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class NI6528
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef RANDOM_DATASOURCE_H_
#define RANDOM_DATASOURCE_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include <pxi6528.h>
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "DataSourceI.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief NI6528 simplified data source implementation.
*
* The configuration syntax is (names and signal quantities are only given as an example):
* +NI6528 = {
* Class = NI6528
* DeviceName = "/dev/pxi6528.0" //Mandatory
* Port = 0 //The port where to write
* Signals = {
* currentValue = {Type = uint8}
* bitmask = {Type = uint8}
* Value = {Type = uint8}
* }
* }
*/
class NI6528: public MARTe::DataSourceI {
public:
CLASS_REGISTER_DECLARATION()
/**
* @brief Constructor. NOOP.
*/
NI6528 ();
/**
* @brief Destructor. NOOP.
*/
virtual ~NI6528();
/**
* @brief The configuration data detailed in the class description
* @return true if all the compulsory parameters are set.
*/
virtual bool Initialise(MARTe::StructuredDataI & data);
/**
* @brief Verifies that at most one signal has been set with the correct type (i.e. any integer).
* @return true if the above conditions are met.
*/
virtual bool SetConfiguredDatabase(MARTe::StructuredDataI & data);
/**
* @brief @see DataSourceI::Synchronise
*/
virtual bool Synchronise();
/**
* @brief @see DataSourceI::AllocateMemory
*/
virtual bool AllocateMemory();
/**
* @brief @see DataSourceI::GetSignalMemoryBuffer
*/
virtual bool GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress);
/**
* @return "MemoryMapSynchronisedInputBroker"
*/
virtual const MARTe::char8 *GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction);
/**
* @brief NOOP
*/
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName);
private:
/**
* The previous value to write.
*/
MARTe::uint8 previousValue;
/**
* The bitmask to write value. (new value) = (current value) || (bitmask) && (write value)
*/
MARTe::uint8 bitmask;
/**
* The value to write.
*/
MARTe::uint8 value;
/**
* The port number
*/
MARTe::uint32 port;
/**
* The board file descriptor
*/
pxi6528_device_t boardFileDescriptor;
/**
* The device name
*/
MARTe::StreamString deviceName;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* RANDOM_DATASOURCE_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,53 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=RandomDataSource.x
PACKAGE=DataSources
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/RandomDataSource$(LIBEXT) \
$(BUILD_DIR)/RandomDataSource$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,146 @@
/**
* @file RandomDataSource.cpp
* @brief Source file for class RandomDataSource
* @date 01/03/2017
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class RandomDataSource (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "CompilerTypes.h"
#include "RandomDataSource.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
RandomDataSource::RandomDataSource() :
MARTe::DataSourceI() {
using namespace MARTe;
seed = 0u;
signalPtr = NULL_PTR(MARTe::char8 *);
signalTypeDescriptor = UnsignedInteger8Bit;
}
RandomDataSource::~RandomDataSource() {
using namespace MARTe;
if (signalPtr) {
delete[] signalPtr;
}
}
bool RandomDataSource::SetConfiguredDatabase(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = (DataSourceI::SetConfiguredDatabase(data));
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "DataSourceI::SetConfiguredDatabas() failed");
}
if (ok) {
ok = (GetNumberOfSignals() == 1u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "GetNumberOfSignals() != 1u");
}
}
if (ok) {
signalTypeDescriptor = GetSignalType(0u);
ok = (signalTypeDescriptor.type == UnsignedInteger);
if (!ok) {
ok = (signalTypeDescriptor.type == SignedInteger);
}
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "GetSignalType(0u) != Un/SignedInteger");
}
}
return ok;
}
bool RandomDataSource::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = DataSourceI::Initialise(data);
if (ok) {
ok = data.Read("Seed", seed);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The Seed shall be specified");
}
}
return ok;
}
bool RandomDataSource::Synchronise() {
using namespace MARTe;
if (signalTypeDescriptor.numberOfBits == 8u) {
GetValue<uint8>();
}
if (signalTypeDescriptor.numberOfBits == 16u) {
GetValue<uint16>();
}
if (signalTypeDescriptor.numberOfBits == 32u) {
GetValue<uint32>();
}
if (signalTypeDescriptor.numberOfBits == 64u) {
GetValue<uint64>();
}
return true;
}
bool RandomDataSource::AllocateMemory() {
signalPtr = new MARTe::char8[signalTypeDescriptor.numberOfBits];
return true;
}
bool RandomDataSource::GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress) {
signalAddress = &signalPtr[0];
return true;
}
const MARTe::char8 *RandomDataSource::GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction) {
using namespace MARTe;
static bool firstTime = true;
const char8 * broker;// = NULL_PTR(const char8 *);
if (firstTime) {
broker = "MemoryMapSynchronisedInputBroker";
}
else {
firstTime = false;
broker = "MemoryMapInputBroker";
}
return broker;
}
bool RandomDataSource::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
CLASS_REGISTER(RandomDataSource, "1.0")

View File

@@ -0,0 +1,137 @@
/**
* @file RandomDataSource.h
* @brief Header file for class RandomDataSource
* @date 07/06/2018
* @author Andre Neto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class RandomDataSource
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef RANDOM_DATASOURCE_H_
#define RANDOM_DATASOURCE_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "DataSourceI.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief DataDource which generates random numbers against a given seed.
*
* The configuration syntax is (names and signal quantities are only given as an example):
* +RandomDataSource = {
* Class = RandomDataSource
* Seed = 8 //Seed against which the the seed will be generated. Note that each signal
* Signals = {
* Random1 = { //Maximum one signal
* Type = uint64 //All the integer types are supported
* }
* }
* }
*/
class RandomDataSource: public MARTe::DataSourceI {
public:
CLASS_REGISTER_DECLARATION()
/**
* @brief Constructor. NOOP.
*/
RandomDataSource ();
/**
* @brief Destructor. NOOP.
*/
virtual ~RandomDataSource();
/**
* @brief The configuration data detailed in the class description
* @return true if all the compulsory parameters are set.
*/
virtual bool Initialise(MARTe::StructuredDataI & data);
/**
* @brief Verifies that at most one signal has been set with the correct type (i.e. any integer).
* @return true if the above conditions are met.
*/
virtual bool SetConfiguredDatabase(MARTe::StructuredDataI & data);
/**
* @brief @see DataSourceI::Synchronise
*/
virtual bool Synchronise();
/**
* @brief @see DataSourceI::AllocateMemory
*/
virtual bool AllocateMemory();
/**
* @brief @see DataSourceI::GetSignalMemoryBuffer
*/
virtual bool GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress);
/**
* @return "MemoryMapSynchronisedInputBroker"
*/
virtual const MARTe::char8 *GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction);
/**
* @brief NOOP
*/
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName);
private:
/**
* The seed to compute the signals.
*/
MARTe::uint32 seed;
/**
* The signal pointer
*/
MARTe::char8 *signalPtr;
/**
* The signal type descriptor.
*/
MARTe::TypeDescriptor signalTypeDescriptor;
/**
* Compute the random value
*/
template<typename T>
void GetValue();
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
template<typename T>
void RandomDataSource::GetValue() {
*(reinterpret_cast<T *>(&signalPtr[0u])) = static_cast<T>(rand_r(&seed));
}
#endif /* RANDOM_DATASOURCE_H_ */

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,463 @@
**********
* EXAMLE *
**********
State1 // RT application state name
==========
1. // Numbered GAMs in order of execution
if (signal_A == 1) // Execution function of the GAM
{
set signal_B = 3
change state to State2
}
----------
*****************
* RT APP STATES *
*****************
WaitStandby
==========
1. // DONE
if (EC-GN-P01-GAF:PLC4110-CON-OPGY1 == 0) //If a Gyrotron is not selected by PLC.
{
change state to Disabled
}
----------
2. // DONE
if (EC-GN-P01-GPF:PLC4110-YTS-ST1R == 1) //If STANDBY signal come from PLC, start Coil&Fil PSs.
{
// TODO should these signals be set only once every time this state is entered?
set signal EC-GN-P01-GAF-MCPS:PSU2120-ACT-SP = 1
set signal EC-GN-P01-GAF-GCPS:PSU2130-ACT-SP = 1
set signal EC-GN-P01-GAF-FHPS:PSU2610-AUTO-START = 1
}
----------
3. // DONE
if (EC-GN-P01-GAF-MCPS:PSU2120-ACT-RB == 1
AND
EC-GN-P01-GAF-MCPS:PSU2120-CURR-MON > 0
AND
EC-GN-P01-GAF-FHPS:PSU2610-OUTON-RB == 1
AND
EC-GN-P01-GAF-FHPS:PSU2610-CURR-RB > 0)
{
change state to Offline
}
----------
Disabled
==========
1. // DONE
if (EC-GN-P01-GAF:PLC4110-CON-OPGY1 == 1)
{
change state to WaitStandby
}
----------
Offline
==========
1. // DONE
if (EC-GN-P01-GAF:PLC4110-CON-OPGY1 == 0) //If Gyrotron selection is turned off.
{
change state to Disabled
}
----------
2. // DONE
// If READY signal come from PLC is equal 1, app starts CCPS.
if (EC-GN-P01-GPF:PLC4110-YTS-ST2R == 1
AND
EC-GN-P01-GAF-CCPS:PLC4110-YON-CCPS1 == 1)
{
// TODO should this signal be set only once every time this state is entered?
set signal EC-GN-P01-GAF-CCPS:PSU2320-OUTON-SP = 1
}
----------
3. // DONE (with a temporary signal that needs to be changed when the record is added)
// TODO: Do we also have to check, that GAM 2. executed? So do we also have to check that EC-GN-P01-GPF:PLC4110-YTS-ST2R == 1?
if (EC-GN-P01-GAF-CCPS:PSU2320-STAT == 1) // TODO: there is no signal named EC-GN-P01-GAF-CCPS:PSU2320-STAT
// MEMO: I need add this record to check whether CCPS in running or stop.
{
change state to WaitPermit
}
----------
4. // DONE
// Wait CSV-LOAD trigger. When the app detect it, save data into the app.
if (EC-GN-P01-GAF:STAT-CSV-LOAD == 1)
{
open csv file (file name: EC-GN-P01-GAF:STAT-CSV-NAME)
load time series data into memory
write data into EPICS waveform PSs.(EC-GN-P01-???:STAT-PREP-WF) // TODO do we realy write first data here or do we wait for PreHeating?
set signal EC-GN-P01-GAF:STAT-CSV-LOADED = 1 // TODO do we write 1 here?
If there is error, write EC-GN-P01-GAF:STAT-CSV-ERROR. // TODO there is no signal named EC-GN-P01-GAF:STAT-CSV-ERROR
}
WaitPermit
==========
1. // DONE
if (EC-GN-P01-GAF:PLC4110-CON-OPGY1 == 0) //If Gyrotron is un-selected.
{
change state to Disabled
}
----------
2. // DONE
if (EC-GN-P01-GAF:STAT-PREP-MODE == 1
AND
EC-GN-P01-GAF:PLC4110-CON-GY1PRM == 1)
{
change state to PreHeating
}
----------
3. // DONE
if (EC-GN-P01-GAF:STAT-PREP-MODE == 0
AND
EC-GN-P01-GAF:PLC4110-CON-GY1PRM == 1)
{
change state to WaitReady
}
----------
4. // DONE
if (EC-GN-P01-GAF:STAT-CSV-LOAD == 1)
{
open csv file (file name: EC-GN-P01-GAF:STAT-CSV-NAME)
load time series data into memory
write data into EPICS waveform PSs.(EC-GN-P01-???:STAT-PREP-WF)
set signal EC-GN-P01-GAF:STAT-CSV-LOADED = 1
If there is error, write EC-GN-P01-GAF:STAT-CSV-ERROR.
}
PreHeating
==========
1. // DONE
every 10 ms do
{
else
{
// TODO do we use float32 for the type of waveform signals?
// TODO is this the right order of columns? Time point is in column 1.
// TODO on what signal do we write time?
set signal EC-GN-P01-PB1F:PSU1000-EREF = setpoint column 2
set signal EC-GN-P01-PA1F:PSU3000-EREF = setpoint column 3 // TODO there are two EC-GN-P01-PA1F:PSU3000-EREF signals. One ending with -P and one with -N.
set signal EC-GN-P01-GAF-MCPS:PSU2120-TRG-CURR-SET = setpoint column 4
set signal EC-GN-P01-GAF-GCPS:PSU2130-TRG-CURR-SET = setpoint column 5
set signal EC-GN-P01-GAF-FHPS:PSU2320-EREF = setpoint column 6
}
}
----------
2. // DONE
if (time == 0)
{
change state to WaitReady
}
----------
WaitReady
==========
1. // DONE
if (EC-GN-P01-PB1F:PSU1000-YSTA == 1
AND
EC-GN-P01-PA1F:PSU3000-YSTA == 1)
{
change state to WaitHVON
}
----------
WaitHVON
==========
1. // DONE
if (EC-GN-P01-GPF:PLC4110-YTS-ST3R == 1)// Check ON signal from PLC. This signal come when PLC check the operation operation possible conditions.
{
change state to HVArming
}
----------
2. // DONE
if (EC-GN-P01-GPF:PLC4110-YTS-ST3R == 1)
{
start HVON timer
}
----------
HVArming //HVArming is a state to startup HV generation in APS and BPS.
==========
1.
at specified time // TODO: Where do I get this specified time? And is it a countdown time or what?
// MEMO: Time is specified by PVs (EC-GN-P01-PB1F:STAT-DT-HVON). When app detect HVON from PLC, it is t=0.
{
set signal EC-GN-P01-PB1F:PSU1000-CON-HV = 1
}
----------
2.
at specified time // TODO: Where do I get this specified time? And is it a countdown time or what?
// MEMO: Time is specified by PVs (EC-GN-P01-PA1F:STAT-DT-HVON)
{
set signal EC-GN-P01-PA1F:PSU3000-CON-HV = 1
}
----------
3.
if (EC-GN-P01-PB1F:PSU1000-CON-HV == 1
AND
EC-GN-P01-PA1F:PSU3000-CON-HV == 1
AND
EC-GN-P01-GPF::PLC4110-YSTA-MPSS == 0) // MEMO: Both HV PVs are 1. i.e.Both PSs are charged HV. and is in async mode.
{
change state to HVArmed
}
----------
4.
if (EC-GN-P01-PB1F:PSU1000-CON-HV == 1
AND
EC-GN-P01-PA1F:PSU3000-CON-HV == 1
AND
EC-GN-P01-GPF::PLC4110-YSTA-MPSS == 1) // MEMO: HVPS HVs are ON and is in SYNC mode.
{
Change state to HVArmedESDN
}
----------
5.
count up elapsed time (time from HVON detection)
Write time to EC-GN-P01-GAF:STAT-ELAPSED
HVArmed
==========
1.
if (EC-GN-P01-GPF:PLC4110-YTS-ST3R == 0) // TODO: when do we go from HVArmed to Offline?
// MEMO: move to Offline when ON signal from PLC is turned off.
{
change state to Offline
}
----------
2.
// TODO: "(Entry) Write EC-GN-P01-GAF:PCF4210-YTS-GA1" What does Entry mean? Does it mean to do something
// only on the first cycle when we enter this state? What do I write to signal EC-GN-P01-GAF:PCF4210-YTS-GA1?
// MEMO: EC-GN-P01-GAF:PCF4210-YTS-GA1 is a PV that fast controller notifies Gyrotron operation state to PLC.
// When enter the HVArmed state, App writes 1 to this EPICS PV.
----------
3.
if (EC-GN-P01-PB1F:PSU1000-CON-SW == 1) // TODO: when do we go from HVArmed to HVInjectionBPS?
// MEMO: If MHVPS HV is turned ON first, goto this state.
{
change state to HVInjectionBPS
}
----------
4.
if (EC-GN-P01-PMF:PSU0000-CON-SW == 1) // TODO: when do we go from HVArmed to HVInjectionMHVPS?
// MEMO: If BPS HV is turned ON first, goto this state.
{
change state to HVInjectionMHVPS
}
----------
5.
count up elapsed time (time from HVON detection)
Write time to EC-GN-P01-GAF:STAT-ELAPSED
----------
6.
if (EC-GN-P01-GPF::PLC4110-YSTA-MPSS == 1) //When SYNC mode turned ON.
{
change state to HVArmedESDN
}
----------
HVArmedESDN // Start ESDN command, waveform subscription.
==========
1.
if (EC-GN-P01-GPF:PLC4110-YTS-ST3R == 0)
{
change state to Offline
}
----------
2.
if (EC-GN-P01-PB1F:PSU1000-CON-SW == 1)
{
change state to HVInjectionBPSESDN
}
----------
3.
if (EC-GN-P01-PMF:PSU0000-CON-SW == 1)
{
change state to HVInjectionMHVPSESDN
}
----------
4.
count up elapsed time (time from HVON detection)
Write time to EC-GN-P01-GAF:STAT-ELAPSED
----------
6.
if (EC-GN-P01-GPF::PLC4110-YSTA-MPSS == 0) //When SYNC mode turned ON.
{
change state to HVArmed
}
----------
HVInjectionBPS
==========
HVInjectionMHVPS
==========
1.
// MEMO: Write Gyrotron state PV (HVInjection) to notify PLC.
Write 1 to EC-GN-P01-GAF:PCF4210-YTS-GA2.
----------
// TODO: Following questions/states are for ALL of the above states
2. (Exist in HVInjection BPS)
set signal EC-GN-P01-PA1F:PSU3000-CON-SW = 1 // TODO when do we set this signal
// MEMO: Countdown time for EC-GN-P01-PA1F:STAT-DT-SWON
----------
2. (Exist in HVInjection MHVPS)
set signal EC-GN-P01-PB1F:PSU1000-CON-SW = 1 // TODO when do we set this signal
// MEMO: Countdown time for EC-GN-P01-PB1F:STAT-DT-SWON
----------
3.
set signal EC-GN-P01-PMF:PSU0000-CON-SW = 1 // TODO when do we set this signal
// MEMO: Countdown time for EC-GN-P01-PMF:STAT-DT-SWON
----------
4.
// TODO when to switch to RFON?
// MEMO: Go to RFON state when All switch PVs are 1. and the mode is async.
if (EC-GN-P01-PA1F:PSU3000-CON-SW == 1 AND
EC-GN-P01-PB1F:PSU1000-CON-SW == 1 AND
EC-GN-P01-PMF:PSU0000-CON-SW == 1)
{
change state to RFON
}
----------
5.
count up elapsed time (time from HVON detection)
Write time to EC-GN-P01-GAF:STAT-ELAPSED
----------
HVInjectionESDN
==========
1.
// MEMO: Write Gyrotron state PV (HVInjection) to notify PLC.
Write 1 to EC-GN-P01-GAF:PCF4210-YTS-GA2.
----------
2.
set signal EC-GN-P01-PA1F:PSU3000-CON-SW = 1
// Write 1 when ESDN command give a command.
----------
3.
set signal EC-GN-P01-PB1F:PSU1000-CON-SW = 1
// Write 1 when ESDN command give a command.
----------
4.
set signal EC-GN-P01-PMF:PSU0000-CON-SW = 1
// Write 1 when ESDN command give a command.
----------
5.
// TODO when to switch to RFONESDN?
// MEMO: Go to RFON state when All switch PVs are 1. and the mode is sync.i,e. change from HVInjectionxxxESDN
if (EC-GN-P01-PA1F:PSU3000-CON-SW == 1 AND
EC-GN-P01-PB1F:PSU1000-CON-SW == 1 AND
EC-GN-P01-PMF:PSU0000-CON-SW == 1)
{
change state to RFONESDN
}
----------
RFON
==========
// TODO is this correct?
1.
// This only executes on the last cycle before we move to HVArmed
if (EC-GN-P01-GAF:STAT-BEAMON-TIME >= EC-GN-P01-GAF:STAT-DT-SHOTLEN)
{
set signal EC-GN-P01-PA1F:PSU3000-CON-SW = 0
set signal EC-GN-P01-PB1F:PSU1000-CON-SW = 0
set signal EC-GN-P01-PMF:PSU0000-CON-SW = 0
}
----------
2.
if (EC-GN-P01-GAF:STAT-BEAMON-TIME >= EC-GN-P01-GAF:STAT-DT-SHOTLEN)
{
change state to HVArmed
}
----------
3.
count up elapsed time (time from HVON detection)
Write time to EC-GN-P01-GAF:STAT-ELAPSED
----------
4.
When enter the state beam-on timer is set to 0.
count up beam-on time. write the time into EC-GN-P01-GAF:STAT-BEAMON-TIME
----------
RFONESDN
==========
// TODO is this correct?
// MEMO: In the ESDN sync mode, HVPS turned off by ESDN packet.
// In both mode, there is mode_limit which is given by (EC-GN-P01-GPF:PLC4110-YTS-MD1,2,3,4).
1.
// This only executes on the last cycle before we move to HVArmed
if (EC-GN-P01-GAF:STAT-BEAMON-TIME >= t_mode_limit) // TODO: where do I get t_mode_limit?
{
set signal EC-GN-P01-PA1F:PSU3000-CON-SW = 0
set signal EC-GN-P01-PB1F:PSU1000-CON-SW = 0
set signal EC-GN-P01-PMF:PSU0000-CON-SW = 0
}
----------
2.
if (EC-GN-P01-GAF:STAT-BEAMON-TIME >= t_mode_limit) // TODO: where do I get t_mode_limit?
{
change state to HVArmedESDN
}
----------
3.
Subscribe ESDN commands. When GAM detect Beam-off command. It turn all HVPS SW OFF.
And change state to HVArmedESDN
----------
4.
count up elapsed time (time from HVON detection)
Write time to EC-GN-P01-GAF:STAT-ELAPSED
----------
5.
When enter the state beam-on timer is set to 0.
count up beam-on time. write the time into EC-GN-P01-GAF:STAT-BEAMON-TIME
----------
Error
==========
1.
// Only execute on the first cycle after entering this state
if (first)
{
set first = false
set signal EC-GN-P01-PA1F:PUS3000-CON-HV = 0 // TODO: there is no signal named EC-GN-P01-PA1F:PUS3000-CON-HV
set signal EC-GN-P01-PA1F:PSU3000-CON-SW = 0
set signal EC-GN-P01-PB1F:PSU1000-CON-HV = 0
set signal EC-GN-P01-PB1F:PSU1000-CON-SW = 0
set signal EC-GN-P01-PMF:PSU0000-CON-SW = 0
// MEMO: PA2F and PB2F are component type for gyrotron B. I will remove following action.
set signal EC-GN-P01-PA2F:PUS4000-CON-HV = 0 // TODO: there is no signal named EC-GN-P01-PA2F:PUS4000-CON-HV
set signal EC-GN-P01-PA2F:PSU4000-CON-SW = 0 // TODO: signal EC-GN-P01-PA2F:PSU4000-CON-SW missing in configuration file
set signal EC-GN-P01-PB2F:PSU2000-CON-HV = 0 // TODO: signal EC-GN-P01-PB2F:PSU2000-CON-HV missing in configuration file
set signal EC-GN-P01-PB2F:PSU2000-CON-SW = 0 // TODO: signal EC-GN-P01-PB2F:PSU2000-CON-SW missing in configuration file
set signal EC-GN-P01-PMF:PSU0000-CON-SW = 1
set signal EC-GN-P01-PA1F:PSU3000-CTRP = 1
set signal EC-GN-P01-PB1F:PSU1000-CTRP = 1
// MEMO: PA2F and PB2F are component type for gyrotron B. I will remove following action.
set signal EC-GN-P01-PA2F:PSU4000-CTRP = 1 // TODO: signal EC-GN-P01-PA2F:PSU4000-CTRP missing in configuration file
set signal EC-GN-P01-PB2F:PSU1000-CTRP = 1 // TODO: there is no signal named EC-GN-P01-PB2F:PSU1000-CTRP
}
----------
2.
if (EC-GN-P01-GPF:STAT-RST-FLT == 1 && ) // TODO: when do we go to Offline state?
{
change state to Offline
}
----------

View File

@@ -0,0 +1,123 @@
/**
* @file JABitReverseGAM.cpp
* @brief Source file for class JABitReverseGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JABitReverseGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JABitReverseGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JABitReverseGAM::JABitReverseGAM() {
//Input signals.
input1 = NULL_PTR(MARTe::uint8 *);
//Output signals.
output1= NULL_PTR(MARTe::uint8 *);
}
JABitReverseGAM::~JABitReverseGAM() {
}
bool JABitReverseGAM::Initialise(MARTe::StructuredDataI & data) {
//GAM parameters are initialized.
using namespace MARTe;
bool ok = GAM::Initialise(data);
return ok;
}
bool JABitReverseGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
//This method changes internal parameter based on next realtime state.
return true;
}
bool JABitReverseGAM::Setup() {
// Setup memory for input/output signals on the GAM.
using namespace MARTe;
bool ok = (numberOfInputSignals == 1u);
if (ok) {
ok = (numberOfOutputSignals == 1u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One output signal shall be defined");
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One input signals shall be defined");
}
// Do type check for input signals.
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = ((inputType == UnsignedInteger8Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
}
}
}
// Do type check for output signals
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = ((outputType == UnsignedInteger8Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
}
}
}
// Do type cast.
if (ok) {
input1 = reinterpret_cast<uint8 *>(GetInputSignalMemory(0));
output1 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(0));
}
return ok;
}
bool JABitReverseGAM::Execute() {
// This method is called every realtime state thread cycle.
using namespace MARTe;
*output1 = ~(*input1);
return true;
}
CLASS_REGISTER(JABitReverseGAM, "1.0")

View File

@@ -0,0 +1,75 @@
/**
* @file JABitReverseGAM.h
* @brief Header file for class JABitReverseGAM
* @date Mar 18, 2020
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JABitReverseGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JABitReverseGAM_H_
#define GAMS_JABitReverseGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
class JABitReverseGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JABitReverseGAM();
virtual ~JABitReverseGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
// Input signals
MARTe::uint8 *input1;
// Output signals
MARTe::uint8 *output1;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JABitReverseGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JABitReverseGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JABitReverseGAM$(LIBEXT) \
$(BUILD_DIR)/JABitReverseGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,143 @@
/**
* @file JABitSumGAM.cpp
* @brief Source file for class JABitSumGAM
* @date Feb 10, 2020
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JABitSumGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JABitSumGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JABitSumGAM::JABitSumGAM() {
//Input signals.
input0 = NULL_PTR(MARTe::uint32 *);
input1 = NULL_PTR(MARTe::uint32 *);
input2 = NULL_PTR(MARTe::uint32 *);
input3 = NULL_PTR(MARTe::uint32 *);
input4 = NULL_PTR(MARTe::uint32 *);
input5 = NULL_PTR(MARTe::uint32 *);
input6 = NULL_PTR(MARTe::uint32 *);
input7 = NULL_PTR(MARTe::uint32 *);
//Output signals.
output= NULL_PTR(MARTe::uint8 *);
}
JABitSumGAM::~JABitSumGAM() {
}
bool JABitSumGAM::Initialise(MARTe::StructuredDataI & data) {
//GAM parameters are initialized.
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (!ok){
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "ParametersError in init.");
}
return ok;
}
bool JABitSumGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
//This method changes internal parameter based on next realtime state.
return true;
}
bool JABitSumGAM::Setup() {
// Setup memory for input/output signals on the GAM.
using namespace MARTe;
bool ok = (numberOfInputSignals == 8u);
if (ok) {
ok = (numberOfOutputSignals == 1u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One output signal shall be defined");
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Eight input signals shall be defined");
}
// Do type check for input signals.
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32.", signalName.Buffer());
}
}
}
// Do type check for output signals
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = (outputType == UnsignedInteger8Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
}
}
}
// Do type cast.
if (ok) {
input0 = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
input1 = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
input2 = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
input3 = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
input4 = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
input5 = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
input6 = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
input7 = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
output = reinterpret_cast<uint8 *>(GetOutputSignalMemory(0));
}
return ok;
}
bool JABitSumGAM::Execute() {
// This method is called every realtime state thread cycle.
using namespace MARTe;
*output = *input0 + *input1*2 + *input2*4 + *input3*8 + *input4*16 +
*input5*32 + *input6*64 + *input7*128;
return true;
}
CLASS_REGISTER(JABitSumGAM, "1.0")

View File

@@ -0,0 +1,81 @@
/**
* @file JABitSumGAM.h
* @brief Header file for class JABitSumGAM
* @date Feb 10, 2020
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JABitSumGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JABitSumGAM_H_
#define GAMS_JABitSumGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
#include "stdio.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
class JABitSumGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JABitSumGAM();
virtual ~JABitSumGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
// Input signals
MARTe::uint32 *input0;
MARTe::uint32 *input1;
MARTe::uint32 *input2;
MARTe::uint32 *input3;
MARTe::uint32 *input4;
MARTe::uint32 *input5;
MARTe::uint32 *input6;
MARTe::uint32 *input7;
// Output signals
MARTe::uint8 *output;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JABitSumGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JABitSumGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JABitSumGAM$(LIBEXT) \
$(BUILD_DIR)/JABitSumGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,309 @@
/**
* @file JAConditionalSignalUpdateGAM.cpp
* @brief Source file for class JAConditionalSignalUpdateGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JAConditionalSignalUpdateGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JAConditionalSignalUpdateGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JAConditionalSignalUpdateGAM::JAConditionalSignalUpdateGAM() {
inputSignals = NULL_PTR(void **);
inputSignalTypes = NULL_PTR(MARTe::TypeDescriptor *);
values = NULL_PTR(MARTe::uint32 *);
valuesCount = 0u;
outputSignals = NULL_PTR(MARTe::uint32 **);
defaultValues = NULL_PTR(MARTe::uint32 **);
needsReset = false;
expectedValues = NULL_PTR(MARTe::uint32 *);
expectedValuesCount = 0u;
operation = And;
comparators = NULL_PTR(ComparisonMode *);
}
JAConditionalSignalUpdateGAM::~JAConditionalSignalUpdateGAM() {
if (outputSignals != NULL_PTR(MARTe::uint32 **)) {
delete[] outputSignals;
}
if (inputSignals != NULL_PTR(void **)) {
delete[] inputSignals;
}
if (inputSignalTypes != NULL_PTR(MARTe::TypeDescriptor *)) {
delete[] inputSignalTypes;
}
if (values != NULL_PTR(MARTe::uint32 *)) {
delete[] values;
}
if (comparators != NULL_PTR(ComparisonMode *)) {
delete[] comparators;
}
if (defaultValues != NULL_PTR(MARTe::uint32 **)) {
delete[] defaultValues;
}
}
bool JAConditionalSignalUpdateGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
// Read expected values.
AnyType valuesArray = data.GetType("ExpectedValues");
if (valuesArray.GetDataPointer() != NULL) {
expectedValuesCount = valuesArray.GetNumberOfElements(0u);
expectedValues = new uint32[expectedValuesCount];
Vector<uint32> valuesVector(expectedValues, expectedValuesCount);
ok = (data.Read("ExpectedValues", valuesVector));
}
}
if (ok) {
// Read comparators.
AnyType comparatorsArray = data.GetType("Comparators");
if (comparatorsArray.GetDataPointer() != NULL) {
uint32 count;
if (ok) {
count = comparatorsArray.GetNumberOfElements(0u);
ok = count == expectedValuesCount;
}
if (ok) {
comparators = new ComparisonMode[count];
StreamString* comp = new StreamString[count];
Vector<StreamString> compVector(comp, count);
ok = (data.Read("Comparators", compVector));
if (ok) {
for (uint32 i = 0; i < count; ++i) {
if (comp[i] == "EQUALS") {
comparators[i] = Equals;
} else if (comp[i] == "NOT") {
comparators[i] = Not;
} else if (comp[i] == "GREATER") {
comparators[i] = Greater;
} else if (comp[i] == "EQUALS_OR_GREATER") {
comparators[i] = EqualsOrGreater;
} else if (comp[i] == "LESS") {
comparators[i] = Less;
} else if (comp[i] == "EQUALS_OR_LESS") {
comparators[i] = EqualsOrLess;
} else {
ok = false;
REPORT_ERROR(ErrorManagement::ParametersError, "Comparator %s is not defined.", comp[i].Buffer());
}
}
}
delete[] comp;
} else {
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
"number of elements.");
}
} else {
// Create default comparators (equals) when they aren't provided in the configuration.
comparators = new ComparisonMode[expectedValuesCount];
for (uint32 i = 0; i < expectedValuesCount; ++i) {
comparators[i] = Equals;
}
}
}
if (ok) {
MARTe::StreamString operationStr;
if (data.Read("Operation", operationStr)) {
if (operationStr == "AND") {
operation = And;
}
else if (operationStr == "OR") {
operation = Or;
}
else if (operationStr == "NOR") {
operation = Nor;
}
else if (operationStr == "XOR") {
operation = Xor;
}
else {
ok = false;
REPORT_ERROR(ErrorManagement::ParametersError, "Operation %s is not defined", operationStr.Buffer());
}
}
}
if (ok) {
// Read output signal values to be set.
AnyType valuesArray = data.GetType("Values");
ok = (valuesArray.GetDataPointer() != NULL);
if (ok) {
valuesCount = valuesArray.GetNumberOfElements(0u);
ok = valuesCount > 0u;
}
if (ok) {
values = new uint32[valuesCount];
Vector<uint32> valuesVector(values, valuesCount);
ok = (data.Read("Values", valuesVector));
}
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Values shall be defined.");
}
}
return ok;
}
bool JAConditionalSignalUpdateGAM::Setup() {
using namespace MARTe;
bool ok = numberOfInputSignals == (expectedValuesCount + numberOfOutputSignals);
if (ok) {
inputSignals = new void*[expectedValuesCount];
defaultValues = new uint32*[numberOfOutputSignals];
uint32 i;
for (i = 0u; i < expectedValuesCount; i++) {
inputSignals[i] = GetInputSignalMemory(i);
}
for (; i < numberOfInputSignals; i++) {
defaultValues[i - expectedValuesCount] = reinterpret_cast<uint32 *>(GetInputSignalMemory(i));
}
} else {
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be equal to number "
"of expected values plus number of output signals.");
}
if (ok) {
inputSignalTypes = new TypeDescriptor[expectedValuesCount];
uint32 i;
for (i = 0u; (i < expectedValuesCount) && (ok); i++) {
inputSignalTypes[i] = GetSignalType(InputSignals, i);
ok = ((inputSignalTypes[i] == UnsignedInteger32Bit) || (inputSignalTypes[i] == UnsignedInteger16Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, i, signalName);
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint16", signalName.Buffer());
}
}
}
if (ok) {
ok = numberOfOutputSignals == valuesCount;
if (ok) {
ok = numberOfOutputSignals > 0u;
if (ok) {
outputSignals = new uint32*[numberOfOutputSignals];
uint32 i;
for (i = 0u; i < numberOfOutputSignals; i++) {
outputSignals[i] = reinterpret_cast<uint32 *>(GetOutputSignalMemory(i));
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "At least one output signal shall be defined");
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Number of output signals shall be the same as "
"number of provided values.");
}
}
return ok;
}
bool JAConditionalSignalUpdateGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
needsReset = false;
return true;
}
bool JAConditionalSignalUpdateGAM::Execute() {
if (!needsReset) {
bool eventDetected = expectedValuesCount == 0;
if (!eventDetected) {
if (operation == Or) {
MARTe::uint32 j;
for (j = 0; (j < expectedValuesCount) && (!eventDetected); j++) {
eventDetected = Compare(j);
}
}
else if (operation == Nor) {
MARTe::uint32 j;
for (j = 0; (j < expectedValuesCount) && (!eventDetected); j++) {
eventDetected = Compare(j);
}
eventDetected = !eventDetected;
}
else if (operation == And) {
MARTe::uint32 j;
eventDetected = Compare(0);
for (j = 1; (j < expectedValuesCount); j++) {
eventDetected &= Compare(j);
}
}
else if (operation == Xor) {
MARTe::uint32 j;
MARTe::uint32 eventDetectedUint32;
if (inputSignalTypes[0] == MARTe::UnsignedInteger32Bit) {
eventDetectedUint32 = *static_cast<MARTe::uint32 *>(inputSignals[0]);
}
else {
eventDetectedUint32 = *static_cast<MARTe::uint16 *>(inputSignals[0]);
}
for (j = 1; (j < expectedValuesCount); j++) {
eventDetectedUint32 ^= Compare(j);
}
eventDetected = (eventDetectedUint32 == 1u);
}
}
if (eventDetected) {
needsReset = true;
MARTe::uint32 i;
for (i = 0u; i < numberOfOutputSignals; ++i) {
*outputSignals[i] = values[i];
MARTe::StreamString signalName;
(void) GetSignalName(MARTe::OutputSignals, i, signalName);
}
}
else {
MARTe::uint32 i;
for (i = 0u; i < numberOfOutputSignals; ++i) {
*outputSignals[i] = *defaultValues[i];
}
}
}
return true;
}
bool JAConditionalSignalUpdateGAM::Compare(MARTe::uint32 index) {
if (inputSignalTypes[index] == MARTe::UnsignedInteger32Bit) {
return Compare<MARTe::uint32>(index);
}
return Compare<MARTe::uint16>(index);
}
CLASS_REGISTER(JAConditionalSignalUpdateGAM, "1.0")

View File

@@ -0,0 +1,180 @@
/**
* @file JAConditionalSignalUpdateGAM.h
* @brief Header file for class JAConditionalSignalUpdateGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JAConditionalSignalUpdateGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JACONDITIONALSIGNALUPDATEGAM_H_
#define GAMS_JACONDITIONALSIGNALUPDATEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that writes predefined values to output signals when a condition is met.
* If there are no conditional signals provided, the condition is presumed to be met.
*
* +ASYNCShotlengthControlGAM = {
* Class = JAConditionalSignalUpdateGAM
* Operation = OR // Logical operation performed between conditional signals
* // Supported values: AND, OR, XOR, NOR
* // Default: AND
* ExpectedValues = {1 1} // Values to which conditional signals will be compared.
* Comparators = {EQUALS EQUALS} // Operator between conditional signal an expected value
* // Supported values: EQUALS, NOT, GREATER, EQUALS_OR_GREATER, LESS, EQUALS_OR_LESS
* // Default: EQUALS
* Values = {0 3} // Values that will be written to output signals when condition is met.
* InputSignals = {
* // Conditional Signals
* SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* // Default values (set to output signals before the condition is met)
* APS_SWON = { // APS_SWON will keep the value from previous state.
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON_DEFAULT = { // BPS_SWON will be set to 7 before condition is met.
* DataSource = DDB1
* Type = uint32
* Default = 7
* }
* }
* OutputSignals = {
* APS_SWON = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON = {
* DataSource = DDB1
* Type = uint32
* }
* }
* }
*/
class JAConditionalSignalUpdateGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JAConditionalSignalUpdateGAM();
virtual ~JAConditionalSignalUpdateGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
/**
* @brief Does the input signal at provided index have the expected value.
* @param[in] index of the signal.
* @return true if the signal has expected value.
*/
bool Compare(MARTe::uint32 index);
template <class T>
bool Compare(MARTe::uint32 index);
enum OperationMode {
And, Or, Xor, Nor
};
enum ComparisonMode {
Equals, Not, Greater, EqualsOrGreater, Less, EqualsOrLess
};
// Input signals
void **inputSignals;
MARTe::TypeDescriptor *inputSignalTypes;
// Condition operation.
OperationMode operation;
// Array of expected values of input signals.
MARTe::uint32* expectedValues;
// Expected values count (must be equal to numberOfInputSignals)
MARTe::uint32 expectedValuesCount;
// Array of comparators
ComparisonMode* comparators;
// Values to be written on output signals when input signal has the expected value.
MARTe::uint32 *values;
// Number of values (must be equal to numberOfOutputSignals)
MARTe::uint32 valuesCount;
// Output signals
MARTe::uint32 **outputSignals;
// Default values of output signals
MARTe::uint32 **defaultValues;
// Were output signals already set and we are waiting for a state change before they are set again.
bool needsReset;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
template <class T>
bool JAConditionalSignalUpdateGAM::Compare(MARTe::uint32 index) {
switch (comparators[index]) {
case Equals:
return *static_cast<T *>(inputSignals[index]) == static_cast<T>(expectedValues[index]);
case Not:
return *static_cast<T *>(inputSignals[index]) != static_cast<T>(expectedValues[index]);
case Greater:
return *static_cast<T *>(inputSignals[index]) > static_cast<T>(expectedValues[index]);
case EqualsOrGreater:
return *static_cast<T *>(inputSignals[index]) >= static_cast<T>(expectedValues[index]);
case Less:
return *static_cast<T *>(inputSignals[index]) < static_cast<T>(expectedValues[index]);
default: // case EqualsOrLess:
return *static_cast<T *>(inputSignals[index]) <= static_cast<T>(expectedValues[index]);
}
}
#endif /* GAMS_JACONDITIONALSIGNALUPDATEGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,53 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JAConditionalSignalUpdateGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JAConditionalSignalUpdateGAM$(LIBEXT) \
$(BUILD_DIR)/JAConditionalSignalUpdateGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,347 @@
/**
* @file JAMessageGAM.cpp
* @brief Source file for class JAMessageGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JAMessageGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "JAMessageGAM.h"
#include "MessageI.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
template<class T, class U>
bool Compare(JAMessageGAM::ComparisonMode comparator, void *inputSignal, U expectedValue) {
switch (comparator) {
case JAMessageGAM::Equals:
return *static_cast<T *>(inputSignal) == expectedValue;
case JAMessageGAM::Not:
return *static_cast<T *>(inputSignal) != expectedValue;
case JAMessageGAM::Greater:
return *static_cast<T *>(inputSignal) > expectedValue;
case JAMessageGAM::EqualsOrGreater:
return *static_cast<T *>(inputSignal) >= expectedValue;
case JAMessageGAM::Less:
return *static_cast<T *>(inputSignal) < expectedValue;
default: // case EqualsOrLess:
return *static_cast<T *>(inputSignal) <= expectedValue;
}
}
JAMessageGAM::JAMessageGAM() {
inputSignals = NULL_PTR(void **);
inputSignalTypes = NULL_PTR(MARTe::TypeDescriptor *);
operation = And;
needsReset = false;
expectedValuesInt = NULL_PTR(MARTe::uint64 *);
expectedValuesFloat = NULL_PTR(MARTe::float64 *);
intValuesCount = 0u;
floatValuesCount = 0u;
comparators = NULL_PTR(ComparisonMode *);
}
JAMessageGAM::~JAMessageGAM() {
if (inputSignals != NULL_PTR(void **)) {
delete[] inputSignals;
}
if (inputSignalTypes != NULL_PTR(MARTe::TypeDescriptor *)) {
delete[] inputSignalTypes;
}
if (expectedValuesInt != NULL_PTR(MARTe::uint64 *)) {
delete[] expectedValuesInt;
}
if (expectedValuesFloat != NULL_PTR(MARTe::float64 *)) {
delete[] expectedValuesFloat;
}
if (comparators != NULL_PTR(ComparisonMode *)) {
delete[] comparators;
}
}
bool JAMessageGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
// Read expected integer values.
AnyType valuesArray = data.GetType("ExpectedIntValues");
bool intValuesProvided = (valuesArray.GetDataPointer() != NULL);
if (intValuesProvided) {
intValuesCount = valuesArray.GetNumberOfElements(0u);
}
if (intValuesProvided) {
expectedValuesInt = new uint64[intValuesCount];
Vector<uint64> valuesVector(expectedValuesInt, intValuesCount);
ok = (data.Read("ExpectedIntValues", valuesVector));
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Failed to read ExpectedIntValues.");
return ok;
}
}
// Read expected float values.
valuesArray = data.GetType("ExpectedFloatValues");
bool floatValuesProvided = (valuesArray.GetDataPointer() != NULL);
if (floatValuesProvided) {
floatValuesCount = valuesArray.GetNumberOfElements(0u);
}
if (floatValuesProvided) {
expectedValuesFloat = new float64[floatValuesCount];
Vector<float64> valuesVector(expectedValuesFloat, floatValuesCount);
ok = (data.Read("ExpectedFloatValues", valuesVector));
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Failed to read ExpectedFloatValues.");
return ok;
}
}
ok = (floatValuesCount + intValuesCount) > 0u;
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "ExpectedFloatValues and or ExpectedIntValues shall be defined.");
}
}
if (ok) {
// Read comparators.
AnyType comparatorsArray = data.GetType("Comparators");
if (comparatorsArray.GetDataPointer() != NULL) {
uint32 count = comparatorsArray.GetNumberOfElements(0u);
ok = count == (intValuesCount + floatValuesCount);
if (ok) {
comparators = new ComparisonMode[count];
StreamString* comp = new StreamString[count];
Vector<StreamString> compVector(comp, count);
ok = (data.Read("Comparators", compVector));
if (ok) {
for (uint32 i = 0; i < count; ++i) {
if (comp[i] == "EQUALS") {
comparators[i] = Equals;
} else if (comp[i] == "NOT") {
comparators[i] = Not;
} else if (comp[i] == "GREATER") {
comparators[i] = Greater;
} else if (comp[i] == "EQUALS_OR_GREATER") {
comparators[i] = EqualsOrGreater;
} else if (comp[i] == "LESS") {
comparators[i] = Less;
} else if (comp[i] == "EQUALS_OR_LESS") {
comparators[i] = EqualsOrLess;
} else {
ok = false;
REPORT_ERROR(ErrorManagement::ParametersError, "Comparator %s is not defined.", comp[i].Buffer());
}
}
}
} else {
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
"number of elements.");
}
} else {
uint32 count = intValuesCount + floatValuesCount;
if (ok) {
// Create default comparators (equals) when they aren't provided in the configuration.
comparators = new ComparisonMode[count];
for (uint32 i = 0; i < count; ++i) {
comparators[i] = Equals;
}
} else {
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
"number of elements.");
}
}
}
if (ok) {
MARTe::StreamString operationStr;
if (data.Read("Operation", operationStr)) {
if (operationStr == "AND") {
operation = And;
}
else if (operationStr == "OR") {
operation = Or;
}
else if (operationStr == "NOR") {
operation = Nor;
}
else if (operationStr == "XOR") {
operation = Xor;
}
else {
ok = false;
REPORT_ERROR(ErrorManagement::ParametersError, "Operation %s is not defined", operationStr.Buffer());
}
}
}
if (ok) {
ok = (Size() == 1);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "A Message object shall be added to this container");
}
}
if (ok) {
eventMsg = Get(0);
ok = (eventMsg.IsValid());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "A valid Message shall be added to this container");
}
}
return ok;
}
bool JAMessageGAM::Setup() {
using namespace MARTe;
bool ok = numberOfInputSignals == (intValuesCount + floatValuesCount);
if (ok) {
ok = numberOfInputSignals > 0u;
if (ok) {
inputSignals = new void*[numberOfInputSignals];
uint32 i;
for (i = 0u; i < numberOfInputSignals; i++) {
inputSignals[i] = GetInputSignalMemory(i);
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "At least one input signal shall be defined");
}
} else {
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be the same as "
"number of expected values.");
}
if (ok) {
inputSignalTypes = new TypeDescriptor[numberOfInputSignals];
uint32 i;
for (i = 0u; (i < numberOfInputSignals) && (ok); i++) {
TypeDescriptor inputType = GetSignalType(InputSignals, i);
inputSignalTypes[i] = inputType;
ok = (inputType == UnsignedInteger32Bit) || (inputType == SignedInteger32Bit) ||
(inputType == UnsignedInteger16Bit) || (inputType == SignedInteger16Bit) ||
(inputType == UnsignedInteger8Bit) || (inputType == SignedInteger8Bit) ||
(inputType == Float64Bit) || (inputType == Float32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, i, signalName);
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as 32/16/8 bit signed/unsigned integer "
"or as 64/32 float.", signalName.Buffer());
}
}
}
return ok;
}
bool JAMessageGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
needsReset = false;
return true;
}
bool JAMessageGAM::Execute() {
using namespace MARTe;
bool ok = true;
bool eventDetected = false;
uint32 inputPortIndex = 0;
uint32 intIndex = 0;
uint32 floatIndex = 0;
if (operation == Or) {
for (inputPortIndex = 0; (inputPortIndex < numberOfInputSignals) && (!eventDetected); inputPortIndex++) {
eventDetected = Compare(inputPortIndex, floatIndex, intIndex);
}
}
else if (operation == Nor) {
for (inputPortIndex = 0; (inputPortIndex < numberOfInputSignals) && (!eventDetected); inputPortIndex++) {
eventDetected = Compare(inputPortIndex, floatIndex, intIndex);
}
eventDetected = !eventDetected;
}
else if (operation == And) {
eventDetected = Compare(0, floatIndex, intIndex);
for (inputPortIndex = 1; (inputPortIndex < numberOfInputSignals); inputPortIndex++) {
eventDetected &= Compare(inputPortIndex, floatIndex, intIndex);
}
}
else if (operation == Xor) {
uint32 eventDetectedUInt32 = Compare(inputPortIndex, floatIndex, intIndex);
for (inputPortIndex = 1; (inputPortIndex < numberOfInputSignals); inputPortIndex++) {
eventDetectedUInt32 ^= Compare(inputPortIndex, floatIndex, intIndex);
}
eventDetected = (eventDetectedUInt32 == 1u);
}
if (eventDetected) {
if (!needsReset) {
ok = (MessageI::SendMessage(eventMsg, this) == ErrorManagement::NoError);
needsReset = true;
}
}
return ok;
}
bool JAMessageGAM::Compare(MARTe::uint32 inputPortIndex, MARTe::uint32 &floatValueIndex, MARTe::uint32 &intValueIndex) {
using namespace MARTe;
bool ret = false;
if (inputSignalTypes[inputPortIndex] == UnsignedInteger32Bit) {
ret = ::Compare<uint32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
++intValueIndex;
}
else if (inputSignalTypes[inputPortIndex] == SignedInteger32Bit) {
ret = ::Compare<int32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
++intValueIndex;
}
else if (inputSignalTypes[inputPortIndex] == UnsignedInteger16Bit) {
ret = ::Compare<uint16>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
++intValueIndex;
}
else if (inputSignalTypes[inputPortIndex] == SignedInteger16Bit) {
ret = ::Compare<int16>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
++intValueIndex;
}
else if (inputSignalTypes[inputPortIndex] == UnsignedInteger8Bit) {
ret = ::Compare<uint8>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
++intValueIndex;
}
else if (inputSignalTypes[inputPortIndex] == SignedInteger8Bit) {
ret = ::Compare<int8>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
++intValueIndex;
}
else if (inputSignalTypes[inputPortIndex] == Float64Bit) {
ret = ::Compare<float64>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesFloat[floatValueIndex]);
++floatValueIndex;
}
else {
ret = ::Compare<float32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesFloat[floatValueIndex]);
++floatValueIndex;
}
return ret;
}
CLASS_REGISTER(JAMessageGAM, "1.0")

View File

@@ -0,0 +1,149 @@
/**
* @file JAMessageGAM.h
* @brief Header file for class JAMessageGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JAMessageGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JAMESSAGEGAM_H_
#define GAMS_JAMESSAGEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
#include "Message.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that sends a message when input signals have expected values. Message will not be sent multiple
* times without first changing the application state.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +MessageGAM = {
* Class = JAMessageGAM
* Operation = AND // Accepted values are: AND, OR, XOR, NOR. Default value is AND.
* ExpectedIntValues = {1 10} // Expected values for input signals of integral type.
* ExpectedFloatValues = {3.5} // Expected values for float signals of floting point type.
* Comparators = {EQUALS GREATER NOT} // Accepted values are: EQUALS, NOT, GREATER, EQUALS_OR_GREATER, LESS, EQUALS_OR_LESS
* // Comparators element is optional. Default comparator is EQUALS.
* InputSignals = {
* Sig1 = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* Sig2 = {
* DataSource = EPICSCAInput
* Type = float32
* }
* Sig3 = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* }
* +Event = { // Message to be sent when condition is true.
* Class = Message
* Destination = StateMachine
* Function = GoDisabled
* }
* }
* </pre>
* This example will send Event message when Sig1 == 1 && Sig2 > 3.5 && Sig3 != 10
*/
class JAMessageGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JAMessageGAM();
virtual ~JAMessageGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
enum ComparisonMode {
Equals, Not, Greater, EqualsOrGreater, Less, EqualsOrLess
};
private:
/**
* @brief Does the input signal at provided index have the expected value.
* @param[in] index of the signal.
* @param[out] floatValueIndex lookup index for expected float values array.
* @param[out] intValueIndex lookup index for expected integer values array.
* @return true if the signal has expected value.
*/
bool Compare(MARTe::uint32 index, MARTe::uint32 &floatValueIndex, MARTe::uint32 &intValueIndex);
enum OperationMode {
And, Or, Xor, Nor
};
// Input signals
void **inputSignals;
MARTe::TypeDescriptor *inputSignalTypes;
// Condition operation.
OperationMode operation;
// Message to be sent when conditions are met.
MARTe::ReferenceT<MARTe::Message> eventMsg;
// Was the message already sent and we are waiting for a state change before next message can be sent.
bool needsReset;
// Array of expected integer values of input signals.
MARTe::uint64* expectedValuesInt;
// Array of expected float values for input signals.
MARTe::float64* expectedValuesFloat;
// Expected integer values count (must be equal to numberOfInputSignals - floatValuesCount)
MARTe::uint32 intValuesCount;
// Expected integer values count (must be equal to numberOfInputSignals - floatValuesCount)
MARTe::uint32 floatValuesCount;
// Array of comparators
ComparisonMode* comparators;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JAMESSAGEGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,53 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JAMessageGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JAMessageGAM$(LIBEXT) \
$(BUILD_DIR)/JAMessageGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,154 @@
/**
* @file JAModeControlGAM.cpp
* @brief Source file for class JAModeControlGAM
* @date Jan, 2019
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JAModeControlGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JAModeControlGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JAModeControlGAM::JAModeControlGAM() {
inputSignals = NULL_PTR(MARTe::uint32 **);
outputSignal = NULL_PTR(MARTe::uint32 *);
pulseLengthLimit = 360000000u;
resetRemainingTime = true;
previousState = 0u;
}
JAModeControlGAM::~JAModeControlGAM() {
if (inputSignals != NULL_PTR(MARTe::uint32 **)) {
delete[] inputSignals;
}
}
bool JAModeControlGAM::Initialise(MARTe::StructuredDataI & data) {
/* read hard coded on cfg file parameter values by using key name. */
using namespace MARTe;
return GAM::Initialise(data);
}
bool JAModeControlGAM::Setup() {
/* read GAM Input signal */
using namespace MARTe;
/* read 4 mode bits and 4 shot length limit values */
bool ok = numberOfInputSignals == 11;
if (ok) {
uint32 i;
for (i = 0u; (i < numberOfInputSignals) && (ok); i++) {
TypeDescriptor inputType = GetSignalType(InputSignals, i);
ok = inputType == UnsignedInteger32Bit;
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, i, signalName);
REPORT_ERROR(ErrorManagement::ParametersError, "InputSignel %s shall be defined as uint32", signalName.Buffer());
}
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Eleven input signals shall be defined.");
}
if (ok) {
ok = numberOfOutputSignals == 1;
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "One output signal shall be defined.");
}
else {
TypeDescriptor type = GetSignalType(OutputSignals, 0);
ok = type == UnsignedInteger32Bit;
if (!ok) {
StreamString signalName;
(void) GetSignalName(OutputSignals, 0, signalName);
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
inputSignals = new uint32*[numberOfInputSignals];
uint32 i;
for (i = 0u; i < 11; i++) {
inputSignals[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(i));
}
}
return ok;
}
bool JAModeControlGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
*outputSignal = 0u;
previousState = 0u;
resetRemainingTime = true;
return true;
}
bool JAModeControlGAM::Execute() {
using namespace MARTe;
//When RT state goes to RFON state, update the limit.
if(previousState == 0u && *inputSignals[8] == 1u && resetRemainingTime) {
rfonTime = *inputSignals[9];
resetRemainingTime = false;
pulseLengthLimit = CalcPulseLengthLimit(inputSignals);
REPORT_ERROR(ErrorManagement::Debug, "Pulse Length was set to Limit:%d", pulseLengthLimit);
}
// Turn on the flag during RFON if the pulse legth over the limit.
if ((*inputSignals[9] - rfonTime <= pulseLengthLimit) && (previousState == 1u)) {
*outputSignal = 0u;
return true;
} else if(*inputSignals[9] == 1u){
resetRemainingTime = true;
*outputSignal = 1u;
}
previousState = *inputSignals[8];
return true;
}
MARTe::uint32 JAModeControlGAM::CalcPulseLengthLimit(MARTe::uint32 **inputSignals) {
if (*inputSignals[0] == 1) {
return *inputSignals[1];
} else if (*inputSignals[2] == 1) {
return *inputSignals[3];
} else if (*inputSignals[4] == 1) {
return *inputSignals[5];
} else if (*inputSignals[6] == 1) {
return *inputSignals[7];
} else {
return 3600000000;//us
}
}
CLASS_REGISTER(JAModeControlGAM, "1.0")

View File

@@ -0,0 +1,149 @@
/**
* @file JAModeControlGAM.h
* @brief Header file for class JAModeControlGAM
* @date Jan, 2019
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JAModeControlGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JAMODECONTROLGAM_H_
#define GAMS_JAMODECONTROLGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that check the pulse lenght limit.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +ModeLimitGAM = {
* Class = JAModeControlGAM
* InputSignals = {
* PLC_MODE1 = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* MD1_SHOTLEN_LIM = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* PLC_MODE2 = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* MD2_SHOTLEN_LIM = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* PLC_MODE3 = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* MD3_SHOTLEN_LIM = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* PLC_MODE4 = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* MD4_SHOTLEN_LIM = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* Time = {
* DataSource = DDB1
* Type = uint32
* }
* HVInjection = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* OutputSignals = {
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* }
* }
* </pre>
* If MODE1 is ON and Time is exceed MD1_SHOTLEN_LIM, MODE_SHOTLEN_FLAG become ON.
*/
class JAModeControlGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JAModeControlGAM();
virtual ~JAModeControlGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
MARTe::uint32 CalcPulseLengthLimit(MARTe::uint32 **inputSignals);
// Input signals
MARTe::uint32 **inputSignals;
// Output signals
MARTe::uint32 *outputSignal;
// Calculated pulse lenght limit.
MARTe::uint32 pulseLengthLimit;
// Amount of time passed per execution cycle.
MARTe::uint32 rfonTime;
// reset flag
bool resetRemainingTime;
MARTe::uint32 previousState;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JAMODECONTROLGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,52 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JAModeControlGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JAModeControlGAM$(LIBEXT) \
$(BUILD_DIR)/JAModeControlGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,460 @@
/**
* @file JAPreProgrammedGAM.cpp
* @brief Source file for class JAPreProgrammedGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JAPreProgrammedGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "CLASSMETHODREGISTER.h"
#include "File.h"
#include "JAPreProgrammedGAM.h"
#include "MessageI.h"
#include "RegisteredMethodsMessageFilter.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
// How often output signals are updated.
const MARTe::uint32 cycleMs = 10u;
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JAPreProgrammedGAM::JAPreProgrammedGAM() :
GAM() {
using namespace MARTe;
filenameSignalIndex = 0u;
timeSignal = NULL_PTR(MARTe::int32 *);
loadTriggerSignal = NULL_PTR(MARTe::uint32 *);
fhpsrefSignal = NULL_PTR(MARTe::float32 *);
rfonStateSignal = NULL_PTR(MARTe::uint32 *);
valueSignals = NULL_PTR(MARTe::float32 **);
preProgrammedValues = NULL_PTR(MARTe::float32 **);
preProgrammedTime = NULL_PTR(MARTe::int32 *);
fileLoadedSignal = NULL_PTR(MARTe::uint32 *);
fileLoadErrorOutput = NULL_PTR(MARTe::uint32 *);
startTime = 0u;
numberOfPreProgrammedValues = 0u;
numberOfPreProgrammedTimeRows = 0u;
currentRow = 0u;
mode = None;
preProgrammedExecutaionPeriodMs = 0u;
msCounter = 0u;
preProgrammedRow = 0u;
resetOutputSignals = false;
readOnce = true;
}
JAPreProgrammedGAM::~JAPreProgrammedGAM() {
DeleteArrays();
if (valueSignals != NULL_PTR(MARTe::float32 **)) {
delete[] valueSignals;
}
}
bool JAPreProgrammedGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("Directory", directory);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
}
}
if (ok) {
ok = data.Read("PreProgrammedPeriodMs", preProgrammedExecutaionPeriodMs);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
}
}
return ok;
}
bool JAPreProgrammedGAM::Setup() {
using namespace MARTe;
//Signal number check.
bool ok = (numberOfInputSignals == 4u);
if (ok) {
ok = (numberOfOutputSignals > 2u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "At least two output signal shall be defined");
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Four input signals with the filename and file load trigger shall be defined");
}
//Input signals type consistency check.
if (ok) {
StreamString signalName = "Filename";
ok = GetSignalIndex(InputSignals, filenameSignalIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Filename input signal shall be defined");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, filenameSignalIndex);
ok = (inputType == CharString);
if (!ok) {
ok = (inputType == Character8Bit);
}
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, filenameSignalIndex, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as string", signalName.Buffer());
}
}
}
if (ok) {
StreamString signalName = "CSV_LOAD";
uint32 loadSignalIndex;
ok = GetSignalIndex(InputSignals, loadSignalIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "CSV_LOAD input signal shall be defined");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, loadSignalIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, loadSignalIndex, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
} else {
loadTriggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(loadSignalIndex));
}
}
}
if (ok) {
StreamString signalName = "FHPS_REF";
uint32 fhpsrefIndex;
ok = GetSignalIndex(InputSignals, fhpsrefIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "FHPS_REF input signal shall be defined");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, fhpsrefIndex);
ok = (inputType == Float32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, fhpsrefIndex, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
} else {
fhpsrefSignal = reinterpret_cast<float32 *>(GetInputSignalMemory(fhpsrefIndex));
}
}
}
if (ok) {
StreamString signalName = "RFON";
uint32 rfonIndex;
ok = GetSignalIndex(InputSignals, rfonIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "RFON input signal shall be defined");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, rfonIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, rfonIndex, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
} else {
rfonStateSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(rfonIndex));
}
}
}
//Output signals type check.
if (ok) {
TypeDescriptor timeType = GetSignalType(OutputSignals, 0);
ok = (timeType == SignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, 0, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as int32", signalName.Buffer());
}
uint32 i;
for (i = 1u; (i <= 6) && (ok); i++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, i);
ok = (outputType == Float32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(OutputSignals, i, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
}
}
if (ok) {
TypeDescriptor fileLoadedType = GetSignalType(OutputSignals, 7u);
ok = (fileLoadedType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(OutputSignals, 6u, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
if (ok) {
TypeDescriptor fileLoadErrorOutputType = GetSignalType(OutputSignals, 8u);
ok = (fileLoadErrorOutputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(OutputSignals, 7u, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
//Register signal memory
if (ok) {
timeSignal = reinterpret_cast<int32 *>(GetOutputSignalMemory(0));
valueSignals = new float32*[6u];
uint32 i;
for (i = 1u; i <= 6u; i++) {
valueSignals[i - 1] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
}
fileLoadedSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7u));
fileLoadErrorOutput = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8u));
}
return ok;
}
bool JAPreProgrammedGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
bool ok = true;
if (strcmp(nextStateName, "WaitReady") == 0) {
mode = LoadFileMode;
resetOutputSignals = true;
// Reset read once flag when reentering WaitReady state.
readOnce = true;
} else if (strcmp(nextStateName, "WaitPermit") == 0) {
mode = LoadFileMode;
resetOutputSignals = true;
currentRow = 0u;
} else if (strcmp(nextStateName, "WaitHVON_PREP") == 0 || strcmp(nextStateName, "WaitHVON_SDN_PREP") == 0) {
ok = numberOfPreProgrammedTimeRows > 0;
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::IllegalOperation, "Entering PreProgrammed mode without any waveform data.");
}
mode = PreProgrammedMode;
msCounter = cycleMs;
currentRow = 0u;
} else {
mode = None;
}
return ok;
}
bool JAPreProgrammedGAM::LoadFile() {
using namespace MARTe;
DeleteArrays();
bool ok = true;
const MARTe::char8 * const filenameSignal = reinterpret_cast<const char8 * const >(GetInputSignalMemory(filenameSignalIndex));
//Prepare full path to the configuration file.
StreamString filename = directory;
filename += DIRECTORY_SEPARATOR;
filename += filenameSignal;
REPORT_ERROR(MARTe::ErrorManagement::Debug, "Opening file %s", filename.Buffer());
//parse prepro configuration file into two arrays(time, values).
File f;
ok = f.Open(filename.Buffer(), BasicFile::ACCESS_MODE_R);
if (ok) {
//Count up number of file Rows.
numberOfPreProgrammedTimeRows = 0u;
StreamString tokenLine;
while (f.GetLine(tokenLine)) {
if (tokenLine[0] != '#' && tokenLine[0] != '-') {
numberOfPreProgrammedTimeRows++;
}
tokenLine = "";
}
//Count up number of file lines
numberOfPreProgrammedValues = 0u;
f.Seek(0);
uint32 t = 0u;
tokenLine = "";
while ((ok) && (f.GetLine(tokenLine))) {
// Skip comment line and minus time
if (tokenLine[0] == '#' || tokenLine[0] == '-') {
tokenLine = "";
continue;
}
// Prepare two arrays at first.
if (numberOfPreProgrammedValues == 0) {
StreamString token;
char8 ignored;
tokenLine.Seek(0);
while (tokenLine.GetToken(token, ",", ignored)) {
numberOfPreProgrammedValues++;
token = "";
}
REPORT_ERROR(MARTe::ErrorManagement::ParametersError,"numberOfPreProgrammedVal %d", numberOfPreProgrammedValues);
ok = (numberOfPreProgrammedValues == 7u);//From time row to FHPS row.
numberOfPreProgrammedValues -= 1u; //From MHVPS row to FHPS row.
if (ok) {
preProgrammedTime = new int32[numberOfPreProgrammedTimeRows];
preProgrammedValues = new float32*[numberOfPreProgrammedTimeRows];
uint32 j;
for (j = 0u; j < numberOfPreProgrammedTimeRows; j++) {
preProgrammedValues[j] = new float32[numberOfPreProgrammedValues];
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError,
"Number of columns in csv file (%d) is not consistent with the number of output signals (%d)",
numberOfPreProgrammedValues, 6u);
*fileLoadErrorOutput = 1;
}
}
// Add loaded data into two arrays.
if (ok) {
StreamString token;
char8 ignored;
tokenLine.Seek(0);
uint32 idx = 0u;
while (tokenLine.GetToken(token, ",", ignored)) {
if (idx == 0u) {
preProgrammedTime[t] = atoi(token.Buffer());
if (t == 0 && preProgrammedTime[0] != 0) {
REPORT_ERROR(MARTe::ErrorManagement::Debug, "Prepro start from none zero time.");
}
}
else {
ok = ((idx - 1) < numberOfPreProgrammedValues);
if (ok) {
preProgrammedValues[t][idx - 1] = static_cast<float32>(atof(token.Buffer()));
}
else {
REPORT_ERROR(MARTe::ErrorManagement::FatalError, "Number of columns in csv file is not consistent with the number of output signals in line %d", t);
*fileLoadErrorOutput = 1;
}
}
token = "";
idx++;
}
t++;
}
tokenLine = "";
}
f.Close();
}
if (ok) {
currentRow = 0u;
}
else {
numberOfPreProgrammedTimeRows = 0u;
REPORT_ERROR(ErrorManagement::Warning, "Failed to read waveform data from file.");
*fileLoadErrorOutput = 2;
}
return ok;
}
bool JAPreProgrammedGAM::Execute() {
using namespace MARTe;
bool ok = true;
switch (mode) {
case LoadFileMode: {
if (*loadTriggerSignal == 1u) {
if (readOnce) {
*fileLoadErrorOutput = 0;
*fileLoadedSignal = LoadFile() ? 1 : 0;
readOnce = false;
}
} else {
// Reset read once flag when loadTriggerSignal is reset.
readOnce = true;
}
if (resetOutputSignals) {
// Write default values to output signals
*timeSignal = 0u;
*valueSignals[FHPS-1] = *fhpsrefSignal;
resetOutputSignals = false;
} else {
*valueSignals[FHPS-1] = *fhpsrefSignal; //copy input(2) to val_arr(4)
}
} break;
case PreProgrammedMode: {
ok = numberOfPreProgrammedTimeRows > 0;
//add 20210105. Before RFON, prepro setpoints should be same as the values listed at csv first line.
if (ok && *rfonStateSignal == 0) {
uint32 j;
for (j = 0u; j < FHPS; j++) {
*valueSignals[j] = preProgrammedValues[0][j];
}
}
//end 20210105
if (ok && currentRow < numberOfPreProgrammedTimeRows && *rfonStateSignal == 1) {
if (msCounter >= cycleMs) {
msCounter -= cycleMs;
int32 currentTime = preProgrammedTime[currentRow];
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Write Time at %d",currentRow);
// Write to output signals
*timeSignal = currentTime;
uint32 j;
for (j = 0u; j < FHPS; j++) {
*valueSignals[j] = preProgrammedValues[currentRow][j];
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Write Value %f at row %d",preProgrammedValues[currentRow][j], currentRow);
}
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Writing pre programmed data for time %d", currentTime);
// Update row
++currentRow;
}
msCounter += preProgrammedExecutaionPeriodMs;
}
} break;
default:
// Nothing to do.
REPORT_ERROR(MARTe::ErrorManagement::Warning, "Unhandled mode.");
break;
}
return ok;
}
void JAPreProgrammedGAM::DeleteArrays() {
if (preProgrammedValues != NULL_PTR(MARTe::float32 **)) {
MARTe::uint32 i;
for (i = 0u; i < numberOfPreProgrammedValues; i++) {
delete preProgrammedValues[i];
}
delete[] preProgrammedValues;
}
if (preProgrammedTime != NULL_PTR(MARTe::int32 *)) {
delete[] preProgrammedTime;
}
}
CLASS_REGISTER(JAPreProgrammedGAM, "1.0")

View File

@@ -0,0 +1,187 @@
/**
* @file JAPreProgrammedGAM.h
* @brief Header file for class JAPreProgrammedGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JAPreProgrammedGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JAPREPROGRAMMEDGAM_H_
#define GAMS_JAPREPROGRAMMEDGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
#include "Message.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that update PS output value for pre-programmed operation.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +PreProgrammedGAM = {
* Class = JAPreProgrammedGAM
* Directory = "../Configurations" // Directory which has pre-pro configuration file.
* PreProgrammedPeriodMs = 1 // RFON state is executed every millisecond.
* InputSignals = {
* CSV_LOAD = {
* DataSource = EPICSCAInput
* Type = uint32
* }
* Filename = {
* Alias = CSV_NAME
* DataSource = EPICSCAInput
* }
* FHPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* OutputSignals = {
* GYA_PREHEAT_TIME = {
* DataSource = DDB1
* Type = int32
* }
* MHVPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* BPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* APS_REF = {
* DataSource = DDB1
* Type = float32
* }
* MCPS_TRG_CURR_SET = {
* DataSource = DDB1
* Type = float32
* }
* GCPS_TRG_CURR_SET = {
* DataSource = DDB1
* Type = float32
* }
* FHPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* CSV_LOADED = {
* DataSource = DDB1
* Type = uint32
* }
* CSV_ERR = {
* DataSource = DDB1
* Type = uint32
* }
* }
* }
* </pre>
*
*/
class JAPreProgrammedGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JAPreProgrammedGAM();
virtual ~JAPreProgrammedGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
bool LoadFile();
void DeleteArrays();
//Parameters
MARTe::StreamString directory; //Location for prepro configuration file.
MARTe::uint32 preProgrammedExecutaionPeriodMs; // Time between to execution cycles in milliseconds in pre-programmed mode.
//Input Signals
MARTe::uint32 *loadTriggerSignal; //index:0
MARTe::uint32 filenameSignalIndex;//index:1
MARTe::float32 *fhpsrefSignal; //index:2
MARTe::uint32 *rfonStateSignal; //index:3
//Output Signals
MARTe::int32 *timeSignal; //index:0
MARTe::float32 **valueSignals; //index:1-5 = BPS,APS,MC,GC,FHPS
MARTe::uint32 *fileLoadedSignal; //index:6
MARTe::uint32 *fileLoadErrorOutput;//index:7
//Internal variables
MARTe::int32 *preProgrammedTime;
MARTe::float32 **preProgrammedValues;
MARTe::uint32 startTime;
//Number of columns in csv, EXCLUDING the time
MARTe::uint32 numberOfPreProgrammedValues; //is 5.(BPS, APS, MC, GC, FHPS)
MARTe::uint32 numberOfPreProgrammedTimeRows; //This start from t=0 row.
MARTe::uint32 currentRow;
// Number of milliseconds since the last time output signals were updated.
MARTe::uint32 msCounter;
// Row number where the pre-programmed data begins (time == 0).
MARTe::uint32 preProgrammedRow;
enum OperationMode {
LoadFileMode, PreProgrammedMode, None
};
enum PreProTableDefinition {
Time, MHVPS, BPS, APS, MCPS, GCPS, FHPS
};
OperationMode mode;
bool resetOutputSignals;
// Flag determining whether file should be read (so it isn't read multiple time)
bool readOnce;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JAPREPROGRAMMEDGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,56 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JAPreProgrammedGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JAPreProgrammedGAM$(LIBEXT) \
$(BUILD_DIR)/JAPreProgrammedGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,411 @@
/**
* @file JARTStateMachineGAM.cpp
* @brief Source file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JARTStateMachineGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JARTStateMachineGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
static MARTe::uint64 getCurrentTimeUs() {
using namespace MARTe;
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
}
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JARTStateMachineGAM::JARTStateMachineGAM() {
currentState = WaitTrigger; // Set Entry state.
plcOnTime = 0; // Triggered time holder.
//Output and condition in a given state.
conditionTrigger = 1;
aps_hvon = 0;
aps_swon = 0;
bps_hvon = 0;
bps_swon = 0;
mhvps_hvon = 0;
// Parameters which get from Input signals.
triggerSignal = NULL_PTR(MARTe::uint32 *);
currentTime = NULL_PTR(MARTe::uint32 *);
turn_off_delay = 2000; //us
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
stopRequest = NULL_PTR(MARTe::uint32 *);
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
short_pulse_mode = NULL_PTR(MARTe::uint32 *);
modulation = NULL_PTR(MARTe::uint32 *);
// write out target.
outputSignal = NULL_PTR(MARTe::uint32 *);
outputBeamON = NULL_PTR(MARTe::uint32 *);
outputHVArmed = NULL_PTR(MARTe::uint32 *);
outputHVInjection = NULL_PTR(MARTe::uint32 *);
outputRFON = NULL_PTR(MARTe::uint32 *);
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
outputRFONTime = NULL_PTR(MARTe::uint32 *);
shotCounter = NULL_PTR(MARTe::uint32 *);
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false;
bps_hvon_is_on = false;
bps_swon_is_on = false;
apsSwonHighResolutionTime = 0;
aps_hvon_state=0;
aps_swon_state=0;
mhvps_hvon_state=0;
bps_hvon_state=0;
bps_swon_state=0;
}
JARTStateMachineGAM::~JARTStateMachineGAM() {
}
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("ConditionTrigger", conditionTrigger);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
}
}
if (ok) {
ok = data.Read("mhvps_hvon", mhvps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_hvon", aps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_swon", aps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_hvon", bps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_swon", bps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
}
}
return ok;
}
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
bool JARTStateMachineGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 12u);
if (ok) {
ok = (numberOfOutputSignals == 16u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
modulation = reinterpret_cast<uint32 *>(GetInputSignalMemory(11));
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
*shotCounter = 0;
}
return ok;
}
bool JARTStateMachineGAM::Execute() {
using namespace MARTe;
if (currentState == WaitTrigger) {
//State Transition condition
if ((*triggerSignal == conditionTrigger)) {
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
plcOnTime = *currentTime; //Save pulse start time.
//*outputBeamON = 0;
//State transition.
currentState = SwitchingHVPS;
}
}
else if (currentState == SwitchingHVPS) {
//Actions in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
*outputSignal = 0;
currentState = HVTerminate;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
//Do action
*outputSignal += bps_hvon;
bps_hvon_is_on = true; bps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
*outputBPSHVON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
//Do action
*outputSignal += aps_hvon;
aps_hvon_is_on = true; aps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
*outputAPSHVON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
//Do action
*outputSignal += bps_swon;
bps_swon_is_on = true; bps_swon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
*outputBPSSWON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
//Do action
*outputSignal += mhvps_hvon;
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
*outputMHVPSON=1;
}
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
//Do action
*outputSignal += aps_swon;
aps_swon_is_on = true; aps_swon_state=1;
apsSwonHighResolutionTime = getCurrentTimeUs();
apsSwonTime = *currentTime;
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
*outputAPSSWON=1;
}
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
if (bps_hvon_is_on && aps_hvon_is_on){
*outputHVArmed = 1;
}
if (bps_swon_is_on || mhvps_hvon_is_on){
*outputHVInjection = 1;
}
//State transition condition
if (aps_swon_is_on){
currentState = RFON;
*outputRFON = 0;
*outputBeamON = 1;
*shotCounter += 1;
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
}
}
else if (currentState == RFON) {
//Action in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
//debug
//if((*stopRequest != 0)){
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
//} else {
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
//}
*outputSignal -= aps_swon;
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
aps_hvon_is_on = false; aps_hvon_state=0;
aps_swon_is_on = false; aps_swon_state=0;
bps_hvon_is_on = false; bps_hvon_state=0;
bps_swon_is_on = false; bps_swon_state=0;
currentState = HVTerminate;
*outputAPSHVON=0;
*outputAPSSWON=0;
*outputBPSHVON=0;
*outputBPSSWON=0;
*outputMHVPSON=0;
}
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
// Now we do busy wait
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
//REPORT_ERROR(ErrorManagement::Debug, "!");
}
// We stop busy waiting #executionOverhead before expected pulse off time
//debug
//if((*modePulseLengthLimit == 1u)){
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
//} else {
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
//}
//debug end.
//Do action
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false; aps_swon_state=0;
bps_hvon_is_on = false;
bps_swon_is_on = false;
*outputAPSHVON=0;
*outputAPSSWON=0;
*outputBPSHVON=0;
*outputBPSSWON=0;
*outputMHVPSON=0;
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
}
*outputRFON = 1;
*outputBeamONTime = *currentTime - plcOnTime;
*outputRFONTime = *currentTime - apsSwonTime;
//State transition condition
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
currentState = HVTerminate;
apsSwoffTime = *currentTime;
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
}
}
else if (currentState == HVTerminate) {
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
//Action in this state.
*outputBeamON = 0;
*outputHVArmed = 0;
*outputHVInjection = 0;
*outputRFON = 0;
// State transition condition.
if (*currentTime - apsSwoffTime >= turn_off_delay){
*outputSignal = 0;
mhvps_hvon_state=0;
aps_hvon_state=0;
bps_hvon_state=0;
bps_swon_state=0;
}
if (*triggerSignal == false){
//Check PLC_ON is reset
currentState = WaitTrigger;
*outputSignal = 0;
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
}
}
if(*short_pulse_mode == 1){
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
*outputSignalNI6259 = 1*aps_swon_state;
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
} else {
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
}
if (modulation) {
p4Value = 8*mhvps_hvon_state + 32;
}
else {
p4Value = 8*mhvps_hvon_state;
}
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
*outputSignalNI6528P4 = ~p4Value;
return true;
}
CLASS_REGISTER(JARTStateMachineGAM, "1.0")

View File

@@ -0,0 +1,262 @@
/**
* @file JARTStateMachineGAM.h
* @brief Header file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JARTStateMachineGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JARTSTATEMACHINEGAM_H_
#define GAMS_JARTSTATEMACHINEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that provides real-time state machine.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +GAMRealTimeStateMachine = {
* Class = JARTStateMachineGAM
* ConditionTrigger = 1
* mhvps_hvon = 4
* aps_hvon = 1
* aps_swon = 16
* bps_hvon = 2
* bps_swon = 8
* InputSignals = {
* Time = {
* DataSource = DDB1
* Type = uint32
* }
* PLC_ON = {
* DataSource = DDB1
* Type = uint32
* }
* MHVPS_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* SHOTLEN = {
* DataSource = DDB1
* Type = uint32
* }
* StopRequest = {
* DataSource = DDB1
* Type = uint32
* }
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* }
* OutputSignals = {
* Value = {
* DataSource = DDB1
* Type = uint32
* Trigger = 1
* }
* BEAM_ON_STAT = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVARMED = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVINJECTION = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* BeamONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* SHOT_ID = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* }
*
* </pre>
*
*/
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JARTStateMachineGAM();
virtual ~JARTStateMachineGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
enum JARealTimeState {
WaitTrigger = 0,
SwitchingHVPS = 1,
RFON = 2,
HVTerminate = 3
};
//The current rtState
JARealTimeState currentState;
//A given condition
MARTe::uint32 conditionTrigger;
//What to output in a given state and condition
MARTe::uint32 mhvps_hvon;
MARTe::uint32 aps_hvon;
MARTe::uint32 aps_swon;
MARTe::uint32 bps_hvon;
MARTe::uint32 bps_swon;
//The trigger signal (PLC_ON)
MARTe::uint32 *triggerSignal;
//Time signal
MARTe::uint32 *currentTime;
// Input signals for trigger delay parameters
MARTe::uint32 *triggerDelay_mhvps_hvon;
MARTe::uint32 *triggerDelay_aps_hvon;
MARTe::uint32 *triggerDelay_aps_swon;
MARTe::uint32 *triggerDelay_bps_hvon;
MARTe::uint32 *triggerDelay_bps_swon;
MARTe::uint32 *triggerDelay_shotlen;
// Input signal for sequence stop request.
MARTe::uint32 *stopRequest;
// Input signal for pulse length limit by mode.
MARTe::uint32 *modePulseLengthLimit;
// Input signal for short pulse mode.
MARTe::uint32 *short_pulse_mode;
// Input signal for modulation pv.
MARTe::uint32 *modulation;
// Output signal to which the output value will be written.
// One state write One signal.
MARTe::uint32 *outputSignal;
// state notify output
MARTe::uint32 *outputBeamON;
MARTe::uint32 *outputHVArmed;
MARTe::uint32 *outputHVInjection;
MARTe::uint32 *outputRFON;
// elapsed time notify output;
MARTe::uint32 *outputBeamONTime;
MARTe::uint32 *outputRFONTime;
// shot counter (coutup every RFON time.)
MARTe::uint32 *shotCounter;
// Added for HVPS state (20201117)
MARTe::uint32 *outputAPSHVON;
MARTe::uint32 *outputAPSSWON;
MARTe::uint32 *outputBPSHVON;
MARTe::uint32 *outputBPSSWON;
MARTe::uint32 *outputMHVPSON;
// Output signals for NI devices
MARTe::uint32 *outputSignalNI6259;
MARTe::uint8 *outputSignalNI6528P3;
MARTe::uint8 *outputSignalNI6528P4;
//////////////////////////////
//Internal Parameters
//////////////////////////////
//PLC_ON time holder
MARTe::uint32 plcOnTime;
//APS_SWON time holder
MARTe::uint32 apsSwonTime;
MARTe::uint32 apsSwoffTime;
MARTe::uint64 apsSwonHighResolutionTime;
//PS turn off delay
MARTe::uint32 turn_off_delay;
//HVPS state holder
bool mhvps_hvon_is_on;
bool aps_hvon_is_on;
bool aps_swon_is_on;
bool bps_hvon_is_on;
bool bps_swon_is_on;
// terminal values
MARTe::uint8 p3Value;
MARTe::uint8 p4Value;
MARTe::uint8 aps_hvon_state;
MARTe::uint8 aps_swon_state;
MARTe::uint8 mhvps_hvon_state;
MARTe::uint8 bps_hvon_state;
MARTe::uint8 bps_swon_state;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */

View File

@@ -0,0 +1,409 @@
/**
* @file JARTStateMachineGAM.cpp
* @brief Source file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JARTStateMachineGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JARTStateMachineGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
static MARTe::uint64 getCurrentTimeUs() {
using namespace MARTe;
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
}
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JARTStateMachineGAM::JARTStateMachineGAM() {
currentState = WaitTrigger; // Set Entry state.
plcOnTime = 0; // Triggered time holder.
//Output and condition in a given state.
conditionTrigger = 1;
aps_hvon = 0;
aps_swon = 0;
bps_hvon = 0;
bps_swon = 0;
mhvps_hvon = 0;
// Parameters which get from Input signals.
triggerSignal = NULL_PTR(MARTe::uint32 *);
currentTime = NULL_PTR(MARTe::uint32 *);
turn_off_delay = 2000; //us
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
stopRequest = NULL_PTR(MARTe::uint32 *);
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
short_pulse_mode = NULL_PTR(MARTe::uint32 *);
modulation = NULL_PTR(MARTe::uint32 *);
// write out target.
outputSignal = NULL_PTR(MARTe::uint32 *);
outputBeamON = NULL_PTR(MARTe::uint32 *);
outputHVArmed = NULL_PTR(MARTe::uint32 *);
outputHVInjection = NULL_PTR(MARTe::uint32 *);
outputRFON = NULL_PTR(MARTe::uint32 *);
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
outputRFONTime = NULL_PTR(MARTe::uint32 *);
shotCounter = NULL_PTR(MARTe::uint32 *);
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false;
bps_hvon_is_on = false;
bps_swon_is_on = false;
apsSwonHighResolutionTime = 0;
aps_hvon_state=0;
aps_swon_state=0;
mhvps_hvon_state=0;
bps_hvon_state=0;
bps_swon_state=0;
}
JARTStateMachineGAM::~JARTStateMachineGAM() {
}
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("ConditionTrigger", conditionTrigger);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
}
}
if (ok) {
ok = data.Read("mhvps_hvon", mhvps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_hvon", aps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_swon", aps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_hvon", bps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_swon", bps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
}
}
return ok;
}
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
bool JARTStateMachineGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 13u);
if (ok) {
ok = (numberOfOutputSignals == 16u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
modulation = reinterpret_cast<uint32 *>(GetInputSignalMemory(11));
pauseSet = reinterpret_cast<uint32 *>(GetInputSignalMemory(12));
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
*shotCounter = 0;
}
return ok;
}
bool JARTStateMachineGAM::Execute() {
using namespace MARTe;
if (currentState == WaitTrigger) {
//State Transition condition
if ((*triggerSignal == conditionTrigger)) {
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
plcOnTime = *currentTime; //Save pulse start time.
//*outputBeamON = 0;
//State transition.
currentState = SwitchingHVPS;
}
}
else if (currentState == SwitchingHVPS) {
//Actions in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
*outputSignal = 0;
currentState = HVTerminate;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
//Do action
*outputSignal += bps_hvon;
bps_hvon_is_on = true; bps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
*outputBPSHVON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
//Do action
*outputSignal += aps_hvon;
aps_hvon_is_on = true; aps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
*outputAPSHVON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
//Do action
*outputSignal += bps_swon;
bps_swon_is_on = true; bps_swon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
*outputBPSSWON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
//Do action
*outputSignal += mhvps_hvon;
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
*outputMHVPSON=1;
}
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
//Do action
*outputSignal += aps_swon;
aps_swon_is_on = true; aps_swon_state=1;
apsSwonHighResolutionTime = getCurrentTimeUs();
apsSwonTime = *currentTime;
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
*outputAPSSWON=1;
}
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
if (bps_hvon_is_on && aps_hvon_is_on){
*outputHVArmed = 1;
}
if (bps_swon_is_on || mhvps_hvon_is_on){
*outputHVInjection = 1;
}
//State transition condition
if (aps_swon_is_on){
currentState = RFON;
*outputRFON = 0;
*outputBeamON = 1;
*shotCounter += 1;
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
}
}
else if (currentState == RFON) {
//Action in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
//debug
//if((*stopRequest != 0)){
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
//} else {
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
//}
*outputSignal -= aps_swon;
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
aps_hvon_is_on = false; aps_hvon_state=0;
aps_swon_is_on = false; aps_swon_state=0;
bps_hvon_is_on = false; bps_hvon_state=0;
bps_swon_is_on = false; bps_swon_state=0;
currentState = HVTerminate;
*outputAPSHVON=0;
*outputAPSSWON=0;
*outputBPSHVON=0;
*outputBPSSWON=0;
*outputMHVPSON=0;
}
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
// Now we do busy wait
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
//REPORT_ERROR(ErrorManagement::Debug, "!");
}
// We stop busy waiting #executionOverhead before expected pulse off time
//debug
//if((*modePulseLengthLimit == 1u)){
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
//} else {
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
//}
//debug end.
//Do action
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false; aps_swon_state=0;
bps_hvon_is_on = false;
bps_swon_is_on = false;
*outputAPSHVON=0;
*outputAPSSWON=0;
*outputBPSHVON=0;
*outputBPSSWON=0;
*outputMHVPSON=0;
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
}
*outputRFON = 1;
*outputBeamONTime = *currentTime - plcOnTime;
*outputRFONTime = *currentTime - apsSwonTime;
//State transition condition
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
currentState = HVTerminate;
apsSwoffTime = *currentTime;
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
}
}
else if (currentState == HVTerminate) {
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
//Action in this state.
*outputBeamON = 0;
*outputHVArmed = 0;
*outputHVInjection = 0;
*outputRFON = 0;
// State transition condition.
if (*currentTime - apsSwoffTime >= turn_off_delay){
*outputSignal = 0;
mhvps_hvon_state=0;
aps_hvon_state=0;
bps_hvon_state=0;
bps_swon_state=0;
}
if (*triggerSignal == false){
//Check PLC_ON is reset
currentState = WaitTrigger;
*outputSignal = 0;
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
}
}
if(*short_pulse_mode == 1){
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
*outputSignalNI6259 = 1*aps_swon_state;
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
} else {
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
}
p4Value = 8*mhvps_hvon_state;
if (modulation) p4Value += 32;
if (pauseSet) p4Value += 1;
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
*outputSignalNI6528P4 = ~p4Value;
return true;
}
CLASS_REGISTER(JARTStateMachineGAM, "1.0")

View File

@@ -0,0 +1,264 @@
/**
* @file JARTStateMachineGAM.h
* @brief Header file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JARTStateMachineGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JARTSTATEMACHINEGAM_H_
#define GAMS_JARTSTATEMACHINEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that provides real-time state machine.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +GAMRealTimeStateMachine = {
* Class = JARTStateMachineGAM
* ConditionTrigger = 1
* mhvps_hvon = 4
* aps_hvon = 1
* aps_swon = 16
* bps_hvon = 2
* bps_swon = 8
* InputSignals = {
* Time = {
* DataSource = DDB1
* Type = uint32
* }
* PLC_ON = {
* DataSource = DDB1
* Type = uint32
* }
* MHVPS_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* SHOTLEN = {
* DataSource = DDB1
* Type = uint32
* }
* StopRequest = {
* DataSource = DDB1
* Type = uint32
* }
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* }
* OutputSignals = {
* Value = {
* DataSource = DDB1
* Type = uint32
* Trigger = 1
* }
* BEAM_ON_STAT = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVARMED = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVINJECTION = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* BeamONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* SHOT_ID = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* }
*
* </pre>
*
*/
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JARTStateMachineGAM();
virtual ~JARTStateMachineGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
enum JARealTimeState {
WaitTrigger = 0,
SwitchingHVPS = 1,
RFON = 2,
HVTerminate = 3
};
//The current rtState
JARealTimeState currentState;
//A given condition
MARTe::uint32 conditionTrigger;
//What to output in a given state and condition
MARTe::uint32 mhvps_hvon;
MARTe::uint32 aps_hvon;
MARTe::uint32 aps_swon;
MARTe::uint32 bps_hvon;
MARTe::uint32 bps_swon;
//The trigger signal (PLC_ON)
MARTe::uint32 *triggerSignal;
//Time signal
MARTe::uint32 *currentTime;
// Input signals for trigger delay parameters
MARTe::uint32 *triggerDelay_mhvps_hvon;
MARTe::uint32 *triggerDelay_aps_hvon;
MARTe::uint32 *triggerDelay_aps_swon;
MARTe::uint32 *triggerDelay_bps_hvon;
MARTe::uint32 *triggerDelay_bps_swon;
MARTe::uint32 *triggerDelay_shotlen;
// Input signal for sequence stop request.
MARTe::uint32 *stopRequest;
// Input signal for pulse length limit by mode.
MARTe::uint32 *modePulseLengthLimit;
// Input signal for short pulse mode.
MARTe::uint32 *short_pulse_mode;
// Input signal for modulation pv.
MARTe::uint32 *modulation;
// Input signal for pause signal set pv.
MARTe::uint32 *pauseSet;
// Output signal to which the output value will be written.
// One state write One signal.
MARTe::uint32 *outputSignal;
// state notify output
MARTe::uint32 *outputBeamON;
MARTe::uint32 *outputHVArmed;
MARTe::uint32 *outputHVInjection;
MARTe::uint32 *outputRFON;
// elapsed time notify output;
MARTe::uint32 *outputBeamONTime;
MARTe::uint32 *outputRFONTime;
// shot counter (coutup every RFON time.)
MARTe::uint32 *shotCounter;
// Added for HVPS state (20201117)
MARTe::uint32 *outputAPSHVON;
MARTe::uint32 *outputAPSSWON;
MARTe::uint32 *outputBPSHVON;
MARTe::uint32 *outputBPSSWON;
MARTe::uint32 *outputMHVPSON;
// Output signals for NI devices
MARTe::uint32 *outputSignalNI6259;
MARTe::uint8 *outputSignalNI6528P3;
MARTe::uint8 *outputSignalNI6528P4;
//////////////////////////////
//Internal Parameters
//////////////////////////////
//PLC_ON time holder
MARTe::uint32 plcOnTime;
//APS_SWON time holder
MARTe::uint32 apsSwonTime;
MARTe::uint32 apsSwoffTime;
MARTe::uint64 apsSwonHighResolutionTime;
//PS turn off delay
MARTe::uint32 turn_off_delay;
//HVPS state holder
bool mhvps_hvon_is_on;
bool aps_hvon_is_on;
bool aps_swon_is_on;
bool bps_hvon_is_on;
bool bps_swon_is_on;
// terminal values
MARTe::uint8 p3Value;
MARTe::uint8 p4Value;
MARTe::uint8 aps_hvon_state;
MARTe::uint8 aps_swon_state;
MARTe::uint8 mhvps_hvon_state;
MARTe::uint8 bps_hvon_state;
MARTe::uint8 bps_swon_state;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */

View File

@@ -0,0 +1,402 @@
/**
* @file JARTStateMachineGAM.cpp
* @brief Source file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JARTStateMachineGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JARTStateMachineGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
static MARTe::uint64 getCurrentTimeUs() {
using namespace MARTe;
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
}
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JARTStateMachineGAM::JARTStateMachineGAM() {
currentState = WaitTrigger; // Set Entry state.
plcOnTime = 0; // Triggered time holder.
//Output and condition in a given state.
conditionTrigger = 1;
aps_hvon = 0;
aps_swon = 0;
bps_hvon = 0;
bps_swon = 0;
mhvps_hvon = 0;
// Parameters which get from Input signals.
triggerSignal = NULL_PTR(MARTe::uint32 *);
currentTime = NULL_PTR(MARTe::uint32 *);
turn_off_delay = 2000; //us
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
stopRequest = NULL_PTR(MARTe::uint32 *);
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
// write out target.
outputSignal = NULL_PTR(MARTe::uint32 *);
outputBeamON = NULL_PTR(MARTe::uint32 *);
outputHVArmed = NULL_PTR(MARTe::uint32 *);
outputHVInjection = NULL_PTR(MARTe::uint32 *);
outputRFON = NULL_PTR(MARTe::uint32 *);
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
outputRFONTime = NULL_PTR(MARTe::uint32 *);
shotCounter = NULL_PTR(MARTe::uint32 *);
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false;
bps_hvon_is_on = false;
bps_swon_is_on = false;
apsSwonHighResolutionTime = 0;
aps_hvon_state=0;
aps_swon_state=0;
mhvps_hvon_state=0;
bps_hvon_state=0;
bps_swon_state=0;
}
JARTStateMachineGAM::~JARTStateMachineGAM() {
}
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("ConditionTrigger", conditionTrigger);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
}
}
if (ok) {
ok = data.Read("mhvps_hvon", mhvps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_hvon", aps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_swon", aps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_hvon", bps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_swon", bps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
}
}
return ok;
}
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
bool JARTStateMachineGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 11u);
if (ok) {
ok = (numberOfOutputSignals == 16u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
*shotCounter = 0;
}
return ok;
}
bool JARTStateMachineGAM::Execute() {
using namespace MARTe;
if (currentState == WaitTrigger) {
//State Transition condition
if ((*triggerSignal == conditionTrigger)) {
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
plcOnTime = *currentTime; //Save pulse start time.
//*outputBeamON = 0;
//State transition.
currentState = SwitchingHVPS;
}
}
else if (currentState == SwitchingHVPS) {
//Actions in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
*outputSignal = 0;
currentState = HVTerminate;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
//Do action
*outputSignal += bps_hvon;
bps_hvon_is_on = true; bps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
*outputBPSHVON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
//Do action
*outputSignal += aps_hvon;
aps_hvon_is_on = true; aps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
*outputAPSHVON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
//Do action
*outputSignal += bps_swon;
bps_swon_is_on = true; bps_swon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
*outputBPSSWON=1;
}
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
//Do action
*outputSignal += mhvps_hvon;
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
*outputMHVPSON=1;
}
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
//Do action
*outputSignal += aps_swon;
aps_swon_is_on = true; aps_swon_state=1;
apsSwonHighResolutionTime = getCurrentTimeUs();
apsSwonTime = *currentTime;
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
*outputAPSSWON=1;
}
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
if (bps_hvon_is_on && aps_hvon_is_on){
*outputHVArmed = 1;
}
if (bps_swon_is_on || mhvps_hvon_is_on){
*outputHVInjection = 1;
}
//State transition condition
if (aps_swon_is_on){
currentState = RFON;
*outputRFON = 0;
*outputBeamON = 1;
*shotCounter += 1;
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
}
}
else if (currentState == RFON) {
//Action in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
//debug
//if((*stopRequest != 0)){
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
//} else {
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
//}
*outputSignal -= aps_swon;
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
aps_hvon_is_on = false; aps_hvon_state=0;
aps_swon_is_on = false; aps_swon_state=0;
bps_hvon_is_on = false; bps_hvon_state=0;
bps_swon_is_on = false; bps_swon_state=0;
currentState = HVTerminate;
*outputAPSHVON=0;
*outputAPSSWON=0;
*outputBPSHVON=0;
*outputBPSSWON=0;
*outputMHVPSON=0;
}
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
// Now we do busy wait
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
//REPORT_ERROR(ErrorManagement::Debug, "!");
}
// We stop busy waiting #executionOverhead before expected pulse off time
//debug
//if((*modePulseLengthLimit == 1u)){
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
//} else {
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
//}
//debug end.
//Do action
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false; aps_swon_state=0;
bps_hvon_is_on = false;
bps_swon_is_on = false;
*outputAPSHVON=0;
*outputAPSSWON=0;
*outputBPSHVON=0;
*outputBPSSWON=0;
*outputMHVPSON=0;
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
}
*outputRFON = 1;
*outputBeamONTime = *currentTime - plcOnTime;
*outputRFONTime = *currentTime - apsSwonTime;
//State transition condition
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
currentState = HVTerminate;
apsSwoffTime = *currentTime;
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
}
}
else if (currentState == HVTerminate) {
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
//Action in this state.
*outputBeamON = 0;
*outputHVArmed = 0;
*outputHVInjection = 0;
*outputRFON = 0;
// State transition condition.
if (*currentTime - apsSwoffTime >= turn_off_delay){
*outputSignal = 0;
mhvps_hvon_state=0;
aps_hvon_state=0;
bps_hvon_state=0;
bps_swon_state=0;
}
if (*triggerSignal == false){
//Check PLC_ON is reset
currentState = WaitTrigger;
*outputSignal = 0;
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
}
}
if(*short_pulse_mode == 1){
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
*outputSignalNI6259 = 1*aps_swon_state;
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
} else {
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
}
p4Value = 8*mhvps_hvon_state;
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
*outputSignalNI6528P4 = ~p4Value;
return true;
}
CLASS_REGISTER(JARTStateMachineGAM, "1.0")

View File

@@ -0,0 +1,260 @@
/**
* @file JARTStateMachineGAM.h
* @brief Header file for class JARTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JARTStateMachineGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JARTSTATEMACHINEGAM_H_
#define GAMS_JARTSTATEMACHINEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that provides real-time state machine.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +GAMRealTimeStateMachine = {
* Class = JARTStateMachineGAM
* ConditionTrigger = 1
* mhvps_hvon = 4
* aps_hvon = 1
* aps_swon = 16
* bps_hvon = 2
* bps_swon = 8
* InputSignals = {
* Time = {
* DataSource = DDB1
* Type = uint32
* }
* PLC_ON = {
* DataSource = DDB1
* Type = uint32
* }
* MHVPS_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* SHOTLEN = {
* DataSource = DDB1
* Type = uint32
* }
* StopRequest = {
* DataSource = DDB1
* Type = uint32
* }
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* }
* OutputSignals = {
* Value = {
* DataSource = DDB1
* Type = uint32
* Trigger = 1
* }
* BEAM_ON_STAT = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVARMED = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVINJECTION = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* BeamONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* SHOT_ID = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* }
*
* </pre>
*
*/
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JARTStateMachineGAM();
virtual ~JARTStateMachineGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
enum JARealTimeState {
WaitTrigger = 0,
SwitchingHVPS = 1,
RFON = 2,
HVTerminate = 3
};
//The current rtState
JARealTimeState currentState;
//A given condition
MARTe::uint32 conditionTrigger;
//What to output in a given state and condition
MARTe::uint32 mhvps_hvon;
MARTe::uint32 aps_hvon;
MARTe::uint32 aps_swon;
MARTe::uint32 bps_hvon;
MARTe::uint32 bps_swon;
//The trigger signal (PLC_ON)
MARTe::uint32 *triggerSignal;
//Time signal
MARTe::uint32 *currentTime;
// Input signals for trigger delay parameters
MARTe::uint32 *triggerDelay_mhvps_hvon;
MARTe::uint32 *triggerDelay_aps_hvon;
MARTe::uint32 *triggerDelay_aps_swon;
MARTe::uint32 *triggerDelay_bps_hvon;
MARTe::uint32 *triggerDelay_bps_swon;
MARTe::uint32 *triggerDelay_shotlen;
// Input signal for sequence stop request.
MARTe::uint32 *stopRequest;
// Input signal for pulse length limit by mode.
MARTe::uint32 *modePulseLengthLimit;
// Input signal for short pulse mode.
MARTe::uint32 *short_pulse_mode;
// Output signal to which the output value will be written.
// One state write One signal.
MARTe::uint32 *outputSignal;
// state notify output
MARTe::uint32 *outputBeamON;
MARTe::uint32 *outputHVArmed;
MARTe::uint32 *outputHVInjection;
MARTe::uint32 *outputRFON;
// elapsed time notify output;
MARTe::uint32 *outputBeamONTime;
MARTe::uint32 *outputRFONTime;
// shot counter (coutup every RFON time.)
MARTe::uint32 *shotCounter;
// Added for HVPS state (20201117)
MARTe::uint32 *outputAPSHVON;
MARTe::uint32 *outputAPSSWON;
MARTe::uint32 *outputBPSHVON;
MARTe::uint32 *outputBPSSWON;
MARTe::uint32 *outputMHVPSON;
// Output signals for NI devices
MARTe::uint32 *outputSignalNI6259;
MARTe::uint8 *outputSignalNI6528P3;
MARTe::uint8 *outputSignalNI6528P4;
//////////////////////////////
//Internal Parameters
//////////////////////////////
//PLC_ON time holder
MARTe::uint32 plcOnTime;
//APS_SWON time holder
MARTe::uint32 apsSwonTime;
MARTe::uint32 apsSwoffTime;
MARTe::uint64 apsSwonHighResolutionTime;
//PS turn off delay
MARTe::uint32 turn_off_delay;
//HVPS state holder
bool mhvps_hvon_is_on;
bool aps_hvon_is_on;
bool aps_swon_is_on;
bool bps_hvon_is_on;
bool bps_swon_is_on;
// terminal values
MARTe::uint8 p3Value;
MARTe::uint8 p4Value;
MARTe::uint8 aps_hvon_state;
MARTe::uint8 aps_swon_state;
MARTe::uint8 mhvps_hvon_state;
MARTe::uint8 bps_hvon_state;
MARTe::uint8 bps_swon_state;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,56 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JARTStateMachineGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JARTStateMachineGAM$(LIBEXT) \
$(BUILD_DIR)/JARTStateMachineGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,295 @@
/**
* @file JARampupGAM.cpp
* @brief Source file for class JARampupGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JARampupGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "JARampupGAM.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JARampupGAM::JARampupGAM() : GAM() {
current_setpoint = NULL_PTR(MARTe::float32 *);
target_value = NULL_PTR(MARTe::float32 *);
rampup_time = NULL_PTR(MARTe::float32 *);
start = NULL_PTR(MARTe::uint32 *);
standby = NULL_PTR(MARTe::uint32 *);
isAuto = NULL_PTR(MARTe::uint32 *);
FHPS_PrePro = NULL_PTR(MARTe::float32 *);
output = NULL_PTR(MARTe::float32 *);
state = NULL_PTR(MARTe::uint32 *);
rampup_rate = 0.0f;
inRampup = false;
resetFlag = true;
inWaitHVON = false;
inWaitStandby = false;
}
JARampupGAM::~JARampupGAM() {
}
bool JARampupGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
return GAM::Initialise(data);
}
bool JARampupGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 7u);
if (ok) {
ok = (numberOfOutputSignals == 2u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Two output signals shall be defined.");
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Six input signals shall be defined.");
}
uint32 currentspvIndex;
uint32 targetvIndex;
uint32 timeIndex;
uint32 startIndex;
uint32 standbyIndex;
uint32 isAutoIndex;
uint32 fhpsPreProIndex;
if (ok) {
StreamString signalName = "Currspv";
ok = GetSignalIndex(InputSignals, currentspvIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Currspv input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, currentspvIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Currspv shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Targetv";
ok = GetSignalIndex(InputSignals, targetvIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Targetv input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, targetvIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Targetv shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Time";
ok = GetSignalIndex(InputSignals, timeIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Time input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, timeIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Time shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Start";
ok = GetSignalIndex(InputSignals, startIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Start input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, startIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Start shall be defined as uint32.");
}
}
}
if (ok) {
StreamString signalName = "PLC_STANDBY";
ok = GetSignalIndex(InputSignals, standbyIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, standbyIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY shall be defined as uint32.");
}
}
}
if (ok) {
StreamString signalName = "MANUAL_AUTO";
ok = GetSignalIndex(InputSignals, isAutoIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, isAutoIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO shall be defined as uint32.");
}
}
}
if (ok) {
StreamString signalName = "FHPS_PrePro";
ok = GetSignalIndex(InputSignals, fhpsPreProIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "FHPS_PrePro input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, fhpsPreProIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal FHPS_PrePro shall be defined as float32.");
}
}
}
if (ok) {
TypeDescriptor inputType = GetSignalType(OutputSignals, 0);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Output shall be defined as float32.");
}
}
if (ok) {
TypeDescriptor inputType = GetSignalType(OutputSignals, 1);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal state shall be defined as float32.");
}
}
if (ok) {
current_setpoint = reinterpret_cast<float32 *>(GetInputSignalMemory(currentspvIndex));
target_value = reinterpret_cast<float32 *>(GetInputSignalMemory(targetvIndex));
rampup_time = reinterpret_cast<float32 *>(GetInputSignalMemory(timeIndex));
start = reinterpret_cast<uint32 *>(GetInputSignalMemory(startIndex));
standby = reinterpret_cast<uint32 *>(GetInputSignalMemory(standbyIndex));
isAuto = reinterpret_cast<uint32 *>(GetInputSignalMemory(isAutoIndex));
FHPS_PrePro = reinterpret_cast<float32 *>(GetInputSignalMemory(fhpsPreProIndex));
output = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
state = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
}
return ok;
}
bool JARampupGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName){
if(strcmp(nextStateName, "WaitHVON_PREP")==0 || strcmp(nextStateName, "WaitHVON_SDN_PREP")==0 ||
strcmp(nextStateName, "WaitHVON")==0 || strcmp(nextStateName, "WaitHVON_SDN")==0){
inWaitHVON = true;
inWaitStandby = false;
} else{
inWaitHVON = false;
if(strcmp(nextStateName,"WaitStandby")==0 ){
inWaitStandby = true;
} else {
inWaitStandby = false;
}
}
return true;
}
bool JARampupGAM::Execute() {
using namespace MARTe;
if(!inWaitHVON){
if (*target_value <= 0.0f || *standby == 0u) {
*output = 0.0f;
rampup_rate = 0.0f;
if(*target_value <= 0.0f){
*state = 3u;
} else {
*state = 0u;
}
return true;
}
if(*start == 1u && *isAuto==0u){ //isAuto = 1.Manual, 0.auto-rampup.
inRampup = true;
resetFlag = true;
*output = 0.0f; //Enable if it should start always zero.
}
// Calcrate new rampup rate.
if(*rampup_time != 0 && resetFlag == true){
rampup_rate = (*target_value - *current_setpoint) / *rampup_time/1000.0f; // Volt/msec
resetFlag = false;
}
// Update Parameter
if(*standby == 1u ){
if(*isAuto == 1u){
if (inWaitStandby){
*output = *target_value;
} else{
*output = *FHPS_PrePro;
}
//*output = *target_value;
*state = 0u;
return true;
}
else if (inRampup){
if (*output + rampup_rate < *target_value && *rampup_time != 0){
*output = *output + rampup_rate;
*state = 1u;
} else {
*output = *target_value;
*state = 2u;
inRampup = false;
}
}
}
return true;
} else {
if(*isAuto == 0){
*output = *FHPS_PrePro;
} else{
*output = *target_value;
}
return true;
}
}
CLASS_REGISTER(JARampupGAM, "1.0")

View File

@@ -0,0 +1,141 @@
/**
* @file JARampupGAM.h
* @brief Header file for class JARampupGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JARampupGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JARampupGAM_H_
#define GAMS_JARampupGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM that rampup output value with specified target value and duration.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +FHPSRampupGAM = {
* Class = JARampupGAM
* InputSignals = {
* Currspv = {
* Alias = FHPS_REF
* DataSource = DDB1
* Type = float32
* }
* Targetv = {
* Alias = FHPS_AUTO_TAGV
* DataSource = EPICSCAInput
* Type = float32
* }
* Time = {
* Alias = FHPS_AUTO_TIME
* DataSource = EPICSCAInput
* Type = float32
* }
* Start = {
* Alias = FHPS_AUTO_START
* DataSource = EPICSCAInput
* Type = uint32
* }
* }
* OutputSignals = {
* FHPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* }
* }
*
* </pre>
*
*/
class JARampupGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JARampupGAM();
virtual ~JARampupGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
// Input signal containing current current_setpoint
MARTe::float32 *current_setpoint;
// Input signal containing the frequency of the waveform.
MARTe::float32 *target_value;
// Input signal containing the amplitude of the waveform.
MARTe::float32 *rampup_time;
// Input signal containing CCPS_ON_REQUEST
MARTe::uint32 *start;
// Input signal PLC_STANDBY
MARTe::uint32 *standby;
// MANUAL AUTO button
MARTe::uint32 *isAuto;
// Input signal
MARTe::float32 *FHPS_PrePro;
// Output
MARTe::float32 *output;
// State output
MARTe::uint32 *state; //0:NotOperation, 1:InOperation, 2:Finish, 3:Error
// Internal variables
MARTe::float32 rampup_rate;
bool inRampup;
bool resetFlag;
bool inWaitHVON;
bool inWaitStandby;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JARampupGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JARampupGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JARampupGAM$(LIBEXT) \
$(BUILD_DIR)/JARampupGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,361 @@
/**
* @file JASDNRTStateMachineGAM.cpp
* @brief Source file for class JASDNRTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JASDNRTStateMachineGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JASDNRTStateMachineGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JASDNRTStateMachineGAM::JASDNRTStateMachineGAM() {
currentState = WaitTrigger; // Set Entry state.
plcOnTime = 0; // Triggered time holder.
sdnTriggerTime = 0;
//Output and condition in a given state.
conditionTrigger = 1;
aps_hvon = 0;
aps_swon = 0;
bps_hvon = 0;
bps_swon = 0;
mhvps_hvon = 0;
// Parameters which get from Input signals.
triggerSignal = NULL_PTR(MARTe::uint32 *);
currentTime = NULL_PTR(MARTe::uint32 *);
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
stopRequest = NULL_PTR(MARTe::uint32 *);
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
sdnCommand = NULL_PTR(MARTe::uint16 *);
// write out target.
outputSignal = NULL_PTR(MARTe::uint32 *);
outputBeamON = NULL_PTR(MARTe::uint32 *);
outputHVArmed = NULL_PTR(MARTe::uint32 *);
outputHVInjection = NULL_PTR(MARTe::uint32 *);
outputRFON = NULL_PTR(MARTe::uint32 *);
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
outputRFONTime = NULL_PTR(MARTe::uint32 *);
shotCounter = NULL_PTR(MARTe::uint32 *);
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false;
bps_hvon_is_on = false;
bps_swon_is_on = false;
}
JASDNRTStateMachineGAM::~JASDNRTStateMachineGAM() {
}
bool JASDNRTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("ConditionTrigger", conditionTrigger);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
}
}
if (ok) {
ok = data.Read("mhvps_hvon", mhvps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_hvon", aps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("aps_swon", aps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_hvon", bps_hvon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
}
}
if (ok) {
ok = data.Read("bps_swon", bps_swon);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
}
}
return ok;
}
bool JASDNRTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
bool JASDNRTStateMachineGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 11u);
if (ok) {
ok = (numberOfOutputSignals == 8u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined");
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger16Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint16", signalName.Buffer());
}
}
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = (outputType == UnsignedInteger32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
}
}
}
if (ok) {
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
sdnCommand = reinterpret_cast<uint16 *>(GetInputSignalMemory(10));
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
*shotCounter = 0;
}
return ok;
}
bool JASDNRTStateMachineGAM::Execute() {
using namespace MARTe;
if (currentState == WaitTrigger) {
//State Transition condition
if ((*triggerSignal == conditionTrigger)) {
REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence in SDN mode.");
plcOnTime = *currentTime; //Save pulse start time.
*outputBeamON = 0;
//State transition.
currentState = SwitchingHVPS_HVON;
}
}
else if (currentState == SwitchingHVPS_HVON) {
//Actions in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
*outputSignal -= aps_swon;
currentState = HVTerminate;
}
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
//Do action
*outputSignal += bps_hvon;
bps_hvon_is_on = true;
REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
}
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
//Do action
*outputSignal += aps_hvon;
aps_hvon_is_on = true;
REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal.");
}
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
if (bps_hvon_is_on && aps_hvon_is_on){
*outputHVArmed = 0;
currentState = WaitSDNTrigger;
}
}
else if (currentState == WaitSDNTrigger) {
// Action in this state
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
// State change conditions
if (*sdnCommand == 1){
sdnTriggerTime = *currentTime;
currentState = SwitchingHVPS_SWON;
}
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
*outputSignal = 0;
currentState = HVTerminate;
}
}
else if (currentState == SwitchingHVPS_SWON) {
//Actions in this state.
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
*outputSignal = 0;
currentState = HVTerminate;
}
if (*currentTime >= (sdnTriggerTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
//Do action
*outputSignal += bps_swon;
bps_swon_is_on = true;
REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
}
if (*currentTime >= (sdnTriggerTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
//Do action
*outputSignal += mhvps_hvon;
mhvps_hvon_is_on = true;
REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
}
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon)){
//Do action
*outputSignal += aps_swon;
aps_swon_is_on = true;
apsSwonTime = *currentTime;
REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
}
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
if (bps_swon_is_on || mhvps_hvon_is_on){
*outputHVInjection = 0;
}
//State transition condition
if (aps_swon_is_on){
currentState = RFON;
*outputRFON = 0;
*shotCounter += 1;
REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
}
}
else if (currentState == RFON) {
//SDN command processing.
if (*sdnCommand == 4 && aps_swon_is_on) {
*outputSignal -= aps_swon;
aps_swon_is_on = false;
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 4");
}
if (*sdnCommand == 3 && !aps_swon_is_on) {
*outputSignal += aps_swon;
aps_swon_is_on = true;
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 3");
}
//Action in this state.
if ((*sdnCommand == 2) || (*modePulseLengthLimit == 1u) || (*currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon + *triggerDelay_shotlen))) {
REPORT_ERROR(ErrorManagement::Debug, "shotlen: %d", *triggerDelay_shotlen);
if (*sdnCommand == 2) {
REPORT_ERROR(ErrorManagement::Information, "sdn command was 2");
} else if (*currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon + *triggerDelay_shotlen)){
REPORT_ERROR(ErrorManagement::Information, "pulse length reached setpoint.");
}
//Do action
*outputSignal -= aps_swon; //Turn off only aps_swon
mhvps_hvon_is_on = false;
aps_hvon_is_on = false;
aps_swon_is_on = false;
bps_hvon_is_on = false;
bps_swon_is_on = false;
REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
}
*outputRFON = 0;
*outputBeamONTime = *currentTime - plcOnTime;
*outputRFONTime = *currentTime - apsSwonTime;
//State transition condition
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
currentState = HVTerminate;
apsSwoffTime = *currentTime;
REPORT_ERROR(ErrorManagement::Information, "state was changed to HVTerminate");
}
}
else if (currentState == HVTerminate) {
//Action in this state.
*outputBeamON = 1;
*outputHVArmed = 1;
*outputHVInjection = 1;
*outputRFON = 1;
// State transition condition.
if (*currentTime - apsSwoffTime >= turn_off_delay){
*outputSignal = 0;
}
if (*triggerSignal == false){
//Check PLC_ON is reset
currentState = WaitTrigger;
*outputSignal = 0;
REPORT_ERROR(ErrorManagement::Debug, "state was changed to WaitTrigger");
}
}
return true;
}
CLASS_REGISTER(JASDNRTStateMachineGAM, "1.0")

View File

@@ -0,0 +1,250 @@
/**
* @file JARTStateMachineGAM.h
* @brief Header file for class JASDNRTStateMachineGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JARTStateMachineGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JASDNRTSTATEMACHINEGAM_H_
#define GAMS_JASDNRTSTATEMACHINEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM provides real-time state machine that communicate with SDN packet.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +GAMSDNRealTimeStateMachine = {
* Class = JASDNRTStateMachineGAM
* ConditionTrigger = 1
* mhvps_hvon = 4
* aps_hvon = 1
* aps_swon = 16
* bps_hvon = 2
* bps_swon = 8
* InputSignals = {
* Time = {
* DataSource = DDB1
* Type = uint32
* }
* PLC_ON = {
* DataSource = DDB1
* Type = uint32
* }
* MHVPS_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* APS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_HVON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON_DT = {
* DataSource = DDB1
* Type = uint32
* }
* SHOTLEN = {
* DataSource = DDB1
* Type = uint32
* }
* StopRequest = {
* DataSource = DDB1
* Type = uint32
* }
* MODE_SHOTLEN_FLAG = {
* DataSource = DDB1
* Type = uint32
* }
* Command = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint16
* }
* }
* OutputSignals = {
* Value = {
* //DataSource = NI6259
* DataSource = Display
* Type = uint32
* Trigger = 1
* }
* BeamON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVARMED = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* HVINJECTION = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFON = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* BeamONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* RFONTime = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* SHOT_ID = {
* DataSource = RealTimeThreadAsyncBridge
* Type = uint32
* }
* }
* }
* </pre>
*
*/
class JASDNRTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JASDNRTStateMachineGAM();
virtual ~JASDNRTStateMachineGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
enum JARealTimeState {
WaitTrigger = 0,
SwitchingHVPS_HVON = 1,
WaitSDNTrigger = 2,
SwitchingHVPS_SWON = 3,
RFON = 4,
HVTerminate = 5
};
//The current rtState
JARealTimeState currentState;
/////////////////////////////////////////////////
// Static parameter given by cfg File
/////////////////////////////////////////////////
//A given condition
MARTe::uint32 conditionTrigger;
//What to output in a given state and condition
MARTe::uint32 mhvps_hvon;
MARTe::uint32 aps_hvon;
MARTe::uint32 aps_swon;
MARTe::uint32 bps_hvon;
MARTe::uint32 bps_swon;
/////////////////////////////////////////////////
// Input signals
/////////////////////////////////////////////////
//The trigger signal (PLC_ON)
MARTe::uint32 *triggerSignal;
//Time signal (Time from TimerGAM)
MARTe::uint32 *currentTime;
// Input signals for trigger delay parameters
MARTe::uint32 *triggerDelay_mhvps_hvon;
MARTe::uint32 *triggerDelay_aps_hvon;
MARTe::uint32 *triggerDelay_aps_swon;
MARTe::uint32 *triggerDelay_bps_hvon;
MARTe::uint32 *triggerDelay_bps_swon;
MARTe::uint32 *triggerDelay_shotlen;
// Input signal for sequence stop request.
MARTe::uint32 *stopRequest;
// Input signal for pulse length limit by mode.
MARTe::uint32 *modePulseLengthLimit;
// Input signal for SDN commands.
MARTe::uint16 *sdnCommand;
/////////////////////////////////////////////////////////////
// Output signal to which the output value will be written.
/////////////////////////////////////////////////////////////
// One state write One signal.
MARTe::uint32 *outputSignal;
// state notify output
MARTe::uint32 *outputBeamON;
MARTe::uint32 *outputHVArmed;
MARTe::uint32 *outputHVInjection;
MARTe::uint32 *outputRFON;
// elapsed time notify output;
MARTe::uint32 *outputBeamONTime;
MARTe::uint32 *outputRFONTime;
// shot counter (coutup every RFON time.)
MARTe::uint32 *shotCounter;
//////////////////////////////
//Internal Parameters
//////////////////////////////
//PLC_ON time holder
MARTe::uint32 plcOnTime;
//APS_SWON time holder
MARTe::uint32 apsSwonTime;
MARTe::uint32 apsSwoffTime;
//PS turn off delay
MARTe::uint32 turn_off_delay;
//SDN trigger command arrival time.
MARTe::uint32 sdnTriggerTime;
//HVPS state holder
bool mhvps_hvon_is_on;
bool aps_hvon_is_on;
bool aps_swon_is_on;
bool bps_hvon_is_on;
bool bps_swon_is_on;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JASDNRTSTATEMACHINEGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JASDNRTStateMachineGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JASDNRTStateMachineGAM$(LIBEXT) \
$(BUILD_DIR)/JASDNRTStateMachineGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,177 @@
/**
* @file JASampleGAM.cpp
* @brief Source file for class JASampleGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JASampleGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JASampleGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JASampleGAM::JASampleGAM() {
// initialize member variables.
param1 = 0;
param2 = 0;
//Input signals.
input1 = NULL_PTR(MARTe::uint32 *);
input2 = NULL_PTR(MARTe::float32 *);
//Output signals.
output1= NULL_PTR(MARTe::uint32 *);
output2 = NULL_PTR(MARTe::float32 *);
}
JASampleGAM::~JASampleGAM() {
}
bool JASampleGAM::Initialise(MARTe::StructuredDataI & data) {
//GAM parameters are initialized.
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("param1", param1);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The param1 shall be specified");
}
}
if (ok) {
ok = data.Read("param2", param2);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The param2 shall be specified");
}
}
return ok;
}
bool JASampleGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
//This method changes internal parameter based on next realtime state.
return true;
}
bool JASampleGAM::Setup() {
// Setup memory for input/output signals on the GAM.
using namespace MARTe;
bool ok = (numberOfInputSignals == 2u);
if (ok) {
ok = (numberOfOutputSignals == 2u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two output signals shall be defined");
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two input signals shall be defined");
}
// Do type check for input signals.
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = ((inputType == UnsignedInteger32Bit) || (inputType == Float32Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or flaot32", signalName.Buffer());
}
}
}
// Do type check for output signals
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = ((outputType == UnsignedInteger32Bit) || (outputType == Float32Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or float32", signalName.Buffer());
}
}
}
// Signal id can get by signal name in configuration file
if (ok) {
StreamString signalName = "InputXXX"; //Variable name in configuration file.
uint32 signalxxxIndex; //Index is copied to this variable by using signal name.
ok = GetSignalIndex(InputSignals, signalxxxIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "InputXXX input signal shall be defined");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, signalxxxIndex);
ok = (inputType == Float32Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, signalxxxIndex, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
} else {
inputXXX = reinterpret_cast<float32 *>(GetInputSignalMemory(signalxxxIndex));
}
}
}
// Do type cast. with explicit signal id.
if (ok) {
input1 = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
input2 = reinterpret_cast<float32 *>(GetInputSignalMemory(1));
output1 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
output2 = reinterpret_cast<float32 *>(GetOutputSignalMemory(1));
}
return ok;
}
bool JASampleGAM::Execute() {
// This method is called every realtime state thread cycle.
using namespace MARTe;
REPORT_ERROR(ErrorManagement::Information, "input1 is %d.", *input1);
REPORT_ERROR(ErrorManagement::Information, "input2 is %f.", *input2);
REPORT_ERROR(ErrorManagement::Information, "inputXXX is %f.", *inputXXX);
REPORT_ERROR(ErrorManagement::Information, "maltiply param value to input.");
*output1 = *input1 * param1;
*output2 = *input2 * param2;
REPORT_ERROR(ErrorManagement::Information, "output1 is %d.", *output1);
REPORT_ERROR(ErrorManagement::Information, "output2 is %f.", *output2);
return true;
}
CLASS_REGISTER(JASampleGAM, "1.0")

View File

@@ -0,0 +1,122 @@
/**
* @file JASampleGAM.h
* @brief Header file for class JASampleGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JASampleGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JASampleGAM_H_
#define GAMS_JASampleGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM Sample Usage.
* @details Sample
*
* The configuration syntax is:
*
* <pre>
* +SampleGAM = {
* Class = JASampleGAM
* InputSignals = {
* Input1 = {
* DataSource = "DDB"
* Type = uint32
* Default = 0
* }
* Input2 = {
* DataSource = "DDB"
* Type = float32
* Default = 100
* }
* InputXXX = {
* DataSource = "DDB"
* Type = float32
* NumberOfElements = 1
* }
* }
* OutputSignals = {
* Output1 = {
* DataSource = "DDB"
* Type = uint32
* Default = 0
* }
* Output2 = {
* DataSource = "DDB"
* Type = int32
* Default = 100
* }
* }
* }
* </pre>
*/
class JASampleGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JASampleGAM();
virtual ~JASampleGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//GAM fixed parameters.
MARTe::uint32 param1;
MARTe::float32 param2;
// Input signals
MARTe::uint32 *input1;
MARTe::float32 *input2;
MARTe::float32 *inputXXX;
// Output signals
MARTe::uint32 *output1;
MARTe::float32 *output2;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JASampleGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JARTSampleGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JARTSampleGAM$(LIBEXT) \
$(BUILD_DIR)/JARTSampleGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,188 @@
/**
* @file JASourceChoiseGAM.cpp
* @brief Source file for class JASourceChoiseGAM
* @date Nov 26, 2018
* @author aneto
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JASourceChoiseGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JASourceChoiseGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JASourceChoiseGAM::JASourceChoiseGAM() {
// initialize member variables.
numberOfPVs = 0;
}
JASourceChoiseGAM::~JASourceChoiseGAM() {
}
bool JASourceChoiseGAM::Initialise(MARTe::StructuredDataI & data) {
//GAM parameters are initialized.
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("numberOfPVs", numberOfPVs);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The numberOfPVs parameter shall be specified");
}
}
return ok;
}
bool JASourceChoiseGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
//This method changes internal parameter based on next realtime state.
return true;
}
bool JASourceChoiseGAM::Setup() {
// Setup memory for input/output signals on the GAM.
using namespace MARTe;
bool ok = (numberOfInputSignals == numberOfPVs*3u);
if (ok) {
ok = (numberOfOutputSignals == numberOfPVs);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "%d *3 output signals shall be defined", numberOfPVs);
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "%d input signals shall be defined", numberOfPVs);
}
// Do type check for input signals.
int int_num = 0;
int float_num = 0;
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
if(inputType == UnsignedInteger32Bit){
int_num++;
} else if (inputType == Float32Bit) {
float_num++;
} else {
ok = false;
};
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or flaot32", signalName.Buffer());
}
}
}
// Do type check for output signals
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = ((outputType == UnsignedInteger32Bit) || (outputType == Float32Bit));
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or float32", signalName.Buffer());
}
}
}
// Set memory
inputUInt32.resize(numberOfPVs*2);
inputFloat32.resize(numberOfPVs*2);
choise.resize(numberOfPVs);
outputUInt32.resize(numberOfPVs);
outputFloat32.resize(numberOfPVs);
prevUInt32.resize(numberOfPVs*2);
prevFloat32.resize(numberOfPVs*2);
if(ok){
for(uint32 i=0; i<numberOfPVs; i++){ //Expected inp1, inp2, choise order in signal list.
TypeDescriptor inputType = GetSignalType(InputSignals, i*3);
if(inputType == UnsignedInteger32Bit){
inputUInt32[2*i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i));
inputUInt32[2*i+1] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+1));
choise[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+2));
outputUInt32[i] = reinterpret_cast<uint32 *>(GetOutputSignalMemory(i));
} else if(inputType == Float32Bit){
inputFloat32[2*i] = reinterpret_cast<float *>(GetInputSignalMemory(3*i));
inputFloat32[2*i+1] = reinterpret_cast<float *>(GetInputSignalMemory(3*i+1));
choise[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+2));
outputFloat32[i] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
}
prevUInt32[2*i] = 0;
prevUInt32[2*i+1] = 0;
prevFloat32[2*i] = 0;
prevFloat32[2*i+1] = 0;
}
}
return ok;
}
bool JASourceChoiseGAM::Execute() {
// This method is called every realtime state thread cycle.
using namespace MARTe;
for (uint32 i=0; i < numberOfPVs; i++){
if(*choise[i]==0){
if(outputUInt32[i]){
if(prevUInt32[i*2] != *inputUInt32[i*2]){
*outputUInt32[i] = *inputUInt32[i*2];
prevUInt32[i*2] = *inputUInt32[i*2];
prevUInt32[1+i*2] = *inputUInt32[1+i*2];
}
} else if(outputFloat32[i]){
if(prevFloat32[i*2] != *inputFloat32[i*2]){
*outputFloat32[i] = *inputFloat32[i*2];
prevFloat32[i*2] = *inputFloat32[i*2];
prevFloat32[1+i*2] = *inputFloat32[1+i*2];
}
}
} else {
if(outputUInt32[i]){
if(prevUInt32[1+i*2] != *inputUInt32[1+i*2]){
*outputUInt32[i] = *inputUInt32[1+i*2];
prevUInt32[i*2] = *inputUInt32[i*2];
prevUInt32[1+i*2] = *inputUInt32[1+i*2];
}
} else if (outputFloat32[i]){
if(prevFloat32[1+i*2] != *inputFloat32[1+i*2]){
*outputFloat32[i] = *inputFloat32[1+i*2];
prevFloat32[i*2] = *inputFloat32[i*2];
prevFloat32[1+i*2] = *inputFloat32[1+i*2];
}
}
}
}
return true;
}
CLASS_REGISTER(JASourceChoiseGAM, "1.0")

View File

@@ -0,0 +1,84 @@
/**
* @file JASourceChoiseGAM.h
* @brief Header file for class JASourceChoiseGAM
* @date Mar 04, 2019
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JASourceChoiseGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JASourceChoiseGAM_H_
#define GAMS_JASourceChoiseGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
#include <vector>
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
class JASourceChoiseGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JASourceChoiseGAM();
virtual ~JASourceChoiseGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
//The list of possible states
//GAM fixed parameters.
MARTe::uint32 numberOfPVs;
// Input signals
std::vector<MARTe::uint32 *> inputUInt32;
std::vector<MARTe::float32 *> inputFloat32;
std::vector<MARTe::uint32 *> choise;
// Output signals
std::vector<MARTe::uint32 *> outputUInt32;
std::vector<MARTe::float32 *> outputFloat32;
// Previous Input value
std::vector<MARTe::uint32> prevUInt32;
std::vector<MARTe::float32> prevFloat32;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JASourceChoiseGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JASourceChoiseGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JASourceChoiseGAM$(LIBEXT) \
$(BUILD_DIR)/JASourceChoiseGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,206 @@
/**
* @file JATerminalInterfaceGAM.cpp
* @brief Source file for class JATerminalInterfaceGAM
* @date Feb 19, 2019
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JATerminalInterfaceGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "JATerminalInterfaceGAM.h"
#include "AdvancedErrorManagement.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
JATerminalInterfaceGAM::JATerminalInterfaceGAM() {
// Fixed GAM input
aps_hvon_term = 0;
// Parameters which get from Input signals.
mhvps_hvon = NULL_PTR(MARTe::uint32 *);
aps_hvon = NULL_PTR(MARTe::uint32 *);
aps_swon = NULL_PTR(MARTe::uint32 *);
bps_hvon = NULL_PTR(MARTe::uint32 *);
bps_swon = NULL_PTR(MARTe::uint32 *);
stateMachineOutput = NULL_PTR(MARTe::uint32 *);
// write out target.
outputSignalNI6259 = NULL_PTR(MARTe::uint32 *);
outputSignalNI6528P3 = NULL_PTR(MARTe::uint8 *);
outputSignalNI6528P4 = NULL_PTR(MARTe::uint8 *);
aps_hvon_state = 0;
aps_swon_state = 0;
mhvps_hvon_state = 0;
bps_hvon_state = 0;
bps_swon_state = 0;
p3Value = 0;
p4Value = 0;
}
JATerminalInterfaceGAM::~JATerminalInterfaceGAM() {
}
bool JATerminalInterfaceGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
bool ok = GAM::Initialise(data);
if (ok) {
ok = data.Read("mhvps_hvon_term", mhvps_hvon_term);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon_term shall be specified");
}
}
if (ok) {
ok = data.Read("aps_hvon_term", aps_hvon_term);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon_term shall be specified");
}
}
if (ok) {
ok = data.Read("aps_swon_term", aps_swon_term);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon_term shall be specified");
}
}
if (ok) {
ok = data.Read("bps_hvon_term", bps_hvon_term);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon_term shall be specified");
}
}
if (ok) {
ok = data.Read("bps_swon_term", bps_swon_term);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon_term shall be specified");
}
}
return ok;
}
bool JATerminalInterfaceGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
return true;
}
bool JATerminalInterfaceGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 9u);
if (ok) {
ok = (numberOfOutputSignals == 3u);
if (!ok) {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Three output signals shall be defined");
}
}
else {
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfInputSignals; c++) {
TypeDescriptor inputType = GetSignalType(InputSignals, c);
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger8Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint8", signalName.Buffer());
}
}
}
if (ok) {
uint32 c;
for (c = 0u; c < numberOfOutputSignals; c++) {
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
if (!ok) {
StreamString signalName;
(void) GetSignalName(InputSignals, c, signalName);
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint8", signalName.Buffer());
}
}
}
if (ok) {
//mhvps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
//aps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
//bps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
stateMachineOutput = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
ni6528p3Value = reinterpret_cast<uint8 *>(GetInputSignalMemory(7));
ni6528p4Value = reinterpret_cast<uint8 *>(GetInputSignalMemory(8));
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(1));
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(2));
}
return ok;
}
bool JATerminalInterfaceGAM::Execute() {
using namespace MARTe;
uint8 sm = *stateMachineOutput;
//Update HVPS state
aps_hvon_state = ((sm >> (0))&1);
aps_swon_state = ((sm >> (4))&1);
mhvps_hvon_state = ((sm >> (2))&1);
bps_hvon_state = ((sm >> (1))&1);
bps_swon_state = ((sm >> (3))&1);
if(*short_pulse_mode == 1){
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state;
*outputSignalNI6259 = 1*aps_swon_state;
//uint8 ni6528p3ValueTemp = 0;//*ni6528p3Value;
//ni6528p3ValueTemp &= ~(1<<2); //Does not turn on ni6258 aps switch
//Update terminal value
//*outputSignalNI6528P3 = ~(ni6528p3ValueTemp | p3Value);
*outputSignalNI6528P3 = ~p3Value;
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
} else {
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state;
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
}
p4Value = 8*mhvps_hvon_state;
*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
return true;
}
CLASS_REGISTER(JATerminalInterfaceGAM, "1.0")

View File

@@ -0,0 +1,157 @@
/**
* @file JATerminalInterfaceGAM.h
* @brief Header file for class JATerminalInterfaceGAM
* @date Feb 19, 2020
* @author kuchida
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JATerminalInterfaceGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JATerminalInterfaceGAM_H_
#define GAMS_JATerminalInterfaceGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM calculates one output value by comparing input value and fixed parameters.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
*
* +terminalInterfaceGAM = {
* Class = JATerminalInterfaceGAM
* mhvps_hvon_term = 4
* aps_hvon_term = 1
* aps_swon_term = 16
* bps_hvon_term = 2
* bps_swon_term = 8
* InputSignals = {
* MHVPS_HVON = {
* DataSource = DDB1
* Type = uint32
* }
* APS_HVON = {
* DataSource = DDB1
* Type = uint32
* }
* APS_SWON = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_HVON = {
* DataSource = DDB1
* Type = uint32
* }
* BPS_SWON = {
* DataSource = DDB1
* Type = uint32
* }
* Value = {
* DataSource = DDB1
* Type = uint32
* }
* }
* OutputSignals = {
* Value = {
* DataSource = NI6259
* Type = uint32
* Trigger = 1
* }
* }
* }
*
* </pre>
*
*/
class JATerminalInterfaceGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
CLASS_REGISTER_DECLARATION()
JATerminalInterfaceGAM();
virtual ~JATerminalInterfaceGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
const MARTe::char8 * const nextStateName);
private:
// Fixed GAM input
MARTe::uint32 mhvps_hvon_term;
MARTe::uint32 aps_hvon_term;
MARTe::uint32 aps_swon_term;
MARTe::uint32 bps_hvon_term;
MARTe::uint32 bps_swon_term;
// Input signals
//MARTe::uint32 *mhvps_manm;
MARTe::uint32 *mhvps_hvon;
//MARTe::uint32 *aps_manm;
MARTe::uint32 *aps_hvon;
MARTe::uint32 *aps_swon;
//MARTe::uint32 *bps_manm;
MARTe::uint32 *bps_hvon;
MARTe::uint32 *bps_swon;
MARTe::uint32 *short_pulse_mode;
MARTe::uint32 *stateMachineOutput;
MARTe::uint8 *ni6528p3Value;
MARTe::uint8 *ni6528p4Value;
// Output signals
MARTe::uint32 *outputSignalNI6259;
MARTe::uint8 *outputSignalNI6528P3;
MARTe::uint8 *outputSignalNI6528P4;
MARTe::uint8 aps_hvon_state;
MARTe::uint8 aps_swon_state;
MARTe::uint8 mhvps_hvon_state;
MARTe::uint8 bps_hvon_state;
MARTe::uint8 bps_swon_state;
MARTe::uint8 p3Value;
MARTe::uint8 p4Value;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JATerminalInterfaceGAM_H_ */

View File

@@ -0,0 +1,27 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
include Makefile.inc

View File

@@ -0,0 +1,55 @@
#############################################################
#
# Copyright 2015 F4E | European Joint Undertaking for ITER
# and the Development of Fusion Energy ('Fusion for Energy')
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=JATerminalInterfaceGAM.x
PACKAGE=GAMs
ROOT_DIR=../../
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/JATerminalInterfaceGAM$(LIBEXT) \
$(BUILD_DIR)/JATerminalInterfaceGAM$(DLLEXT)
echo $(OBJS)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,178 @@
/**
* @file JATriangleWaveGAM.cpp
* @brief Source file for class JATriangleWaveGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This source file contains the definition of all the methods for
* the class JATriangleWaveGAM (public, protected, and private). Be aware that some
* methods, such as those inline could be defined on the header file, instead.
*/
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "AdvancedErrorManagement.h"
#include "JATriangleWaveGAM.h"
/*---------------------------------------------------------------------------*/
/* Static definitions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
MARTe::float32 absFloat(MARTe::float32 x) {
if (x < 0.0f) {
return -x;
}
return x;
}
JATriangleWaveGAM::JATriangleWaveGAM() {
frequency = NULL_PTR(MARTe::float32 *);
amplitude = NULL_PTR(MARTe::float32 *);
offset = NULL_PTR(MARTe::float32 *);
plcStandby = NULL_PTR(MARTe::uint32 *);
waveOutput = NULL_PTR(MARTe::float32 *);
time = 0.0f;
}
JATriangleWaveGAM::~JATriangleWaveGAM() {
}
bool JATriangleWaveGAM::Initialise(MARTe::StructuredDataI & data) {
using namespace MARTe;
return GAM::Initialise(data);
}
bool JATriangleWaveGAM::Setup() {
using namespace MARTe;
bool ok = (numberOfInputSignals == 4u);
if (ok) {
ok = (numberOfOutputSignals == 1u);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "One output signal shall be defined.");
}
}
else {
REPORT_ERROR(ErrorManagement::ParametersError, "Four input signals shall be defined.");
}
uint32 freqIndex;
uint32 ampIndex;
uint32 offsetIndex;
uint32 plcStandbyIndex;
if (ok) {
StreamString signalName = "Frequency";
ok = GetSignalIndex(InputSignals, freqIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Frequency input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, freqIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Frequency shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Amplitude";
ok = GetSignalIndex(InputSignals, ampIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Amplitude input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, ampIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Amplitude shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "Offset";
ok = GetSignalIndex(InputSignals, offsetIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Offset input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, offsetIndex);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Offset shall be defined as float32.");
}
}
}
if (ok) {
StreamString signalName = "PLCSTANDBY";
ok = GetSignalIndex(InputSignals, plcStandbyIndex, signalName.Buffer());
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "PLCSTANDBY input signal shall be defined.");
}
else {
TypeDescriptor inputType = GetSignalType(InputSignals, plcStandbyIndex);
ok = (inputType == UnsignedInteger32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "PLCSTANDBY shall be defined as uint32.");
}
}
}
if (ok) {
TypeDescriptor inputType = GetSignalType(OutputSignals, 0);
ok = (inputType == Float32Bit);
if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Amplitude shall be defined as float32.");
}
}
if (ok) {
frequency = reinterpret_cast<float32 *>(GetInputSignalMemory(freqIndex));
amplitude = reinterpret_cast<float32 *>(GetInputSignalMemory(ampIndex));
offset = reinterpret_cast<float32 *>(GetInputSignalMemory(offsetIndex));
plcStandby = reinterpret_cast<uint32 *>(GetInputSignalMemory(plcStandbyIndex));
waveOutput = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
}
return ok;
}
bool JATriangleWaveGAM::Execute() {
using namespace MARTe;
// If frequency is not set, output 0.
if (*frequency <= 0.0f || *plcStandby == 0u) {
*waveOutput = 0.0f;
return true;
}
// Increase the current time.
++time;
// Calculate the period in milliseconds
float32 periodMs = 1000.0 / *frequency;
// Make sure the time is on [0, periodMs] interval.
while (time > periodMs) {
time -= periodMs;
}
// Formula:
// f(x) = |x - 0.5| * 2 * amplitude
// where x is between 0 and 1
*waveOutput = absFloat((time / periodMs) - 0.5f) * 2.0f * (*amplitude) + *offset;
return true;
}
CLASS_REGISTER(JATriangleWaveGAM, "1.0")

View File

@@ -0,0 +1,130 @@
/**
* @file JATriangleWaveGAM.h
* @brief Header file for class JATriangleWaveGAM
* @date Jan, 2019
* @author rhari
*
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
* the Development of Fusion Energy ('Fusion for Energy').
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence")
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
*
* @warning Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an "AS IS"
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence permissions and limitations under the Licence.
* @details This header file contains the declaration of the class JATriangleWaveGAM
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef GAMS_JATRIANGLEWAVEGAM_H_
#define GAMS_JATRIANGLEWAVEGAM_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "GAM.h"
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief GAM provides triangular waveform output within 1kHz thread.
*
* The configuration syntax is (names and signal quantity are only given as an example):
* <pre>
* +CCPSWaveformGAM = {
* Class = JATriangleWaveGAM
* InputSignals = {
* Offset = {
* Alias = OFFSET
* DataSource = EPICSCAInput
* Type = float32
* }
* Frequency = {
* Alias = CCPS_OUTPUT_FREQ
* DataSource = EPICSCAInput
* Type = float32
* }
* Amplitude = {
* Alias = CCPS_OUTPUT_AMP
* DataSource = EPICSCAInput
* Type = float32
* }
* PLCCCPSON = {
* Alias = PLC_CCPSON
* DataSource = EPICSCAInput
* Type = uint32
* }
* READY = {
* Alias = PLC_READY
* DataSource = EPICSCAInput
* Type = uint32
* }
* }
* OutputSignals = {
* CCPS_REF = {
* DataSource = DDB1
* Type = float32
* }
* }
* }
*
* </pre>
*
*/
class JATriangleWaveGAM : public MARTe::GAM {
public:
CLASS_REGISTER_DECLARATION()
JATriangleWaveGAM();
virtual ~JATriangleWaveGAM();
virtual bool Initialise(MARTe::StructuredDataI & data);
virtual bool Setup();
virtual bool Execute();
private:
// Input signal containing the frequency of the waveform.
MARTe::float32 *frequency;
// Input signal containing the amplitude of the waveform.
MARTe::float32 *amplitude;
// Input signal cantaining the offset of the waveform.
MARTe::float32 *offset;
// Input signal containing CCPS_ON_REQUEST
//MARTe::uint32 *plcccpson;
// Input signal condition CCPS_READY
//MARTe::uint32 *plcReady;
// Input signal condition CCPS_STANDBY
MARTe::uint32 *plcStandby;
MARTe::float32 *waveOutput;
MARTe::float32 time;
};
/*---------------------------------------------------------------------------*/
/* Inline method definitions */
/*---------------------------------------------------------------------------*/
#endif /* GAMS_JATRIANGLEWAVEGAM_H_ */

Some files were not shown because too many files have changed in this diff Show More