Commit 5fed8559 authored by Mateus Goto's avatar Mateus Goto

[error] socket

parent 71d30d66
...@@ -26,13 +26,15 @@ class controlInterface: ...@@ -26,13 +26,15 @@ class controlInterface:
else: else:
return -1 return -1
new.locateIp(self.__listIp) new.locateIp(self.__listIp)
print(new.getIp())
print(new.getS())
usedIp = new.getIp() usedIp = new.getIp()
print("usedIP:" + str(usedIp)) print("usedIP:" + str(usedIp))
try: try:
self.__listIp.remove(usedIp) self.__listIp.remove(usedIp)
self.__listUsedIp.append(usedIp) self.__listUsedIp.append(usedIp)
if(nhr == "9410"): if nhr == "9410":
self.__nhr9410.append(new) self.__nhr9410.append(new)
elif nhr == "9430": elif nhr == "9430":
self.__nhr9430.append(new) self.__nhr9430.append(new)
......
...@@ -3,7 +3,7 @@ import socket ...@@ -3,7 +3,7 @@ import socket
from UtilitiesRei.refineOutput import refineOutput from UtilitiesRei.refineOutput import refineOutput
class NHR9400: class NHR9400():
def __init__(self, name): def __init__(self, name):
self.__name = name self.__name = name
...@@ -23,6 +23,7 @@ class NHR9400: ...@@ -23,6 +23,7 @@ class NHR9400:
msg = self.__s.recv(1024) msg = self.__s.recv(1024)
recv = self.receiveString(msg) recv = self.receiveString(msg)
id = "NH Research," + str(self.__name) id = "NH Research," + str(self.__name)
self.__s.send("SOUR:VOLT: 110\n".encode())
if recv.find(id) != -1: #if find this subtring if recv.find(id) != -1: #if find this subtring
self.__ip = client self.__ip = client
print(self.__ip) print(self.__ip)
...@@ -35,6 +36,8 @@ class NHR9400: ...@@ -35,6 +36,8 @@ class NHR9400:
def getIp(self): def getIp(self):
return self.__ip return self.__ip
def getS(self):
return self.__s
#chose a mode with the instrument will run, check the manual to see all modes. #chose a mode with the instrument will run, check the manual to see all modes.
def configMode(self, mode): def configMode(self, mode):
...@@ -106,11 +109,12 @@ class NHR9400: ...@@ -106,11 +109,12 @@ class NHR9400:
#Function to see if exist any error in the carry #Function to see if exist any error in the carry
def checkErrors(self): def checkErrors(self):
self.__s.send("SYST:ERR?\n".encode()) self.__s.send("SYST:ERR?\n".encode())
self.__s.timeout(5) value = self.__s.recv(1024)
return self.receive() return self.receiveString(value)
def close(self): def close(self):
self.__s.send("SYST:LOC\n".encode()) self.__s.send("SYST:LOC\n".encode())
print(self.checkErrors())
self.__s.close() self.__s.close()
# Controle do relé de saída do hardware (LIGAR OU DESLIGAR) # Controle do relé de saída do hardware (LIGAR OU DESLIGAR)
# 0 OFF - Instrumento desabilitado # 0 OFF - Instrumento desabilitado
...@@ -123,7 +127,12 @@ class NHR9400: ...@@ -123,7 +127,12 @@ class NHR9400:
################################# Setters and Getters ################################################ ################################# Setters and Getters ################################################
#set limit voltage of all phases #set limit voltage of all phases
def setVoltage(self,voltage): def setVoltage(self,voltage):
self.__s.send(("SOUR:VOLT " + str(voltage) + "\n").encode()) self.__s.send("INIT\n".encode())
msg = "SOUR:VOLT: 110\n"
print(msg)
print(self.__s)
self.__s.send(msg.encode())
print("ok")
#Functions that sets the limits voltage on one phase (A, B or C) #Functions that sets the limits voltage on one phase (A, B or C)
def setVoltageA(self,voltage): def setVoltageA(self,voltage):
self.__s.send(("SOUR:VOLT:APH " + str(voltage) + "\n").encode()) self.__s.send(("SOUR:VOLT:APH " + str(voltage) + "\n").encode())
...@@ -136,7 +145,7 @@ class NHR9400: ...@@ -136,7 +145,7 @@ class NHR9400:
#Command establishes the True Power limit (W) as a positive value for the selected instrument. #Command establishes the True Power limit (W) as a positive value for the selected instrument.
def setPower(self, pow): def setPower(self, pow):
self.__s.send(("SOUR:POW " + str(pow) + "\n").encode()) self.__s.send(("SOUR:POW: " + str(pow) + "\n").encode())
#Individual command for one phase #Individual command for one phase
def setPowerA(self, pow): def setPowerA(self, pow):
self.__s.send(("SOUR:POW:APHase " + str(pow) + "\n").encode()) self.__s.send(("SOUR:POW:APHase " + str(pow) + "\n").encode())
...@@ -201,7 +210,7 @@ class NHR9400: ...@@ -201,7 +210,7 @@ class NHR9400:
self.__s.send("FETC:CURR:BPHase?\n".encode()) self.__s.send("FETC:CURR:BPHase?\n".encode())
value = self.__s.recv(1024) value = self.__s.recv(1024)
return self.receiveFloat(value) return self.receiveFloat(value)
def getCurrentC(self): def getCurrentC(self):
self.__s.send("FETC:CURR:CPHase?\n".encode()) self.__s.send("FETC:CURR:CPHase?\n".encode())
value = self.__s.recv(1024) value = self.__s.recv(1024)
......
...@@ -5,5 +5,6 @@ class NHR9410(NHR9400): ...@@ -5,5 +5,6 @@ class NHR9410(NHR9400):
def __init__(self): def __init__(self):
super().__init__("9410") super().__init__("9410")
def getS(self):
return self.__s
import socket
from NHR9400series.NHR9400 import NHR9400 from NHR9400series.NHR9400 import NHR9400
class NHR9430(NHR9400): class NHR9430(NHR9400):
...@@ -40,6 +41,7 @@ class NHR9430(NHR9400): ...@@ -40,6 +41,7 @@ class NHR9430(NHR9400):
#set the current of all phases ** Available only to NHR9430-12 #set the current of all phases ** Available only to NHR9430-12
def setCurrent(self, current): def setCurrent(self, current):
print(self.__s)
self.__s.send(("SOUR:CURR " + str(current) + "\n").encode()) self.__s.send(("SOUR:CURR " + str(current) + "\n").encode())
#Functions that sets the limite currents on one phase (A, B or C) #Functions that sets the limite currents on one phase (A, B or C)
def setCurrentA(self, current): def setCurrentA(self, current):
...@@ -49,6 +51,8 @@ class NHR9430(NHR9400): ...@@ -49,6 +51,8 @@ class NHR9430(NHR9400):
def setCurrentC(self, current): def setCurrentC(self, current):
self.__s.send(("SOUR:CURR:CPHase " + str(current) + "\n").encode()) self.__s.send(("SOUR:CURR:CPHase " + str(current) + "\n").encode())
import socket
import time
from Control_Interface.controlInterface import controlInterface from Control_Interface.controlInterface import controlInterface
interface = controlInterface() interface = controlInterface()
interface.__init__() interface.__init__()
print(interface.getListIp()) print(interface.getListIp())
interface.newNhr("9410") interface.newNhr("9410")
interface.newNhr("9430") interface.newNhr("9430")
interface.newNhr("9430") #interface.newNhr("9430")
nhr10 = [] nhr10 = []
nhr30 = [] nhr30 = []
...@@ -17,8 +18,13 @@ nhr30 = interface.getNhr9430() ...@@ -17,8 +18,13 @@ nhr30 = interface.getNhr9430()
print(nhr10) print(nhr10)
print(nhr30) print(nhr30)
for elem in nhr10: for elem in nhr10:
print("nhr10 ip: ",elem.getIp()) print("nhr10 ip: ",elem.getIp())
elem.setVoltage(220)
time.sleep(1)
elem.setPower(0.7)
print(elem.checkErrors())
print("voltage:",elem.getVoltage()) print("voltage:",elem.getVoltage())
print("current:", elem.getCurrent()) print("current:", elem.getCurrent())
print("Power:", elem.getPower()) print("Power:", elem.getPower())
...@@ -26,6 +32,7 @@ for elem in nhr10: ...@@ -26,6 +32,7 @@ for elem in nhr10:
for elem in nhr30: for elem in nhr30:
print("nhr30 ip: ",elem.getIp()) print("nhr30 ip: ",elem.getIp())
elem.setCurrent(30)
print("voltage:",elem.getVoltage()) print("voltage:",elem.getVoltage())
print("current:", elem.getCurrent()) print("current:", elem.getCurrent())
print("Power:", elem.getPower()) print("Power:", elem.getPower())
......
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