In the following example, the virtual counter returns the Petra current. Since the return value of a counter has to be an integer value, the current reading is multiplied by 1000 and casted to long.
#!/bin/env python import PyTango import HasyUtils class VC: def __init__(self): try: # self.proxy = PyTango.DeviceProxy( 'tango_host:10000/petra/globals/keyword') self.proxy = PyTango.DeviceProxy( 'petra/globals/keyword') except Exception, e: print "VC.petra3current: failed to create proxy" print repr( e) return self.lastReading = 0. # def dev_state( self): return PyTango.DevState.ON # def read_Counts( self): try: argout = self.proxy.BeamCurrent self.lastReading = argout except Exception, e: argout = self.lastReading return argout # def write_Counts( self, argin): pass # def Reset(self): return 1