Skip to content

Commit 2114f90

Browse files
Merge branch 'main' of github01.hclpnp.com:Modeling/rtistic-pub-doc
2 parents edeb2cf + 54be38f commit 2114f90

4 files changed

Lines changed: 83 additions & 0 deletions

File tree

art-comp-test/art-comp-test.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
{
156156
"path": "tests/protocol_inheritance_redefined_event"
157157
},
158+
{
159+
"path": "tests/protocol_signals_array_sorted"
160+
},
158161
{
159162
"path": "tests/receive_any"
160163
},
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
protocol AlphaSorted {
2+
3+
in zTestSymmetric();
4+
in zTestSymmetric2();
5+
in rTest();
6+
in ktest();
7+
in mTest();
8+
in aCap();
9+
in bCap();
10+
in aTest();
11+
12+
13+
out zTest();
14+
out zTestSymmetric();
15+
out zTestSymmetric2();
16+
out rTest();
17+
out ktest();
18+
out mTest();
19+
out aCap();
20+
out bCap();
21+
out aTest();
22+
23+
};
24+
capsule Top{
25+
26+
27+
[[rt::header_preface]]
28+
`
29+
#include "testlib.art.h"
30+
#include "AlphaSorted.h"
31+
32+
`
33+
behavior port alphaAlphaSortedConj~ : AlphaSorted;
34+
behavior port alphaAlphaSorted : AlphaSorted;
35+
36+
connect alphaAlphaSortedConj with alphaAlphaSorted;
37+
38+
statemachine {
39+
state State1;
40+
initial -> State1
41+
`
42+
const RTProtocolDescriptor& pdConj = alphaAlphaSortedConj.rt_class;
43+
int i = pdConj.inSignalNamed("zTestSymmetric");
44+
ASSERT(i == 4, "Event zTestSymmetric was not found at the expected index 4");
45+
i = pdConj.outSignalNamed("zTestSymmetric");
46+
ASSERT(i == 3, "Event zTestSymmetric was not found at the expected index 3");
47+
48+
i = pdConj.inSignalNamed("zTest");
49+
ASSERT(i == 3, "Event zTest was not found at the expected index 3");
50+
i = pdConj.outSignalNamed("aTest");
51+
ASSERT(i == 10, "Event aTest was not found at the expected index 10");
52+
53+
const RTProtocolDescriptor& pd = alphaAlphaSorted.rt_class;
54+
i = pd.inSignalNamed("zTestSymmetric");
55+
ASSERT(i == 3, "Event zTestSymmetric was not found at the expected index 3");
56+
i = pd.outSignalNamed("zTestSymmetric");
57+
ASSERT(i == 4, "Event zTestSymmetric was not found at the expected index 4");
58+
59+
i = pd.inSignalNamed("aTest");
60+
ASSERT(i == 10, "Event aTest was not found at the expected index 10");
61+
i = pd.outSignalNamed("zTest");
62+
ASSERT(i == 3, "Event zTest was not found at the expected index 3");
63+
PASS();
64+
65+
`;
66+
};
67+
68+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
group: cpp_code_generation
3+
---
4+
This test ensures that protocol events are sorted alphabetically in the rt_signals array in the generated code. It shows how the TargetRTS functions RTProtocolDescriptor::inSignalNamed() and RTProtocolDescriptor::outSignalNamed() can be used for looking up the index of in-events and out-events in this array.
5+
6+
7+
8+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let tc = TCF.define(TCF.CPP_TRANSFORM);
2+
tc.topCapsule = 'Top';
3+
tc.prerequisites = ["../../TestUtils/testlib.tcjs"];
4+
tc.targetFolder = 'protocol_signals_array_sorted_target';

0 commit comments

Comments
 (0)