Commit 29ab8c8e authored by Mateus Goto's avatar Mateus Goto

[Fixed] minors issues 2

parent fa51a0e2
...@@ -8,15 +8,14 @@ from Utility.IPFinder import IPFinder ...@@ -8,15 +8,14 @@ from Utility.IPFinder import IPFinder
class controlInterface: class controlInterface:
def __init__(self): def __init__(self):
self.__listIp = [] self.__listIp = IPFinder().getList()
self.__listUsedIp = [] self.__listUsedIp = []
self.__nhr9410 = [] self.__nhr9410 = []
self.__nhr9430 = [] self.__nhr9430 = []
#refresh the list of ip #refresh the list of ip
def refresh(self): def refresh(self):
ipfinder = IPFinder() self.__listIp = IPFinder().getList()
self.__listIp = ipfinder.getList()
for ip in self.__listUsedIp: for ip in self.__listUsedIp:
self.__listIp.remove(ip) self.__listIp.remove(ip)
...@@ -25,22 +24,28 @@ class controlInterface: ...@@ -25,22 +24,28 @@ class controlInterface:
new = NHR9410() new = NHR9410()
new.__init__() new.__init__()
new.locateIp(self.__listIp) new.locateIp(self.__listIp)
print(self.getListIp())
usedIp = new.getIp() usedIp = new.getIp()
self.__listIp.remove(usedIp) print(type(usedIp))
self.__listUsedIp.append(usedIp) try:
self.__nhr9410.append(new) self.__listIp.remove(usedIp)
self.__listUsedIp.append(usedIp)
self.__nhr9430.append(new)
except:
print("Any IP adress matched")
#create a NHR9430 object #create a NHR9430 object
def newNhr9430(self): def newNhr9430(self):
new = NHR9430() new = NHR9430()
new.__init__() new.__init__()
new.locateIp(self.__listIp) usedIp = new.locateIp(self.__listIp)
usedIp = new.getIp() #print(usedIp)
self.__listIp.remove(usedIp) try:
self.__listUsedIp.append(usedIp) self.__listIp.remove(usedIp)
self.__nhr9430.append(new) self.__listUsedIp.append(usedIp)
self.__nhr9430.append(new)
except:
print("Any IP adress matched")
def getNhr9410(self): def getNhr9410(self):
return self.__nhr9410 return self.__nhr9410
......
usedIp = new.getIp()
\ No newline at end of file
...@@ -16,13 +16,12 @@ class NHR9410(NHR9400): ...@@ -16,13 +16,12 @@ class NHR9410(NHR9400):
if recv.find("NH Research,9410-") != -1: #if find this subtring if recv.find("NH Research,9410-") != -1: #if find this subtring
self.__ip = client self.__ip = client
print("Connection successfully") print("Connection successfully")
break return self.__ip
else: else:
print("Connection failed 1") print("Connection failed 1")
self.__s.close() self.__s.close()
except: except:
print("Connection failed 2") print("Connection failed 2")
pass
......
...@@ -73,7 +73,7 @@ class NHR9430(NHR9400): ...@@ -73,7 +73,7 @@ class NHR9430(NHR9400):
if recv.find("NH Research,9430-") != -1: #if find this subtring if recv.find("NH Research,9430-") != -1: #if find this subtring
self.__ip = client self.__ip = client
print("Connection successfully") print("Connection successfully")
break return self.__ip
else: else:
print("Connection failed 1") print("Connection failed 1")
self.__s.close() self.__s.close()
......
...@@ -23,8 +23,7 @@ class IPFinder: ...@@ -23,8 +23,7 @@ class IPFinder:
result = srp(packet, timeout=3,retry = 1, verbose = 0)[0] result = srp(packet, timeout=3,retry = 1, verbose = 0)[0]
clients = [] clients = []
for sent, received in result: for sent, received in result:
clients.append({"ip": received.psrc}) clients.append(received.psrc)
print(clients)
self.__clients = clients self.__clients = clients
......
...@@ -2,20 +2,14 @@ from Control_Interface.controlInterface import controlInterface ...@@ -2,20 +2,14 @@ from Control_Interface.controlInterface import controlInterface
from Utility.IPFinder import IPFinder from Utility.IPFinder import IPFinder
interface = controlInterface() interface = controlInterface()
ips = [] interface.__init__()
ips = IPFinder().getList()
print(ips)
interface.newNhr9410() interface.newNhr9410()
interface.newNhr9430() interface.newNhr9430()
#interface.newNhr9430() #interface.newNhr9430()
nhr10 = [] nhr10 = []
print(nhr10)
nhr30 = [] nhr30 = []
nhr10 = interface.getNhr9410() nhr10 = interface.getNhr9410()
nhr30 = interface.getNhr9430() nhr30 = interface.getNhr9430()
print(nhr10) print(nhr10)
print(nhr30) print(nhr30)
\ No newline at end of file
nhr10[0].getIp
nhr30[0].getIp
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment