02-17-2020 06:42 AM
Hi Delacor,
I've been using the DQMH to create a plug and play architecture for a project at work. The project requires a DUT to respond to an identifying command and then to populate a user interface accordingly. It then updates it's stats on a 0.5s interval. It's all going reasonably well but I seem to be missing events. I suspect that some modules are not initialising and shutting down in the correct order so I created a module to monitor this and nothing else, and to output a timestamped entry to a text log. The logging module starts up with the main user interface and I get an entry that the UI (the red module) has started and stopped, but not for the others. Occasionally I get an entry that the "CHAS" module has stopped, but not started? I can definitely see these events in the Test VI's, and if I breakpoint on any module before the Init broadcast the VI pauses, but I don't see the event being triggered in the monitoring module?
Solved! Go to Solution.
02-17-2020 07:13 AM - edited 02-17-2020 07:15 AM
My best guess is that the order of starting a module and registering for its broadcasts is off.
As the broadcast events are created during launching a module, we can only register for these events after the module was started. Also, in order to see all the broadcast events of a module, we need to register before the module starts doing stuff.
If you look at the API tester, you'll see that it uses the (1) "Obtain Broadcast Events for Registration.vi" outside the for loop / event structure to register for the broadcasts events, and then (2) takes the event references from "Start Module.vi" to overwrite the registration with the actual event references when actually starting the module. It then uses "Synchronize Module Events.vi" to make sure that the module only continues execution after the registration has been done.
There's a bit more information available in this discussion.
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
02-17-2020 08:42 AM
Thanks Joerg,
I think I get you - my monitor module will never respond to these events as it it running prior to the other modules starting. This is a lot different from events in text based languages (such as VB.Net). My assumption was that a module would just "listen" for any event it is registered to.
Labview bites me again....
02-17-2020 09:23 AM
You just need to coordinate with your monitor module.
For example if your main launches Module A and the monitor is already running, then create a request and wait for reply to send the broadcast events from A to the monitor. Call that before you call the sychronize VI and you should be good. Then the monitor will be registered before Module A starts broadcasting anything.
It may not be the most elegant solution, but it should work.
02-17-2020 10:06 AM
Hi macjock,
Here is another related post: https://forums.ni.com/t5/Delacor-Toolkits-Discussions/Module-broadcasts-registered-but-events-never-...
On Joerg's picture, the first registration is just "declaring the events data type". If the module is already running, it also registers for the events but if it is not already running, it only specifies the data type.
When the module starts and creates its own events, now the second registration for sure registers for the events.
Thanks for your trust in DQMH.
Regards,
Fab
02-17-2020 10:26 AM
Thanks Fabiola,
That makes more sense - I'll give a try and get back to you.
02-18-2020 09:13 AM
Hi Delacor,
I created an event in my logging module to re-obtain broadcasts. When should this event be fired? I tried putting the event inside the Initialize for the Logging module, as per the solution shown, but I still don't get any Init events for some modules.
Also, I don't know which modules may be started at any given time - for these I attempted to put the event inside the Initialize section of the MHL, prior to their Init event being called. Again, I don't get the event.
Thanks for your patience!
02-18-2020 01:32 PM
Would you make a diagram, it can be back of the napkin type of deal that shows who is calling the Start Module for who?
Also, sequence diagrams can help.
Tip 1 of this blogpost discusses modeling:
https://delacor.com/tips-and-tricks-for-a-successful-dqmh-based-project/
This will help us (you included) find where to fire the event to register for all the events.
02-19-2020 03:40 AM
Hi Fabiola,
I created a tester project to get my head around this.
Module 1 launches Module 2, which launches module 3.
Each module is registered to each other events. Module 1 has no reference to Module 3, other than Obtain Registration.
Module 1 launches Module 2 (and Mod2 launches Mod 3):
Module 1 can make a request to Modules 2 and 3, and both respond.
Module 1 can say hello to Module 2, and hear back from it:
If Module 3 broadcasts, it is not heard by Module 1:
If I now send a request to Module 1 to re-register for Module 3 events, it will now be heard:
Noted that if Module 3 is restarted, Module 1 must re-register for these events
So tried to capture Module 3 Init broadcast, which didn’t work, but I was registered for later events.
Then I put a stall between Module 1 re-register broadcast and Module 3 Did Init:
Module 1 now registers to Module 3 Init event:
I experimented with a few values in the stall – even 1ms seemed sufficient, but I guess that is dependent on processor speed, memory etc.
Anyway, this is much clearer now. Thanks for you help!
02-19-2020 07:41 AM
Hey macjock, if you're already looking into removing dependencies between 1 and 3, you might want to remove them completely.
You could adopt a tree-like structure, where module 1 would not know anything about module 3, but module 2 would have to "forward" broadcasts from module 3 to module 1.
There's a thread with more information on this topic:
PS: I dare say that having to put wait or stall VIs is almost always a code smell...
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )