-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestpattern.py
More file actions
executable file
·117 lines (95 loc) · 2.35 KB
/
testpattern.py
File metadata and controls
executable file
·117 lines (95 loc) · 2.35 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
import time
import math
import itertools
import sys
import random
import thread
from multiprocessing import Process, Queue
from lib import dac
from lib.common import *
from lib.set_frame import set_frame
from lib.stream import PointStream
from lib.entity import Entity
from lib.point import *
from lib.frame import *
from lib.wrap import Wrap
from lib.distortion import Distortion
from lib.queues import NonblockQueue
from entities.circle import Circle
from entities.square import Square
entities = []
IPAddrs = {
'china': '169.254.156.113',
'usa': '169.254.97.12',
}
queues = NonblockQueue()
queues.createQueue('china')
queues.createQueue('usa')
dacs = {}
dacs['china'] = None
dacs['usa'] = None
distortions = {}
distortions['china'] = Distortion(5000, -6600, 0.75, 0.75,
blankingSamplePts=15,
trackingSamplePts=10
)
distortions['usa'] = Distortion(-5000, 6600,
blankingSamplePts=30,
trackingSamplePts=30
)
frame = LogicalFrame()
def dac_thread(key, queues):
while True:
try:
print 'Connecting to dac @ %s' % IPAddrs[key]
dacs[key] = dac.DAC(IPAddrs[key])
d = dacs[key]
d.stream = PointStream()
d.stream.laserKey = key
d.stream.setQueue(queues.getQueue(key))
d.stream.distortion = distortions[key]
print 'playing stream...!'
d.play_stream(d.stream)
except KeyboardInterrupt:
sys.exit()
except Exception as e:
"""
import sys, traceback
print '\n---------------------'
print 'Exception: %s' % e
print '- - - - - - - - - - -'
traceback.print_tb(sys.exc_info()[2])
print "\n"
"""
continue
p1 = Process(target=dac_thread, args=('china', queues))
p2 = Process(target=dac_thread, args=('usa', queues))
p1.start()
p2.start()
for i in range(5) :
for key in ['usa', 'china']:
e = Square()
e.laserKey = key
e.x = 0 + (2000* i)
e.y = 0 + (2000* i)
entities.append(e)
def draw_thread(dacs, distortions, queues):
while True:
try:
frame = LogicalFrame()
tmpEnt = entities[:]
for e in entities:
frame.add(e)
set_frame(frame, distortions, queues)
time.sleep(1/60.0)
except Exception as e:
import sys, traceback
print '\n---------------------'
print 'Exception: %s' % e
print '- - - - - - - - - - -'
traceback.print_tb(sys.exc_info()[2])
print "\n"
thread.start_new_thread(draw_thread, (dacs, distortions, queues))
while True:
time.sleep(100000)