##// END OF EJS Templates
changes to integrate to the web interface
imanay -
r138:139
parent child
Show More
@@ -15,7 +15,7
15 def createObjects(self):
15 def createObjects(self):
16
16
17 self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino)
17 self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino)
18 self.wFiles = library3.FilesStuff()
18 # self.wFiles = library3.FilesStuff()
19
19
20 def __ConnectionWithCentralControl(self, cmd, data):
20 def __ConnectionWithCentralControl(self, cmd, data):
21
21
@@ -26,22 +26,22
26
26
27 return output
27 return output
28
28
29 def abs2ControlModuleFormatFile(self, filename):
29 # def abs2ControlModuleFormatFile(self, filename):
30
30 #
31 #From matriz to control module format
31 # #From matriz to control module format
32 self.wFiles.toCentralControlFormat(filename)
32 # self.wFiles.toCentralControlFormat(filename)
33 FileName = "CentralControlFormat.txt"
33 # FileName = "CentralControlFormat.txt"
34 F_Obj = open(FileName,"r")
34 # F_Obj = open(FileName,"r")
35 FileList = F_Obj.readlines()
35 # FileList = F_Obj.readlines()
36 F_Obj.close()
36 # F_Obj.close()
37 FileStr = "".join(FileList)
37 # FileStr = "".join(FileList)
38
38 #
39 return FileStr
39 # return FileStr
40
40
41 def sendFile(self, filename):
41 def sendFile(self, filename):
42
42
43 data = self.abs2ControlModuleFormatFile(filename)
43 # data = self.abs2ControlModuleFormatFile(filename)
44
44 data = self.__readFile(filename)
45 self.__ConnectionWithCentralControl(cmd = "SNDF", data = data)
45 self.__ConnectionWithCentralControl(cmd = "SNDF", data = data)
46
46
47 def changeBeam(self, newBeam):
47 def changeBeam(self, newBeam):
@@ -53,6 +53,15
53 fobj = open(filename,"w")
53 fobj = open(filename,"w")
54 fobj.writelines(data)
54 fobj.writelines(data)
55 fobj.close()
55 fobj.close()
56
57 def __readFile(self, filename):
58
59 fobj = open(filename,"r")
60 listData = fobj.readlines()
61 fobj.close()
62 data = "".join(listData)
63 return data
64
56
65
57 def getControlModuleStatus(self, data):
66 def getControlModuleStatus(self, data):
58
67
@@ -25,6 +25,7
25 asServer = True
25 asServer = True
26 self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer)
26 self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer)
27 self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2)
27 self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2)
28 self.wFiles = library3.FilesStuff()
28
29
29 def waitRequest(self):
30 def waitRequest(self):
30
31
@@ -74,10 +75,19
74 else:
75 else:
75 status_array.append("192.168.1." + str(address) + " [0 0]\n")
76 status_array.append("192.168.1." + str(address) + " [0 0]\n")
76
77
77 f = open("module_status.txt","w")
78 filename = "module_status.txt"
78 f.writelines(status_array)
79 self.__writeFile(filename,status_array)
79 f.close()
80 # f = open("module_status.txt","w")
80
81 # f.writelines(status_array)
82 # f.close()
83
84
85 def __writeFile(self, filename, data):
86
87 fobj = open(filename,"w")
88 fobj.writelines(data)
89 fobj.close()
90
81 def checkAntenna(self):
91 def checkAntenna(self):
82
92
83 """
93 """
@@ -107,7 +117,19
107 ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData()
117 ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData()
108 self.commClientObj.close_socket()
118 self.commClientObj.close_socket()
109
119
110 return tmp
120 return tmp
121
122 def abs2ControlModuleFormatFile(self, filename):
123
124 #From matriz to control module format
125 self.wFiles.toCentralControlFormat(filename)
126 FileName = "CentralControlFormat.txt"
127 F_Obj = open(FileName,"r")
128 FileList = F_Obj.readlines()
129 F_Obj.close()
130 FileStr = "".join(FileList)
131
132 return FileStr
111
133
112 def __All2Blocks(self,input):
134 def __All2Blocks(self,input):
113
135
@@ -121,9 +143,12
121
143
122
144
123 def __sendFile2Modules(self,cmd):
145 def __sendFile2Modules(self,cmd):
124
146
147 filename = "tmp.txt"
148 self.__writeFile(filename,self.rx_buffer)
149 data = self.abs2ControlModuleFormatFile(filename)
125 #Needed for the loop
150 #Needed for the loop
126 header, control_modules_lst = self.__All2Blocks(self.rx_buffer)
151 header, control_modules_lst = self.__All2Blocks(data)
127 correct = 0
152 correct = 0
128
153
129 for id in range(1,65):
154 for id in range(1,65):
General Comments 0
You need to be logged in to leave comments. Login now