##// END OF EJS Templates
imanay -
r243:244
parent child
Show More
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -1,110 +1,110
1 import library3 No newline at end of file
1 import library3
2 import os.path No newline at end of file
2 import os.path
3 No newline at end of file
3
4 class ABSClient(object): No newline at end of file
4 class ABSClient(object):
5 No newline at end of file
5
6 def __init__(self,ipSource="192.168.1.117", iDSource="Clnt_01", ipDestino="192.168.1.117", iDDestino = "CeCnMod", portDestino=7000): No newline at end of file
6 def __init__(self,ipSource="192.168.1.117", iDSource="Clnt_01", ipDestino="192.168.1.117", iDDestino = "CeCnMod", portDestino=7000):
7 No newline at end of file
7
8 self.ipSource = ipSource No newline at end of file
8 self.ipSource = ipSource
9 self.iDSource = iDSource No newline at end of file
9 self.iDSource = iDSource
10 self.ipDestino = ipDestino No newline at end of file
10 self.ipDestino = ipDestino
11 self.iDDestino = iDDestino No newline at end of file
11 self.iDDestino = iDDestino
12 self.portDestino = portDestino No newline at end of file
12 self.portDestino = portDestino
13 No newline at end of file
13
14 self.createObjects() No newline at end of file
14 self.createObjects()
15 No newline at end of file
15
16 def createObjects(self): No newline at end of file
16 def createObjects(self):
17 No newline at end of file
17
18 self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino) No newline at end of file
18 self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino)
19 #self.wFiles = library3.FilesStuff() No newline at end of file
19 #self.wFiles = library3.FilesStuff()
20 No newline at end of file
20
21 def __ConnectionWithCentralControl(self, cmd, data): No newline at end of file
21 def __ConnectionWithCentralControl(self, cmd, data):
22 No newline at end of file
22
23 self.commObj.open_socket() No newline at end of file
23 self.commObj.open_socket()
24 self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino) No newline at end of file
24 self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino)
25 ipSource, ipDestino, cmd, output = self.commObj.waitData() No newline at end of file
25 ipSource, ipDestino, cmd, output = self.commObj.waitData()
26 self.commObj.close_socket() No newline at end of file
26 self.commObj.close_socket()
27 No newline at end of file
27
28 return output No newline at end of file
28 return output
29 No newline at end of file
29
30 # def abs2ControlModuleFormatFile(self, filename): No newline at end of file
30 # def abs2ControlModuleFormatFile(self, filename):
31 # No newline at end of file
31 #
32 # #From matriz to control module format No newline at end of file
32 # #From matriz to control module format
33 # self.wFiles.toCentralControlFormat(filename) No newline at end of file
33 # self.wFiles.toCentralControlFormat(filename)
34 # FileName = "CentralControlFormat.txt" No newline at end of file
34 # FileName = "CentralControlFormat.txt"
35 # F_Obj = open(FileName,"r") No newline at end of file
35 # F_Obj = open(FileName,"r")
36 # FileList = F_Obj.readlines() No newline at end of file
36 # FileList = F_Obj.readlines()
37 # F_Obj.close() No newline at end of file
37 # F_Obj.close()
38 # FileStr = "".join(FileList) No newline at end of file
38 # FileStr = "".join(FileList)
39 # No newline at end of file
39 #
40 # return FileStr No newline at end of file
40 # return FileStr
41 No newline at end of file
41
42 def sendFile(self, filename): No newline at end of file
42 def sendFile(self, filename):
43 No newline at end of file
43
44 data = self.__readFile(filename) No newline at end of file
44 data = self.__readFile(filename)
45 answer = self.__ConnectionWithCentralControl(cmd = "SNDF", data = data) No newline at end of file
45 answer = self.__ConnectionWithCentralControl(cmd = "SNDF", data = data)
46 return answer No newline at end of file
46 return answer
47 No newline at end of file
47
48 def readFile(self,filename): No newline at end of file
48 def readFile(self,filename):
49 No newline at end of file
49
50 data = filename No newline at end of file
50 data = filename
51 file = self.__ConnectionWithCentralControl(cmd = "GETF", data = data)
51 file = self.__ConnectionWithCentralControl(cmd = "GETF", data = data)
No newline at end of file
52 self.__writeFile(filename, file) No newline at end of file
52 No newline at end of file
53 return file No newline at end of file
53 return file
54 No newline at end of file
54
55 def changeBeam(self, newBeam): No newline at end of file
55 def changeBeam(self, newBeam):
56 No newline at end of file
56
57 answer = self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam) No newline at end of file
57 answer = self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam)
58 return answer No newline at end of file
58 return answer
59 No newline at end of file
59
60 def __writeFile(self, filename, data): No newline at end of file
60 def __writeFile(self, filename, data):
61 No newline at end of file
61
62 fobj = open(filename,"w") No newline at end of file
62 fobj = open(filename,"w")
63 fobj.writelines(data) No newline at end of file
63 fobj.writelines(data)
64 fobj.close() No newline at end of file
64 fobj.close()
65 No newline at end of file
65
66 def __readFile(self, filename): No newline at end of file
66 def __readFile(self, filename):
67 No newline at end of file
67
68 fobj = open(filename,"r") No newline at end of file
68 fobj = open(filename,"r")
69 listData = fobj.readlines() No newline at end of file
69 listData = fobj.readlines()
70 fobj.close() No newline at end of file
70 fobj.close()
71 tmp = "".join(listData) No newline at end of file
71 tmp = "".join(listData)
72 #Adding filename to the begining of the data No newline at end of file
72 #Adding filename to the begining of the data
73 newfilename = os.path.split(filename)[1] No newline at end of file
73 newfilename = os.path.split(filename)[1]
74 #data = filename + '\n' + tmp No newline at end of file
74 #data = filename + '\n' + tmp
75 data = newfilename + '\n' + tmp No newline at end of file
75 data = newfilename + '\n' + tmp
76 return data No newline at end of file
76 return data
77 No newline at end of file
77
78 No newline at end of file
78
79 def getControlModuleStatus(self, data): No newline at end of file
79 def getControlModuleStatus(self, data):
80 No newline at end of file
80
81 bits = self.__ConnectionWithCentralControl(cmd = "ANST", data = data) No newline at end of file
81 bits = self.__ConnectionWithCentralControl(cmd = "ANST", data = data)
82 #self.__writeFile("report.txt", data) No newline at end of file
82 #self.__writeFile("report.txt", data)
83 No newline at end of file
83
84 print "Report:\n" No newline at end of file
84 print "Report:\n"
85 print "======:\n" No newline at end of file
85 print "======:\n"
86 print bits No newline at end of file
86 print bits
87 No newline at end of file
87
88 def getControlModulePhase(self, opt, u = "50", pw = "10"): No newline at end of file
88 def getControlModulePhase(self, opt, u = "50", pw = "10"):
89 No newline at end of file
89
90 if opt == '0': No newline at end of file
90 if opt == '0':
91 data = self.__ConnectionWithCentralControl(cmd = "LWPH", data = u + '/' + pw + '/') No newline at end of file
91 data = self.__ConnectionWithCentralControl(cmd = "LWPH", data = u + '/' + pw + '/')
92 elif opt == '1': No newline at end of file
92 elif opt == '1':
93 data = self.__ConnectionWithCentralControl(cmd = "BGPH", data = u + '/' + pw + '/') No newline at end of file
93 data = self.__ConnectionWithCentralControl(cmd = "BGPH", data = u + '/' + pw + '/')
94 elif opt == '2': No newline at end of file
94 elif opt == '2':
95 data = self.__ConnectionWithCentralControl(cmd = "cBPH", data = u + '/' + pw + '/') No newline at end of file
95 data = self.__ConnectionWithCentralControl(cmd = "cBPH", data = u + '/' + pw + '/')
96 else: No newline at end of file
96 else:
97 data = self.__ConnectionWithCentralControl(cmd = "cLPH", data = u + '/' + pw + '/') No newline at end of file
97 data = self.__ConnectionWithCentralControl(cmd = "cLPH", data = u + '/' + pw + '/')
98 # self.__writeFile("report.txt", data) No newline at end of file
98 # self.__writeFile("report.txt", data)
99 No newline at end of file
99
100 def getConnectionStatus(self): No newline at end of file
100 def getConnectionStatus(self):
101 No newline at end of file
101
102 data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none") No newline at end of file
102 data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none")
103 self.__writeFile("connection_status.txt", data) No newline at end of file
103 self.__writeFile("connection_status.txt", data)
104 No newline at end of file
104
105 if __name__ == '__main__': No newline at end of file
105 if __name__ == '__main__':
106 No newline at end of file
106
107 filename = "experimento1.abs" No newline at end of file
107 filename = "experimento1.abs"
108 No newline at end of file
108
109 absObj = ABSClient() No newline at end of file
109 absObj = ABSClient()
110 print absObj.sendFile(filename) No newline at end of file
110 print absObj.sendFile(filename)
General Comments 0
You need to be logged in to leave comments. Login now