#!/usr/bin/env	python
#coding: utf8
# Copyright CERN, 2011
# Author: Ross Millar <ross.millar@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org

import sys
import rr
import random
import time
import spi
import csr
import i2c
import gn4124
import fmc_adc_test_suite
#from pylab import *
from ptsexcept import *


"""
Test03
Tests Front Panel LEDs

"""

def main (default_directory='.'):

    spec = rr.Gennum() # bind to the SPEC board
    fmc = fmc_adc_test_suite.CFmcAdc100ks(spec)

    print "Starting blinking leds test."		
 
  # Start the leds blinking
    fmc.start_leds_blinking()
   
    ask = "";
    tmp_stdout = sys.stdout;
    sys.stdout = sys.__stdout__;
    tmp_stdin = sys.stdin;
    sys.stdin = sys.__stdin__;
    while ((ask != "Y") and (ask != "N")) :
	print "-------------------------------------------------------------"
	print "\t Look at the ADC BOARD "
    	ask = raw_input("Are the LEDs blinking? [Y/N]")
	ask = ask.upper()
	print "-------------------------------------------------------------"

    
    
    sys.stdout = tmp_stdout;
    sys.stdin = tmp_stdin;
    if (ask == "N") :
	raise PtsError("Error: There is a problem with the LEDs");
    		
    print "The LEDs are working as expected"
    
    fmc.stop_leds_blinking()

if __name__ == '__main__':
    main()        
    
