@@ -1,184 +1,179 | |||||
1 | import threading |
|
1 | import threading | |
2 | import Queue |
|
2 | import Queue | |
3 |
|
3 | |||
4 | from schainpy.controller import Project |
|
4 | from schainpy.controller import Project | |
5 | from schainpy.model.graphics.jroplotter import PlotManager |
|
5 | from schainpy.model.graphics.jroplotter import PlotManager | |
6 |
|
6 | |||
7 | class ControllerThread(threading.Thread, Project): |
|
7 | class ControllerThread(threading.Thread, Project): | |
8 |
|
8 | |||
9 | def __init__(self, plotter_queue=None): |
|
9 | def __init__(self, plotter_queue=None): | |
10 |
|
10 | |||
11 | threading.Thread.__init__(self) |
|
11 | threading.Thread.__init__(self) | |
12 | Project.__init__(self, plotter_queue) |
|
12 | Project.__init__(self, plotter_queue) | |
13 |
|
13 | |||
14 | self.setDaemon(True) |
|
14 | self.setDaemon(True) | |
15 |
|
15 | |||
16 | self.lock = threading.Lock() |
|
16 | self.lock = threading.Lock() | |
17 | self.control = {'stop':False, 'pause':False} |
|
17 | self.control = {'stop':False, 'pause':False} | |
18 |
|
18 | |||
19 | def __del__(self): |
|
19 | def __del__(self): | |
20 |
|
20 | |||
21 | self.control['stop'] = True |
|
21 | self.control['stop'] = True | |
22 |
|
22 | |||
23 | def stop(self): |
|
23 | def stop(self): | |
24 |
|
24 | |||
25 | self.lock.acquire() |
|
25 | self.lock.acquire() | |
26 |
|
26 | |||
27 | self.control['stop'] = True |
|
27 | self.control['stop'] = True | |
28 |
|
28 | |||
29 | self.lock.release() |
|
29 | self.lock.release() | |
30 |
|
30 | |||
31 | def pause(self): |
|
31 | def pause(self): | |
32 |
|
32 | |||
33 | self.lock.acquire() |
|
33 | self.lock.acquire() | |
34 |
|
34 | |||
35 | self.control['pause'] = not(self.control['pause']) |
|
35 | self.control['pause'] = not(self.control['pause']) | |
36 | paused = self.control['pause'] |
|
36 | paused = self.control['pause'] | |
37 |
|
37 | |||
38 | self.lock.release() |
|
38 | self.lock.release() | |
39 |
|
39 | |||
40 | return paused |
|
40 | return paused | |
41 |
|
41 | |||
42 | def isPaused(self): |
|
42 | def isPaused(self): | |
43 |
|
43 | |||
44 | self.lock.acquire() |
|
44 | self.lock.acquire() | |
45 | paused = self.control['pause'] |
|
45 | paused = self.control['pause'] | |
46 | self.lock.release() |
|
46 | self.lock.release() | |
47 |
|
47 | |||
48 | return paused |
|
48 | return paused | |
49 |
|
49 | |||
50 | def isStopped(self): |
|
50 | def isStopped(self): | |
51 |
|
51 | |||
52 | self.lock.acquire() |
|
52 | self.lock.acquire() | |
53 | stopped = self.control['stop'] |
|
53 | stopped = self.control['stop'] | |
54 | self.lock.release() |
|
54 | self.lock.release() | |
55 |
|
55 | |||
56 | return stopped |
|
56 | return stopped | |
57 |
|
57 | |||
58 | def run(self): |
|
58 | def run(self): | |
59 | self.control['stop'] = False |
|
59 | self.control['stop'] = False | |
60 | self.control['pause'] = False |
|
60 | self.control['pause'] = False | |
61 |
|
61 | |||
62 | self.writeXml() |
|
62 | self.writeXml() | |
63 |
|
63 | |||
64 | self.createObjects() |
|
64 | self.createObjects() | |
65 | self.connectObjects() |
|
65 | self.connectObjects() | |
66 | Project.run(self) |
|
66 | Project.run(self) | |
67 |
|
67 | |||
68 | def isRunning(self): |
|
68 | def isRunning(self): | |
69 |
|
69 | |||
70 | return self.is_alive() |
|
70 | return self.is_alive() | |
71 |
|
71 | |||
72 | def isFinished(self): |
|
72 | def isFinished(self): | |
73 |
|
73 | |||
74 | return not self.is_alive() |
|
74 | return not self.is_alive() | |
75 |
|
75 | |||
76 | def setPlotters(self): |
|
76 | def setPlotters(self): | |
77 |
|
77 | |||
78 |
plotterList = |
|
78 | plotterList = PlotManager.plotterList | |
79 | 'SpectraPlot', 'RTIPlot', |
|
|||
80 | 'CrossSpectraPlot', 'CoherenceMap', |
|
|||
81 | 'PowerProfilePlot', 'Noise', 'BeaconPhase', |
|
|||
82 | 'CorrelationPlot', |
|
|||
83 | 'SpectraHeisScope','RTIfromSpectraHeis'] |
|
|||
84 |
|
79 | |||
85 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
80 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
86 |
|
81 | |||
87 | inputId = thisPUConfObj.getInputId() |
|
82 | inputId = thisPUConfObj.getInputId() | |
88 |
|
83 | |||
89 | if int(inputId) == 0: |
|
84 | if int(inputId) == 0: | |
90 | continue |
|
85 | continue | |
91 |
|
86 | |||
92 | for thisOpObj in thisPUConfObj.getOperationObjList(): |
|
87 | for thisOpObj in thisPUConfObj.getOperationObjList(): | |
93 |
|
88 | |||
94 | if thisOpObj.type == "self": |
|
89 | if thisOpObj.type == "self": | |
95 | continue |
|
90 | continue | |
96 |
|
91 | |||
97 | if thisOpObj.name in plotterList: |
|
92 | if thisOpObj.name in plotterList: | |
98 | thisOpObj.type = "plotter" |
|
93 | thisOpObj.type = "plotter" | |
99 |
|
94 | |||
100 | def setPlotterQueue(self, plotter_queue): |
|
95 | def setPlotterQueue(self, plotter_queue): | |
101 |
|
96 | |||
102 | self.plotterQueue = plotter_queue |
|
97 | self.plotterQueue = plotter_queue | |
103 |
|
98 | |||
104 | def getPlotterQueue(self): |
|
99 | def getPlotterQueue(self): | |
105 |
|
100 | |||
106 | return self.plotterQueue |
|
101 | return self.plotterQueue | |
107 |
|
102 | |||
108 | def useExternalPlotter(self): |
|
103 | def useExternalPlotter(self): | |
109 |
|
104 | |||
110 | self.plotterQueue = Queue.Queue(10) |
|
105 | self.plotterQueue = Queue.Queue(10) | |
111 | self.setPlotters() |
|
106 | self.setPlotters() | |
112 |
|
107 | |||
113 | plotManagerObj = PlotManager(self.plotterQueue) |
|
108 | plotManagerObj = PlotManager(self.plotterQueue) | |
114 | plotManagerObj.setController(self) |
|
109 | plotManagerObj.setController(self) | |
115 |
|
110 | |||
116 | return plotManagerObj |
|
111 | return plotManagerObj | |
117 |
|
112 | |||
118 | # from PyQt4 import QtCore |
|
113 | # from PyQt4 import QtCore | |
119 | # from PyQt4.QtCore import SIGNAL |
|
114 | # from PyQt4.QtCore import SIGNAL | |
120 | # |
|
115 | # | |
121 | # class ControllerQThread(QtCore.QThread, Project): |
|
116 | # class ControllerQThread(QtCore.QThread, Project): | |
122 | # |
|
117 | # | |
123 | # def __init__(self, filename): |
|
118 | # def __init__(self, filename): | |
124 | # |
|
119 | # | |
125 | # QtCore.QThread.__init__(self) |
|
120 | # QtCore.QThread.__init__(self) | |
126 | # Project.__init__(self) |
|
121 | # Project.__init__(self) | |
127 | # |
|
122 | # | |
128 | # self.filename = filename |
|
123 | # self.filename = filename | |
129 | # |
|
124 | # | |
130 | # self.lock = threading.Lock() |
|
125 | # self.lock = threading.Lock() | |
131 | # self.control = {'stop':False, 'pause':False} |
|
126 | # self.control = {'stop':False, 'pause':False} | |
132 | # |
|
127 | # | |
133 | # def __del__(self): |
|
128 | # def __del__(self): | |
134 | # |
|
129 | # | |
135 | # self.control['stop'] = True |
|
130 | # self.control['stop'] = True | |
136 | # self.wait() |
|
131 | # self.wait() | |
137 | # |
|
132 | # | |
138 | # def stop(self): |
|
133 | # def stop(self): | |
139 | # |
|
134 | # | |
140 | # self.lock.acquire() |
|
135 | # self.lock.acquire() | |
141 | # |
|
136 | # | |
142 | # self.control['stop'] = True |
|
137 | # self.control['stop'] = True | |
143 | # |
|
138 | # | |
144 | # self.lock.release() |
|
139 | # self.lock.release() | |
145 | # |
|
140 | # | |
146 | # def pause(self): |
|
141 | # def pause(self): | |
147 | # |
|
142 | # | |
148 | # self.lock.acquire() |
|
143 | # self.lock.acquire() | |
149 | # |
|
144 | # | |
150 | # self.control['pause'] = not(self.control['pause']) |
|
145 | # self.control['pause'] = not(self.control['pause']) | |
151 | # paused = self.control['pause'] |
|
146 | # paused = self.control['pause'] | |
152 | # |
|
147 | # | |
153 | # self.lock.release() |
|
148 | # self.lock.release() | |
154 | # |
|
149 | # | |
155 | # return paused |
|
150 | # return paused | |
156 | # |
|
151 | # | |
157 | # def isPaused(self): |
|
152 | # def isPaused(self): | |
158 | # |
|
153 | # | |
159 | # self.lock.acquire() |
|
154 | # self.lock.acquire() | |
160 | # paused = self.control['pause'] |
|
155 | # paused = self.control['pause'] | |
161 | # self.lock.release() |
|
156 | # self.lock.release() | |
162 | # |
|
157 | # | |
163 | # return paused |
|
158 | # return paused | |
164 | # |
|
159 | # | |
165 | # def isStopped(self): |
|
160 | # def isStopped(self): | |
166 | # |
|
161 | # | |
167 | # self.lock.acquire() |
|
162 | # self.lock.acquire() | |
168 | # stopped = self.control['stop'] |
|
163 | # stopped = self.control['stop'] | |
169 | # self.lock.release() |
|
164 | # self.lock.release() | |
170 | # |
|
165 | # | |
171 | # return stopped |
|
166 | # return stopped | |
172 | # |
|
167 | # | |
173 | # def run(self): |
|
168 | # def run(self): | |
174 | # |
|
169 | # | |
175 | # self.control['stop'] = False |
|
170 | # self.control['stop'] = False | |
176 | # self.control['pause'] = False |
|
171 | # self.control['pause'] = False | |
177 | # |
|
172 | # | |
178 | # self.readXml(self.filename) |
|
173 | # self.readXml(self.filename) | |
179 | # self.createObjects() |
|
174 | # self.createObjects() | |
180 | # self.connectObjects() |
|
175 | # self.connectObjects() | |
181 | # self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) |
|
176 | # self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) | |
182 | # Project.run(self) |
|
177 | # Project.run(self) | |
183 | # self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) |
|
178 | # self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) | |
184 | # No newline at end of file |
|
179 | # |
General Comments 0
You need to be logged in to leave comments.
Login now