I try to stop some task inside an abstract Tag driver when the device is disabled.
But I don’t find how to obtainthis information with the driver context ?
Your device driver’s shutdown() method will be called.
Your driver instance is “started” when your DriverType creates it. Your driver instance is told to shutdown via the shutdown method, and will be garbage collected when all of your own references are deleted. Any given instance will not be restarted. This sequence happens for any event that starts and stops your device, including module restart.
If your module is creating objects with their own lifetimes that interact with your devices, you must implement a flag in your driver to remember that it is shut down, and supply that to interested code with an isShutdown() method. Or something like that. Perhaps you should manage a static list of your own driver instances.
Remember that your module hook has its own shutdown() method. That is separate from the driver instance shutdown. I believe it happens after all enabled devices in your module are shutdown.
Phil’s right, there’s no difference between being disabled and being shutdown, or being removed, other than when you get disabled/removed you aren’t subsequently started back up…