
    var listenerClass = Java.extend(Java.type("ch.psi.pshell.device.DeviceListener"))
    var listener = new listenerClass() {
        onStateChanged: function (device, state, former) {
        },
        onValueChanged: function (device, value, former) {
            print ("Moved  to: " + value.toString())
        },
        onValueChanging: function (device, value, former) {
            if (value > 20){            
                throw ("Forbidden move to " + value.toString());
            }
            print ("Moving to: " + value.toString() + " ... ")
        },
    }







inp.addListener(listener)

try{
    lscan(inp, [sin,], 0, 40, 20, 0.01) 
}  finally {
 inp.removeListener(listener)
}
