Commit 474b2bde authored by Mateus Goto's avatar Mateus Goto

[Fixed] set voltage [Tested] setters and fetchs

parent 5fed8559
......@@ -21,16 +21,15 @@ class controlInterface:
def newNhr(self, nhr):
if(nhr == "9410"):
new = NHR9410()
elif nhr == "9430":
new = NHR9430()
else:
return -1
new.locateIp(self.__listIp)
print(new.getIp())
print(new.getS())
new.setS()
usedIp = new.getIp()
print("usedIP:" + str(usedIp))
try:
self.__listIp.remove(usedIp)
self.__listUsedIp.append(usedIp)
......
......@@ -12,6 +12,12 @@ class NHR9400():
self.__ip = ""
################################# Configurations ######################################################
#Default start: Enable all instruments and close output relays and starts an aperture measurement on all channels which will run for the time specified by the last received SENSe:SWEep:APERture instrument command
#!!!!!! upgrade this function later
def start(self):
self.__s.send("SOUR:OUTP:ON 1\n".encode())
self.__s.send("INIT\n".encode())
def locateIp(self, clients = []):
for client in clients:
try:
......@@ -23,7 +29,6 @@ class NHR9400():
msg = self.__s.recv(1024)
recv = self.receiveString(msg)
id = "NH Research," + str(self.__name)
self.__s.send("SOUR:VOLT: 110\n".encode())
if recv.find(id) != -1: #if find this subtring
self.__ip = client
print(self.__ip)
......@@ -36,6 +41,7 @@ class NHR9400():
def getIp(self):
return self.__ip
def getS(self):
return self.__s
......@@ -113,6 +119,8 @@ class NHR9400():
return self.receiveString(value)
def close(self):
self.__s.send("SOUR:OUTP:ON 0\n".encode())
self.__s.send("ABOR\n".encode())
self.__s.send("SYST:LOC\n".encode())
print(self.checkErrors())
self.__s.close()
......@@ -124,10 +132,12 @@ class NHR9400():
self.__s.send(("SOUR:OUTP:ON "+ str(value) + "\n").encode())
else:
print("INVALID INPUT")
################################# System command #####################################################
#Command places the touch panel (if present) in local control mode. All front panel keys are returned to a functional state.
def systLocal(self):
################################# Setters and Getters ################################################
#set limit voltage of all phases
def setVoltage(self,voltage):
self.__s.send("INIT\n".encode())
msg = "SOUR:VOLT: 110\n"
print(msg)
print(self.__s)
......@@ -155,7 +165,12 @@ class NHR9400():
self.__s.send(("SOUR:POW:CPHase " + str(pow) + "\n").encode())
#Command establishes the operating frequency for the selected instrument.
def setFreq(self, freq):
self.__s.send(("SOUR:POW " + str(freq) + "\n").encode())
self.__s.send(("SOUR:FREQ " + str(freq) + "\n").encode())
#!!!! Doesnt work!!!!
def getFreq(self):
self.__s.send("FETC:FREQ\n".encode())
value = self.__s.recv(1024)
return self.receiveFloat(value)
#Fetch the average voltage of all channels
def getVoltage(self):
self.__s.send("FETC:VOLT?\n".encode())
......
......@@ -5,6 +5,6 @@ class NHR9410(NHR9400):
def __init__(self):
super().__init__("9410")
def getS(self):
return self.__s
def setS(self):
self.__s = self.getS()
import socket
from NHR9400series.NHR9400 import NHR9400
class NHR9430(NHR9400):
def __init__(self):
super().__init__("9430")
def setS(self):
self.__s = self.getS()
#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
# 0 = NORMal = CC / CP / CVA with modifiers (PF, CF, & IWAVESHAPE)
# 1 = CR = Constant Resistance (with optional CC limit)
# 2 = RL = Constant series Resistance & Inductance
def instrumentLoad(self, value):
if value < 0 or value > 2:
print("INVALID INPUT")
......
......@@ -15,25 +15,31 @@ nhr30 = []
nhr10 = interface.getNhr9410()
nhr30 = interface.getNhr9430()
print(nhr10)
print(nhr30)
for elem in nhr10:
print("nhr10 ip: ",elem.getIp())
elem.setVoltage(220)
time.sleep(1)
elem.setPower(0.7)
print(elem.checkErrors())
elem.setPower(5)
elem.start()
print("voltage:",elem.getVoltage())
print("current:", elem.getCurrent())
print("Power:", elem.getPower())
elem.close()
print(elem.checkErrors())
for elem in nhr30:
print("nhr30 ip: ",elem.getIp())
elem.setCurrent(30)
elem.start()
print("voltage:",elem.getVoltage())
print("current:", elem.getCurrent())
print("Power:", elem.getPower())
time.sleep(20)
for elem in nhr10:
elem.close()
for elem in nhr30:
elem.close()
\ No newline at end of file
......@@ -10,4 +10,6 @@ class can(mug.mug):
self.__id = id
def getId(self):
return self.__id
\ No newline at end of file
return self.__id
def getS(self):
return self.__s
\ No newline at end of file
......@@ -8,5 +8,5 @@ can.setId(132)
print(can.getId())
print(can.decode("isso aqui é "))
print(can.getS()) #this should be working on the project was well
print("can s: ", can.getS()) #this should be working on the project was well
print(mug.getS())
\ No newline at end of file
......@@ -11,5 +11,4 @@ class mug():
recv = dec.dec().rewrite(recv)
return recv
def getS(self):
return self.__s
\ No newline at end of file
\ No newline at end of file
......@@ -5,31 +5,29 @@ import socket
import time
start = time.time()
def getAllIp():
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.connect(("10.255.255.255",1))
local_ip = s.getsockname()[0]
print(local_ip)
local_ip = local_ip[:-3] + "1/24"
print(local_ip)
print(type(local_ip))
arp = ARP(pdst=local_ip)
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
packet = ether/arp
result= srp(packet, timeout=3,retry = 1, verbose = 0)[0]
clients = []
for sent, received in result:
clients.append(received.psrc)
for client in clients:
print(client)
getAllIp()
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.settimeout(1)
try:
s.connect(("192.168.15.10", 5025))
except:
print("conexão falhou")
print (time.time() - start)
s.connect(("192.168.0.2",5025))
s.send("SYST:RWL\n".encode()) #Command to activate remote control and locking the touchscreen
s.send("*IDN?\r\n".encode())
msg = s.recv(1024)
print(msg)
s.send("SOUR:OUTP:ON 1\n".encode())
s.send("INIT\n".encode())
s.send("SOUR:VOLT: 110\r\n".encode())
s.send("SYST:ERR?\n".encode())
msg = s.recv(1024)
print(msg)
time.sleep(5)
s.send("SOUR:OUTP:ON 0\n".encode())
s.send("SYST:LOC\n".encode())
s.close()
\ 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