04-10-2024 09:39 AM - edited 04-10-2024 09:40 AM
In OpconUnit the methods SetEvent, SetExtEvent, ClearEvent and UnlockEvent are all PUBLIC. In OpconAddonEvHdl only ClearEvent is PUBLIC, the other methods are PROTECTED.
While I understand that they should be PROTECTED if possible, I would like to make the request to make them PUBLIC anyway. I guess for units they are public so that chains can access them but add-ons don't have this requirement in the Nexeed framework. We in BMG are currently working on creating some plugins (utility classes) that make event handling more convenient. For Units (and this includes handlers) we can do this without problems, but for Addons I am hitting the limitation that SetExtEvent is PROTECTED. I only need ClearEvent (already PUBLIC) and SetExtEvent so far. Maybe I can come up with some tricks to bypass this restriction but I would appreciate it if I don't have to 🙂
Another thing that I was wondering for quite some time, so I may as well address it here: The method SetExtEventFromDeviceError is useful in quite a few places but it is not visible. I guess it is using {attribute 'hide'}. Only people who know that it exists or who ever found it using THIS^. or SUPER^. will be able to use it. I think it would be a good idea to make it visible to everybody. I think in most (station program) situations where people are using SetExtEvent they could actually benefit from directly using SetExtEventFromDeviceError instead, because most external events you want to throw are device error events from BinIo in my experience.
04-10-2024 04:51 PM
It is planned to provide a successor method for CheckUnitDone and CheckAddonDone, in which accessing SetExtEvent would also be helpful to show an error message if the provided unit/addon is not RUNNING (= coding error in application code). Therefore we have internally the same request like you.
What's your use case?
04-11-2024 02:56 AM
We have several convenience event handling methods, for example SetEventOnce which checks if an event was set before to make it very simple to avoid setting events multiple times, even without event handle variables. Or ClearEventByNumber which works similar to the old clear event function in Opcon.
These functions should be available in Units, ExecUnits, ExecHandlers (and its derivatives), AddonEvHdls and AddonExecs. But I don't want to implement these methods 5 or more times in derived FBs, so I put them into a separate FB (called Plugin) that handles all of that. Now my derived FBs just instantiate the Plugin, register themselves with it and then they can use the Plugin to call these convenience methods. Since the plugin is a separate FB and not derived from OpconUnit or OpconEvHdl, it can only access their public methods.