Commit 68e6e2a6917 by Julien Salort

Change newport xps rl to allow help future asynchroneous implementation and black

parent c3bb13164bd
......@@ -210,9 +210,9 @@ class NewportXpsRL:
def __init__(self, ip_address, port=5001):
self.ip_address = ip_address
self.port = port
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def open(self):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((self.ip_address, self.port))
def close(self):
......@@ -225,17 +225,7 @@ class NewportXpsRL:
def __exit__(self, type_, value, cb):
self.close()
def query(self, command_str):
if isinstance(command_str, str):
command_str = command_str.encode("ascii")
self.socket.sendall(command_str)
chunks = []
while True:
chunk = self.socket.recv(1024)
if len(chunk) > 0:
chunks.append(chunk)
if len(chunks) < 1024:
break
def _parse_chunks(self, chunks):
data_raw = b"".join(chunks).decode("ascii")
parsed = data_raw.split(",")
status = parsed[0]
......@@ -249,6 +239,19 @@ class NewportXpsRL:
raise RuntimeError("Wrong answer from XPS-RL Controller")
return int(status), response
def query(self, command_str):
if isinstance(command_str, str):
command_str = command_str.encode("ascii")
self.socket.sendall(command_str)
chunks = []
while True:
chunk = self.socket.recv(1024)
if len(chunk) > 0:
chunks.append(chunk)
if len(chunks) < 1024:
break
return self._parse_chunks(chunks)
def FirmwareVersionGet(self):
status, response = self.query("FirmwareVersionGet(char *)")
if status != 0:
......
......@@ -46,7 +46,9 @@ features = [
# # # # # # # # # # # #
# Read-only commands #
# # # # # # # # # # # #
FloatValue("temperature", doc="MGC3 internal temperature", command_get="MGC3GET 0"),
FloatValue(
"temperature", doc="MGC3 internal temperature", command_get="MGC3GET 0"
),
# PID0 commands
FloatValue(
"pid0_meas",
......
......@@ -46,27 +46,57 @@ features = [
# # # # # # # # # # # #
# Read-only commands #
# # # # # # # # # # # #
FloatValue("temperature", doc="MMR3 internal temperature", command_get="MMR3GET 2"),
FloatValue(
"temperature", doc="MMR3 internal temperature", command_get="MMR3GET 2"
),
# CH1 commands
FloatValue("r1_meas", doc="MMR3 R1 measurement result", command_get="MMR3GET 3"),
FloatValue("r1_range", doc="MMR3 R1 range computation", command_get="MMR3GET 4"),
FloatValue("r1_convert", doc="MMR3 R1 converted value", command_get="MMR3GET 5"),
FloatValue("r1_status", doc="MMR3 R1 measurement status", command_get="MMR3GET 6"),
FloatValue("r1_offset", doc="MMR3 R1 offset measurement", command_get="MMR3GET 13"),
FloatValue(
"r1_meas", doc="MMR3 R1 measurement result", command_get="MMR3GET 3"
),
FloatValue(
"r1_range", doc="MMR3 R1 range computation", command_get="MMR3GET 4"
),
FloatValue(
"r1_convert", doc="MMR3 R1 converted value", command_get="MMR3GET 5"
),
FloatValue(
"r1_status", doc="MMR3 R1 measurement status", command_get="MMR3GET 6"
),
FloatValue(
"r1_offset", doc="MMR3 R1 offset measurement", command_get="MMR3GET 13"
),
# CH2 commands
FloatValue("r2_meas", doc="MMR3 R2 measurement result", command_get="MMR3GET 14"),
FloatValue("r2_range", doc="MMR3 R2 range computation", command_get="MMR3GET 15"),
FloatValue("r2_convert", doc="MMR3 R2 converted value", command_get="MMR3GET 16"),
FloatValue("r2_status", doc="MMR3 R2 measurement status", command_get="MMR3GET 17"),
FloatValue("r2_offset", doc="MMR3 R2 offset measurement", command_get="MMR3GET 24"),
FloatValue(
"r2_meas", doc="MMR3 R2 measurement result", command_get="MMR3GET 14"
),
FloatValue(
"r2_range", doc="MMR3 R2 range computation", command_get="MMR3GET 15"
),
FloatValue(
"r2_convert", doc="MMR3 R2 converted value", command_get="MMR3GET 16"
),
FloatValue(
"r2_status", doc="MMR3 R2 measurement status", command_get="MMR3GET 17"
),
FloatValue(
"r2_offset", doc="MMR3 R2 offset measurement", command_get="MMR3GET 24"
),
# CH3 commands
FloatValue("r3_meas", doc="MMR3 R3 measurement result", command_get="MMR3GET 25"),
FloatValue("r3_range", doc="MMR3 R3 range computation", command_get="MMR3GET 26"),
FloatValue(
"r3_meas", doc="MMR3 R3 measurement result", command_get="MMR3GET 25"
),
FloatValue(
"r3_range", doc="MMR3 R3 range computation", command_get="MMR3GET 26"
),
FloatValue(
"r3_convert", doc="MMR3 MMR3 R3 converted value", command_get="MMR3GET 27"
),
FloatValue("r3_status", doc="MMR3 R3 measurement status", command_get="MMR3GET 28"),
FloatValue("r3_offset", doc="MMR3 R3 offset measurement", command_get="MMR3GET 35"),
FloatValue(
"r3_status", doc="MMR3 R3 measurement status", command_get="MMR3GET 28"
),
FloatValue(
"r3_offset", doc="MMR3 R3 offset measurement", command_get="MMR3GET 35"
),
# # # # # # # # # #
# R+W commands #
# # # # # # # # # #
......
......@@ -74,7 +74,7 @@ class Agilent34970a(IEC60488):
def set_tmo(self, tmo):
self.tmo = tmo
def set_range(self, channelNumber, manualRange=False, rangeValue=None):
if not manualRange and str(channelNumber) in self.Range:
del self.Range[str(channelNumber)]
......
......@@ -61,6 +61,7 @@ def prepare_calibration(rho_min=1, rho_max=1.18, nb_solutions=6):
class Calibration:
"""Calibrate density"""
def __init__(self, path_rho, path_temp=None):
self.path_rho = path_rho
......
......@@ -22,6 +22,7 @@ serial_numbers = {"horiz": 470012356, "vert": 470012767}
class Galva:
"""Galvanometer which controls an oscillating mirror to set angles."""
def __init__(self):
self.t7 = T7(identifier=serial_numbers["horiz"])
......
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