##// END OF EJS Templates
Fix SendToWeb operation
jespinoza -
r911:7e8096f3f048
parent child
Show More
@@ -86,6 +86,9 class PlotData(Operation, Process):
86
86
87 print 'plotting...{}'.format(self.CODE)
87 print 'plotting...{}'.format(self.CODE)
88
88
89 if self.show:
90 self.figure.show()
91
89 self.plot()
92 self.plot()
90 self.figure.suptitle('{} {} - Date:{}'.format(self.title, self.CODE.upper(),
93 self.figure.suptitle('{} {} - Date:{}'.format(self.title, self.CODE.upper(),
91 datetime.datetime.utcfromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')))
94 datetime.datetime.utcfromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')))
@@ -184,7 +187,6 class PlotSpectraData(PlotData):
184 n += 1
187 n += 1
185
188
186 self.figure.subplots_adjust(left=0.1, right=0.95, bottom=0.15, top=0.85, wspace=0.9, hspace=0.5)
189 self.figure.subplots_adjust(left=0.1, right=0.95, bottom=0.15, top=0.85, wspace=0.9, hspace=0.5)
187 self.figure.show()
188
190
189 def plot(self):
191 def plot(self):
190
192
@@ -277,7 +279,6 class PlotRTIData(PlotData):
277 ax.firsttime = True
279 ax.firsttime = True
278 self.axes.append(ax)
280 self.axes.append(ax)
279 self.figure.subplots_adjust(hspace=0.5)
281 self.figure.subplots_adjust(hspace=0.5)
280 self.figure.show()
281
282
282 def plot(self):
283 def plot(self):
283
284
@@ -367,7 +368,6 class PlotCOHData(PlotRTIData):
367 self.axes.append(ax)
368 self.axes.append(ax)
368
369
369 self.figure.subplots_adjust(hspace=0.5)
370 self.figure.subplots_adjust(hspace=0.5)
370 self.figure.show()
371
371
372 class PlotNoiseData(PlotData):
372 class PlotNoiseData(PlotData):
373 CODE = 'noise'
373 CODE = 'noise'
@@ -392,8 +392,6 class PlotNoiseData(PlotData):
392 self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1)
392 self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1)
393 self.ax.firsttime = True
393 self.ax.firsttime = True
394
394
395 self.figure.show()
396
397 def plot(self):
395 def plot(self):
398
396
399 x = self.times
397 x = self.times
@@ -31,7 +31,9 def roundFloats(obj):
31
31
32 def decimate(z):
32 def decimate(z):
33 # dx = int(len(self.x)/self.__MAXNUMX) + 1
33 # dx = int(len(self.x)/self.__MAXNUMX) + 1
34
34 dy = int(len(z[0])/MAXNUMY) + 1
35 dy = int(len(z[0])/MAXNUMY) + 1
36
35 return z[::, ::dy]
37 return z[::, ::dy]
36
38
37 class throttle(object):
39 class throttle(object):
@@ -148,8 +150,6 class PublishData(Operation):
148 self.zmq_socket.connect(address)
150 self.zmq_socket.connect(address)
149 time.sleep(1)
151 time.sleep(1)
150
152
151
152
153 def publish_data(self):
153 def publish_data(self):
154 self.dataOut.finished = False
154 self.dataOut.finished = False
155 if self.mqtt is 1:
155 if self.mqtt is 1:
@@ -355,8 +355,12 class ReceiverData(ProcessingUnit, Process):
355 if plottype == 'phase':
355 if plottype == 'phase':
356 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
356 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
357 if self.realtime:
357 if self.realtime:
358 self.data_web[plottype] = roundFloats(decimate(self.data[plottype][t]).tolist())
358 if plottype == 'spc':
359 self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist())
360 else:
361 self.data_web[plottype] = roundFloats(decimate(self.data[plottype][t]).tolist())
359 self.data_web['time'] = t
362 self.data_web['time'] = t
363
360 def run(self):
364 def run(self):
361
365
362 print '[Starting] {} from {}'.format(self.name, self.address)
366 print '[Starting] {} from {}'.format(self.name, self.address)
@@ -366,8 +370,8 class ReceiverData(ProcessingUnit, Process):
366 self.receiver.bind(self.address)
370 self.receiver.bind(self.address)
367 monitor = self.receiver.get_monitor_socket()
371 monitor = self.receiver.get_monitor_socket()
368 self.sender = self.context.socket(zmq.PUB)
372 self.sender = self.context.socket(zmq.PUB)
369 if self.realtime:
373 if self.realtime:
370 self.sender_web = self.context.socket(zmq.PUB)
374 self.sender_web = self.context.socket(zmq.PUB)
371 self.sender_web.bind(self.plot_address)
375 self.sender_web.bind(self.plot_address)
372 self.sender.bind("ipc:///tmp/zmq.plots")
376 self.sender.bind("ipc:///tmp/zmq.plots")
373
377
@@ -398,23 +402,21 class ReceiverData(ProcessingUnit, Process):
398 self.started = True
402 self.started = True
399
403
400 return
404 return
401
405
402 def sendToWeb(self):
406 def sendToWeb(self):
403
407
404 if not self.isWebConfig:
408 if not self.isWebConfig:
405 context = zmq.Context()
409 context = zmq.Context()
406 sender_web_config = context.socket(zmq.PUB)
410 sender_web_config = context.socket(zmq.PUB)
407 if 'tcp://' in self.plot_address:
411 if 'tcp://' in self.plot_address:
408 print self.plot_address
409 dum, address, port = self.plot_address.split(':')
412 dum, address, port = self.plot_address.split(':')
410 conf_address = '{}:{}:{}'.format(dum, address, int(port)+1)
413 conf_address = '{}:{}:{}'.format(dum, address, int(port)+1)
411 else:
414 else:
412 conf_address = self.plot_address + '.config'
415 conf_address = self.plot_address + '.config'
413 sender_web_config.bind(conf_address)
416 sender_web_config.bind(conf_address)
414
417 time.sleep(1)
415 for kwargs in self.operationKwargs.values():
418 for kwargs in self.operationKwargs.values():
416 if 'plot' in kwargs:
419 if 'plot' in kwargs:
420 print '[Sending] Config data to web for {}'.format(kwargs['code'].upper())
417 sender_web_config.send_string(json.dumps(kwargs))
421 sender_web_config.send_string(json.dumps(kwargs))
418 print kwargs
419 self.isWebConfig = True
422 self.isWebConfig = True
420
General Comments 0
You need to be logged in to leave comments. Login now