Source code for cmd_ha_hmp4030

#!/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 ha_hmp4030_class(scpi.scpi):
    # Available channels
    channels=["OUT1","OUT2","OUT3"]

    def __init__(self):
        super(ha_hmp4030_class,self).__init__("ha_hmp4030")

    def set_voltage(self,ha_hmp4030_id,voltage):
        command= r"INST {channel}\n"
        command+=r"SOUR:CURR {current:.3f}\n"
        command+=r"SOUR:VOLT {voltage:.3f}"
        return super(ha_hmp4030_class,self).set_voltage(ha_hmp4030_id,voltage,command)

    def set_current(self,ha_hmp4030_id,current):
        command= r"INST {channel}\n"
        command+=r"SOUR:VOLT {voltage:.3f}\n"
        command+=r"SOUR:CURR {current:.3f}"
        return super(ha_hmp4030_class,self).set_current(ha_hmp4030_id,current,command)

    def set_voltage_limit(self,ha_hmp4030_id,voltage_limit):
        command= r"INST {channel}\n"
        command+=r"SOUR:VOLT:PROT:LEV {voltage_limit:.3f}\n"
        command+=r"SOUR:VOLT {voltage_limit:.3f}"
        return super(ha_hmp4030_class,self).set_voltage_limit(ha_hmp4030_id,voltage_limit,command)

    def set_current_limit(self,ha_hmp4030_id,current_limit):
        command= r"INST {channel}\n"
        command+=r"SOUR:CURR {current_limit:.3f}"
        return super(ha_hmp4030_class,self).set_current_limit(ha_hmp4030_id,current_limit,command)

    def get_voltage(self,ha_hmp4030_id):
        query= r"INST {channel}\n"
        query+=r"MEAS:VOLT?"
        return self.simple_query(ha_hmp4030_id,query)

    def get_current(self,ha_hmp4030_id):
        query= r"INST {channel}\n"
        query+=r"MEAS:CURR?"
        return self.simple_query(ha_hmp4030_id,query)

    def power_on(self,ha_hmp4030_id):
        command= r"INST {channel}\n"
        command+=r"OUTP ON"
        return self.simple_command(ha_hmp4030_id,command)

    def power_off(self,ha_hmp4030_id):
        command= r"INST {channel}\n"
        command+=r"OUTP OFF"
        return self.simple_command(ha_hmp4030_id,command)

# CREATE POOL ####################################################

me=ha_hmp4030_class()

# COMMANDS #######################################################

[docs]def init_ha_hmp4030(ha_hmp4030_id,conf_string): """Initialize ha_hmp4030 power supply identified by *ha_hmp4030_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(ha_hmp4030_id,conf_string)
[docs]def deinit_ha_hmp4030(ha_hmp4030_id): "Deinitialize an ha_hmp4030" return me.deinit(ha_hmp4030_id)
[docs]def config_ha_hmp4030(ha_hmp4030_id): "Configure an ha_hmp4030" return me.config(ha_hmp4030_id,"",0.005)
[docs]def inval_ha_hmp4030(ha_hmp4030_id): "Invalidate an ha_hmp4030" return me.inval(ha_hmp4030_id)
[docs]def reset_ha_hmp4030(ha_hmp4030_id): "Send RST signal to PS" return me.reset(ha_hmp4030_id)
[docs]def set_voltage_ha_hmp4030(ha_hmp4030_id,voltage): "Set voltage in Volts. channel can be 1, 2 or 3." return me.set_voltage(ha_hmp4030_id,voltage)
[docs]def set_current_ha_hmp4030(ha_hmp4030_id,current): "Set current in Ampers. channel can be 1, 2 or 3." return me.set_current(ha_hmp4030_id,current)
[docs]def set_voltage_limit_ha_hmp4030(ha_hmp4030_id,voltage_limit): "Set voltage limit in Volts. channel can be 1, 2 or 3. Over Voltage Protection is also set." return me.set_voltage_limit(ha_hmp4030_id,voltage_limit)
[docs]def set_current_limit_ha_hmp4030(ha_hmp4030_id,current_limit): "Set current limit in Ampers. channel can be 1, 2 or 3." return me.set_current_limit(ha_hmp4030_id,current_limit)
[docs]def get_voltage_ha_hmp4030(ha_hmp4030_id): "Get voltage in Volts. channel can be 1, 2 or 3." return me.get_voltage(ha_hmp4030_id)
[docs]def get_current_ha_hmp4030(ha_hmp4030_id): "Get current in Ampers. channel can be 1, 2 or 3." return me.get_current(ha_hmp4030_id)
[docs]def power_on_ha_hmp4030(ha_hmp4030_id): "Turn on all channels." return me.power_on(ha_hmp4030_id)
[docs]def power_off_ha_hmp4030(ha_hmp4030_id): "Turn off all channels" return me.power_off(ha_hmp4030_id)
[docs]def free_command_ha_hmp4030(ha_hmp4030_id,command): "Send a raw command to the PS" return me.free_command(ha_hmp4030_id,command)
[docs]def free_query_ha_hmp4030(ha_hmp4030_id,query): "Send a raw command to the PS" return me.free_query(ha_hmp4030_id,query)
[docs]def get_error_queue_ha_hmp4030(ha_hmp4030_id): "Read error queue until the end (code 0)" return me.get_error_queue(ha_hmp4030_id)