@@ -0,0 +1,68 | |||
|
1 | ''' | |
|
2 | Created on Jul 9, 2014 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | import os | |
|
7 | import datetime | |
|
8 | import numpy | |
|
9 | ||
|
10 | from figure import Figure | |
|
11 | ||
|
12 | class Plotter(Figure): | |
|
13 | ||
|
14 | isConfig = None | |
|
15 | name = None | |
|
16 | plotterQueue = None | |
|
17 | ||
|
18 | def __init__(self, plotter_name, plotter_queue=None): | |
|
19 | ||
|
20 | self.isConfig = False | |
|
21 | self.name = plotter_name | |
|
22 | self.plotterQueue = plotter_queue | |
|
23 | ||
|
24 | def getSubplots(self): | |
|
25 | ||
|
26 | nrow = self.nplots | |
|
27 | ncol = 1 | |
|
28 | return nrow, ncol | |
|
29 | ||
|
30 | def setup(self, **kwargs): | |
|
31 | ||
|
32 | # self.nplots = nplots | |
|
33 | # | |
|
34 | # self.createFigure(id=id, | |
|
35 | # wintitle=wintitle, | |
|
36 | # show=show) | |
|
37 | # | |
|
38 | # nrow,ncol = self.getSubplots() | |
|
39 | # colspan = 3 | |
|
40 | # rowspan = 1 | |
|
41 | # | |
|
42 | # for i in range(nplots): | |
|
43 | # self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
|
44 | ||
|
45 | ||
|
46 | ||
|
47 | print "Initializing ..." | |
|
48 | ||
|
49 | ||
|
50 | def run(self, dataOut, **kwargs): | |
|
51 | ||
|
52 | """ | |
|
53 | ||
|
54 | Input: | |
|
55 | dataOut : | |
|
56 | id : | |
|
57 | wintitle : | |
|
58 | channelList : | |
|
59 | show : | |
|
60 | """ | |
|
61 | ||
|
62 | if not self.isConfig: | |
|
63 | self.setup(**kwargs) | |
|
64 | self.isConfig=True | |
|
65 | ||
|
66 | print "Putting data on %s queue:" %self.name | |
|
67 | print kwargs | |
|
68 |
@@ -4,4 +4,4 Created on Feb 7, 2012 | |||
|
4 | 4 | @author $Author$ |
|
5 | 5 | @version $Id$ |
|
6 | 6 | ''' |
|
7 |
__version__ = "2.1.4. |
|
|
7 | __version__ = "2.1.4.2" No newline at end of file |
@@ -377,11 +377,15 class OperationConf(): | |||
|
377 | 377 | for parmConfObj in self.parmConfObjList: |
|
378 | 378 | parmConfObj.printattr() |
|
379 | 379 | |
|
380 | def createObject(self): | |
|
380 | def createObject(self, plotter_queue=None): | |
|
381 | 381 | |
|
382 | 382 | if self.type == 'self': |
|
383 | 383 | raise ValueError, "This operation type cannot be created" |
|
384 | 384 | |
|
385 | if self.type == 'plotter': | |
|
386 | #Plotter(plotter_name) | |
|
387 | opObj = Plotter(self.name, plotter_queue) | |
|
388 | ||
|
385 | 389 | if self.type == 'external' or self.type == 'other': |
|
386 | 390 | className = eval(self.name) |
|
387 | 391 | opObj = className() |
@@ -587,7 +591,7 class ProcUnitConf(): | |||
|
587 | 591 | for opConfObj in self.opConfObjList: |
|
588 | 592 | opConfObj.printattr() |
|
589 | 593 | |
|
590 | def createObjects(self): | |
|
594 | def createObjects(self, plotter_queue=None): | |
|
591 | 595 | |
|
592 | 596 | className = eval(self.name) |
|
593 | 597 | procUnitObj = className() |
@@ -597,7 +601,7 class ProcUnitConf(): | |||
|
597 | 601 | if opConfObj.type == 'self': |
|
598 | 602 | continue |
|
599 | 603 | |
|
600 | opObj = opConfObj.createObject() | |
|
604 | opObj = opConfObj.createObject(plotter_queue) | |
|
601 | 605 | |
|
602 | 606 | self.opObjDict[opConfObj.id] = opObj |
|
603 | 607 | procUnitObj.addOperation(opObj, opConfObj.id) |
@@ -816,12 +820,17 class Project(): | |||
|
816 | 820 | |
|
817 | 821 | ELEMENTNAME = 'Project' |
|
818 | 822 | |
|
819 | def __init__(self): | |
|
823 | __plotterQueue = None | |
|
824 | ||
|
825 | def __init__(self, filename="./schain.xml", plotter_queue=None): | |
|
820 | 826 | |
|
821 | 827 | self.id = None |
|
822 | 828 | self.name = None |
|
823 | 829 | self.description = None |
|
824 | 830 | |
|
831 | self.filename = filename | |
|
832 | self.__plotterQueue = plotter_queue | |
|
833 | ||
|
825 | 834 | self.procUnitConfObjDict = {} |
|
826 | 835 | |
|
827 | 836 | def __getNewId(self): |
@@ -1023,7 +1032,7 class Project(): | |||
|
1023 | 1032 | def createObjects(self): |
|
1024 | 1033 | |
|
1025 | 1034 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
1026 | procUnitConfObj.createObjects() | |
|
1035 | procUnitConfObj.createObjects(self.__plotterQueue) | |
|
1027 | 1036 | |
|
1028 | 1037 | def __connect(self, objIN, thisObj): |
|
1029 | 1038 | |
@@ -1113,7 +1122,19 class Project(): | |||
|
1113 | 1122 | return 0 |
|
1114 | 1123 | |
|
1115 | 1124 | return 1 |
|
1125 | ||
|
1126 | def setFilename(self, filename): | |
|
1127 | ||
|
1128 | self.filename = filename | |
|
1129 | ||
|
1130 | def setPlotterQueue(self, plotter_queue): | |
|
1131 | ||
|
1132 | self.__plotterQueue = plotter_queue | |
|
1116 | 1133 | |
|
1134 | def getPlotterQueue(self): | |
|
1135 | ||
|
1136 | return self.__plotterQueue | |
|
1137 | ||
|
1117 | 1138 | def run(self): |
|
1118 | 1139 | |
|
1119 | 1140 | |
@@ -1164,15 +1185,12 class Project(): | |||
|
1164 | 1185 | procUnitConfObj.close() |
|
1165 | 1186 | |
|
1166 | 1187 | print "Process finished" |
|
1167 | ||
|
1168 | def start(self, filename): | |
|
1169 | 1188 | |
|
1170 | if not self.writeXml(filename): | |
|
1171 | return | |
|
1189 | def start(self): | |
|
1172 | 1190 | |
|
1173 |
if not self.re |
|
|
1191 | if not self.writeXml(self.filename): | |
|
1174 | 1192 | return |
|
1175 | ||
|
1193 | ||
|
1176 | 1194 | self.createObjects() |
|
1177 | 1195 | self.connectObjects() |
|
1178 | 1196 | self.run() |
@@ -4,15 +4,13 from schainpy.controller import Project | |||
|
4 | 4 | |
|
5 | 5 | class ControllerThread(threading.Thread, Project): |
|
6 | 6 | |
|
7 | def __init__(self, filename): | |
|
7 | def __init__(self, filename=None, plotter_queue=None): | |
|
8 | 8 | |
|
9 | 9 | threading.Thread.__init__(self) |
|
10 | Project.__init__(self) | |
|
10 | Project.__init__(self, filename, plotter_queue) | |
|
11 | 11 | |
|
12 | 12 | self.setDaemon(True) |
|
13 | 13 | |
|
14 | self.filename = filename | |
|
15 | ||
|
16 | 14 | self.lock = threading.Lock() |
|
17 | 15 | self.control = {'stop':False, 'pause':False} |
|
18 | 16 |
@@ -2,4 +2,5 from jroplot_voltage import * | |||
|
2 | 2 | from jroplot_spectra import * |
|
3 | 3 | from jroplot_heispectra import * |
|
4 | 4 | from jroplot_correlation import * |
|
5 | from jroplot_parameters import * No newline at end of file | |
|
5 | from jroplot_parameters import * | |
|
6 | from jroplotter import * No newline at end of file |
@@ -161,26 +161,31 class ProcessingUnit(object): | |||
|
161 | 161 | |
|
162 | 162 | opType : Puede ser "self" o "external" |
|
163 | 163 | |
|
164 |
|
|
|
164 | Depende del tipo de operacion para llamar a:callMethod or callObject: | |
|
165 | 165 | |
|
166 |
1. |
|
|
166 | 1. If opType = "self": Llama a un metodo propio de esta clase: | |
|
167 | ||
|
168 | name_method = getattr(self, name) | |
|
169 | name_method(**kwargs) | |
|
167 | 170 | |
|
168 | opType = "self" | |
|
169 | 171 | |
|
170 | 2. El metodo "run" de un objeto del tipo Operation o de un derivado de ella: | |
|
172 | 2. If opType = "other" o"external": Llama al metodo "run()" de una instancia de la | |
|
173 | clase "Operation" o de un derivado de ella: | |
|
171 | 174 | |
|
172 | opType = "other" or "external". | |
|
175 | instanceName = self.operationList[opId] | |
|
176 | instanceName.run(**kwargs) | |
|
173 | 177 | |
|
174 | 178 | opName : Si la operacion es interna (opType = 'self'), entonces el "opName" sera |
|
175 | 179 | usada para llamar a un metodo interno de la clase Processing |
|
176 | 180 | |
|
177 |
opId : Si la operacion es externa (opType = 'other'), entonces el |
|
|
178 |
usada para llamar al metodo "run" de la clase Operation |
|
|
181 | opId : Si la operacion es externa (opType = 'other' o 'external), entonces el | |
|
182 | "opId" sera usada para llamar al metodo "run" de la clase Operation | |
|
183 | registrada anteriormente con ese Id | |
|
179 | 184 | |
|
180 | 185 | Exception: |
|
181 | 186 | Este objeto de tipo Operation debe de haber sido agregado antes con el metodo: |
|
182 | 187 | "addOperation" e identificado con el valor "opId" = el id de la operacion. |
|
183 |
De lo contrario retornara un error del tipo |
|
|
188 | De lo contrario retornara un error del tipo ValueError | |
|
184 | 189 | |
|
185 | 190 | """ |
|
186 | 191 | |
@@ -191,16 +196,19 class ProcessingUnit(object): | |||
|
191 | 196 | |
|
192 | 197 | sts = self.callMethod(opName, **kwargs) |
|
193 | 198 | |
|
194 | if opType == 'other' or opType == 'external': | |
|
199 | elif opType == 'other' or opType == 'external' or opType == 'plotter': | |
|
195 | 200 | |
|
196 | 201 | if not opId: |
|
197 | 202 | raise ValueError, "opId parameter should be defined" |
|
198 | 203 | |
|
199 | 204 | if opId not in self.operations2RunDict.keys(): |
|
200 |
raise ValueError, " |
|
|
205 | raise ValueError, "Any operation with id=%s has been added" %str(opId) | |
|
201 | 206 | |
|
202 | 207 | sts = self.callObject(opId, **kwargs) |
|
203 | 208 | |
|
209 | else: | |
|
210 | raise ValueError, "opType should be 'self', 'external' or 'plotter'; and not '%s'" %opType | |
|
211 | ||
|
204 | 212 | return sts |
|
205 | 213 | |
|
206 | 214 | def setInput(self, dataIn): |
General Comments 0
You need to be logged in to leave comments.
Login now