Skip to content

Commit bb9b0ea

Browse files
authored
Merge pull request #198 from lf-lang/ts-cyclic-dependencies
Handle cyclic dependencies by applying the `MLAA` based execution and `TPO level`
2 parents ed95e68 + b3c9595 commit bb9b0ea

File tree

8 files changed

+517
-141
lines changed

8 files changed

+517
-141
lines changed

__tests__/action.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("Intended tag tests", function () {
5151
const app = new ReactorWithFederatePortAction();
5252
expect(() => {
5353
app._start();
54-
}).toThrowError("FederatedPortAction must have an intended tag from RTI.");
54+
}).toThrowError("No intended tag given while attempting to schedule an event coming from another federate.");
5555
});
5656

5757
it("Intended tag smaller than current tag", function () {

__tests__/time.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ describe("add time value", function () {
310310
expect(
311311
new Tag(oneThousandMS, 0)
312312
.getLaterTag(straightZero)
313-
.isSimultaneousWith(new Tag(oneThousandMS, 0))
313+
.isSimultaneousWith(new Tag(oneThousandMS, 1))
314314
).toBeTruthy();
315315
expect(
316316
new Tag(oneThousandMS, 1)
317317
.getLaterTag(straightZero)
318-
.isSimultaneousWith(new Tag(oneThousandMS, 1))
318+
.isSimultaneousWith(new Tag(oneThousandMS, 2))
319319
).toBeTruthy();
320320
});
321321

lingua-franca-ref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
master
1+
ts-cyclic-dependencies

src/core/action.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,11 @@ export class Action<T> extends ScheduledTrigger<T> implements Read<T> {
7979
tag = tag.getLaterTag(delay);
8080

8181
if (this.action.origin === Origin.physical) {
82-
// If the resulting timestamp from delay is less than the current physical time
83-
// on the platform, then the timestamp becomes the current physical time.
84-
// Otherwise the tag is computed like a logical action's tag.
85-
86-
const physicalTime = getCurrentPhysicalTime();
87-
if (tag.time.isEarlierThan(physicalTime)) {
88-
tag = new Tag(getCurrentPhysicalTime(), 0);
89-
} else {
90-
tag = tag.getMicroStepsLater(1);
91-
}
82+
tag = new Tag(getCurrentPhysicalTime(), 0).getLaterTag(delay);
9283
} else if (this.action instanceof FederatePortAction) {
9384
if (intendedTag === undefined) {
9485
throw new Error(
95-
"FederatedPortAction must have an intended tag from RTI."
86+
"No intended tag given while attempting to schedule an event coming from another federate."
9687
);
9788
}
9889
if (
@@ -132,8 +123,6 @@ export class Action<T> extends ScheduledTrigger<T> implements Read<T> {
132123
)}`
133124
);
134125
tag = intendedTag;
135-
} else if (delay.isEqualTo(TimeValue.zero())) {
136-
tag = tag.getMicroStepsLater(1);
137126
}
138127

139128
Log.debug(
@@ -198,7 +187,7 @@ export class FederatePortAction<T> extends Action<T> {
198187
constructor(
199188
__parent__: Reactor,
200189
origin: Origin,
201-
minDelay: TimeValue = TimeValue.secs(0)
190+
minDelay: TimeValue = TimeValue.zero()
202191
) {
203192
super(__parent__, origin, minDelay);
204193
}

0 commit comments

Comments
 (0)