If a channel detaches and reattaches, any callback functions (event handlers) that you have assigned will still be there, because they're still associated to the software object you used to open the channel in the first place.
Think of it like this- when you declare the object and set parameters and callbacks, this is like making a house. When you call open(), you unlock the door so the channel can go inside and work in the house. Sometimes, the channel might detach and leave the house (USB unplugged, interference, etc). The house is still there and the door is open so it can reattach. When you call close(), you push the channel out of the house and lock the door. One of the big changes with Phidget22 is that there are houses for each input and output on the InterfaceKit, whereas in Phidget21 there is just one big house for everything on that board.
I hope this illustrates why there's no good reason to call close() from the detach handler only to go through the work of calling open() again.
hcfman wrote:Note that now that the close call applies just to a single digital input or output object and the detach callback in principle happens to all jobs associated with a device
Close() applies to a single channel, yes. The detach event handler can apply to a single channel, or it can apply to multiple depending on how you assign them. If you apply it to multiple, you can check the channel index of the sender using e.getSource() (where 'e' is the event args) to avoid doing things to the wrong channel. You can certainly have situations where some channels are open and some are not, and that's intentional in Phidget22.