#
# Mike Zelazny
# Example of how to use SCORE API from Python
#
from edu.stanford.slac.score.api import ScoreAPI
from sys import exit
from java.sql import Timestamp
from java.lang.System import currentTimeMillis

# connect to LCLS SCORE
score = ScoreAPI('LCLS')

# get a list of regions
print("LCLS SCORE Regions: ")
print(score.getScoreRegions())
print()

# get a list of snapshot ids given a region
score.initialize("Zelazny", "CAMAC Timing-Beamcode 1")
ts1 = Timestamp(0) 
ts2 = Timestamp(currentTimeMillis())
snapshotList = score.readSnapshots(ts1, ts2)
print("CAMAC Timing-Beamcode 1 Snapshots:")
print(snapshotList)
print("=======================================================")

# dump a snapshot
snapshot = snapshotList[10]
score.readData(snapshot.getTimestamp())
print("Comment: " + score.getComment())
print("Title  : " + score.getConfigTitle())
print("Data   : ")
print(score.getData())
exit()
