##// END OF EJS Templates
Correct localtime in plots, handle exception in send_to_server
Juan C. Espinoza -
r1327:e2336f44bb45
parent child
Show More
@@ -1114,7 +1114,7 class PlotterData(object):
1114 MAXNUMX = 200
1114 MAXNUMX = 200
1115 MAXNUMY = 200
1115 MAXNUMY = 200
1116
1116
1117 def __init__(self, code, throttle_value, exp_code, buffering=True, snr=False):
1117 def __init__(self, code, throttle_value, exp_code, localtime=True, buffering=True, snr=False):
1118
1118
1119 self.key = code
1119 self.key = code
1120 self.throttle = throttle_value
1120 self.throttle = throttle_value
@@ -1122,7 +1122,7 class PlotterData(object):
1122 self.buffering = buffering
1122 self.buffering = buffering
1123 self.ready = False
1123 self.ready = False
1124 self.flagNoData = False
1124 self.flagNoData = False
1125 self.localtime = False
1125 self.localtime = localtime
1126 self.data = {}
1126 self.data = {}
1127 self.meta = {}
1127 self.meta = {}
1128 self.__heights = []
1128 self.__heights = []
@@ -1144,7 +1144,6 class PlotterData(object):
1144 for plot in self.plottypes:
1144 for plot in self.plottypes:
1145 self.data[plot] = {}
1145 self.data[plot] = {}
1146
1146
1147
1148 def __str__(self):
1147 def __str__(self):
1149 dum = ['{}{}'.format(key, self.shape(key)) for key in self.data]
1148 dum = ['{}{}'.format(key, self.shape(key)) for key in self.data]
1150 return 'Data[{}][{}]'.format(';'.join(dum), len(self.times))
1149 return 'Data[{}][{}]'.format(';'.join(dum), len(self.times))
@@ -1222,7 +1221,6 class PlotterData(object):
1222 self.pairs = dataOut.pairsList
1221 self.pairs = dataOut.pairsList
1223
1222
1224 self.interval = dataOut.getTimeInterval()
1223 self.interval = dataOut.getTimeInterval()
1225 self.localtime = dataOut.useLocalTime
1226 if True in ['spc' in ptype for ptype in self.plottypes]:
1224 if True in ['spc' in ptype for ptype in self.plottypes]:
1227 self.xrange = (dataOut.getFreqRange(1)/1000.,
1225 self.xrange = (dataOut.getFreqRange(1)/1000.,
1228 dataOut.getAcfRange(1), dataOut.getVelRange(1))
1226 dataOut.getAcfRange(1), dataOut.getVelRange(1))
@@ -164,7 +164,7 class Plot(Operation):
164 self.sender_time = 0
164 self.sender_time = 0
165 self.data = None
165 self.data = None
166 self.firsttime = True
166 self.firsttime = True
167 self.sender_queue = Queue(maxsize=10)
167 self.sender_queue = Queue(maxsize=60)
168 self.plots_adjust = {'left': 0.125, 'right': 0.9, 'bottom': 0.15, 'top': 0.9, 'wspace': 0.2, 'hspace': 0.2}
168 self.plots_adjust = {'left': 0.125, 'right': 0.9, 'bottom': 0.15, 'top': 0.9, 'wspace': 0.2, 'hspace': 0.2}
169
169
170 def __fmtTime(self, x, pos):
170 def __fmtTime(self, x, pos):
@@ -185,7 +185,6 class Plot(Operation):
185 self.show = kwargs.get('show', True)
185 self.show = kwargs.get('show', True)
186 self.save = kwargs.get('save', False)
186 self.save = kwargs.get('save', False)
187 self.save_period = kwargs.get('save_period', 1)
187 self.save_period = kwargs.get('save_period', 1)
188 self.ftp = kwargs.get('ftp', False)
189 self.colormap = kwargs.get('colormap', self.colormap)
188 self.colormap = kwargs.get('colormap', self.colormap)
190 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
189 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
191 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
190 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
@@ -223,7 +222,6 class Plot(Operation):
223 self.grid = kwargs.get('grid', False)
222 self.grid = kwargs.get('grid', False)
224 self.pause = kwargs.get('pause', False)
223 self.pause = kwargs.get('pause', False)
225 self.save_code = kwargs.get('save_code', None)
224 self.save_code = kwargs.get('save_code', None)
226 self.realtime = kwargs.get('realtime', True)
227 self.throttle = kwargs.get('throttle', 0)
225 self.throttle = kwargs.get('throttle', 0)
228 self.exp_code = kwargs.get('exp_code', None)
226 self.exp_code = kwargs.get('exp_code', None)
229 self.plot_server = kwargs.get('plot_server', False)
227 self.plot_server = kwargs.get('plot_server', False)
@@ -232,7 +230,7 class Plot(Operation):
232 self.height_index = kwargs.get('height_index', None)
230 self.height_index = kwargs.get('height_index', None)
233 self.__throttle_plot = apply_throttle(self.throttle)
231 self.__throttle_plot = apply_throttle(self.throttle)
234 self.data = PlotterData(
232 self.data = PlotterData(
235 self.CODE, self.throttle, self.exp_code, self.buffering, snr=self.showSNR)
233 self.CODE, self.throttle, self.exp_code, self.localtime, self.buffering, snr=self.showSNR)
236
234
237 if self.plot_server:
235 if self.plot_server:
238 if not self.plot_server.startswith('tcp://'):
236 if not self.plot_server.startswith('tcp://'):
@@ -485,7 +483,7 class Plot(Operation):
485 for ax in self.axes+self.pf_axes+self.cb_axes:
483 for ax in self.axes+self.pf_axes+self.cb_axes:
486 ax.clear()
484 ax.clear()
487 ax.firsttime = True
485 ax.firsttime = True
488 if ax.cbar:
486 if hasattr(ax, 'cbar') and ax.cbar:
489 ax.cbar.remove()
487 ax.cbar.remove()
490
488
491 def __plot(self):
489 def __plot(self):
@@ -588,20 +586,27 class Plot(Operation):
588 self.data.meta['colormap'] = 'Viridis'
586 self.data.meta['colormap'] = 'Viridis'
589 self.data.meta['interval'] = int(interval)
587 self.data.meta['interval'] = int(interval)
590 # msg = self.data.jsonify(self.data.tm, self.plot_name, self.plot_type)
588 # msg = self.data.jsonify(self.data.tm, self.plot_name, self.plot_type)
591 self.sender_queue.put(self.data.tm)
589 try:
590 self.sender_queue.put(self.data.tm, block=False)
591 except:
592 tm = self.sender_queue.get()
593 self.sender_queue.put(self.data.tm)
592
594
593 while True:
595 while True:
594 if self.sender_queue.empty():
596 if self.sender_queue.empty():
595 break
597 break
596 tm = self.sender_queue.get()
598 tm = self.sender_queue.get()
597 msg = self.data.jsonify(tm, self.plot_name, self.plot_type)
599 try:
600 msg = self.data.jsonify(tm, self.plot_name, self.plot_type)
601 except:
602 continue
598 self.socket.send_string(msg)
603 self.socket.send_string(msg)
599 socks = dict(self.poll.poll(5000))
604 socks = dict(self.poll.poll(5000))
600 if socks.get(self.socket) == zmq.POLLIN:
605 if socks.get(self.socket) == zmq.POLLIN:
601 reply = self.socket.recv_string()
606 reply = self.socket.recv_string()
602 if reply == 'ok':
607 if reply == 'ok':
603 log.log("Response from server ok", self.name)
608 log.log("Response from server ok", self.name)
604 time.sleep(0.1)
609 time.sleep(0.2)
605 continue
610 continue
606 else:
611 else:
607 log.warning(
612 log.warning(
@@ -649,14 +654,10 class Plot(Operation):
649
654
650 t = getattr(dataOut, self.attr_time)
655 t = getattr(dataOut, self.attr_time)
651
656
652 if dataOut.useLocalTime:
657 if self.localtime:
653 self.getDateTime = datetime.datetime.fromtimestamp
658 self.getDateTime = datetime.datetime.fromtimestamp
654 if not self.localtime:
655 t += time.timezone
656 else:
659 else:
657 self.getDateTime = datetime.datetime.utcfromtimestamp
660 self.getDateTime = datetime.datetime.utcfromtimestamp
658 if self.localtime:
659 t -= time.timezone
660
661
661 if self.xmin is None:
662 if self.xmin is None:
662 self.tmin = t
663 self.tmin = t
@@ -679,11 +680,6 class Plot(Operation):
679 self.poll.register(self.socket, zmq.POLLIN)
680 self.poll.register(self.socket, zmq.POLLIN)
680
681
681 tm = getattr(dataOut, self.attr_time)
682 tm = getattr(dataOut, self.attr_time)
682
683 if not dataOut.useLocalTime and self.localtime:
684 tm -= time.timezone
685 if dataOut.useLocalTime and not self.localtime:
686 tm += time.timezone
687
683
688 if self.data and (tm - self.tmin) >= self.xrange*60*60:
684 if self.data and (tm - self.tmin) >= self.xrange*60*60:
689 self.save_counter = self.save_period
685 self.save_counter = self.save_period
General Comments 0
You need to be logged in to leave comments. Login now