@@ -823,7 +823,7 class Project(): | |||
|
823 | 823 | |
|
824 | 824 | ELEMENTNAME = 'Project' |
|
825 | 825 | |
|
826 |
|
|
|
826 | plotterQueue = None | |
|
827 | 827 | |
|
828 | 828 | def __init__(self, plotter_queue=None): |
|
829 | 829 | |
@@ -831,7 +831,7 class Project(): | |||
|
831 | 831 | self.name = None |
|
832 | 832 | self.description = None |
|
833 | 833 | |
|
834 |
self. |
|
|
834 | self.plotterQueue = plotter_queue | |
|
835 | 835 | |
|
836 | 836 | self.procUnitConfObjDict = {} |
|
837 | 837 | |
@@ -1046,7 +1046,7 class Project(): | |||
|
1046 | 1046 | def createObjects(self): |
|
1047 | 1047 | |
|
1048 | 1048 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
1049 |
procUnitConfObj.createObjects(self. |
|
|
1049 | procUnitConfObj.createObjects(self.plotterQueue) | |
|
1050 | 1050 | |
|
1051 | 1051 | def __connect(self, objIN, thisObj): |
|
1052 | 1052 | |
@@ -1143,35 +1143,15 class Project(): | |||
|
1143 | 1143 | |
|
1144 | 1144 | def setPlotterQueue(self, plotter_queue): |
|
1145 | 1145 | |
|
1146 | self.__plotterQueue = plotter_queue | |
|
1146 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" | |
|
1147 | 1147 | |
|
1148 | 1148 | def getPlotterQueue(self): |
|
1149 | 1149 | |
|
1150 | return self.__plotterQueue | |
|
1150 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" | |
|
1151 | 1151 | |
|
1152 |
def useExternalPlot |
|
|
1152 | def useExternalPlotter(self): | |
|
1153 | 1153 | |
|
1154 | plotterList = ['Scope', | |
|
1155 | 'SpectraPlot', 'RTIPlot', | |
|
1156 | 'CrossSpectraPlot', 'CoherenceMap', | |
|
1157 | 'PowerProfilePlot', 'Noise', 'BeaconPhase', | |
|
1158 | 'CorrelationPlot', | |
|
1159 | 'SpectraHeisScope','RTIfromSpectraHeis'] | |
|
1160 | ||
|
1161 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
|
1162 | ||
|
1163 | inputId = thisPUConfObj.getInputId() | |
|
1164 | ||
|
1165 | if int(inputId) == 0: | |
|
1166 | continue | |
|
1167 | ||
|
1168 | for thisOpObj in thisPUConfObj.getOperationObjList(): | |
|
1169 | ||
|
1170 | if thisOpObj.type == "self": | |
|
1171 | continue | |
|
1172 | ||
|
1173 | if thisOpObj.name in plotterList: | |
|
1174 | thisOpObj.type = "plotter" | |
|
1154 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" | |
|
1175 | 1155 | |
|
1176 | 1156 | def run(self): |
|
1177 | 1157 |
@@ -1,6 +1,8 | |||
|
1 | 1 | import threading |
|
2 | import Queue | |
|
2 | 3 | |
|
3 | 4 | from schainpy.controller import Project |
|
5 | from schainpy.model.graphics.jroplotter import PlotManager | |
|
4 | 6 | |
|
5 | 7 | class ControllerThread(threading.Thread, Project): |
|
6 | 8 | |
@@ -71,6 +73,48 class ControllerThread(threading.Thread, Project): | |||
|
71 | 73 | |
|
72 | 74 | return not self.is_alive() |
|
73 | 75 | |
|
76 | def setPlotters(self): | |
|
77 | ||
|
78 | plotterList = ['Scope', | |
|
79 | 'SpectraPlot', 'RTIPlot', | |
|
80 | 'CrossSpectraPlot', 'CoherenceMap', | |
|
81 | 'PowerProfilePlot', 'Noise', 'BeaconPhase', | |
|
82 | 'CorrelationPlot', | |
|
83 | 'SpectraHeisScope','RTIfromSpectraHeis'] | |
|
84 | ||
|
85 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
|
86 | ||
|
87 | inputId = thisPUConfObj.getInputId() | |
|
88 | ||
|
89 | if int(inputId) == 0: | |
|
90 | continue | |
|
91 | ||
|
92 | for thisOpObj in thisPUConfObj.getOperationObjList(): | |
|
93 | ||
|
94 | if thisOpObj.type == "self": | |
|
95 | continue | |
|
96 | ||
|
97 | if thisOpObj.name in plotterList: | |
|
98 | thisOpObj.type = "plotter" | |
|
99 | ||
|
100 | def setPlotterQueue(self, plotter_queue): | |
|
101 | ||
|
102 | self.plotterQueue = plotter_queue | |
|
103 | ||
|
104 | def getPlotterQueue(self): | |
|
105 | ||
|
106 | return self.plotterQueue | |
|
107 | ||
|
108 | def useExternalPlotter(self): | |
|
109 | ||
|
110 | self.plotterQueue = Queue.Queue(10) | |
|
111 | self.setPlotters() | |
|
112 | ||
|
113 | plotManagerObj = PlotManager(self.plotterQueue) | |
|
114 | plotManagerObj.setController(self) | |
|
115 | ||
|
116 | return plotManagerObj | |
|
117 | ||
|
74 | 118 | # from PyQt4 import QtCore |
|
75 | 119 | # from PyQt4.QtCore import SIGNAL |
|
76 | 120 | # |
@@ -4685,11 +4685,7 class BasicWindow(QMainWindow, Ui_BasicWindow): | |||
|
4685 | 4685 | |
|
4686 | 4686 | def use_plotmanager(self, controllerThread): |
|
4687 | 4687 | |
|
4688 | plotter_queue = Queue(10) | |
|
4689 | controllerThread.setPlotterQueue(plotter_queue) | |
|
4690 | controllerThread.useExternalPlotManager() | |
|
4691 | ||
|
4692 | self.plotManager = PlotManager(plotter_queue) | |
|
4688 | self.plotManager = controllerThread.useExternalPlotter() | |
|
4693 | 4689 | |
|
4694 | 4690 | self.plot_timer = QtCore.QTimer() |
|
4695 | 4691 | self.plot_timer.timeout.connect(self.on_plotmanager_timer) |
@@ -4750,11 +4746,9 class BasicWindow(QMainWindow, Ui_BasicWindow): | |||
|
4750 | 4746 | |
|
4751 | 4747 | self.threadStarted = False |
|
4752 | 4748 | self.controllerThread.stop() |
|
4749 | self.plot_timer.stop() | |
|
4753 | 4750 | |
|
4754 |
|
|
|
4755 | self.plotManager.run() | |
|
4756 | ||
|
4757 | self.plotManager.close() | |
|
4751 | self.plotManager.join() | |
|
4758 | 4752 | self.plotManager = None |
|
4759 | 4753 | |
|
4760 | 4754 | while self.controllerThread.isRunning(): |
@@ -68,6 +68,7 class Plotter(Operation): | |||
|
68 | 68 | # class PlotManager(Thread): |
|
69 | 69 | class PlotManager(): |
|
70 | 70 | __stop = False |
|
71 | controllerThreadObj = None | |
|
71 | 72 | |
|
72 | 73 | def __init__(self, plotter_queue): |
|
73 | 74 | |
@@ -96,6 +97,9 class PlotManager(): | |||
|
96 | 97 | |
|
97 | 98 | for i in range(n): |
|
98 | 99 | |
|
100 | if self.__queue.empty(): | |
|
101 | break | |
|
102 | ||
|
99 | 103 | serial_data = self.__queue.get() |
|
100 | 104 | self.__queue.task_done() |
|
101 | 105 | |
@@ -137,3 +141,27 class PlotManager(): | |||
|
137 | 141 | |
|
138 | 142 | self.__lock.release() |
|
139 | 143 |
|
|
144 | def setController(self, controllerThreadObj): | |
|
145 | ||
|
146 | self.controllerThreadObj = controllerThreadObj | |
|
147 | ||
|
148 | def start(self): | |
|
149 | ||
|
150 | if not self.controllerThreadObj.isRunning(): | |
|
151 | raise RuntimeError, "controllerThreadObj has not been initialized. Use controllerThreadObj.start() before call this method" | |
|
152 | ||
|
153 | self.join() | |
|
154 | ||
|
155 | def join(self): | |
|
156 | ||
|
157 | #Execute plotter while controller is running | |
|
158 | while self.controllerThreadObj.isRunning(): | |
|
159 | self.run() | |
|
160 | ||
|
161 | self.controllerThreadObj.stop() | |
|
162 | ||
|
163 | #Wait until plotter queue is empty | |
|
164 | while not self.isEmpty(): | |
|
165 | self.run() | |
|
166 | ||
|
167 | self.close() No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now