Commit b0e5c791 authored by Mateus Goto's avatar Mateus Goto

[Fixed] Minor issues: duplicates attributes

parent a71cae1d
......@@ -20,7 +20,6 @@ class controlInterface:
#create a NHR9410 object
def newNhr9410(self):
new = NHR9410()
new.__init__()
new.locateIp(self.__listIp)
usedIp = new.getIp()
......@@ -35,7 +34,6 @@ class controlInterface:
#create a NHR9430 object
def newNhr9430(self):
new = NHR9430()
new.__init__()
usedIp = new.locateIp(self.__listIp)
#print(usedIp)
try:
......
......@@ -9,15 +9,29 @@ class NHR9400:
self.__name = name
self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.__s.settimeout(1)
self.__out = refineOutput()
self.__ip = ""
################################# Configurations ######################################################
@abstractmethod
def locateIp(self):
pass
def getIp(self):
return self.__ip
def locateIp(self, clients = []):
for client in clients:
try:
self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.__s.settimeout(1)
self.__s.connect((client, 5025))
self.__s.send("SYST:RWL\n".encode()) #Command to activate remote control and locking the touchscreen
self.__s.send("*IDN?\n".encode())
msg = self.__s.recv(1024)
recv = self.receiveString(msg)
if recv.find("NH Research," + self.__name) != -1: #if find this subtring
print("o cliente encontrado: " + client)
self.__ip = client
print(self.__ip)
print("Connection successfully")
break
else:
print("Connection failed 1")
self.__s.close()
except:
print("Connection failed 2")
#chose a mode with the instrument will run, check the manual to see all modes.
def configMode(self, mode):
if mode < 0 and mode > 16:
......@@ -84,9 +98,8 @@ class NHR9400:
return recv
#Function that receives messages back and transform it in a float
def receiveFloat(self):
msg = self.__s.recv(1024)
msg = self.byteToFloat(msg)
def receiveFloat(self, msg):
msg = refineOutput().byteToFloat(msg)
return msg
def identify(self):
......
from NHR9400series.NHR9400 import NHR9400
import socket
class NHR9410(NHR9400):
def __init__(self):
super().__init__("NHR9410")
self.__ip = 0
self.__ip = ""
def locateIp(self,clients = []):
for client in clients:
try:
self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.__s.settimeout(1)
self.__s.connect((client, 5025))
self.__s.send("SYST:RWL\n".encode()) #Command to activate remote control and locking the touchscreen
self.__s.send("*IDN?\n".encode())
msg = self.__s.recv(1024)
recv = self.receiveString(msg)
if recv.find("NH Research,9410-") != -1: #if find this subtring
print("o cliente encontrado: " + client)
self.__ip = client
print(self.__ip)
print("Connection successfully")
return self.__ip
else:
print("Connection failed 1")
self.__s.close()
except:
print("Connection failed 2")
def getIp(self):
return self.__ip
......
from NHR9400series.NHR9400 import NHR9400
import socket
class NHR9430(NHR9400):
def __init__(self):
super().__init__("NHR9430")
self.__ip = 0
self.__ip = ""
#Command sets the loading features <loading mode> for a 9430 AC output Query returns the loading features enabled on a 9430
#Command is only accepted if the instrument is a 9430, with AC outputs mode, and in an OFF state Other models & modes: This command is invalid
......@@ -65,28 +64,6 @@ class NHR9430(NHR9400):
value = self.__s.send("FETC:CURR:CPHase?\n".encode())
return self.receiveFloat(value)
def locateIp(self,clients = []):
for client in clients:
try:
self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.__s.settimeout(1)
self.__s.connect((client, 5025))
self.__s.send("SYST:RWL\n".encode()) #Command to activate remote control and locking the touchscreen
self.__s.send("*IDN?\n".encode())
msg = self.__s.recv(1024)
recv = self.receiveString(msg)
if recv.find("NH Research,9430-") != -1: #if find this subtring
print("o cliente encontrado: " + client)
self.__ip = client
print(self.__ip)
print("Connection successfully")
return self.__ip
else:
print("Connection failed 1")
self.__s.close()
except:
print("Connection failed 2")
def getIp(self):
return self.__ip
......
class refineOutput:
def byteToFloat(recv):
def byteToFloat(self, recv):
recv = recv.decode("UTF-8")
recv = recv.rstrip("\n\x00")
return float(recv)
def byteToString(recv):
def byteToString(self, recv):
print("fail8")
recv = bytes(recv)
recv = recv.decode("UTF-8")
......
import mug
class can(mug.mug):
def __init__(self, name):
super().__init__(name)
self.__id = 0
def setId(self, id):
self.__id = id
def getId(self):
return self.__id
\ No newline at end of file
class dec():
def rewrite(self, recv):
recv = recv + "blablabla"
return recv
\ No newline at end of file
#files to test any problems that was find in the project
#02/08/22: solving the problems with heritage
import can
import mug
can = can.can("caneca")
mug = mug.mug("mug")
can.setId(132)
print(can.getId())
print(can.decode("isso aqui é "))
print(can.getS()) #this should be working on the project was well
print(mug.getS())
\ No newline at end of file
import socket
import dec
class mug():
def __init__(self,name):
self.__name: name
self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.__s.settimeout(1)
def decode(self, recv):
recv = dec.dec().rewrite(recv)
return recv
def getS(self):
return self.__s
\ No newline at end of file
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