#!/usr/bin/python
import Manyo as m
API = m.AcquireNeutronSourceTextInformation()
##################################################
def valInfo4(sig,begin,end,step):
    valDate=[]
    valTime=[]
    valData=[]
    print "valInfo-4 >>>", sig, begin, end, step

    valData = API.PutValueInformation(sig,begin,end,step)
    valDate = API.PutDateBinInformation()
    valTime = API.PutTimeBinInformation()

    return valDate,valTime,valData
##################################################
def valInfo2(sig,begin):
    #valDate=[]
    valTime=[]
    valData=[]
    print "valInfo-2 >>>", sig, begin

    valData = API.PutValueInformation(sig,begin)
    valDate = API.PutDateBinInformation()
    valTime = API.PutTimeBinInformation()

    retDate = valDate[0]
    retTime = valTime[0]

    return retDate,retTime,valData
##################################################
def valInfo1(sig):
    #valDate=[]
    valTime=[]
    valData=[]
    print "valInfo-1 >>>", sig

    valData = API.PutValueInformation(sig)
    valDate = API.PutDateBinInformation()
    valTime = API.PutTimeBinInformation()

    retDate = valDate[0]
    retTime = valTime[0]

    return retDate,retTime,valData
##################################################
def toCurrent(Proton,bin):
    current=[]
    print "toCurrent >>>", len(Proton),bin

    current = API.ConvertProtonToCurrent(Proton,bin)

    return current
##################################################
def toBeampower(Current):
    beampower=[]
    print "toBeamPower >>>", len(Current)

    beampower = API.ConvertCurrentToBeampower(Current)

    return beampower
##################################################

listDate, listTime, listData = valInfo4("H2in","2009/06/03 10:00:00","2009/06/03 10:01:00",1)
#listDate, listTime, listData = valInfo4("H2cm","2009/06/03 10:00:00","2009/06/03 10:01:00",1)
#listDate, listTime, listData = valInfo4("H2dm","2009/06/03 10:00:00","2009/06/03 10:01:00",1)
#listDate, listTime, listData = valInfo4("H2pm","2009/06/03 10:00:00","2009/06/03 10:01:00",1)

#listDate, listTime, listData = valInfo4("CT8","2009/06/03 10:00:00","2009/06/03 10:00:30",1)
#listDate, listTime, listData = valInfo4("CT9","2009/06/03 10:00:00","2009/06/03 10:00:30",1)

print
print "      ##### result #####"
for i in range(len(listData)):
    print "[",i,"] date, time, val = ", listDate[i], listTime[i], listData[i]
print

#listDate, listTime, listData = valInfo2("H2in","2009/06/01 00:00:00")
#listDate, listTime, listData = valInfo1("H2in")
#listDate, listTime, listData = valInfo2("H2cm","2009/06/01 00:00:00")
#listDate, listTime, listData = valInfo1("H2cm")
#listDate, listTime, listData = valInfo2("H2dm","2009/06/01 00:00:00")
#listDate, listTime, listData = valInfo1("H2dm")
#listDate, listTime, listData = valInfo2("H2pm","2009/06/01 00:00:00")
#listDate, listTime, listData = valInfo1("H2pm")

#listDate, listTime, listData = valInfo2("CT8","2009/06/01 00:00:00")
#listDate, listTime, listData = valInfo1("CT8")
#listDate, listTime, listData = valInfo2("CT9","2009/06/01 00:00:00")
#listDate, listTime, listData = valInfo1("CT9")

#print
#print "      ##### result #####"
#print "date, time, val = ", listDate, listTime, listData
#print


#listDate, listTime, listProton = valInfo4("CT8","2009/06/03 10:00:00","2009/06/03 10:00:10",2)
#listCurrent = toCurrent(listProton,2)
#listBeampower = toBeampower(listCurrent)
#print
#print "      ##### result #####"
#for i in range(len(listProton)):
#    print "[",i,"]date,time,Proton,Current,Beam =", listDate[i], listTime[i], listProton[i], listCurrent[i], listBeampower[i]
#print
