Skip to content

Commit 517c388

Browse files
Merge branch 'main' of github01.hclpnp.com:Modeling/rtistic-pub-doc
2 parents 19e0ed8 + b044083 commit 517c388

File tree

20 files changed

+2052
-5
lines changed

20 files changed

+2052
-5
lines changed

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/part_inheritance"
157157
},
158+
{
159+
"path": "tests/passive_class_sm_entry_exit"
160+
},
158161
{
159162
"path": "tests/passive_class_sm_shallow_history"
160163
},

art-comp-test/connectors.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
{
99
"path": "tests/delegation_connector_02"
1010
},
11+
{
12+
"path": "tests/delegation_connector_03"
13+
},
1114
{
1215
"path": "tests/delegation_connector_nested"
1316
},
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
protocol Proto {
2+
in init();
3+
out init_done();
4+
};
5+
6+
protocol HEvents {
7+
in init();
8+
out init_done();
9+
in h();
10+
out h_done();
11+
};
12+
13+
protocol SEvents {
14+
in init();
15+
out init_done();
16+
in s();
17+
out s_done();
18+
};
19+
20+
capsule S {
21+
service behavior port p_s : SEvents;
22+
service behavior port r_s~ : SEvents;
23+
statemachine {
24+
state State, Initialized;
25+
initial -> State;
26+
State -> Initialized on p_s.init
27+
`
28+
r_s.init().send();
29+
`;
30+
};
31+
};
32+
33+
capsule H {
34+
part x : S;
35+
part y : S;
36+
37+
service port r_xs~ : SEvents, r_ys~ : SEvents;
38+
connect x.r_s with r_xs; // delegation connector
39+
connect y.r_s with r_ys; // delegation connector
40+
41+
behavior port xs~ : SEvents, ys~ : SEvents;
42+
connect xs with x.p_s;
43+
connect ys with y.p_s;
44+
45+
service behavior port p_h : HEvents;
46+
service behavior port r_h~ : HEvents;
47+
48+
statemachine {
49+
state State, Initialized;
50+
initial -> State;
51+
State -> Initialized on p_h.init
52+
`
53+
xs.init().send();
54+
ys.init().send();
55+
r_h.init().send();
56+
`;
57+
};
58+
};
59+
60+
capsule Main {
61+
part h : H;
62+
63+
service port r_h~ : HEvents, r_xs~ : SEvents, r_ys~ : SEvents;
64+
connect h.r_h with r_h; // delegation connector
65+
connect h.r_xs with r_xs; // delegation connector
66+
connect h.r_ys with r_ys; // delegation connector
67+
68+
behavior port p_h~ : HEvents;
69+
connect p_h with h.p_h;
70+
71+
service behavior port p_main : Proto;
72+
service behavior port r_main~ : Proto;
73+
74+
statemachine {
75+
state State, Initialized;
76+
initial -> State;
77+
State -> Initialized on p_main.init
78+
`
79+
p_h.init().send();
80+
r_main.init().send();
81+
`;
82+
};
83+
};
84+
85+
capsule Tester {
86+
[[rt::decl]]
87+
`
88+
bool xi = false, yi = false, hi = false, mi = false;
89+
`
90+
service behavior port p~ : Proto;
91+
service behavior port r : Proto;
92+
service behavior port h : HEvents, xs : SEvents, ys : SEvents;
93+
behavior port timer : Timing;
94+
statemachine {
95+
state Initialized;
96+
initial -> State `
97+
p.init().send();
98+
timer.informEvery(RTTimespec(0, 100));
99+
`;
100+
state State {
101+
on xs.init `xi = true;`;
102+
on ys.init `yi = true;`;
103+
on h.init `hi = true;`;
104+
on r.init `mi = true;`;
105+
};
106+
State -> Initialized on timer.timeout when `xi && yi && hi && mi`
107+
`
108+
PASS();
109+
`;
110+
};
111+
};
112+
113+
capsule Top [[rt::properties(color="#100f0f")]] {
114+
part tester : Tester;
115+
part main : Main;
116+
117+
connect tester.p with main.p_main;
118+
connect tester.r with main.r_main;
119+
connect tester.h with main.r_h;
120+
connect tester.xs with main.r_xs;
121+
connect tester.ys with main.r_ys;
122+
123+
statemachine {
124+
state State;
125+
initial -> State;
126+
};
127+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
group: cpp_code_generation
3+
---
4+
Model contains complex structure of ports and connectors. Delegation connectors are used for sending reflection events from various components to top tester.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let tc = TCF.define(TCF.ART_TO_CPP);
2+
tc.topCapsule = 'Top';
3+
tc.prerequisites = ["../../TestUtils/testlib.tcjs"];
4+
tc.targetFolder = 'delegation_connector_03_target';
5+
tc.commonPreface = `
6+
#include "testlib.art.h"
7+
#include <stdio.h>
8+
`;
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
2+
class MyClass {
3+
[[rt::header_preface]]
4+
`
5+
#include <iostream>
6+
#include <string>
7+
`
8+
[[rt::decl]]
9+
`
10+
public:
11+
MyClass();
12+
public:
13+
std::string entryStack = "";
14+
bool route_to_s4 = false;
15+
`
16+
[[rt::impl]]
17+
`
18+
MyClass::MyClass() {
19+
rtg_init1();
20+
}
21+
`
22+
/* Trigger Operations */
23+
trigger op();
24+
/* State Machine */
25+
statemachine {
26+
state State1 {
27+
entry
28+
`
29+
entryStack += " entry#State1";
30+
`;
31+
exit
32+
`
33+
entryStack += " exit#State1 ";
34+
`;
35+
}, State3 {
36+
entry
37+
`
38+
entryStack += " entry#State3 ";
39+
`;
40+
exit
41+
`
42+
entryStack += " exit#State3 ";
43+
`;
44+
}, State2 {
45+
entry
46+
`
47+
entryStack += " entry#State2 ";
48+
`;
49+
exit
50+
`
51+
entryStack += " exit#State2 ";
52+
`;
53+
entrypoint ep;
54+
_state_s1_on_true: ep -> S1.ep when
55+
`route_to_s4`
56+
`
57+
entryStack += "-->state_s1_on_true-->";
58+
`;
59+
_state_s1_on_false: ep -> S1.ep2 when
60+
`!route_to_s4`
61+
`
62+
entryStack += "-->state_s1_on_false-->";
63+
`;
64+
state S1 {
65+
entry
66+
`
67+
entryStack += " entry#S1 ";
68+
69+
`;
70+
exit
71+
`
72+
entryStack += " exit#S1 ";
73+
`;
74+
entrypoint ep, ep2;
75+
_s1_s2_on_true: ep -> S2.ep when
76+
`route_to_s4`
77+
`
78+
entryStack += "-->s1_s2_on_true-->";
79+
`;
80+
_s1_s2_on_false: ep2 -> S2.ep2 when
81+
`!route_to_s4`
82+
`
83+
entryStack += "-->s1_s2_on_false-->";
84+
`;
85+
state S2 {
86+
entrypoint ep, ep2;
87+
entry
88+
`
89+
entryStack += " entry#S2 ";
90+
91+
`;
92+
exit
93+
`
94+
entryStack += " exit#S2 ";
95+
`;
96+
_s2_s4_on_true: ep -> S4 when
97+
`route_to_s4`
98+
`
99+
entryStack += "-->s2_s4_on_true-->";
100+
`;
101+
_s2_s3_on_false: ep2 -> S3 when
102+
`!route_to_s4`
103+
`
104+
entryStack += "-->s2_s3_on_false-->";
105+
`;
106+
state S3 {
107+
entry
108+
`
109+
entryStack += " entry#S3";
110+
`;
111+
exit
112+
`
113+
entryStack += " exit#S3 ";
114+
`;
115+
};
116+
state S4 {
117+
entry
118+
`
119+
entryStack += " entry#S4";
120+
`;
121+
exit
122+
`
123+
entryStack += " exit#S4 ";
124+
`;
125+
};
126+
};
127+
};
128+
};
129+
_init_State: initial -> State1
130+
`
131+
entryStack += "init_State1-->";
132+
`;
133+
_State_State2: State1 -> State2.ep on op()
134+
`
135+
entryStack += "State1_State2-->";
136+
`;
137+
_State2_State3: State2 -> State3 on op()
138+
`
139+
entryStack += "-->State2_State3-->";
140+
`;
141+
_State3_State2: State3 -> State1 on op()
142+
`
143+
entryStack += "-->State3_State1-->";
144+
`;
145+
};
146+
};
147+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
capsule Top {
3+
[[rt::header_preface]]
4+
`
5+
#include "testlib.art.h"
6+
#include "MyClass.h"
7+
#include <iostream>
8+
`
9+
[[rt::decl]]
10+
`
11+
private:
12+
MyClass _myClass;
13+
`
14+
behavior port t : Timing;
15+
statemachine {
16+
state State2;
17+
initial -> State2
18+
`
19+
20+
ASSERT(_myClass.entryStack == "init_State1--> entry#State1", "Expected to call init_State");
21+
22+
_myClass.entryStack = "";
23+
24+
_myClass.op();
25+
ASSERT(_myClass.entryStack == " exit#State1 State1_State2--> entry#State2 -->state_s1_on_false--> entry#S1 -->s1_s2_on_false--> entry#S2 -->s2_s3_on_false--> entry#S3", "Stack not called as expected");
26+
_myClass.entryStack = "";
27+
28+
29+
_myClass.op();
30+
ASSERT(_myClass.entryStack == " exit#S3 exit#S2 exit#S1 exit#State2 -->State2_State3--> entry#State3 ", "Stack not called as expected");
31+
_myClass.entryStack = "";
32+
33+
_myClass.op();
34+
ASSERT(_myClass.entryStack == " exit#State3 -->State3_State1--> entry#State1", "Stack not called as expected");
35+
_myClass.entryStack = "";
36+
37+
_myClass.route_to_s4 = true;
38+
_myClass.op();
39+
ASSERT(_myClass.entryStack == " exit#State1 State1_State2--> entry#State2 -->state_s1_on_true--> entry#S1 -->s1_s2_on_true--> entry#S2 -->s2_s4_on_true--> entry#S4", "Stack not called as expected");
40+
41+
PASS();
42+
`;
43+
};
44+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
group: cpp_code_generation
3+
---
4+
This test case verifies that the passive state machine triggerOp handles transitions correctly when they occur between two entry points. It ensures the following:
5+
6+
State entry actions are called in the correct order.
7+
Effect code executes properly when the transition occurs between multiple entry points.
8+
Exit actions are called in the correct order.
9+
10+
In the above example, _State_State1 is split into two transitions based on conditions. This test case verifies that the effect code for the transition _State_State1 is executed in both cases.
11+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const tc = TCF.define(TCF.ART_TO_CPP);
2+
tc.topCapsule = 'Top';
3+
tc.prerequisites = ["../../TestUtils/testlib.tcjs"];
4+
tc.targetFolder = 'passive_class_sm_entry_exit_target';

0 commit comments

Comments
 (0)