Index: trunk/absroot/source/abspy/abscontrol/server3.py =================================================================== diff --git a/trunk/absroot/source/abspy/abscontrol/server3.py b/trunk/absroot/source/abspy/abscontrol/server3.py --- a/trunk/absroot/source/abspy/abscontrol/server3.py (revision 149) +++ b/trunk/absroot/source/abspy/abscontrol/server3.py (revision 150) @@ -1,6 +1,7 @@ import os import library3 import time +import threading class ABSServer: @@ -20,7 +21,10 @@ self.createObjects() + print "Checking control modules, please wait ..." self.enaModules = self.checkAntenna() + print "Starting automatic control module status." + self.__AutomaticControlModules() def createObjects(self): @@ -32,32 +36,26 @@ def waitRequest(self): #Using rx buffer - ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() +# ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() + ipSource, ipDestino, cmd, rx_buffer = self.commServerObj.waitData() if cmd == "SNDF": - datarpta = self.__sendFile2Modules(cmd = cmd) + datarpta = self.__sendFile2Modules(cmd = cmd, rx_buffer = rx_buffer) if cmd == "CHGB": - datarpta = self.__changeBeam(cmd = cmd) + datarpta = self.__changeBeam(cmd = cmd, rx_buffer = rx_buffer) if cmd == "ANST": - self.__getControlModuleStatus(cmd = cmd) - #Using tx buffer - datarpta = self.tx_buffer + datarpta = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) if cmd == "BGPH": - self.__getControlModuleBigPhase(cmd = cmd) - #Using tx buffer - datarpta = self.tx_buffer + datarpta = self.__getControlModuleBigPhase(cmd = cmd, rx_buffer = rx_buffer) if cmd == "LWPH": - self.__getControlModuleLowPhase(cmd = cmd) - #Using tx buffer - datarpta = self.tx_buffer + datarpta = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) if cmd == "NTST": - #Using tx buffer - datarpta = self.__getConnectionStatus(cmd = cmd) + datarpta = self.__getConnectionStatus(cmd = cmd, rx_buffer = rx_buffer) self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) @@ -149,9 +147,10 @@ return header, control_modules_lst - def __sendFile2Modules(self,cmd): - - rx_buffer_lst = self.rx_buffer.split('\n',1) + def __sendFile2Modules(self,cmd, rx_buffer): + +# rx_buffer_lst = self.rx_buffer.split('\n',1) + rx_buffer_lst = rx_buffer.split('\n',1) #Getting the filename from the begining of data filename = rx_buffer_lst[0] tmp = rx_buffer_lst[1] @@ -176,7 +175,7 @@ return rpta - def __changeBeam(self, cmd): + def __changeBeam(self, cmd, rx_buffer): correct = 0 # enaModules = self.checkAntenna() @@ -186,7 +185,7 @@ if id not in self.enaModules: continue - if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK": + if self.__ConnectionWithControlModules(rx_buffer,cmd,id) == "OK": correct = correct + 1 if correct == len(self.enaModules): @@ -196,7 +195,7 @@ return rpta - def __getControlModuleStatus(self, cmd): + def __getControlModuleStatus(self, cmd, rx_buffer): all_blocks = "" # enaModules = self.checkAntenna() @@ -206,14 +205,14 @@ if id not in self.enaModules: continue - one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) + one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id) all_blocks = all_blocks + one_block #Using tx buffer - print all_blocks - self.tx_buffer = all_blocks - - def __getControlModuleBigPhase(self, cmd): + + return all_blocks + + def __getControlModuleBigPhase(self, cmd, rx_buffer): all_blocks = "" # enaModules = self.checkAntenna() @@ -223,14 +222,13 @@ if id not in self.enaModules: continue - one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) + one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id) all_blocks = all_blocks + one_block #Using tx buffer - print all_blocks - self.tx_buffer = all_blocks - - def __getControlModuleLowPhase(self, cmd): + return all_blocks + + def __getControlModuleLowPhase(self, cmd, rx_buffer): all_blocks = "" # enaModules = self.checkAntenna() @@ -240,14 +238,13 @@ if id not in self.enaModules: continue - one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) + one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id) all_blocks = all_blocks + one_block #Using tx buffer - print all_blocks - self.tx_buffer = all_blocks - - def __getConnectionStatus(self, cmd): + return all_blocks + + def __getConnectionStatus(self, cmd, rx_buffer): ena = self.checkAntenna() print ena @@ -259,6 +256,24 @@ if id not in self.enaModules: continue + blockStr = self.__ConnectionWithControlModules(rx_buffer,cmd,id) + blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") + #Using tx buffer + all_blocks = "".join(blockLst) + + return all_blocks + + def getConnectionStatus(self, cmd): + + ena = self.checkAntenna() + self.enaModules = ena + + blockLst = [] + + for id in range(1,65): + if id not in self.enaModules: + continue + blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") #Using tx buffer @@ -266,25 +281,6 @@ print self.tx_buffer return self.tx_buffer - - def getConnectionStatus(self, cmd): - - ena = self.checkAntenna() - self.enaModules = ena - - blockLst = [] - - for id in range(1,65): - if id not in self.enaModules: - continue - - blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) - blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") - #Using tx buffer - self.tx_buffer = "".join(blockLst) - print self.tx_buffer - - return self.tx_buffer def getControlModuleStatus(self, cmd): @@ -304,6 +300,21 @@ self.tx_buffer = all_blocks return all_blocks + + def __AutomaticControlModules(self): + + cmd = "ANST" + rx_buffer = "1" + tmp1 = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) + + cmd = "LWPH" + rx_buffer = "0" + tmp2 = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) + print "getting this: " + print tmp1 + print tmp2 + + threading.Timer(30, self.__AutomaticControlModules).start() if __name__ == '__main__': Index: trunk/absroot/source/abspy/scripts/getControlModuleStatus.py =================================================================== diff --git a/trunk/absroot/source/abspy/scripts/getControlModuleStatus.py b/trunk/absroot/source/abspy/scripts/getControlModuleStatus.py --- a/trunk/absroot/source/abspy/scripts/getControlModuleStatus.py (revision 149) +++ b/trunk/absroot/source/abspy/scripts/getControlModuleStatus.py (revision 150) @@ -1,8 +1,12 @@ import file from client3 import * +import sys -ns = "4" - absObj = ABSClient(ipDestino="10.10.10.97") #absObj = ABSClient() -absObj.getControlModuleStatus(ns) \ No newline at end of file +if len(sys.argv) == 2: +# ns = "4" + ns = sys.argv[1] + absObj.getControlModuleStatus(ns) +else: + print "Only one argument needed." \ No newline at end of file