forked from spiraltechnica/Spout-for-Python
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest_mult.py
executable file
·38 lines (31 loc) · 942 Bytes
/
test_mult.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# load library
from Library.Spout import Spout
import random
def main() :
# create spout object
spout = Spout(silent = True, n_rec = 3, n_send = 3)
# create receiver
spout.createReceiver('input1', id = 0)
spout.createReceiver('input2', id = 1)
spout.createReceiver('input3', id = 2)
# create sender
spout.createSender('output1', id = 0)
spout.createSender('output2', id = 1)
spout.createSender('output3', id = 2)
while True :
# check on close window
spout.check()
# receive data
data = spout.receive(id = 0)
data1 = spout.receive(id = 1)
data2 = spout.receive(id = 2)
# send data
if random.random() > .9:
spout.send(data1)
spout.send(data, 1)
else:
spout.send(data)
spout.send(data1, 1)
spout.send(data2, id = 2)
if __name__ == "__main__":
main()