The following script shows how an MCA is operated. The timer is gating the ADC which feeds the MCA.
#!/usr/bin/python
from PyTango import *
import sys
import time
try :
mca1 = DeviceProxy( "hires/exp/mca1")
t1 = DeviceProxy( "hires/exp/t1")
attr = mca1.read_attribute( "BankId")
attr.value = 0
mca1.write_attribute( attr)
t1.command_inout( "Stop")
mca1.command_inout( "Clear")
mca1.command_inout( "Start")
#
# start the timer
#
attr = t1.read_attribute( "sampleTime")
attr.value = 0.5
t1.write_attribute( attr)
t1.command_inout( "Start")
while( t1.command_inout( "Check")):
print " Timer: ", t1.command_inout( "Read")
time.sleep(0.1)
mca1.command_inout( "Stop")
mca1.command_inout( "Read")
attr = mca1.read_attribute( "DataLength")
len = attr.value
print " Spectrum length ", len
attr = mca1.read_attribute( "Data")
for i in range( len):
if attr.value[i] > 0 :
print " i=", i, ",val=", attr.value[i]
except :
print "Failed with exception !"
print sys.exc_info()[0]