
type = '[s'
name = 'TESTCAS:c4'


import java.beans.PropertyChangeListener as PropertyChangeListener
#import java.beans.PropertyChangeEvent as PropertyChangeEvent

scalar = not type.startswith('[')
#val = lambda x: x if scalar else x.tolist()
val = lambda x: x
class MonitorListener(PropertyChangeListener):
    def propertyChange(self, pce):
        print val(pce.getNewValue())




channel = create_channel(name, type = type)

print val(channel.getValue())
channel.setMonitored(True)
changeListener = MonitorListener()
channel.addPropertyChangeListener(changeListener)

try:
    time.sleep(sys.maxint)
finally:
    channel.removePropertyChangeListener(changeListener)   
    Epics.closeChannel(channel)
    print "ok"
    