We are moving! We are currently migrating our community to the new Bosch Connected Industry Online Portal. The community will be available latest in the new year again, until then it will be in read-only mode. Click here for more information.
09-05-2022 10:41 AM
Hello comununity,
I'm tI'm wondering how i can disable the execution of ana AddOn.
Units you can disable via UnitStateReq but not in AddOns. Even in the past I experienced that AddOns still run on a disable Unit. Is this still happens now?
Is there no other way to disable the AddOn other than programming it specifically in the AddOn?
Thanks.
09-05-2022 02:09 PM
You are right, add-ons don't have their own state machine. And they are always called even if the parent handler is disabled. The reason is that it is not easy to tell what would be the expected behavior for an add-on. Some add-ons should definitely consider the UnitState of their parent, but there are others that should just continue working even if the parent is disabled. So it is really the responsibility of the add-on programmer to decide this.
09-05-2022 02:42 PM
If I need to temporarily "disable" an add-on, then I go to the hosting handler's OnInitHierarchy and remove it from there. If it is not added to the handler, then it will never be executed. Since the code is inside the OES generated code, the next export will bring it back. For a slightly more permanent solution, you can wrap the OES part in an IF ( FALSE ) and copy-paste everything except the add-on below your END_IF. Never did it like this, but it should work. Then export will have no effect anymore, so other changes to children etc. will also not be updated. So it's also a temporary solution at best. Also, add a !!!BIG WARNING!!! pragma in that OnInitHierarchy to avoid bad accidents if the software unexpectedly changes hands.
09-05-2022 03:27 PM
Thanks,
We do something like that but I expect something more "clean" than override OnIniHierarchy. We try to implement TwinCAT feature of Project Variant to recognice "almost twins Stations" betwen lines so this feature will be permanent on the code. We have to take care and review from time to time the InstancesId. I don't like this way I wont sleep well if i release my SW with this tricks.
Honestly i don't understand that we can disable almost everything but AddOns. And worst if Unit is disable, AddOns still running.
09-06-2022 03:23 AM
You can remove the addon from the handler again, which basically stops it from being called. I wouldn't call this "clean" either, since the Nexeed framework clearly does want you to do that. And depending on what the add-on is doing exactly, it may have some weird consequences. If you do it straight at the end of OnUnitInitialize (after the exported code), it should be fine in most cases though.
You can also link this to the unit state if you wanted to, but that requires you to either manually add this to all your handlers or create new handlers that extend the Nexeed version, like we have in our ATMOx handlers anyway.
I'll contact you separately how to do this, I don't really want to advertise this solution publically. Maybe the Nexeed developer team picks up on your requirement and adds this to the official framework someday.