##// END OF EJS Templates
schain serializer: minor changes
schain serializer: minor changes

File last commit:

r703:b448cc54ea50
r705:2b21a763c9a1
Show More
jroplotter.py
110 lines | 2.5 KiB | text/x-python | PythonLexer
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691 '''
Created on Jul 9, 2014
@author: roj-idl71
'''
import os
import datetime
import numpy
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 from time import sleep
from Queue import Queue
from threading import Thread
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 from schainpy.model.proc.jroproc_base import Operation
from schainpy.model.serializer.data import obj2Dict, dict2Obj
Miguel Valdez
ImportError when msgpack is not installed
r701 from jroplot_correlation import *
from jroplot_heispectra import *
from jroplot_parameters import *
from jroplot_spectra import *
from jroplot_voltage import *
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698
class Plotter(Operation):
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
isConfig = None
name = None
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 __queue = None
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
def __init__(self, plotter_name, plotter_queue=None):
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 Operation.__init__(self)
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691 self.isConfig = False
self.name = plotter_name
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 self.__queue = plotter_queue
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
def getSubplots(self):
nrow = self.nplots
ncol = 1
return nrow, ncol
def setup(self, **kwargs):
print "Initializing ..."
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 def run(self, dataOut, id=None, **kwargs):
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
"""
Input:
dataOut :
id :
"""
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 packDict = {}
packDict['id'] = id
packDict['name'] = self.name
packDict['kwargs'] = kwargs
packDict['data'] = obj2Dict(dataOut)
self.__queue.put(packDict)
class PlotterManager(Thread):
__stop = False
def __init__(self, plotter_queue):
Thread.__init__(self)
Miguel Valdez
jroplotter.py updated
r703 self.setDaemon(True)
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 self.__queue = plotter_queue
self.plotInstanceDict = {}
self.__stop = False
def run(self):
while True:
if self.__stop:
break
if self.__queue.empty():
Miguel Valdez
jroplotter.py updated
r703 sleep(0.1)
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 continue
serial_data = self.__queue.get(True)
plot_id = serial_data['id']
plot_name = serial_data['name']
kwargs = serial_data['kwargs']
dataDict = serial_data['data']
dataPlot = dict2Obj(dataDict)
if plot_id not in self.plotInstanceDict.keys():
className = eval(plot_name)
self.plotInstanceDict[plot_id] = className()
plotter = self.plotInstanceDict[plot_id]
plotter.run(dataPlot, plot_id, **kwargs)
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 def stop(self):
Miguel Valdez
A new Plotter Class was added for plotting using queues
r691
Miguel Valdez
SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain
r698 self.__stop = True