Commit 5c044d95 authored by Alén Arias Vázquez's avatar Alén Arias Vázquez 😎

- change default value of tty \ - change the prints \ - add function to read parameters

parent 6e7d6584
......@@ -5,7 +5,7 @@ import argparse
class CPX400DP(object):
def __init__(self, name='CPX400DP', devname='/dev/tty_CPX', baudrate=115200, log_level=logging.INFO):
def __init__(self, name='CPX400DP', devname='/dev/ttyACM0', baudrate=115200, log_level=logging.INFO):
logging.basicConfig(format='%(asctime)s.%(msecs)03d %(name)s-%(levelname)-s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=log_level)
self.name = name
self.log = logging.getLogger(self.name)
......@@ -34,7 +34,7 @@ class CPX400DP(object):
cmd='V'+str(chan)+'O?\n'
self.send_cmd(cmd)
answer=self.recv_cmd()
self.log.info("Channel {} ---- {}}V".format(chan,float(answer[:-3])))
self.log.info("Voltage channel {}: {}V".format(chan,float(answer[:-3])))
return float(answer[:-3])
def set_current(self, amps, chan=1):
......@@ -46,7 +46,7 @@ class CPX400DP(object):
cmd='I'+str(chan)+'O?\n'
self.send_cmd(cmd)
answer=self.recv_cmd()
self.log.info("Channel {} ---- {}A".format(chan,float(answer[:-3])))
self.log.info("Current channel {}: {}A".format(chan,float(answer[:-3])))
return float(answer[:-3])
def unlock(self):
......@@ -72,8 +72,17 @@ class CPX400DP(object):
self.set_current(amps=amps, chan=chan)
self.turn_on(chan=chan)
def get_values(self, chan=1, volts=10.0, amps=0.3):
for i in range()
def get_parameters_chan(self, chan=1):
V = self.get_voltage(chan=chan)
I = self.get_current(chan=chan)
return V, I
def get_parameters(self):
V1, I1 = self.get_parameters_chan(chan=1)
V2, I2 = self.get_parameters_chan(chan=2)
P1=V1*I1
P2=V2*I2
return V1, V2, I1, I2, P1, P2
def main():
parser = argparse.ArgumentParser(description='Control CPX400DP from USB', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
......
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