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