|
| 1 | +protocol TestEvents { |
| 2 | +}; |
| 3 | + |
| 4 | +capsule A { |
| 5 | + service behavior notify port p: TestEvents; |
| 6 | + statemachine { |
| 7 | + state Created { |
| 8 | + rtBound: on p.rtBound |
| 9 | + ` |
| 10 | + std::cout << "Bound port " << this->getName() << ".p[" << msg->sapIndex0() << "]\n"; |
| 11 | + `; |
| 12 | + }; |
| 13 | + initial -> Created |
| 14 | + ` |
| 15 | + std::cout << "Created " << this->getName() << ":A\n"; |
| 16 | + `; |
| 17 | + }; |
| 18 | + |
| 19 | +}; |
| 20 | + |
| 21 | +capsule Top { |
| 22 | + behavior notify port pb~ : TestEvents [4]; |
| 23 | + behavior port frame : Frame; |
| 24 | + |
| 25 | + part part1 : A; |
| 26 | + connect part1.p with pb; |
| 27 | + |
| 28 | + part part2 : A; |
| 29 | + connect part2.p with pb; |
| 30 | + |
| 31 | + optional part part3 : A [0..1]; |
| 32 | + connect part3.p with pb; |
| 33 | + |
| 34 | + optional part part4 : A [0..1]; |
| 35 | + connect part4.p with pb; |
| 36 | + |
| 37 | + statemachine { |
| 38 | + state S1, S2, S3, S4; |
| 39 | + state AllDone { |
| 40 | + entry `PASS();`; |
| 41 | + }; |
| 42 | + |
| 43 | + initial -> S1 |
| 44 | + ` |
| 45 | + std::cout << "Created " << this->getName() << ":Top\n"; |
| 46 | + `; |
| 47 | + |
| 48 | + t1: S1 -> S2 on pb.rtBound |
| 49 | + ` |
| 50 | + std::cout << "Bound port " << this->getName() << ".pb[" << msg->sapIndex0() << "]\n"; |
| 51 | + ASSERT(msg->sapIndex0() == 0, "Expect pb bound on index 0"); |
| 52 | + `; |
| 53 | + incarnate_part3: S2 -> S3 on pb.rtBound |
| 54 | + ` |
| 55 | + std::cout << "Bound port " << this->getName() << ".pb[" << msg->sapIndex0() << "]\n"; |
| 56 | + ASSERT(msg->sapIndex0() == 1, "Expect pb bound on index 1"); |
| 57 | + RTActorId id = frame.incarnate(part3); |
| 58 | + ASSERT(id.isValid(), "Incarnate in 'part3' failed"); |
| 59 | + `; |
| 60 | + incarnate_part4: S3 -> S4 on pb.rtBound |
| 61 | + ` |
| 62 | + std::cout << "Bound port " << this->getName() << ".pb[" << msg->sapIndex0() << "]\n"; |
| 63 | + ASSERT(msg->sapIndex0() == 2, "Expect pb bound on index 2"); |
| 64 | + RTActorId id = frame.incarnate(part4); |
| 65 | + ASSERT(id.isValid(), "Incarnate in 'part4' failed"); |
| 66 | + `; |
| 67 | + pass: S4 -> AllDone on pb.rtBound |
| 68 | + ` |
| 69 | + std::cout << "Bound port " << this->getName() << ".pb[" << msg->sapIndex0() << "]\n"; |
| 70 | + ASSERT(msg->sapIndex0() == 3, "Expect pb bound on index 3"); |
| 71 | + `; |
| 72 | + }; |
| 73 | +}; |
0 commit comments