Python Client

The following script shows how a counter and a timer are operated from Python. Note: after a power-up the counter server has to restarted or the Init command has to be invoked.

 
#!/usr/bin/python 
#
# A test program for the V260 and the DGG2. 
# If you connect the CLK OUT of the DGG2 to
# c1, you'll find some counts
#
from PyTango import *
import sys
import time

try :
    c1 = DeviceProxy( "hires/exp/c1")
    t1 = DeviceProxy( "hires/exp/t1")
    #
    # reset the counter
    #
    c1.command_inout( "Reset")
    #
    # start the timer
    #
    attr=t1.read_attribute( "sampleTime")
    attr.value = 1.0
    t1.write_attribute( attr)
    t1.command_inout( "Start")

    while( t1.command_inout( "Check")):
        print " Timer: ", t1.command_inout( "Read") 
        time.sleep(0.5)
	
    print " C1: reading Counts ", c1.read_attribute( "Counts").value
    print " C1: calling 'Read' ", c1.command_inout( "Read")

except :
    print "Failed with exception !"
    print sys.exc_info()[0]