@@ -34,4 +34,9 VERSIONS: | |||||
34 |
|
34 | |||
35 | 2.1.4.2: |
|
35 | 2.1.4.2: | |
36 | -A new Plotter Class was added |
|
36 | -A new Plotter Class was added | |
|
37 | -Project.start() does not accept filename as a parameter anymore | |||
|
38 | ||||
|
39 | 2.1.5: | |||
|
40 | -serializer module added to Signal Chain | |||
|
41 | -jroplotter.py added to Signal Chain | |||
37 |
|
42 |
@@ -4,4 +4,4 Created on Feb 7, 2012 | |||||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
__version__ = "2.1. |
|
7 | __version__ = "2.1.5" No newline at end of file |
@@ -7,19 +7,27 import os | |||||
7 | import datetime |
|
7 | import datetime | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 |
from |
|
10 | from time import sleep | |
|
11 | from Queue import Queue | |||
|
12 | from threading import Thread | |||
11 |
|
13 | |||
12 | class Plotter(Figure): |
|
14 | from schainpy.model.proc.jroproc_base import Operation | |
|
15 | from schainpy.model.serializer.data import obj2Dict, dict2Obj | |||
|
16 | from schainpy.model.graphics import * | |||
|
17 | ||||
|
18 | class Plotter(Operation): | |||
13 |
|
19 | |||
14 | isConfig = None |
|
20 | isConfig = None | |
15 | name = None |
|
21 | name = None | |
16 |
|
|
22 | __queue = None | |
17 |
|
23 | |||
18 | def __init__(self, plotter_name, plotter_queue=None): |
|
24 | def __init__(self, plotter_name, plotter_queue=None): | |
19 |
|
25 | |||
|
26 | Operation.__init__(self) | |||
|
27 | ||||
20 | self.isConfig = False |
|
28 | self.isConfig = False | |
21 | self.name = plotter_name |
|
29 | self.name = plotter_name | |
22 |
self. |
|
30 | self.__queue = plotter_queue | |
23 |
|
31 | |||
24 | def getSubplots(self): |
|
32 | def getSubplots(self): | |
25 |
|
33 | |||
@@ -29,40 +37,68 class Plotter(Figure): | |||||
29 |
|
37 | |||
30 | def setup(self, **kwargs): |
|
38 | def setup(self, **kwargs): | |
31 |
|
39 | |||
32 | # self.nplots = nplots |
|
|||
33 | # |
|
|||
34 | # self.createFigure(id=id, |
|
|||
35 | # wintitle=wintitle, |
|
|||
36 | # show=show) |
|
|||
37 | # |
|
|||
38 | # nrow,ncol = self.getSubplots() |
|
|||
39 | # colspan = 3 |
|
|||
40 | # rowspan = 1 |
|
|||
41 | # |
|
|||
42 | # for i in range(nplots): |
|
|||
43 | # self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
|||
44 |
|
||||
45 |
|
||||
46 |
|
||||
47 | print "Initializing ..." |
|
40 | print "Initializing ..." | |
48 |
|
41 | |||
49 |
|
42 | |||
50 | def run(self, dataOut, **kwargs): |
|
43 | def run(self, dataOut, id=None, **kwargs): | |
51 |
|
44 | |||
52 | """ |
|
45 | """ | |
53 |
|
46 | |||
54 | Input: |
|
47 | Input: | |
55 | dataOut : |
|
48 | dataOut : | |
56 | id : |
|
49 | id : | |
57 | wintitle : |
|
|||
58 | channelList : |
|
|||
59 | show : |
|
|||
60 | """ |
|
50 | """ | |
61 |
|
51 | |||
62 | if not self.isConfig: |
|
52 | packDict = {} | |
63 | self.setup(**kwargs) |
|
53 | ||
64 | self.isConfig=True |
|
54 | packDict['id'] = id | |
|
55 | packDict['name'] = self.name | |||
|
56 | packDict['kwargs'] = kwargs | |||
|
57 | ||||
|
58 | packDict['data'] = obj2Dict(dataOut) | |||
|
59 | ||||
|
60 | self.__queue.put(packDict) | |||
|
61 | ||||
|
62 | class PlotterManager(Thread): | |||
|
63 | ||||
|
64 | __stop = False | |||
|
65 | ||||
|
66 | def __init__(self, plotter_queue): | |||
|
67 | ||||
|
68 | Thread.__init__(self) | |||
|
69 | ||||
|
70 | self.__queue = plotter_queue | |||
|
71 | ||||
|
72 | self.plotInstanceDict = {} | |||
|
73 | self.__stop = False | |||
|
74 | ||||
|
75 | def run(self): | |||
|
76 | ||||
|
77 | while True: | |||
|
78 | ||||
|
79 | if self.__stop: | |||
|
80 | break | |||
|
81 | ||||
|
82 | if self.__queue.empty(): | |||
|
83 | sleep(0.5) | |||
|
84 | continue | |||
|
85 | ||||
|
86 | serial_data = self.__queue.get(True) | |||
|
87 | ||||
|
88 | plot_id = serial_data['id'] | |||
|
89 | plot_name = serial_data['name'] | |||
|
90 | kwargs = serial_data['kwargs'] | |||
|
91 | dataDict = serial_data['data'] | |||
|
92 | ||||
|
93 | dataPlot = dict2Obj(dataDict) | |||
|
94 | ||||
|
95 | if plot_id not in self.plotInstanceDict.keys(): | |||
|
96 | className = eval(plot_name) | |||
|
97 | self.plotInstanceDict[plot_id] = className() | |||
|
98 | ||||
|
99 | plotter = self.plotInstanceDict[plot_id] | |||
|
100 | plotter.run(dataPlot, plot_id, **kwargs) | |||
65 |
|
101 | |||
66 | print "Putting data on %s queue:" %self.name |
|
102 | def stop(self): | |
67 | print kwargs |
|
|||
68 |
|
103 | |||
|
104 | self.__stop = True No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now