#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright 2012-2017 Frédéric Magniette, Miguel Rubio-Roy
# This file is part of Pyrame.
#
# Pyrame is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrame is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrame. If not, see <http://www.gnu.org/licenses/>
import scpi
# CLASS ##########################################################
class ag_e3631a_class(scpi.scpi):
# Available channels
channels=["P6V","P25V","N25V"]
def __init__(self):
super(ag_e3631a_class,self).__init__("ag_e3631a")
def set_voltage(self,ag_e3631a_id,voltage):
command= r"INST {channel}\n"
command+=r"CURR {current:.6f}\n"
command+=r"VOLT {voltage:.6f}"
return super(ag_e3631a_class,self).set_voltage(ag_e3631a_id,voltage,command)
def set_current(self,ag_e3631a_id,current):
command= r"INST {channel}\n"
command+=r"VOLT {voltage:.6f}\n"
command+=r"CURR {current:.6f}"
return super(ag_e3631a_class,self).set_current(ag_e3631a_id,current,command)
def set_voltage_limit(self,ag_e3631a_id,voltage_limit):
command= r"INST {channel}\n"
command+=r"VOLT {voltage_limit:.6f}"
return super(ag_e3631a_class,self).set_voltage_limit(ag_e3631a_id,voltage_limit,command)
def set_current_limit(self,ag_e3631a_id,current_limit):
command= r"INST {channel}\n"
command+=r"CURR {current_limit:.6f}"
return super(ag_e3631a_class,self).set_current_limit(ag_e3631a_id,current_limit,command)
def get_voltage(self,ag_e3631a_id):
query= r"INST {channel}\n"
query+=r"MEAS:VOLT?"
return self.simple_query(ag_e3631a_id,query)
def get_current(self,ag_e3631a_id):
query= r"INST {channel}\n"
query+=r"MEAS:CURR?"
return self.simple_query(ag_e3631a_id,query)
def power_on(self,ag_e3631a_id):
command="OUTP ON"
return self.simple_command(ag_e3631a_id,command)
def power_off(self,ag_e3631a_id):
command="OUTP OFF"
return self.simple_command(ag_e3631a_id,command)
# CREATE POOL ####################################################
me=ag_e3631a_class()
# COMMANDS #######################################################
[docs]def init_ag_e3631a(ag_e3631a_id,conf_string):
"""Initialize ag_e3631a power supply identified by *ag_e3631a_id*
*conf_string* must include the parameter:
- bus: conf_string of the underlying link module (GPIB, TCP, ...)
- channel: channel on which the id will act"""
return me.init(ag_e3631a_id,conf_string)
[docs]def deinit_ag_e3631a(ag_e3631a_id):
"Deinitialize an ag_e3631a"
return me.deinit(ag_e3631a_id)
[docs]def config_ag_e3631a(ag_e3631a_id):
"Configure an ag_e3631a"
return me.config(ag_e3631a_id)
[docs]def inval_ag_e3631a(ag_e3631a_id):
"Invalidate an ag_e3631a"
return me.inval(ag_e3631a_id)
[docs]def reset_ag_e3631a(ag_e3631a_id):
"Send RST signal to PS"
return me.reset(ag_e3631a_id)
[docs]def set_voltage_ag_e3631a(ag_e3631a_id,voltage):
"Set voltage in Volts. channel can be 1 for P6V, 2 for P25V or 3 for N25V"
return me.set_voltage(ag_e3631a_id,voltage)
[docs]def set_current_ag_e3631a(ag_e3631a_id,current):
"Set current in Ampers. channel can be 1 for P6V, 2 for P25V or 3 for N25"
return me.set_current(ag_e3631a_id,current)
[docs]def set_voltage_limit_ag_e3631a(ag_e3631a_id,voltage_limit):
"Set voltage limit in Volts. channel can be 1 for P6V, 2 for P25V or 3 for N25V"
return me.set_voltage_limit(ag_e3631a_id,voltage_limit)
[docs]def set_current_limit_ag_e3631a(ag_e3631a_id,current_limit):
"Set current limit in Ampers. channel can be 1 for P6V, 2 for P25V or 3 for N25"
return me.set_current_limit(ag_e3631a_id,current_limit)
[docs]def get_voltage_ag_e3631a(ag_e3631a_id):
"Get voltage in Volts. channel can be 1 for P6V, 2 for P25V or 3 for N25"
return me.get_voltage(ag_e3631a_id)
[docs]def get_current_ag_e3631a(ag_e3631a_id):
"Get current in Ampers. channel can be 1 for P6V, 2 for P25V or 3 for N25"
return me.get_current(ag_e3631a_id)
[docs]def power_on_ag_e3631a(ag_e3631a_id):
"Turn on all channels."
return me.power_on(ag_e3631a_id)
[docs]def power_off_ag_e3631a(ag_e3631a_id):
"Turn off all channels"
return me.power_off(ag_e3631a_id)
[docs]def free_command_ag_e3631a(ag_e3631a_id,command):
"Send a raw command to the PS"
return me.free_command(ag_e3631a_id,command)
[docs]def get_error_queue_ag_e3631a(ag_e3631a_id):
"Read error queue until the end (code 0)"
return me.get_error_queue(ag_e3631a_id)