Skip to content

Commit

Permalink
Merge pull request #198 from lf-lang/ts-cyclic-dependencies
Browse files Browse the repository at this point in the history
Handle cyclic dependencies by applying the `MLAA` based execution and `TPO level`
  • Loading branch information
byeonggiljun authored Aug 16, 2023
2 parents ed95e68 + b3c9595 commit bb9b0ea
Show file tree
Hide file tree
Showing 8 changed files with 517 additions and 141 deletions.
2 changes: 1 addition & 1 deletion __tests__/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("Intended tag tests", function () {
const app = new ReactorWithFederatePortAction();
expect(() => {
app._start();
}).toThrowError("FederatedPortAction must have an intended tag from RTI.");
}).toThrowError("No intended tag given while attempting to schedule an event coming from another federate.");
});

it("Intended tag smaller than current tag", function () {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ describe("add time value", function () {
expect(
new Tag(oneThousandMS, 0)
.getLaterTag(straightZero)
.isSimultaneousWith(new Tag(oneThousandMS, 0))
.isSimultaneousWith(new Tag(oneThousandMS, 1))
).toBeTruthy();
expect(
new Tag(oneThousandMS, 1)
.getLaterTag(straightZero)
.isSimultaneousWith(new Tag(oneThousandMS, 1))
.isSimultaneousWith(new Tag(oneThousandMS, 2))
).toBeTruthy();
});

Expand Down
2 changes: 1 addition & 1 deletion lingua-franca-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
master
ts-cyclic-dependencies
17 changes: 3 additions & 14 deletions src/core/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,11 @@ export class Action<T> extends ScheduledTrigger<T> implements Read<T> {
tag = tag.getLaterTag(delay);

if (this.action.origin === Origin.physical) {
// If the resulting timestamp from delay is less than the current physical time
// on the platform, then the timestamp becomes the current physical time.
// Otherwise the tag is computed like a logical action's tag.

const physicalTime = getCurrentPhysicalTime();
if (tag.time.isEarlierThan(physicalTime)) {
tag = new Tag(getCurrentPhysicalTime(), 0);
} else {
tag = tag.getMicroStepsLater(1);
}
tag = new Tag(getCurrentPhysicalTime(), 0).getLaterTag(delay);
} else if (this.action instanceof FederatePortAction) {
if (intendedTag === undefined) {
throw new Error(
"FederatedPortAction must have an intended tag from RTI."
"No intended tag given while attempting to schedule an event coming from another federate."
);
}
if (
Expand Down Expand Up @@ -132,8 +123,6 @@ export class Action<T> extends ScheduledTrigger<T> implements Read<T> {
)}`
);
tag = intendedTag;
} else if (delay.isEqualTo(TimeValue.zero())) {
tag = tag.getMicroStepsLater(1);
}

Log.debug(
Expand Down Expand Up @@ -198,7 +187,7 @@ export class FederatePortAction<T> extends Action<T> {
constructor(
__parent__: Reactor,
origin: Origin,
minDelay: TimeValue = TimeValue.secs(0)
minDelay: TimeValue = TimeValue.zero()
) {
super(__parent__, origin, minDelay);
}
Expand Down
Loading

0 comments on commit bb9b0ea

Please sign in to comment.