-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for connecting multiports in TypeScript runtime. #81
Merged
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
9f67ec3
Add _connectMultiplePorts to support connection between multi ports.
hokeun d10b503
Extend Variable to Array of Read<unknown> to support Array as a multi…
hokeun 9d223df
Refactoring of connect function to treat regular IO ports and caller/…
lhstrh 0e018a3
WIP toward Banks as containers
lhstrh ebd9611
Add Bank class implementation.
hokeun ba7a2d9
Add preliminary implementation of MultiPort class.
hokeun 01574c0
Add InMultiPort and OutMultiPort.
hokeun 9de0be3
Fix MultiPort generic.
hokeun 5ac91bf
Remove Container Type and make Bank inherit Reactor.
hokeun 45fce1b
Add helper functions to be used by generated code in MultiPort class.
hokeun f53a5a8
Added Bank with type-safe higher-order instantiation
lhstrh 102ac73
Add support for handling of the special bank_index parameter of the r…
hokeun 3cb1021
Update lingua franca version.
hokeun ad9338c
Simplified implementation of banks with access to bank index
lhstrh fc44748
Remove bogus test code
lhstrh 13c3f64
Merge branch 'simpler-banks' of github.com:lf-lang/reactor-ts into ts…
hokeun 5d2d00f
Update lingua franca version.
hokeun 6d2659c
Implement repeatLeft for ()+ -> syntax, e.g., (source.out)+ -> sink.i…
hokeun 6d1b299
Update lingua franca version.
hokeun 981fd12
Propose syntax for generic banks
lhstrh 996d31d
Merge branch 'simpler-banks' of github.com:lf-lang/reactor-ts into ts…
hokeun 3954e8f
Update lingua franca version.
hokeun d446e9e
Added `select` function to collect ports from bank. Not sure it has t…
lhstrh 7c2a065
Renamed `select` to `port` and removed unnecessary spread
lhstrh ffe855f
Started refactoring
lhstrh 9f16fd5
Breaking more things while fixing others
lhstrh b368361
Fix import and export errors.
hokeun c6b4757
Add _uncheckedConnect and tests for connections.
hokeun f70086b
Add canConnect check for _connectMulti.
hokeun b980f0d
Interim commit before pulling
lhstrh a92a67c
Refactoring
lhstrh c4b5748
Add missing files
lhstrh 87cd681
Fix type error in federation.ts.
hokeun b164f42
Quickfix to allow test to run
lhstrh f535ce0
Further use of "internal" pattern
lhstrh 4aefa8e
Fix type error in federation.ts.
hokeun 9fa6c31
Merge branch 'cyclic-deps' of github.com:lf-lang/reactor-ts into cycl…
hokeun c075ac7
add missing file
lhstrh a20a7ba
All tests except one passing again
lhstrh aa10a90
Fixed bug
lhstrh 1daf706
Multiport test now passes but using regular _connect
lhstrh 6883e98
Test now passes with _connectMulti
lhstrh ca7d7dc
Also fixed remaining failing test
lhstrh c1da6dc
Some simplifications and cleanups
lhstrh 8ca16dc
Improve code coverage
lhstrh 9b9cdea
Lookup names for channels of multiports. Added test.
lhstrh 3954bac
Also check fully qualified name
lhstrh 462fe3e
Added missing file
lhstrh 0bac1d3
Merge pull request #84 from lf-lang/cyclic-deps
hokeun 5dd7175
Remove federation from internal's exports as there's no other .ts fil…
hokeun fb761bb
Removed aliases. Revised naming scheme.
lhstrh 6c1ce2a
Improved code coverage ot multiport.ts to 90%
lhstrh 226ee69
Add width() interface to MultiWrite so that we can get width for Mult…
hokeun fbc49bc
Add values() interface to MultiWrite so that we can get width for Mul…
hokeun 103ef87
Update lingua franca version.
hokeun e7d1dff
Simplification of dealings with (multiport) triggers.
lhstrh 7779b12
Fixed unit tests
lhstrh 54145d3
Clean up code and add missing comments.
hokeun 681283f
Improving code coverage of multiports
lhstrh 980074a
Update lingua-franca version.
hokeun 54249f5
Added comments
lhstrh 4b4e51c
Added type annotation
lhstrh 6d0028c
Adjust LF pointer
lhstrh 1fb6e3e
Update lingua franca version.
hokeun 0341e3d
Fix for the bank-index-not-available-in-constructor-problem
lhstrh 4c49de8
Fix for the bank index problem that actually works
lhstrh f0b6c23
Adjusted test but still stuck with index not being readable
lhstrh 24e82b5
Added test and fixed getFullyQualifiedName for bank members. Still di…
lhstrh 0c75655
Fix for the bank index issue
lhstrh b2c7dd6
Update LF version.
hokeun 70f472a
Adding missing dependencies for multiports
lhstrh 2139355
Fixed problems with wrong/missing dependencies
lhstrh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Bank , Reactor, App, Timer, Triggers, Args, Present, OutPort, InPort, TimeValue } from "../src/core/internal"; | ||
|
||
class Periodic extends Reactor { | ||
|
||
t: Timer = new Timer(this, 0, TimeValue.sec(1)); | ||
o: OutPort<number> = new OutPort(this) | ||
constructor(parent: Reactor) { | ||
super(parent) | ||
this.addReaction( | ||
new Triggers(this.t), | ||
new Args(this.t), | ||
function (this) { | ||
console.log(this.getBankIndex()); | ||
} | ||
); | ||
} | ||
} | ||
|
||
class Generic<T extends Present> extends Reactor { | ||
input: InPort<T> = new InPort(this); | ||
} | ||
|
||
describe('Check bank index', () => { | ||
|
||
class myApp extends App { | ||
b = new Bank(this, 3, Periodic, this) | ||
c = new Bank<Generic<number>, [Reactor]>(this, 2, Generic, this); | ||
constructor() { | ||
super(); | ||
test('contained bank member name', () => { | ||
expect(this.b.get(0)._getFullyQualifiedName()).toBe("myApp.b[0]") | ||
expect(this.b.get(1)._getFullyQualifiedName()).toBe("myApp.b[1]") | ||
expect(this.b.get(2)._getFullyQualifiedName()).toBe("myApp.b[2]") | ||
}) | ||
it('contained bank member index', () => { | ||
expect(this.b.get(0).getBankIndex()).toBe(0); | ||
expect(this.b.get(1).getBankIndex()).toBe(1); | ||
expect(this.b.get(2).getBankIndex()).toBe(2); | ||
}); | ||
|
||
it('generic bank', () => { | ||
this.c.all().forEach(r => expect(typeof r.input == "number")) | ||
}); | ||
var foo = this.b.port((member) => member.o) | ||
var bar = [this.b.get(0).o, this.b.get(1).o, this.b.get(2).o] | ||
it('select port', () => { | ||
for (let i=0; i < foo.length; i++) { | ||
expect(foo[i]).toBe(bar[i]); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
new myApp(); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Reactor, App, Triggers, Args, State, OutPort, InPort, TimeUnit, TimeValue } from '../src/core/internal'; | ||
|
||
describe('Check canConnect', () => { | ||
class Source extends Reactor { | ||
out: OutPort<number> = new OutPort(this) | ||
} | ||
class Destination extends Reactor { | ||
in: InPort<number> = new InPort(this) | ||
out: InPort<number> = new InPort(this) | ||
} | ||
|
||
class TestApp extends App { | ||
source: Source | ||
destination: Destination | ||
|
||
constructor() { | ||
super() | ||
this.source = new Source(this) | ||
this.destination = new Destination(this) | ||
|
||
it('canConnect success out->in', () => { | ||
expect(this.canConnect(this.source.out, this.destination.in)).toBe(true) | ||
}) | ||
|
||
it('canConnect success out->out', () => { | ||
expect(this.canConnect(this.source.out, this.destination.out)).toBe(true) | ||
}) | ||
|
||
it('canConnect failure', () => { | ||
expect(this.canConnect(this.destination.in, this.source.out)).toBe(false) | ||
}) | ||
} | ||
} | ||
var testApp = new TestApp() | ||
}) | ||
|
||
describe('Check _connect', () => { | ||
jest.setTimeout(5000); | ||
|
||
class Source extends Reactor { | ||
out: OutPort<number> = new OutPort(this) | ||
constructor(container: Reactor) { | ||
super(container); | ||
this.addReaction( | ||
new Triggers(this.startup), | ||
new Args(this.writable(this.out)), | ||
function(this, __out) { | ||
__out.set(100); | ||
|
||
} | ||
); | ||
} | ||
} | ||
class Destination extends Reactor { | ||
in: InPort<number> = new InPort(this) | ||
received: State<number> = new State(0) | ||
constructor(container: Reactor) { | ||
super(container) | ||
this.addReaction( | ||
new Triggers(this.in), | ||
new Args(this.in, this.received), | ||
function(this, __in, __received) { | ||
let tmp = __in.get(); | ||
try | ||
{ | ||
if(tmp) | ||
{ | ||
__received.set(tmp) | ||
} | ||
} finally { | ||
|
||
} | ||
} | ||
) | ||
} | ||
} | ||
|
||
class TestApp extends App { | ||
source: Source | ||
destination: Destination | ||
|
||
constructor(timeout: TimeValue, success?: () => void, fail?: () => void) { | ||
super(timeout, false, false, success, fail) | ||
this.source = new Source(this) | ||
this.destination = new Destination(this) | ||
this._connect(this.source.out, this.destination.in) | ||
} | ||
} | ||
|
||
it("_connect success", done => { | ||
function fail() { | ||
throw new Error("Test has failed."); | ||
}; | ||
|
||
let testApp = new TestApp(TimeValue.withUnits(1,TimeUnit.nsec), done, fail) | ||
testApp._start() | ||
expect(testApp.destination.received.get()).toBe(100) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests should probably not use the internal exports but the external ones, which we yet have to set up.