#!   /usr/bin/env   python
#    coding: utf8

# Copyright CERN, 2011
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org

import sys
import rr
import time
import os

import cp210x_gpio
from PAGE.Agilent33250A import *
from PAGE.SineWaveform import *


"""
calibr_box: Access to calibration box via USB-UART bridge CP2103

"""


class CCalibr_box:
	def __init__(self, device):
            self.cp210x = cp210x_gpio.CCP210x(device)
            # Select AWG as default output
            self.cp210x.gpio_set(0x0)

        def select_output(self, out):
            if('10V' == out):
                self.cp210x.gpio_set(0xF)
            elif('1V' == out):
                self.cp210x.gpio_set(0xD)
            elif('100mV' == out):
                self.cp210x.gpio_set(0xC)
            elif('AWG' == out):
                self.cp210x.gpio_set(0x0)
            else:
                raise Exception('Invalid output selection!')

        def get_config(self):
            return self.cp210x.gpio_get()
