Commit 8aca4beb authored by Alén Arias Vázquez's avatar Alén Arias Vázquez 😎

change name functions

parent 2ddfff19
......@@ -25,24 +25,24 @@ class CPX400DP(object):
def recv_cmd(self):
return self.serial.readline()
def setVoltage(self, volts, chan=1):
def set_voltage(self, volts, chan=1):
self.log.info("Set oltage {}V in channel {}".format(volts,chan))
cmd='V'+str(chan)+' '+str(volts)+'\n'
self.send_cmd(cmd)
def getVoltage(self, chan=1):
def get_voltage(self, chan=1):
cmd='V'+str(chan)+'O?\n'
self.send_cmd(cmd)
answer=self.recv_cmd()
self.log.info("Channel {} ---- {}}V".format(chan,float(answer[:-3])))
return float(answer[:-3])
def setCurrent(self, amps, chan=1):
def set_current(self, amps, chan=1):
self.log.info("Set current to {}A in channel {}".format(amps,chan))
cmd='I'+str(chan)+' '+str(amps)+'\n'
self.send_cmd(cmd)
def getCurrent(self, chan=1):
def get_current(self, chan=1):
cmd='I'+str(chan)+'O?\n'
self.send_cmd(cmd)
answer=self.recv_cmd()
......@@ -57,20 +57,25 @@ class CPX400DP(object):
cmd='IFLOCK\n'
self.send_cmd(cmd)
def switchOn(self, chan=1):
def turn_on(self, chan=1):
cmd='OP'+str(chan)+' 1\n'
self.log.info("Turning ON Channel {}".format(chan))
self.send_cmd(cmd)
def switchOff(self, chan=1):
def turn_off(self, chan=1):
cmd='OP'+str(chan)+' 0\n'
self.log.info("Turning OFF Channel {}".format(chan))
self.send_cmd(cmd)
def setup(self, chan=1, volts=10.0, amps=0.3):
self.setVoltage(volts=volts, chan=chan)
self.setCurrent(amps=amps, chan=chan)
self.switchOn(chan=chan)
self.set_voltage(volts=volts, chan=chan)
self.set_current(amps=amps, chan=chan)
self.turn_on(chan=chan)
def get_values(self, chan=1, volts=10.0, amps=0.3):
self.set_voltage(volts=volts, chan=chan)
self.set_current(amps=amps, chan=chan)
self.turn_on(chan=chan)
def main():
parser = argparse.ArgumentParser(description='Control CPX400DP from USB', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
......@@ -85,7 +90,7 @@ def main():
if args.powerup:
psu.setup(chan=args.chan, volts=args.volts, amps=args.amps)
else:
psu.switchOff(chan=args.chan)
psu.turn_off(chan=args.chan)
psu.close()
if __name__ == '__main__':
......
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