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

# Copyright INCAA Computers, 2012
# Author: Bert Gooijer <bert.gooijer@incaacomputers.com>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org

from ptsexcept import *
from utilFunctions import *
from fmc_eeprom import *

import sys, time


from spec import *
from ad9516 import *
from ad9510 import *
from adf4002 import *
from dac import *
from sys import __stdout__



"""
test06: Prepares IPMI card information (serial number, production date, etc.) 
"""

def main (card=None, serial=None, default_directory='.', suite=None):
    
    
    ############################################################################
    if(serial == None):
        print "-------------------------------------------------------------"
        print >> __stdout__, "Please scan CERN serial number bar-code, then press [ENTER]: "
        serial1 = raw_input()
        print "-------------------------------------------------------------"
        print >> __stdout__, "If needed input extra serial number and press [ENTER] OR just press [ENTER]: "
        serial2 = raw_input()
        if(serial2 == ""):
            serial2 = "0000"
        serial_no = serial1 + "_" + serial2
    else:
        serial_no = serial
         
    bia = BoardInfoArea(int(time.time()), "INCAA Computers BV", "FmcDac600m12b1chaDds", serial_no, "EDA-03010-V1-0", "")

    dcload0 = DCLoadRecord(0, 2.5, 2.4, 2.6, 0.02, 0, 200)
    dcload1 = DCLoadRecord(1, 3.3, 3.2, 3.4, 0.02, 0, 2000)
    dcload2 = DCLoadRecord(2, 12.0, 11.8, 12.2, 0.0, 0, 300)
    
    dcload = [ dcload0, dcload1, dcload2 ]
    dcout = []
    oem = OEMRecord(0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0)

    iua = InternalUseArea([])

    # Open, set, write, close!
    ipmi_open_file(os.path.join(default_directory, "sdbfs/IPMI-FRU"))
    ipmi_set(bia, dcload, dcout, oem, iua)
    ipmi_write()
    ipmi_close_file()
    
    
    
    return card
    
if __name__ == '__main__' :
    main()
