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