File tree Expand file tree Collapse file tree
sysml/src/validation/03-Function-based Behavior Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package '3c-Function-based Behavior-structure mod-1' {
2+
3+ part def Vehicle;
4+ part def VehicleFrame;
5+
6+ part def HitchBall;
7+ part def TrailerCoupler;
8+
9+ part def Trailer;
10+ part def TrailerFrame;
11+
12+ connection def TrailerHitch {
13+ end hitch : HitchBall;
14+ end coupler : TrailerCoupler;
15+ }
16+
17+ part 'vehicle-trailer system' {
18+
19+ part vehicle : Vehicle {
20+ part vehicleFrame : VehicleFrame {
21+ part hitch : HitchBall;
22+ }
23+ }
24+
25+ connection trailerHitch : TrailerHitch[0..1]
26+ connect vehicle.vehicleFrame.hitch to trailer.trailerFrame.coupler;
27+
28+ part trailer : Trailer {
29+ part trailerFrame : TrailerFrame {
30+ part coupler : TrailerCoupler;
31+ }
32+ }
33+
34+ perform action {
35+ // Create a link and assign it as the TrailerHitch connection.
36+ // Link participants are determined from inherited ends.
37+ action 'connect trailer to vehicle'
38+ assign 'vehicle-trailer system'.trailerHitch := TrailerHitch();
39+
40+ // Remove the link from the TrailerHitch connection.
41+ // TODO: Destroy the link object.
42+ then action 'disconnect trailer from vehicle'
43+ assign 'vehicle-trailer system'.trailerHitch := null;
44+ }
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ package '3c-Function-based Behavior-structure mod-2' {
2+
3+ part def Vehicle;
4+ part def VehicleFrame;
5+
6+ part def HitchBall;
7+ part def TrailerCoupler;
8+
9+ part def Trailer;
10+ part def TrailerFrame;
11+
12+ connection def TrailerHitch {
13+ end hitch : HitchBall;
14+ end coupler : TrailerCoupler;
15+ }
16+
17+ part 'vehicle-trailer system' {
18+
19+ part vehicle : Vehicle {
20+ part vehicleFrame : VehicleFrame {
21+ part hitch : HitchBall;
22+ }
23+ }
24+
25+ connection trailerHitch : TrailerHitch[0..1]
26+ connect vehicle.vehicleFrame.hitch to trailer.trailerFrame.coupler;
27+
28+ part trailer : Trailer {
29+ part trailerFrame : TrailerFrame {
30+ part coupler : TrailerCoupler;
31+ }
32+ }
33+
34+ perform action {
35+ action 'connect trailer to vehicle' {
36+ // Assert that exactly one connection exists during the
37+ // performance of this action.
38+ abstract ref connection :>> trailerHitch[1];
39+ }
40+ then action 'disconnect trailer from vehicle' {
41+ // Assert that exactly no connection exists during the
42+ // performance of this action.
43+ abstract ref connection :>> trailerHitch[0];
44+ }
45+ }
46+
47+ }
48+
49+ }
Original file line number Diff line number Diff line change 1+ package '3c-Function-based Behavior-structure mod-3' {
2+
3+ part def Vehicle;
4+ part def VehicleFrame;
5+ part def HitchBall;
6+ part def Trailer;
7+ part def TrailerFrame;
8+ part def TrailerCoupler;
9+
10+ part vehicle : Vehicle {
11+ part vehicleFrame : VehicleFrame {
12+ part hitch : HitchBall;
13+ }
14+ }
15+
16+ part trailer : Trailer {
17+ part trailerFrame : TrailerFrame {
18+ part coupler : TrailerCoupler {
19+ ref part hitch : HitchBall;
20+ }
21+ }
22+ }
23+
24+ action {
25+ // Insert the vehicle HitchBall into the TrailerCoupler.
26+ action 'connect trailer to vehicle'
27+ assign trailer.trailerFrame.coupler.hitch := vehicle.vehicleFrame.hitch;
28+
29+ // Remove the HitchBall from the TrailerCoupler.
30+ then action 'disconnect trailer from vehicle'
31+ assign trailer.trailerFrame.coupler.hitch := null;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments