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

[error] socket

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