From 060cd0e7af3385a69ea86b8e9bc80f774e4070f6 2015-12-03 05:02:08 From: Miguel Valdez Date: 2015-12-03 05:02:08 Subject: [PATCH] SChain v2.1.5: jroplotter.py and testPlotter.py were added to Signal Chain --- diff --git a/schainpy/VERSION b/schainpy/VERSION index 0a539ce..ca06fbd 100644 --- a/schainpy/VERSION +++ b/schainpy/VERSION @@ -34,4 +34,9 @@ VERSIONS: 2.1.4.2: -A new Plotter Class was added +-Project.start() does not accept filename as a parameter anymore + +2.1.5: +-serializer module added to Signal Chain +-jroplotter.py added to Signal Chain diff --git a/schainpy/__init__.py b/schainpy/__init__.py index 26b6d8f..d8e4bb1 100644 --- a/schainpy/__init__.py +++ b/schainpy/__init__.py @@ -4,4 +4,4 @@ Created on Feb 7, 2012 @author $Author$ @version $Id$ ''' -__version__ = "2.1.4.2" \ No newline at end of file +__version__ = "2.1.5" \ No newline at end of file diff --git a/schainpy/model/graphics/jroplotter.py b/schainpy/model/graphics/jroplotter.py index 485d169..cfafd76 100644 --- a/schainpy/model/graphics/jroplotter.py +++ b/schainpy/model/graphics/jroplotter.py @@ -7,19 +7,27 @@ import os import datetime import numpy -from figure import Figure +from time import sleep +from Queue import Queue +from threading import Thread -class Plotter(Figure): +from schainpy.model.proc.jroproc_base import Operation +from schainpy.model.serializer.data import obj2Dict, dict2Obj +from schainpy.model.graphics import * + +class Plotter(Operation): isConfig = None name = None - plotterQueue = None + __queue = None def __init__(self, plotter_name, plotter_queue=None): + Operation.__init__(self) + self.isConfig = False self.name = plotter_name - self.plotterQueue = plotter_queue + self.__queue = plotter_queue def getSubplots(self): @@ -29,40 +37,68 @@ class Plotter(Figure): def setup(self, **kwargs): -# self.nplots = nplots -# -# self.createFigure(id=id, -# wintitle=wintitle, -# show=show) -# -# nrow,ncol = self.getSubplots() -# colspan = 3 -# rowspan = 1 -# -# for i in range(nplots): -# self.addAxes(nrow, ncol, i, 0, colspan, rowspan) - - - print "Initializing ..." - def run(self, dataOut, **kwargs): + def run(self, dataOut, id=None, **kwargs): """ Input: dataOut : id : - wintitle : - channelList : - show : """ - if not self.isConfig: - self.setup(**kwargs) - self.isConfig=True + 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) + + self.__queue = plotter_queue + + self.plotInstanceDict = {} + self.__stop = False + + def run(self): + + while True: + + if self.__stop: + break + + if self.__queue.empty(): + sleep(0.5) + 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) - print "Putting data on %s queue:" %self.name - print kwargs + def stop(self): + self.__stop = True \ No newline at end of file