@@ -17,3 +17,7 VERSIONS: | |||||
17 | 2.1.3.1: |
|
17 | 2.1.3.1: | |
18 | -GUI: every icon were resized |
|
18 | -GUI: every icon were resized | |
19 | -jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file |
|
19 | -jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file | |
|
20 | ||||
|
21 | 2.1.3.2: | |||
|
22 | -GUI: user interaction enhanced | |||
|
23 | -controller_api.py: Safe access to ControllerThead No newline at end of file |
@@ -4,4 +4,4 Created on Feb 7, 2012 | |||||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
__version__ = "2.1.3. |
|
7 | __version__ = "2.1.3.2" No newline at end of file |
@@ -6,13 +6,14 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring | |||||
6 | from xml.dom import minidom |
|
6 | from xml.dom import minidom | |
7 |
|
7 | |||
8 | from model import * |
|
8 | from model import * | |
9 |
|
9 | from time import sleep | ||
10 | try: |
|
|||
11 | from gevent import sleep |
|
|||
12 | except: |
|
|||
13 | from time import sleep |
|
|||
14 |
|
10 | |||
|
11 | import sys | |||
15 | import ast |
|
12 | import ast | |
|
13 | import traceback | |||
|
14 | ||||
|
15 | SCHAIN_MAIL = "miguel.urco@jro.igp.gob.pe" | |||
|
16 | EMAIL_SERVER = "jro.igp.gob.pe" | |||
16 |
|
17 | |||
17 | def prettify(elem): |
|
18 | def prettify(elem): | |
18 | """Return a pretty-printed XML string for the Element. |
|
19 | """Return a pretty-printed XML string for the Element. | |
@@ -603,7 +604,7 class ProcUnitConf(): | |||||
603 |
|
604 | |||
604 | def run(self): |
|
605 | def run(self): | |
605 |
|
606 | |||
606 |
|
|
607 | is_ok = False | |
607 |
|
608 | |||
608 | for opConfObj in self.opConfObjList: |
|
609 | for opConfObj in self.opConfObjList: | |
609 |
|
610 | |||
@@ -619,9 +620,9 class ProcUnitConf(): | |||||
619 | opName = opConfObj.name, |
|
620 | opName = opConfObj.name, | |
620 | opId = opConfObj.id, |
|
621 | opId = opConfObj.id, | |
621 | **kwargs) |
|
622 | **kwargs) | |
622 |
|
|
623 | is_ok = is_ok or sts | |
623 |
|
624 | |||
624 |
return |
|
625 | return is_ok | |
625 |
|
626 | |||
626 | def close(self): |
|
627 | def close(self): | |
627 |
|
628 | |||
@@ -763,7 +764,7 class Project(): | |||||
763 |
|
764 | |||
764 | ELEMENTNAME = 'Project' |
|
765 | ELEMENTNAME = 'Project' | |
765 |
|
766 | |||
766 |
def __init__(self |
|
767 | def __init__(self): | |
767 |
|
768 | |||
768 | self.id = None |
|
769 | self.id = None | |
769 | self.name = None |
|
770 | self.name = None | |
@@ -771,14 +772,6 class Project(): | |||||
771 |
|
772 | |||
772 | self.procUnitConfObjDict = {} |
|
773 | self.procUnitConfObjDict = {} | |
773 |
|
774 | |||
774 | #global data_q |
|
|||
775 | #data_q = dataq |
|
|||
776 |
|
||||
777 | if control==None: |
|
|||
778 | control = {'stop':False,'pause':False} |
|
|||
779 |
|
||||
780 | self.control = control |
|
|||
781 |
|
||||
782 | def __getNewId(self): |
|
775 | def __getNewId(self): | |
783 |
|
776 | |||
784 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
777 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 | |
@@ -979,12 +972,43 class Project(): | |||||
979 |
|
972 | |||
980 | self.__connect(puObjIN, thisPUObj) |
|
973 | self.__connect(puObjIN, thisPUObj) | |
981 |
|
974 | |||
|
975 | def isPaused(self): | |||
|
976 | return 0 | |||
|
977 | ||||
|
978 | def isStopped(self): | |||
|
979 | return 0 | |||
|
980 | ||||
|
981 | def runController(self): | |||
|
982 | """ | |||
|
983 | returns 0 when this process has been stopped, 1 otherwise | |||
|
984 | """ | |||
|
985 | ||||
|
986 | if self.isPaused(): | |||
|
987 | print "Process suspended" | |||
|
988 | ||||
|
989 | while True: | |||
|
990 | sleep(0.1) | |||
|
991 | ||||
|
992 | if not self.isPaused(): | |||
|
993 | break | |||
|
994 | ||||
|
995 | if self.isStopped(): | |||
|
996 | break | |||
|
997 | ||||
|
998 | print "Process reinitialized" | |||
|
999 | ||||
|
1000 | if self.isStopped(): | |||
|
1001 | print "Process stopped" | |||
|
1002 | return 0 | |||
|
1003 | ||||
|
1004 | return 1 | |||
|
1005 | ||||
982 | def run(self): |
|
1006 | def run(self): | |
983 |
|
1007 | |||
984 |
|
1008 | |||
985 |
print "*"* |
|
1009 | print "*"*60 | |
986 | print " Starting SIGNAL CHAIN PROCESSING " |
|
1010 | print " Starting SIGNAL CHAIN PROCESSING " | |
987 |
print "*"* |
|
1011 | print "*"*60 | |
988 |
|
1012 | |||
989 |
|
1013 | |||
990 | keyList = self.procUnitConfObjDict.keys() |
|
1014 | keyList = self.procUnitConfObjDict.keys() | |
@@ -992,35 +1016,40 class Project(): | |||||
992 |
|
1016 | |||
993 | while(True): |
|
1017 | while(True): | |
994 |
|
1018 | |||
995 |
|
|
1019 | is_ok = False | |
996 |
|
1020 | |||
997 | for procKey in keyList: |
|
1021 | for procKey in keyList: | |
998 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
1022 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
999 |
|
1023 | |||
1000 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1024 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
1001 | sts = procUnitConfObj.run() |
|
1025 | ||
1002 | finalSts = finalSts or sts |
|
1026 | message = "" | |
|
1027 | try: | |||
|
1028 | sts = procUnitConfObj.run() | |||
|
1029 | is_ok = is_ok or sts | |||
|
1030 | except: | |||
|
1031 | sleep(1) | |||
|
1032 | err = traceback.format_exception(sys.exc_info()[0], | |||
|
1033 | sys.exc_info()[1], | |||
|
1034 | sys.exc_info()[2]) | |||
|
1035 | ||||
|
1036 | for thisLine in err: | |||
|
1037 | message += thisLine | |||
|
1038 | ||||
|
1039 | print message | |||
|
1040 | # self.sendReport(message) | |||
|
1041 | sleep(0.1) | |||
|
1042 | is_ok = False | |||
|
1043 | ||||
|
1044 | break | |||
1003 |
|
1045 | |||
1004 | #If every process unit finished so end process |
|
1046 | #If every process unit finished so end process | |
1005 |
if not( |
|
1047 | if not(is_ok): | |
|
1048 | print message | |||
1006 | print "Every process unit have finished" |
|
1049 | print "Every process unit have finished" | |
1007 | break |
|
1050 | break | |
1008 |
|
1051 | |||
1009 |
if self. |
|
1052 | if not self.runController(): | |
1010 | print "Process suspended" |
|
|||
1011 |
|
||||
1012 | while True: |
|
|||
1013 | sleep(0.1) |
|
|||
1014 |
|
||||
1015 | if not self.control['pause']: |
|
|||
1016 | break |
|
|||
1017 |
|
||||
1018 | if self.control['stop']: |
|
|||
1019 | break |
|
|||
1020 | print "Process reinitialized" |
|
|||
1021 |
|
||||
1022 | if self.control['stop']: |
|
|||
1023 | # print "Process stopped" |
|
|||
1024 | break |
|
1053 | break | |
1025 |
|
1054 | |||
1026 | #Closing every process |
|
1055 | #Closing every process | |
@@ -1038,6 +1067,23 class Project(): | |||||
1038 | self.createObjects() |
|
1067 | self.createObjects() | |
1039 | self.connectObjects() |
|
1068 | self.connectObjects() | |
1040 | self.run() |
|
1069 | self.run() | |
|
1070 | ||||
|
1071 | def sendReport(self, message, subject="Error occurred in Signal Chain", email=SCHAIN_MAIL): | |||
|
1072 | ||||
|
1073 | import smtplib | |||
|
1074 | ||||
|
1075 | print subject | |||
|
1076 | print "Sending report to %s ..." %email | |||
|
1077 | ||||
|
1078 | message = 'From: (Python Signal Chain API) ' + email + '\n' + \ | |||
|
1079 | 'To: ' + email + '\n' + \ | |||
|
1080 | 'Subject: ' + str(subject) + '\n' + \ | |||
|
1081 | 'Content-type: text/html\n\n' + message | |||
|
1082 | ||||
|
1083 | server = smtplib.SMTP(EMAIL_SERVER) | |||
|
1084 | server.sendmail(email.split(',')[0], | |||
|
1085 | email.split(','), message) | |||
|
1086 | server.quit() | |||
1041 |
|
1087 | |||
1042 | if __name__ == '__main__': |
|
1088 | if __name__ == '__main__': | |
1043 |
|
1089 |
@@ -15,80 +15,49 class ControllerThread(threading.Thread, Project): | |||||
15 | self.setDaemon(True) |
|
15 | self.setDaemon(True) | |
16 |
|
16 | |||
17 | self.filename = filename |
|
17 | self.filename = filename | |
|
18 | ||||
|
19 | self.lock = threading.Lock() | |||
18 | self.control = {'stop':False, 'pause':False} |
|
20 | self.control = {'stop':False, 'pause':False} | |
19 |
|
21 | |||
20 | def __del__(self): |
|
22 | def __del__(self): | |
21 |
|
23 | |||
22 | self.control['stop'] = True |
|
24 | self.control['stop'] = True | |
23 | # self.pause(1) |
|
|||
24 | # self.wait() |
|
|||
25 |
|
25 | |||
26 | def stop(self): |
|
26 | def stop(self): | |
|
27 | ||||
|
28 | self.lock.acquire() | |||
|
29 | ||||
27 | self.control['stop'] = True |
|
30 | self.control['stop'] = True | |
28 |
|
31 | |||
|
32 | self.lock.release() | |||
|
33 | ||||
29 | def pause(self): |
|
34 | def pause(self): | |
|
35 | ||||
|
36 | self.lock.acquire() | |||
|
37 | ||||
30 | self.control['pause'] = not(self.control['pause']) |
|
38 | self.control['pause'] = not(self.control['pause']) | |
|
39 | paused = self.control['pause'] | |||
|
40 | ||||
|
41 | self.lock.release() | |||
31 |
|
42 | |||
32 |
return |
|
43 | return paused | |
33 |
|
44 | |||
34 |
def |
|
45 | def isPaused(self): | |
35 |
|
46 | |||
36 |
|
47 | self.lock.acquire() | ||
37 | print "*"*40 |
|
48 | paused = self.control['pause'] | |
38 | print " Starting SIGNAL CHAIN PROCESSING " |
|
49 | self.lock.release() | |
39 | print "*"*40 |
|
|||
40 |
|
||||
41 |
|
50 | |||
42 | keyList = self.procUnitConfObjDict.keys() |
|
51 | return paused | |
43 | keyList.sort() |
|
52 | ||
44 |
|
53 | def isStopped(self): | ||
45 | while(True): |
|
|||
46 |
|
||||
47 | finalSts = False |
|
|||
48 | #executed proc units |
|
|||
49 | procUnitExecutedList = [] |
|
|||
50 |
|
||||
51 | for procKey in keyList: |
|
|||
52 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
|||
53 |
|
||||
54 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
|||
55 |
|
||||
56 | inputId = procUnitConfObj.getInputId() |
|
|||
57 |
|
||||
58 | sts = procUnitConfObj.run() |
|
|||
59 | finalSts = finalSts or sts |
|
|||
60 |
|
||||
61 | procUnitExecutedList.append(procUnitConfObj.id) |
|
|||
62 |
|
||||
63 | #If every process unit finished so end process |
|
|||
64 | if not(finalSts): |
|
|||
65 | print "Every process unit have finished" |
|
|||
66 | break |
|
|||
67 |
|
||||
68 | if self.control['pause']: |
|
|||
69 | print "Process suspended" |
|
|||
70 |
|
||||
71 | while True: |
|
|||
72 | sleep(0.1) |
|
|||
73 |
|
||||
74 | if not self.control['pause']: |
|
|||
75 | break |
|
|||
76 |
|
||||
77 | if self.control['stop']: |
|
|||
78 | break |
|
|||
79 | print "Process reinitialized" |
|
|||
80 |
|
||||
81 | if self.control['stop']: |
|
|||
82 | # print "Process stopped" |
|
|||
83 | break |
|
|||
84 |
|
||||
85 | #Closing every process |
|
|||
86 | for procKey in keyList: |
|
|||
87 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
|||
88 | procUnitConfObj.close() |
|
|||
89 |
|
||||
90 | print "Process finished" |
|
|||
91 |
|
54 | |||
|
55 | self.lock.acquire() | |||
|
56 | stopped = self.control['stop'] | |||
|
57 | self.lock.release() | |||
|
58 | ||||
|
59 | return stopped | |||
|
60 | ||||
92 | def run(self): |
|
61 | def run(self): | |
93 | self.control['stop'] = False |
|
62 | self.control['stop'] = False | |
94 | self.control['pause'] = False |
|
63 | self.control['pause'] = False | |
@@ -114,6 +83,8 class ControllerQThread(QtCore.QThread, Project): | |||||
114 | Project.__init__(self) |
|
83 | Project.__init__(self) | |
115 |
|
84 | |||
116 | self.filename = filename |
|
85 | self.filename = filename | |
|
86 | ||||
|
87 | self.lock = threading.Lock() | |||
117 | self.control = {'stop':False, 'pause':False} |
|
88 | self.control = {'stop':False, 'pause':False} | |
118 |
|
89 | |||
119 | def __del__(self): |
|
90 | def __del__(self): | |
@@ -122,12 +93,42 class ControllerQThread(QtCore.QThread, Project): | |||||
122 | self.wait() |
|
93 | self.wait() | |
123 |
|
94 | |||
124 | def stop(self): |
|
95 | def stop(self): | |
|
96 | ||||
|
97 | self.lock.acquire() | |||
|
98 | ||||
125 | self.control['stop'] = True |
|
99 | self.control['stop'] = True | |
126 |
|
100 | |||
|
101 | self.lock.release() | |||
|
102 | ||||
127 | def pause(self): |
|
103 | def pause(self): | |
|
104 | ||||
|
105 | self.lock.acquire() | |||
|
106 | ||||
128 | self.control['pause'] = not(self.control['pause']) |
|
107 | self.control['pause'] = not(self.control['pause']) | |
129 |
|
108 | paused = self.control['pause'] | ||
|
109 | ||||
|
110 | self.lock.release() | |||
|
111 | ||||
|
112 | return paused | |||
|
113 | ||||
|
114 | def isPaused(self): | |||
|
115 | ||||
|
116 | self.lock.acquire() | |||
|
117 | paused = self.control['pause'] | |||
|
118 | self.lock.release() | |||
|
119 | ||||
|
120 | return paused | |||
|
121 | ||||
|
122 | def isStopped(self): | |||
|
123 | ||||
|
124 | self.lock.acquire() | |||
|
125 | stopped = self.control['stop'] | |||
|
126 | self.lock.release() | |||
|
127 | ||||
|
128 | return stopped | |||
|
129 | ||||
130 | def run(self): |
|
130 | def run(self): | |
|
131 | ||||
131 | self.control['stop'] = False |
|
132 | self.control['stop'] = False | |
132 | self.control['pause'] = False |
|
133 | self.control['pause'] = False | |
133 |
|
134 | |||
@@ -136,4 +137,5 class ControllerQThread(QtCore.QThread, Project): | |||||
136 | self.connectObjects() |
|
137 | self.connectObjects() | |
137 | self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) |
|
138 | self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) | |
138 | Project.run(self) |
|
139 | Project.run(self) | |
139 | self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) No newline at end of file |
|
140 | self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) | |
|
141 | No newline at end of file |
@@ -5892,6 +5892,10 class ShowMeConsole(QtCore.QObject): | |||||
5892 |
|
5892 | |||
5893 | def write(self, text): |
|
5893 | def write(self, text): | |
5894 |
|
5894 | |||
|
5895 | if len(text) == 0: | |||
|
5896 | self.textWritten.emit("\n") | |||
|
5897 | return | |||
|
5898 | ||||
5895 | if text[-1] == "\n": |
|
5899 | if text[-1] == "\n": | |
5896 | text = text[:-1] |
|
5900 | text = text[:-1] | |
5897 |
|
5901 |
@@ -287,10 +287,9 class Ui_EnvWindow(object): | |||||
287 | def aboutEvent(self): |
|
287 | def aboutEvent(self): | |
288 | title = "Signal Chain Processing Software v%s" %__version__ |
|
288 | title = "Signal Chain Processing Software v%s" %__version__ | |
289 | message = """ |
|
289 | message = """ | |
290 |
|
|
290 | Developed by Jicamarca Radio Observatory | |
291 |
|
|
291 | Any comment to miguel.urco@jro.igp.gob.pe | |
292 | """ |
|
292 | """ | |
293 |
|
||||
294 | QtGui.QMessageBox.about(self, title, message) |
|
293 | QtGui.QMessageBox.about(self, title, message) | |
295 |
|
294 | |||
296 |
|
295 |
@@ -84,11 +84,14 class Header(object): | |||||
84 |
|
84 | |||
85 | def printInfo(self): |
|
85 | def printInfo(self): | |
86 |
|
86 | |||
87 | print "#"*100 |
|
87 | message = "#"*50 + "\n" | |
88 |
|
|
88 | message += self.__class__.__name__.upper() + "\n" | |
89 | print "#"*100 |
|
89 | message += "#"*50 + "\n" | |
|
90 | ||||
90 | for key in self.__dict__.keys(): |
|
91 | for key in self.__dict__.keys(): | |
91 |
|
|
92 | message += "%s = %s" %(key, self.__dict__[key]) + "\n" | |
|
93 | ||||
|
94 | print message | |||
92 |
|
95 | |||
93 | class BasicHeader(Header): |
|
96 | class BasicHeader(Header): | |
94 |
|
97 |
@@ -7,7 +7,7 if 'linux' in sys.platform: | |||||
7 | matplotlib.use("TKAgg") |
|
7 | matplotlib.use("TKAgg") | |
8 |
|
8 | |||
9 | if 'darwin' in sys.platform: |
|
9 | if 'darwin' in sys.platform: | |
10 |
matplotlib.use(' |
|
10 | matplotlib.use('WXAgg') | |
11 | #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX' |
|
11 | #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX' | |
12 | import matplotlib.pyplot |
|
12 | import matplotlib.pyplot | |
13 |
|
13 | |||
@@ -33,27 +33,27 def createFigure(id, wintitle, width, height, facecolor="w", show=True): | |||||
33 | def closeFigure(show=False, fig=None): |
|
33 | def closeFigure(show=False, fig=None): | |
34 |
|
34 | |||
35 | matplotlib.pyplot.ioff() |
|
35 | matplotlib.pyplot.ioff() | |
36 | matplotlib.pyplot.pause(0.1) |
|
36 | # matplotlib.pyplot.pause(0.1) | |
37 |
|
37 | |||
38 | if show: |
|
38 | if show: | |
39 | matplotlib.pyplot.show() |
|
39 | matplotlib.pyplot.show() | |
40 |
|
40 | |||
41 | if fig != None: |
|
41 | if fig != None: | |
42 | matplotlib.pyplot.close(fig) |
|
42 | matplotlib.pyplot.close(fig.number) | |
43 | matplotlib.pyplot.pause(0.1) |
|
43 | # matplotlib.pyplot.pause(0.1) | |
44 | matplotlib.pyplot.ion() |
|
44 | # matplotlib.pyplot.ion() | |
45 | return |
|
45 | return | |
46 |
|
46 | |||
47 | matplotlib.pyplot.close("all") |
|
47 | matplotlib.pyplot.close("all") | |
48 | matplotlib.pyplot.pause(0.1) |
|
48 | # matplotlib.pyplot.pause(0.1) | |
49 | matplotlib.pyplot.ion() |
|
49 | # matplotlib.pyplot.ion() | |
50 | return |
|
50 | return | |
51 |
|
51 | |||
52 | def saveFigure(fig, filename): |
|
52 | def saveFigure(fig, filename): | |
53 |
|
53 | |||
54 | matplotlib.pyplot.ioff() |
|
54 | # matplotlib.pyplot.ioff() | |
55 | fig.savefig(filename) |
|
55 | fig.savefig(filename) | |
56 | matplotlib.pyplot.ion() |
|
56 | # matplotlib.pyplot.ion() | |
57 |
|
57 | |||
58 | def setWinTitle(fig, title): |
|
58 | def setWinTitle(fig, title): | |
59 |
|
59 |
@@ -33,6 +33,7 setup(name="schainpy", | |||||
33 | install_requires=["numpy >= 1.6.0", |
|
33 | install_requires=["numpy >= 1.6.0", | |
34 | "scipy >= 0.9.0", |
|
34 | "scipy >= 0.9.0", | |
35 | "h5py >= 2.0.1", |
|
35 | "h5py >= 2.0.1", | |
|
36 | "wxpython >= 2.8", | |||
36 | "matplotlib >= 1.0.0" |
|
37 | "matplotlib >= 1.0.0" | |
37 | ], |
|
38 | ], | |
38 | ) No newline at end of file |
|
39 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now