-
Notifications
You must be signed in to change notification settings - Fork 13
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
Implement draft #13
base: main
Are you sure you want to change the base?
Implement draft #13
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||||
target Python { | ||||||||
timeout: 5 sec | ||||||||
} | ||||||||
|
||||||||
reactor Counter(stride(1), period(1 sec)) { | ||||||||
state count(0); | ||||||||
// timer triggers reaction | ||||||||
timer t(0, period); | ||||||||
output out; | ||||||||
reaction(t) -> out {= | ||||||||
out.set(self.count) | ||||||||
self.count += self.stride | ||||||||
=} | ||||||||
} | ||||||||
|
||||||||
reactor Adder(bank_value(1)) { | ||||||||
input _in; | ||||||||
output out; | ||||||||
reaction(_in) -> out {= | ||||||||
out.set(_in.value + self.bank_value) | ||||||||
=} | ||||||||
} | ||||||||
|
||||||||
reactor Printer(N(4)) { | ||||||||
input[N] _in; | ||||||||
reaction(_in) {= | ||||||||
for i in range(self.N): | ||||||||
print(f"Result {_in[i].value}") | ||||||||
=} | ||||||||
} | ||||||||
|
||||||||
main reactor(stride(10), period(1 sec), N(4)) { | ||||||||
c = new Counter(stride=stride, period=period); | ||||||||
a = new[4] Adder(); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this meant to be
|
||||||||
p = new Printer(N=N); | ||||||||
(c.out)+ -> a._in; | ||||||||
a.out -> p._in; | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||
target Python { | ||||||||
timeout: 3 sec | ||||||||
} | ||||||||
|
||||||||
reactor Counter(stride(1)) { | ||||||||
state count(0) | ||||||||
timer t(0, 1 sec) | ||||||||
output out | ||||||||
reaction(t) -> out {= | ||||||||
out.set(self.count) | ||||||||
self.count += self.stride | ||||||||
=} | ||||||||
} | ||||||||
|
||||||||
reactor Printer { | ||||||||
input _in | ||||||||
reaction(_in) {= | ||||||||
# using thread-safe print function provided by the runtime | ||||||||
print(f"Hello World! {_in.value}.") | ||||||||
=} | ||||||||
} | ||||||||
|
||||||||
main reactor { | ||||||||
c = new Counter(stride = 1) | ||||||||
p = new Printer() | ||||||||
c.out -> p._in | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||
''' | ||||||
This is a shared itemlist for multiple people | ||||||
to appendItem or deltetItem at the same time | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Simulate when multiple clients append or delete items from the | ||||||
same sharedItem list. | ||||||
''' | ||||||
target Python | ||||||
|
||||||
reactor ItemList { | ||||||
state itemList; | ||||||
timer t(0, 1 sec); | ||||||
output out; | ||||||
reaction(t) -> out {= | ||||||
out.set(self.itemList) | ||||||
=} | ||||||
} | ||||||
|
||||||
reactor AddItem { | ||||||
// a int type | ||||||
input index; | ||||||
|
||||||
// a string type | ||||||
input value; | ||||||
|
||||||
// a list data structure in Python | ||||||
input itemList; | ||||||
|
||||||
output out; | ||||||
reaction(index, value, itemList) -> out {= | ||||||
out.set(itemList.insert(index, value)) | ||||||
=} | ||||||
} | ||||||
|
||||||
reactor DeleteItem { | ||||||
|
||||||
} | ||||||
|
||||||
|
||||||
# Print current items on the SharedList | ||||||
reactor Printer { | ||||||
input _in; | ||||||
reaction(_in) {= | ||||||
for item in _in.itemList: | ||||||
print(item) | ||||||
=} | ||||||
} | ||||||
|
||||||
main reactor { | ||||||
l = new ItemList(); | ||||||
p = new Printer(); | ||||||
l.out -> p._in | ||||||
} | ||||||
|
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.
Is this meant to be
bank_index
rather thanbank_value
?