
class Listener implements ch.psi.pshell.device.DeviceListener{
    void onStateChanged(ch.psi.pshell.device.Device device, state, former){
    }

    void onValueChanged(ch.psi.pshell.device.Device device, value, former){
        println "Moved  to: " + value.toString()
    }


    void onValueChanging(ch.psi.pshell.device.Device device, value, former){        
        if (value > 20){
            
            throw new Exception("Forbidden move to " + value.toString());
        }
        println "Moving to: " + value.toString() + " ... " 
    }

}

listener = new Listener()
inp.addListener(listener)

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