Is there a simple way to totally disable further data collection on a VoltageInput device?
I used voltageInput0.setOnVoltageChangeHandler(onVoltageChange) to set the handler, and then set the data rate, but at some point I want to turn off the data collection.
I will try setting the VoltageChangeHandler to a dummy function, but this seems a bit crude. Is there a way to just say: stop all collection, no matter what? Or do I just have to close it?
thanks,
John
If you want to keep the channel open but suspend data events temporarily, the easiest way would be to set the VoltageChangeTrigger to 5. As long as the voltage value was not 0.0V or 5.0V, it will be impossible for another event to occur until the change trigger is set back to 0. If the voltage value was 0 or 5V, then you could theoretically still get an event if the voltage goes from 0 to 5 or 5 to 0.
Another solution would be to create a simple global variable in your program that you can set to true or false. Then in the change handler, only do stuff with the data if the variable is set to true.
You could also just close and reopen the channel, since I can't think of any reason you'd want the channel to stay open if you're not interested in the data coming in for that period of time.
Actually, I am using VCP1001_0, which has a +- 40 V input. Should I then set the voltage change to 40V?
The API says: "The channel will not issue a VoltageChange event until the voltage value has changed by the amount specified by the VoltageChangeTrigger."
I assumed this really meant by an amount greater than the VoltageChangeTrigger, since that made more sense to me. Is that right?
Thanks,John
Actually, setting the voltage change handler to None is perfectly valid - the library will see that a handler isn't registered anymore, and stop calling it.
voltageInput0.setOnVoltageChangeHandler(None)
Although if you don't need voltages anymore, you could also just close the channel.