@@ -1,6 +1,10 | |||
|
1 | 1 | from jroplot_voltage import * |
|
2 | 2 | from jroplot_spectra import * |
|
3 | 3 | from jroplot_heispectra import * |
|
4 | 4 | from jroplot_correlation import * |
|
5 | 5 | from jroplot_parameters import * |
|
6 | from jroplotter import * No newline at end of file | |
|
6 | try: | |
|
7 | from jroplotter import * | |
|
8 | except ImportError, e: | |
|
9 | print e | |
|
10 | No newline at end of file |
@@ -1,104 +1,109 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Jul 9, 2014 |
|
3 | 3 | |
|
4 | 4 | @author: roj-idl71 |
|
5 | 5 | ''' |
|
6 | 6 | import os |
|
7 | 7 | import datetime |
|
8 | 8 | import numpy |
|
9 | 9 | |
|
10 | 10 | from time import sleep |
|
11 | 11 | from Queue import Queue |
|
12 | 12 | from threading import Thread |
|
13 | 13 | |
|
14 | 14 | from schainpy.model.proc.jroproc_base import Operation |
|
15 | 15 | from schainpy.model.serializer.data import obj2Dict, dict2Obj |
|
16 | from schainpy.model.graphics import * | |
|
16 | from jroplot_correlation import * | |
|
17 | from jroplot_heispectra import * | |
|
18 | from jroplot_parameters import * | |
|
19 | from jroplot_spectra import * | |
|
20 | from jroplot_voltage import * | |
|
21 | ||
|
17 | 22 | |
|
18 | 23 | class Plotter(Operation): |
|
19 | 24 | |
|
20 | 25 | isConfig = None |
|
21 | 26 | name = None |
|
22 | 27 | __queue = None |
|
23 | 28 | |
|
24 | 29 | def __init__(self, plotter_name, plotter_queue=None): |
|
25 | 30 | |
|
26 | 31 | Operation.__init__(self) |
|
27 | 32 | |
|
28 | 33 | self.isConfig = False |
|
29 | 34 | self.name = plotter_name |
|
30 | 35 | self.__queue = plotter_queue |
|
31 | 36 | |
|
32 | 37 | def getSubplots(self): |
|
33 | 38 | |
|
34 | 39 | nrow = self.nplots |
|
35 | 40 | ncol = 1 |
|
36 | 41 | return nrow, ncol |
|
37 | 42 | |
|
38 | 43 | def setup(self, **kwargs): |
|
39 | 44 | |
|
40 | 45 | print "Initializing ..." |
|
41 | 46 | |
|
42 | 47 | |
|
43 | 48 | def run(self, dataOut, id=None, **kwargs): |
|
44 | 49 | |
|
45 | 50 | """ |
|
46 | 51 | |
|
47 | 52 | Input: |
|
48 | 53 | dataOut : |
|
49 | 54 | id : |
|
50 | 55 | """ |
|
51 | 56 | |
|
52 | 57 | packDict = {} |
|
53 | 58 | |
|
54 | 59 | packDict['id'] = id |
|
55 | 60 | packDict['name'] = self.name |
|
56 | 61 | packDict['kwargs'] = kwargs |
|
57 | 62 | |
|
58 | 63 | packDict['data'] = obj2Dict(dataOut) |
|
59 | 64 | |
|
60 | 65 | self.__queue.put(packDict) |
|
61 | 66 | |
|
62 | 67 | class PlotterManager(Thread): |
|
63 | 68 | |
|
64 | 69 | __stop = False |
|
65 | 70 | |
|
66 | 71 | def __init__(self, plotter_queue): |
|
67 | 72 | |
|
68 | 73 | Thread.__init__(self) |
|
69 | 74 | |
|
70 | 75 | self.__queue = plotter_queue |
|
71 | 76 | |
|
72 | 77 | self.plotInstanceDict = {} |
|
73 | 78 | self.__stop = False |
|
74 | 79 | |
|
75 | 80 | def run(self): |
|
76 | 81 | |
|
77 | 82 | while True: |
|
78 | 83 | |
|
79 | 84 | if self.__stop: |
|
80 | 85 | break |
|
81 | 86 | |
|
82 | 87 | if self.__queue.empty(): |
|
83 | 88 | sleep(0.5) |
|
84 | 89 | continue |
|
85 | 90 | |
|
86 | 91 | serial_data = self.__queue.get(True) |
|
87 | 92 | |
|
88 | 93 | plot_id = serial_data['id'] |
|
89 | 94 | plot_name = serial_data['name'] |
|
90 | 95 | kwargs = serial_data['kwargs'] |
|
91 | 96 | dataDict = serial_data['data'] |
|
92 | 97 | |
|
93 | 98 | dataPlot = dict2Obj(dataDict) |
|
94 | 99 | |
|
95 | 100 | if plot_id not in self.plotInstanceDict.keys(): |
|
96 | 101 | className = eval(plot_name) |
|
97 | 102 | self.plotInstanceDict[plot_id] = className() |
|
98 | 103 | |
|
99 | 104 | plotter = self.plotInstanceDict[plot_id] |
|
100 | 105 | plotter.run(dataPlot, plot_id, **kwargs) |
|
101 | 106 | |
|
102 | 107 | def stop(self): |
|
103 | 108 | |
|
104 | 109 | self.__stop = True No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now