'''report.py -- BitLib 2.0 Capture Device Report Generator (Python)
See API.txt for details about all the Library calls used here'''
from bitlib import *
MY_DEVICE = 0 MY_CHANNEL = 0 MY_PROBE_FILE = "" MY_MODE = BL_MODE_FAST MY_RATE = 1000000 MY_SIZE = 5 TRUE = 1
MODES = ("FAST","DUAL","MIXED","LOGIC","STREAM")
SOURCES = ("POD","BNC","X10","X20","X50","ALT","GND")
def main(argv=None):
print "\nStarting: Attempting to open one device..."
if BL_Open(MY_PROBE_FILE,1):
print " Library: %s (%s)" % (
BL_Version(BL_VERSION_LIBRARY),
BL_Version(BL_VERSION_BINDING))
BL_Select(BL_SELECT_DEVICE,MY_DEVICE)
print " Link: %s" % BL_Name(0)
print "BitScope: %s (%s)" % (BL_Version(BL_VERSION_DEVICE),BL_ID())
print "Channels: %d (%d analog + %d logic)" % (
BL_Count(BL_COUNT_ANALOG)+BL_Count(BL_COUNT_LOGIC),
BL_Count(BL_COUNT_ANALOG),BL_Count(BL_COUNT_LOGIC))
print " Modes:" + "".join(["%s" % (
(" " + MODES[i]) if i == BL_Mode(i) else "") for i in range(len(MODES))])
BL_Mode(BL_MODE_LOGIC) == BL_MODE_LOGIC or BL_Mode(BL_MODE_FAST)
print " Capture: %d @ %.0fHz = %fs (%s)" % (
BL_Size(),BL_Rate(),
BL_Time(),MODES[BL_Mode()])
BL_Range(BL_Count(BL_COUNT_RANGE));
if BL_Offset(-1000) != BL_Offset(1000):
print " Offset: %+.4gV to %+.4gV" % (
BL_Offset(1000), BL_Offset(-1000))
for i in range(len(SOURCES)):
if i == BL_Select(2,i):
print " %s: " % SOURCES[i] + " ".join(["%5.2fV" % BL_Range(n) for n in range(BL_Count(3)-1,-1,-1)])
BL_Mode(MY_MODE) BL_Intro(BL_ZERO); BL_Delay(BL_ZERO); BL_Rate(MY_RATE); BL_Size(MY_SIZE); BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL); BL_Trigger(BL_ZERO,BL_TRIG_RISE); BL_Select(BL_SELECT_SOURCE,BL_SOURCE_POD); BL_Range(BL_Count(BL_COUNT_RANGE)); BL_Offset(BL_ZERO); BL_Enable(TRUE); BL_Trace()
DATA = BL_Acquire()
print " Data(%d): " % MY_SIZE + ", ".join(["%f" % DATA[n] for n in range(len(DATA))])
print "Complete: trace and acquisition complete. Dump the log...\n"
print "%s" % BL_Log()
print "Finished: close the library to release resources."
BL_Close()
else:
print " FAILED: device not found (check your probe file)."
if __name__ == "__main__":
import sys
sys.exit(main())